packages feed

AERN-Real-0.9.7: tests/ISin3.hs

{-# LANGUAGE CPP #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveDataTypeable #-}
module Main

where

import qualified Data.Number.ER.Real as AERN
import qualified Data.Number.ER.RnToRm as AERNFunc
import Data.Number.ER.BasicTypes
import Data.Number.ER.Misc
import Data.Number.ER.RnToRm.TestingDefs

import Data.Maybe
import qualified Data.List as List
import qualified Data.Map as Map

#ifdef USE_MPFR
type B = AERN.BMPFR -- use MPFR floats
#else
type B = AERN.BAP -- use pure Haskell floats
--type B = AERN.BMAP -- use combination of double and pure Haskell floats
#endif
type RA = AERN.RA B
type IRA = AERN.IRA B

main =
    do
    AERN.initialiseBaseArithmetic (0 :: RA)
    putStrLn $ "integ(sin(sin(sin(x)))dx = " ++ show result
    putStrLn $ " precision = " ++ show (AERN.getPrecision result)
    where
    result = 
        head $ 
            AERNFunc.eval (AERNFunc.unary 1) $ 
                AERNFunc.integrateUnary 0 
                    (sin3 120 0 42 160) 
                    0 (0 AERN.\/ 1) [0]
    sin3 ix depth deg gran = 
        AERN.sin ix $ 
            AERN.sin ix $ 
                AERN.sin ix $ 
                    AERNFunc.bisectUnbisectDepth depth $ 
                        AERN.setMinGranularity gran $ 
                            AERNFunc.setMaxDegree deg fapwUPX0