-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Numbers in the range [0.005, 1] as a sum of 2, 3, 4 or 5 unit fractions of special types.
--
-- Inspired by the ancient Egyptian mathematics. See the ideas
-- description and formulation in the related draft paper.
@package fractionizer
@version 0.13.0.0
module UnitFractionsDecomposition2
-- | Rounding to thousandth.
threeDigitsK :: Double -> Double
-- | Characterizes the impact of the absolute error sign on the
-- approximation.
type ErrorImpact = Int
-- | 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.
absErr2Frac :: Double -> Double -> Double
absErrUDecomp3 :: [Double] -> Double -> Double
elemSolution2 :: Integral a => Int -> a -> Double -> Bool
-- | 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.
setOfSolutionsGmin :: ErrorImpact -> Double -> (Double, Double)
-- | Searches for the minimum absolute error solution to two unit fractions
-- decomposition (approximation) for the fraction in k the
-- isRangeN k = True.
suitable2 :: Double -> (Double, Double)
-- | 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.
suitable21G :: ErrorImpact -> Double -> Maybe ([Double], Double)
suitable21 :: Double -> Maybe ([Double], Double)
isRangeN :: Double -> Bool
-- | The preferable range of the argument for suitable2 and
-- suitable21 functions. For arguments in this range the functions
-- always have informative results.
isRangeNPref :: Double -> Bool
-- | 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.
check1FracDecompG :: ErrorImpact -> Double -> Maybe ([Double], Double)
-- | 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 -> Bool -> Double -> Maybe ([Double], Double)
-- | 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 -> Bool -> [Int] -> Double -> Maybe ([Double], Double)
-- | 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.
lessErrSimpleDecompPG :: ErrorImpact -> [Int] -> Double -> (Int, Maybe ([Double], Double), Double)
-- | 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]
-- | Tries to approximate the fraction by just one unit fraction. Can be
-- used for the numbers between 0.005 and 0.501.
check1FracDecomp :: Double -> Maybe ([Double], Double)
-- | 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.
check3FracDecompPartial :: Bool -> Double -> Maybe ([Double], Double)
-- | 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. -
check3FracDecompPartialP :: Bool -> [Int] -> Double -> Maybe ([Double], Double)
lessErrSimpleDecompP :: [Int] -> Double -> (Int, Maybe ([Double], Double), Double)
-- | 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.
lessErrDenomsP :: [Int] -> Double -> [Integer]
-- | 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.
lessErrSimpleDecomp4PG :: ErrorImpact -> [Int] -> Double -> ([Integer], Double)
-- | 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.
lessErrSimpleDecomp5PG :: ErrorImpact -> [Int] -> Double -> ([Integer], Double)
-- | The argument should be greater or equal than 0.005 (1/200) though it
-- is not checked. Returns the representation of the fraction using
-- canonical ancient Egyptian representation and its error as
-- Double value in the resulting tuple.
egyptianFractionDecomposition :: Double -> ([(Integer, Integer)], Double)