RealArithmetic

public protocol RealArithmetic : RationalArithmetic

A type that can be used for real arithmetic.

Conformance Requirements:

  • RationalArithmetic
  • static var π: Self { get }
  • static var e: Self { get }
  • mutating func formLogarithm(toBase base: Self)
  • static func sin(_ angle: Angle<Self>) -> Self
  • static func arctan(_ tangent: Self) -> Angle<Self>
  • π Default implementation

    An instance of π.

    Default Implementation

    An instance of π.

    Declaration

    Swift

    static var π: Self
  • τ Default implementation

    An instance of τ.

    Default Implementation

    An instance of τ.

    τ in the same type.

    Note

    This is an alias for Self.τ to improve the legibility of code involving mathematical equations.

    Declaration

    Swift

    static var τ: Self
  • e Default implementation

    An instance of e.

    Default Implementation

    e in the same type.

    Note

    This is an alias for Self.e to improve the legibility of code involving mathematical equations.

    Declaration

    Swift

    static var e: Self
  • root(ofDegree:) Default implementation

    Returns the degree‐th root of self.

    Mutating variant

    formRoot

    Default Implementation

    Returns the degree‐th root of self.

    Mutating variant

    formRoot

    Declaration

    Swift

    func root(ofDegree degree: Self) -> Self

    Parameters

    degree

    The degree of the root.

  • formRoot(ofDegree:) Default implementation

    Sets self to its degree‐th root.

    Nonmutating variant

    root

    Default Implementation

    Sets self to its degree‐th root.

    Nonmutating variant

    root

    Declaration

    Swift

    mutating func formRoot(ofDegree degree: Self)

    Parameters

    degree

    The degree of the root.

  • √(_:) Default implementation

    Returns the sequare root of operand.

    Mutating variant

    √=

    Default Implementation

    Returns the sequare root of operand.

    Mutating variant

    √=

    Declaration

    Swift

    static prefix func  (operand: Self) -> Self

    Parameters

    operand

    The radicand.

  • √=(_:) Default implementation

    Sets operand to its square root.

    Nonmutating variant

    Default Implementation

    Sets operand to its square root.

    Nonmutating variant

    Declaration

    Swift

    static postfix func = (operand: inout Self)

    Parameters

    operand

    The value to modify.

  • log(toBase:of:) Default implementation

    Returns the base base logarithm of antilogarithm.

    Precondition

    antilogarithm > 0

    Precondition

    base > 0

    Precondition

    base ≠ 1

    Mutating variant

    formLogarithm

    Default Implementation

    Returns the base base logarithm of antilogarithm.

    Precondition

    antilogarithm > 0

    Precondition

    base > 0

    Precondition

    base ≠ 1

    Mutating variant

    formLogarithm

    Declaration

    Swift

    static func log(toBase base: Self, of antilogarithm: Self) -> Self

    Parameters

    base

    The base.

    antilogarithm

    The antilogarithm.

  • formLogarithm(toBase:) Default implementation

    Sets self to its base base logarithm.

    Precondition

    self > 0

    Precondition

    base > 0

    Precondition

    base ≠ 1

    Nonmutating variant

    log

    Default Implementation

    Sets self to its base base logarithm.

    Precondition

    self > 0

    Precondition

    base > 0

    Precondition

    base ≠ 1

    Nonmutating variant

    log

    Declaration

    Swift

    mutating func formLogarithm(toBase base: Self)

    Parameters

    base

    The base.

  • log(_:) Default implementation

    Returns the common logarithm of antilogarithm.

    Precondition

    antilogarithm > 0

    Mutating variant

    formCommonLogarithm

    Default Implementation

    Returns the common logarithm of antilogarithm.

    Precondition

    antilogarithm > 0

    Mutating variant

    formCommonLogarithm

    Declaration

    Swift

    static func log(_ antilogarithm: Self) -> Self

    Parameters

    antilogarithm

    The antilogarithm.

  • formCommonLogarithm() Default implementation

    Sets self to its common logarithm.

    Precondition

    self > 0

    Nonmutating variant

    log

    Default Implementation

    Sets self to its common logarithm.

    Precondition

    self > 0

    Nonmutating variant

    log

    Declaration

    Swift

    mutating func formCommonLogarithm()
  • ln(_:) Default implementation

    Returns the natural logarithm of antilogarithm.

    Precondition

    antilogarithm > 0

    Mutating variant

    formNaturalLogarithm

    Default Implementation

    Returns the natural logarithm of antilogarithm.

    Precondition

    antilogarithm > 0

    Mutating variant

    formNaturalLogarithm

    Declaration

    Swift

    static func ln(_ antilogarithm: Self) -> Self

    Parameters

    antilogarithm

    The antilogarithm.

  • formNaturalLogarithm() Default implementation

    Sets self to its natural logarithm.

    Precondition

    self > 0

    Nonmutating variant

    ln

    Default Implementation

    Sets self to its natural logarithm.

    Precondition

    self > 0

    Nonmutating variant

    ln

    Declaration

    Swift

    mutating func formNaturalLogarithm()
  • sin(_:) Default implementation

    Returns the sine of an angle.

    Default Implementation

    Returns the sine of an angle.

    Declaration

    Swift

    static func sin(_ angle: Angle<Self>) -> Self

    Parameters

    angle

    The angle.

  • cos(_:) Default implementation

    Returns the cosine of an angle.

    Default Implementation

    Returns the cosine of an angle.

    Declaration

    Swift

    static func cos(_ angle: Angle<Self>) -> Self

    Parameters

    angle

    The angle.

  • tan(_:) Default implementation

    Returns the tangent of an angle.

    Default Implementation

    Returns the tangent of an angle.

    Declaration

    Swift

    static func tan(_ angle: Angle<Self>) -> Self

    Parameters

    angle

    The angle.

  • csc(_:) Default implementation

    Returns the cosecant of an angle.

    Default Implementation

    Returns the cosecant of an angle.

    Declaration

    Swift

    static func csc(_ angle: Angle<Self>) -> Self

    Parameters

    angle

    The angle.

  • sec(_:) Default implementation

    Returns the secant of an angle.

    Default Implementation

    Returns the secant of an angle.

    Declaration

    Swift

    static func sec(_ angle: Angle<Self>) -> Self

    Parameters

    angle

    The angle.

  • cot(_:) Default implementation

    Returns the cotangent of an angle.

    Default Implementation

    Returns the cotangent of an angle.

    Declaration

    Swift

    static func cot(_ angle: Angle<Self>) -> Self

    Parameters

    angle

    The angle.

  • arcsin(_:) Default implementation

    Returns the arcsine of a value.

    The returned angle will be between −90° and 90° inclusive.

    Precondition

    −1 ≤ sine ≤ 1

    Default Implementation

    Returns the arcsine of a value.

    The returned angle will be between −90° and 90° inclusive.

    Precondition

    −1 ≤ sine ≤ 1

    Declaration

    Swift

    static func arcsin(_ sine: Self) -> Angle<Self>

    Parameters

    sine

    The sine.

  • arccos(_:) Default implementation

    Returns the arccosine of a value.

    The returned angle will be between 0° and 180° inclusive.

    Precondition

    −1 ≤ sine ≤ 1

    Default Implementation

    Returns the arccosine of a value.

    The returned angle will be between 0° and 180° inclusive.

    Precondition

    −1 ≤ sine ≤ 1

    Declaration

    Swift

    static func arccos(_ cosine: Self) -> Angle<Self>

    Parameters

    cosine

    The cosine.

  • arctan(_:) Default implementation

    Returns the arctangent of a value.

    The returned angle will be between −90° and 90°.

    Default Implementation

    Returns the arctangent of a value.

    The returned angle will be between −90° and 90°.

    Declaration

    Swift

    static func arctan(_ tangent: Self) -> Angle<Self>

    Parameters

    tangent

    The tangent.

  • arccsc(_:) Default implementation

    Returns the arccosecant of a value.

    The returned angle will be between −90° and 90° inclusive, but never 0°.

    Precondition

    −1 ≥ cosecantcosecant ≤ 1

    Default Implementation

    Returns the arccosecant of a value.

    The returned angle will be between −90° and 90° inclusive, but never 0°.

    Precondition

    −1 ≥ cosecantcosecant ≤ 1

    Declaration

    Swift

    static func arccsc(_ cosecant: Self) -> Angle<Self>

    Parameters

    cosecant

    The cosecant.

  • arcsec(_:) Default implementation

    Returns the arcsecant of a value.

    The returned angle will be between 0° and 180° inclusive, but never 90°.

    Precondition

    −1≥ secantsecant ≤ 1

    Default Implementation

    Returns the arcsecant of a value.

    The returned angle will be between 0° and 180° inclusive, but never 90°.

    Precondition

    −1≥ secantsecant ≤ 1

    Declaration

    Swift

    static func arcsec(_ secant: Self) -> Angle<Self>

    Parameters

    secant

    The secant.

  • arccot(_:) Default implementation

    Returns the arccotangent of a value.

    The returned angle will be between 0° and 180°.

    Default Implementation

    Returns the arccotangent of a value.

    The returned angle will be between 0° and 180°.

    Declaration

    Swift

    static func arccot(_ cotangent: Self) -> Angle<Self>

    Parameters

    cotangent

    The cotangent.

  • radians Extension method

    Returns an angle in radians.

    Declaration

    Swift

    public var radians: Angle<Self>
  • rad Extension method

    Returns an angle in radians.

    Declaration

    Swift

    public var rad: Angle<Self>
  • rotations Extension method

    Returns an angle in rotations.

    Declaration

    Swift

    public var rotations: Angle<Self>
  • degrees Extension method

    Returns an angle in degrees.

    Declaration

    Swift

    public var degrees: Angle<Self>
  • minutes Extension method

    Returns an angle in minutes.

    Declaration

    Swift

    public var minutes: Angle<Self>
  • seconds Extension method

    Returns an angle in seconds.

    Declaration

    Swift

    public var seconds: Angle<Self>
  • gradians Extension method

    Returns an angle in gradians.

    Declaration

    Swift

    public var gradians: Angle<Self>