RealArithmetic
public protocol RealArithmetic : RationalArithmetic
A type that can be used for real arithmetic.
Conformance Requirements:
RationalArithmeticstatic var π: Self { get }static var e: Self { get }mutating func formLogarithm(toBase base: Self)static func sin(_ angle: Angle<Self>) -> Selfstatic func arctan(_ tangent: Self) -> Angle<Self>
-
πDefault implementationAn instance of π.
Default Implementation
An instance of π.
Declaration
Swift
static var π: Self -
τDefault implementationAn instance of τ.
Default Implementation
An instance of τ.
τ in the same type.
Note
This is an alias forSelf.τto improve the legibility of code involving mathematical equations.Declaration
Swift
static var τ: Self -
eDefault implementationAn instance of e.
Default Implementation
e in the same type.
Note
This is an alias forSelf.eto improve the legibility of code involving mathematical equations.Declaration
Swift
static var e: Self
-
root(ofDegree:)Default implementationReturns the
degree‐th root ofself.Mutating variant
formRoot
Default Implementation
Returns the
degree‐th root ofself.Mutating variant
formRoot
Declaration
Swift
func root(ofDegree degree: Self) -> SelfParameters
degreeThe degree of the root.
-
formRoot(ofDegree:)Default implementationSets
selfto itsdegree‐th root.Nonmutating variant
root
Default Implementation
Sets
selfto itsdegree‐th root.Nonmutating variant
root
Declaration
Swift
mutating func formRoot(ofDegree degree: Self)Parameters
degreeThe degree of the root.
-
√(_:)Default implementationReturns the sequare root of
operand.Mutating variant
√=
Default Implementation
Returns the sequare root of
operand.Mutating variant
√=
Declaration
Swift
static prefix func √ (operand: Self) -> SelfParameters
operandThe radicand.
-
√=(_:)Default implementationSets
operandto its square root.Nonmutating variant
√
Default Implementation
Sets
operandto its square root.Nonmutating variant
√
Declaration
Swift
static postfix func √= (operand: inout Self)Parameters
operandThe value to modify.
-
log(toBase:of:)Default implementationReturns the base
baselogarithm ofantilogarithm.Precondition
antilogarithm> 0Precondition
base> 0Precondition
base≠ 1Mutating variant
formLogarithm
Default Implementation
Returns the base
baselogarithm ofantilogarithm.Precondition
antilogarithm> 0Precondition
base> 0Precondition
base≠ 1Mutating variant
formLogarithm
Declaration
Swift
static func log(toBase base: Self, of antilogarithm: Self) -> SelfParameters
baseThe base.
antilogarithmThe antilogarithm.
-
formLogarithm(toBase:)Default implementationSets
selfto its basebaselogarithm.Precondition
self> 0Precondition
base> 0Precondition
base≠ 1Nonmutating variant
log
Default Implementation
Sets
selfto its basebaselogarithm.Precondition
self> 0Precondition
base> 0Precondition
base≠ 1Nonmutating variant
log
Declaration
Swift
mutating func formLogarithm(toBase base: Self)Parameters
baseThe base.
-
log(_:)Default implementationReturns the common logarithm of
antilogarithm.Precondition
antilogarithm> 0Mutating variant
formCommonLogarithm
Default Implementation
Returns the common logarithm of
antilogarithm.Precondition
antilogarithm> 0Mutating variant
formCommonLogarithm
Declaration
Swift
static func log(_ antilogarithm: Self) -> SelfParameters
antilogarithmThe antilogarithm.
-
formCommonLogarithm()Default implementationSets
selfto its common logarithm.Precondition
self> 0Nonmutating variant
log
Default Implementation
Sets
selfto its common logarithm.Precondition
self> 0Nonmutating variant
log
Declaration
Swift
mutating func formCommonLogarithm() -
ln(_:)Default implementationReturns the natural logarithm of
antilogarithm.Precondition
antilogarithm> 0Mutating variant
formNaturalLogarithm
Default Implementation
Returns the natural logarithm of
antilogarithm.Precondition
antilogarithm> 0Mutating variant
formNaturalLogarithm
Declaration
Swift
static func ln(_ antilogarithm: Self) -> SelfParameters
antilogarithmThe antilogarithm.
-
formNaturalLogarithm()Default implementationSets
selfto its natural logarithm.Precondition
self> 0Nonmutating variant
ln
Default Implementation
Sets
selfto its natural logarithm.Precondition
self> 0Nonmutating variant
ln
Declaration
Swift
mutating func formNaturalLogarithm() -
sin(_:)Default implementationReturns the sine of an angle.
Default Implementation
Returns the sine of an angle.
Declaration
Swift
static func sin(_ angle: Angle<Self>) -> SelfParameters
angleThe angle.
-
cos(_:)Default implementationReturns the cosine of an angle.
Default Implementation
Returns the cosine of an angle.
Declaration
Swift
static func cos(_ angle: Angle<Self>) -> SelfParameters
angleThe angle.
-
tan(_:)Default implementationReturns the tangent of an angle.
Default Implementation
Returns the tangent of an angle.
Declaration
Swift
static func tan(_ angle: Angle<Self>) -> SelfParameters
angleThe angle.
-
csc(_:)Default implementationReturns the cosecant of an angle.
Default Implementation
Returns the cosecant of an angle.
Declaration
Swift
static func csc(_ angle: Angle<Self>) -> SelfParameters
angleThe angle.
-
sec(_:)Default implementationReturns the secant of an angle.
Default Implementation
Returns the secant of an angle.
Declaration
Swift
static func sec(_ angle: Angle<Self>) -> SelfParameters
angleThe angle.
-
cot(_:)Default implementationReturns the cotangent of an angle.
Default Implementation
Returns the cotangent of an angle.
Declaration
Swift
static func cot(_ angle: Angle<Self>) -> SelfParameters
angleThe angle.
-
arcsin(_:)Default implementationReturns the arcsine of a value.
The returned angle will be between −90° and 90° inclusive.
Precondition
−1 ≤
sine≤ 1Default Implementation
Returns the arcsine of a value.
The returned angle will be between −90° and 90° inclusive.
Precondition
−1 ≤
sine≤ 1Declaration
Swift
static func arcsin(_ sine: Self) -> Angle<Self>Parameters
sineThe sine.
-
arccos(_:)Default implementationReturns the arccosine of a value.
The returned angle will be between 0° and 180° inclusive.
Precondition
−1 ≤
sine≤ 1Default Implementation
Returns the arccosine of a value.
The returned angle will be between 0° and 180° inclusive.
Precondition
−1 ≤
sine≤ 1Declaration
Swift
static func arccos(_ cosine: Self) -> Angle<Self>Parameters
cosineThe cosine.
-
arctan(_:)Default implementationReturns 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
tangentThe tangent.
-
arccsc(_:)Default implementationReturns the arccosecant of a value.
The returned angle will be between −90° and 90° inclusive, but never 0°.
Precondition
−1 ≥
cosecant∨cosecant≤ 1Default Implementation
Returns the arccosecant of a value.
The returned angle will be between −90° and 90° inclusive, but never 0°.
Precondition
−1 ≥
cosecant∨cosecant≤ 1Declaration
Swift
static func arccsc(_ cosecant: Self) -> Angle<Self>Parameters
cosecantThe cosecant.
-
arcsec(_:)Default implementationReturns the arcsecant of a value.
The returned angle will be between 0° and 180° inclusive, but never 90°.
Precondition
−1≥
secant∨secant≤ 1Default Implementation
Returns the arcsecant of a value.
The returned angle will be between 0° and 180° inclusive, but never 90°.
Precondition
−1≥
secant∨secant≤ 1Declaration
Swift
static func arcsec(_ secant: Self) -> Angle<Self>Parameters
secantThe secant.
-
arccot(_:)Default implementationReturns 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
cotangentThe cotangent.
-
radiansExtension methodReturns an angle in radians.
Declaration
Swift
public var radians: Angle<Self> -
radExtension methodReturns an angle in radians.
Declaration
Swift
public var rad: Angle<Self> -
rotationsExtension methodReturns an angle in rotations.
Declaration
Swift
public var rotations: Angle<Self> -
degreesExtension methodReturns an angle in degrees.
Declaration
Swift
public var degrees: Angle<Self> -
minutesExtension methodReturns an angle in minutes.
Declaration
Swift
public var minutes: Angle<Self> -
secondsExtension methodReturns an angle in seconds.
Declaration
Swift
public var seconds: Angle<Self> -
gradiansExtension methodReturns an angle in gradians.
Declaration
Swift
public var gradians: Angle<Self>
View on GitHub
RealArithmetic Protocol Reference