ContinuedFractionsSolver
public struct ContinuedFractionsSolver
Continued Fractions can be used to find an
approximation to a given Rational number
-
Declaration
Swift
public enum FindApproximationError : Error -
Finds an approximation to a
valuewith a difference belowlimit.Declaration
Swift
public static func findApproximation(of value: Rational, differenceBelowOrEqual limit: Rational) -> Result<Rational, FindApproximationError>Parameters
valueRationalnumber for which an approximation is required.limitRationalnumber that sets the maximum difference between the result andvalue.Return Value
A
Rationalnumber which distance tovalueis below or equal tolimit. OrFindApproximationErrorerror.
ContinuedFractionsSolver Structure Reference