- Dr. Alistair Ward
- Exports a common interface for square-root implementations.
- Provides utilities for these implementations.
- class Algorithm algorithm where
- class Iterator algorithm where
- type Result = Rational
- type Estimate = (Result, DecimalDigits)
- getAccuracy :: Real operand => operand -> Result -> DecimalDigits
- getDiscrepancy :: Real operand => operand -> Result -> Result
- getEstimate :: Real operand => operand -> Estimate
- isPrecise :: Real operand => operand -> Result -> Bool
Defines the methods expected of a square-root algorithm.
|:: Real operand|
An initial estimate from which to start.
The required precision.
The value for which to find the square-root.
Returns an improved estimate of the square-root, found using the specified algorithm, accurate to at least the required number of decimal digits.
The interface required to iterate, from an estimate of the required value, to the next approximation.
|:: Real operand|
The value for which the square-root is required;
The current estimate;
An improved estimate;
The ultimate ratio of successive terms as the iteration converges.
Contains an estimate for the square-root of a value, and its accuracy.
- For a given value and an estimate of its square-root, returns the number of decimals digits to which the square-root is accurate; including the integral digits.
- CAVEAT: the result returned for an exact match has been bodged.
- The signed difference between the square of an estimate for the square-root of a value, and that value.
- Positive when the estimate is too low.
- CAVEAT: the magnitude is twice the error in the square-root.
Double-precision floating-point arithmetic, to obtain an initial estimate for the square-root, and its accuracy.