-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Allows to approximate the fractional numbers in the range [0.005, 1] with sum of 2 or 3 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.8.0.0 module UnitFractionsDecomposition2 -- | Rounding to thousandth. threeDigitsK :: Double -> Double -- | Characterizes the impact of the absolute error sign on the -- approximation. type ErrorImpact = Int -- | 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, if it is equal to -1 - the absolute -- error can be only negative, otherwise - only positive -- -- setOfSolutionsG :: ErrorImpact -> Double -> [(Double, Double)] setOfSolutions :: Double -> [(Double, Double)] -- | Partially defined function, if there is no solutions then returns a -- tuple of undefined. Beter to use suitable21 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, if it is equal to -1 - the absolute -- error can be only negative, otherwise - only positive 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, if it is equal to -1 - the absolute -- error can be only negative, otherwise - only positive 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, if it is equal to -1 - the absolute -- error can be only negative, otherwise - only positive 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, if it is equal to -1 - the absolute -- error can be only negative, otherwise - only positive 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, if it is equal to -1 - the absolute -- error can be only negative, otherwise - only positive 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, if it is equal to -1 - the absolute -- error can be only negative, otherwise - only positive 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]