diff --git a/Sources/ComplexModule/Arithmetic.swift b/Sources/ComplexModule/Arithmetic.swift index a90c857..c72dbe7 100644 --- a/Sources/ComplexModule/Arithmetic.swift +++ b/Sources/ComplexModule/Arithmetic.swift @@ -163,7 +163,7 @@ extension Complex: AlgebraicField { /// If z.reciprocal is non-nil, you can safely replace division by z with /// multiplication by this value. It is not advantageous to do this for an /// isolated division, but if you are dividing many values by a single - /// denominator, this will often be a significant performance win. + /// denominator, this may sometimes be a significant performance win. /// /// A typical use case looks something like this: /// ``` @@ -178,7 +178,7 @@ extension Complex: AlgebraicField { /// ``` /// /// Error Bounds: - /// - + /// /// Unlike real types, when working with complex types, multiplying by the /// reciprocal instead of dividing cannot change the result. If the /// reciprocal is non-nil, the two computations are always equivalent. diff --git a/Sources/RealModule/AlgebraicField.swift b/Sources/RealModule/AlgebraicField.swift index 2a38fb4..ccdcfbc 100644 --- a/Sources/RealModule/AlgebraicField.swift +++ b/Sources/RealModule/AlgebraicField.swift @@ -56,11 +56,6 @@ public protocol AlgebraicField: SignedNumeric { /// The (approximate) reciprocal (multiplicative inverse) of this number, /// if it is representable. /// - /// If reciprocal is non-nil, you can replace division by self with - /// multiplication by reciprocal and either get exact the same result - /// (for finite fields) or approximately the same result up to a typical - /// rounding error (for floating-point formats). - /// /// If self is zero and the type has no representation for infinity (as /// in a typical finite field implementation), or if a reciprocal would /// overflow or underflow such that it cannot be accurately represented, @@ -70,17 +65,17 @@ public protocol AlgebraicField: SignedNumeric { /// for `Real` or `Complex` types, because these types have an /// `.infinity` value that acts as the reciprocal of `.zero`. /// - /// If `b.reciprocal` is non-nil, you may be able to replace division by `b` + /// If `x.reciprocal` is non-nil, you may be able to replace division by `x` /// with multiplication by this value. It is not advantageous to do this /// for an isolated division unless it is a compile-time constant visible /// to the compiler, but if you are dividing many values by a single /// denominator, this will often be a significant performance win. /// - /// Note that this will slightly perturb results for fields with approximate - /// arithmetic, such as real or complex types--using a normal division + /// Note that this will slightly perturb results for some fields with + /// approximate arithmetic, such as real types--using a normal division /// is generally more accurate--but no catastrophic loss of accuracy will - /// result. For fields with exact arithmetic, the results are necessarily - /// identical. + /// result. For fields with exact arithmetic, or for the Complex types, + /// the results are identical. /// /// A typical use case looks something like this: /// ``` diff --git a/Sources/RealModule/Real.swift b/Sources/RealModule/Real.swift index 0ef492d..7f61f28 100644 --- a/Sources/RealModule/Real.swift +++ b/Sources/RealModule/Real.swift @@ -102,10 +102,10 @@ extension Real { /// The (approximate) reciprocal (multiplicative inverse) of this number, /// if it is representable. /// - /// If `a` if finite and nonzero, and `1/a` overflows or underflows, - /// then `a.reciprocal` is `nil`. Otherwise, `a.reciprocal` is `1/a`. + /// If `x` if finite and nonzero, and `1/x` overflows or underflows, + /// then `x.reciprocal` is `nil`. Otherwise, `a.reciprocal` is `1/x`. /// - /// If `b.reciprocal` is non-nil, you may be able to replace division by `b` + /// If `x.reciprocal` is non-nil, you may be able to replace division by `x` /// with multiplication by this value. It is not advantageous to do this /// for an isolated division unless it is a compile-time constant visible /// to the compiler, but if you are dividing many values by a single @@ -124,7 +124,7 @@ extension Real { /// ``` /// /// Error Bounds: - /// - + /// /// Multiplying by the reciprocal instead of dividing will slightly /// perturb results. For example `5.0 / 3` is 1.6666666666666667, but /// `5.0 * 3.reciprocal!` is 1.6666666666666665. @@ -135,12 +135,14 @@ extension Real { /// operators to denote real-number arithmetic, and normal operators /// for floating-point arithmetic): /// + /// ``` /// a * b.reciprocal! = a * (1/b) /// = a * (1 ⊘ b)(1 + δ₁) /// = (a ⊘ b)(1 + δ₁)(1 + δ₂) /// = (a ⊘ b)(1 + δ₁ + δ₂ + δ₁δ₂) + /// ``` /// - /// where 0 < δᵢ <= ulpOfOne/2. This gives a roughly 1-ulp error, + /// where `0 < δᵢ <= ulpOfOne/2`. This gives a roughly 1-ulp error, /// about twice the error bound we get using division. For most /// purposes this is an acceptable error, but if you need to match /// results obtained using division, you should not use this.