fractionizer-0.17.0.0: Numbers in the range [0.005, 1] as a sum of 2, 3, 4 or 5 unit fractions of special types.
Safe HaskellSafe-Inferred
LanguageHaskell2010

UnitFractionsDecomposition2

Synopsis

Documentation

threeDigitsK :: Double -> Double Source #

Rounding to thousandth.

type ErrorImpact = Int Source #

Characterizes the impact of the absolute error sign on the approximation.

absErr2Frac :: Double -> Double -> Double Source #

Absolute error with sign for the two unit fractions approximations and the first argument (a in the related paper) being taken as the second parameter for the function. The second argument here is expected to be fromIntegral a0 where elem a0 [2..] == True.

absErr2FracI :: ErrorImpact -> Double -> Double -> Double Source #

A generalization of the absErr2Frac with the possibility to check the sign.

setOfSolutionsGmin :: ErrorImpact -> Double -> (Double, Double) Source #

Searches for the minimum absolute error solution to two unit fractions decomposition (approximation) for the fraction in the isRangeN True values with taking into account the sign of the absolute error.

If the ErrorImpact parameter is equal to 0 , then absolute error can be of any sign, otherwise the sign of it is the same as the sign of the ErrorImpact argument.

setOfSolutionsGmin3 :: Integral a => ErrorImpact -> a -> Double -> (Double, Double) Source #

A variant of setOfSolutionsGmin where possible Integral values are not equal to the second argument.

suitable2 :: Double -> (Double, Double) Source #

Searches for the minimum absolute error solution to two unit fractions decomposition (approximation) for the fraction in k the isRangeN k = True.

suitable21G :: ErrorImpact -> Double -> Maybe ([Double], Double) Source #

Allows to take into account the sign of the absolute error of the aproximation. If the ErrorImpact parameter is equal to 0 , then absolute error can be of any sign, otherwise the sign of it is the same as the sign of the ErrorImpact argument.

suitable21G3 :: Integral a => ErrorImpact -> a -> Double -> Maybe ([Double], Double) Source #

A variant of suitable21G where possible Integral values are not equal to the second argument.

isRangeNPref :: Double -> Bool Source #

The preferable range of the argument for suitable2 and suitable21 functions. For arguments in this range the functions always have informative results.

check1FracDecompG :: ErrorImpact -> Double -> Maybe ([Double], Double) Source #

Allows to take into account the sign of the absolute error of the aproximation. If the ErrorImpact parameter is equal to 0 , then absolute error can be of any sign, otherwise the sign of it is the same as the sign of the ErrorImpact argument.

check3FracDecompPartialG :: ErrorImpact -> Double -> Maybe ([Double], Double) Source #

Allows to take into account the sign of the absolute error of the aproximation. If the ErrorImpact parameter is equal to 0 , then absolute error can be of any sign, otherwise the sign of it is the same as the sign of the ErrorImpact argument.

check3FracDecompPartialPG :: ErrorImpact -> [Int] -> Double -> Maybe ([Double], Double) Source #

Allows to take into account the sign of the absolute error of the aproximation. If the ErrorImpact parameter is equal to 0 , then absolute error can be of any sign, otherwise the sign of it is the same as the sign of the ErrorImpact argument.

check3FracDecompPartialPG3 :: ErrorImpact -> [Int] -> Double -> Maybe ([Double], Double) Source #

A variant of check3FracDecompPartialPG where there is no possible equal Integral values as the result.

lessErrSimpleDecompPG :: ErrorImpact -> [Int] -> Double -> (Int, Maybe ([Double], Double), Double) Source #

Allows to take into account the sign of the absolute error of the aproximation. If the ErrorImpact parameter is equal to 0 , then absolute error can be of any sign, otherwise the sign of it is the same as the sign of the ErrorImpact argument.

lessErrDenomsPG :: ErrorImpact -> [Int] -> Double -> [Integer] Source #

Allows to take into account the sign of the absolute error of the aproximation. If the ErrorImpact parameter is equal to 0 , then absolute error can be of any sign, otherwise the sign of it is the same as the sign of the ErrorImpact argument.

check1FracDecomp :: Double -> Maybe ([Double], Double) Source #

Tries to approximate the fraction by just one unit fraction. Can be used for the numbers between 0.005 and 0.501.

check3FracDecompPartial :: Double -> Maybe ([Double], Double) Source #

Function to find the less by absolute value error approximation. One of the denominators is taken from the range [2..10]. The two others are taken from the appropriate suitable21 applicattion.

check3FracDecompPartialP :: [Int] -> Double -> Maybe ([Double], Double) Source #

Extended version of the check3FracDecompPartial with the first denominator being taken not - only from the [2..10], but also from the custom user provided list. -

lessErrDenomsP :: [Int] -> Double -> [Integer] Source #

Returns a list of denominators for fraction decomposition using also those ones from the the list provided as the first argument. Searches for the least error from the checked ones.

lessErrSimpleDecomp4PG :: ErrorImpact -> [Int] -> Double -> ([Integer], Double) Source #

Returns a unit fraction decomposition into 4 unit fractions. For the cases where the fraction can be represented as a sum of three or less unit fractions, the last element in the resulting list is really related to the floating-point arithmetic rounding errors and it depends on the machine architecture and the realization of the floating-point arithmetic operations. Almost any Double value inside the [0.005, 2/3] can be rather well approximated by the sum of 4 unit fractions from the function here. There are also some intervals in the (2/3, 1] that have also good approximations, though not every fraction is approximated well here.

lessErrSimpleDecomp5PG :: ErrorImpact -> [Int] -> Double -> ([Integer], Double) Source #

Returns a unit fraction decomposition into 5 unit fractions. For the cases where the fraction can be represented as a sum of three or less unit fractions, the last element(s) in the resulting list is (are) really related to the floating-point arithmetic rounding errors and it depends on the machine architecture and the realization of the floating-point arithmetic operations. Almost any Double value inside the [0.005, 2/3] can be rather well approximated by the sum of 5 unit fractions from the function here. There are also some intervals in the (2/3, 1] that have also good approximations, though not every fraction is approximated well here.