X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FODE%2FIVP.hs;h=5bffe08cfff387210c3bdd7cc3f5483dba81c13e;hb=e1bf90ef57aaa37620e001d04cabec0ea2e8ddbf;hp=615c668367bd6a26e22567ed0f70a0f90da6e7c0;hpb=2f54e89d36e835c58efcc281741632d457859b20;p=numerical-analysis.git diff --git a/src/ODE/IVP.hs b/src/ODE/IVP.hs index 615c668..5bffe08 100644 --- a/src/ODE/IVP.hs +++ b/src/ODE/IVP.hs @@ -9,15 +9,18 @@ -- for x in [x0, xN]. -- -module ODE.IVP +module ODE.IVP ( + eulers_method, + eulers_method1, + eulers_methodH ) where -import Misc (partition) -import NumericPrelude hiding (abs) -import qualified Algebra.Field as Field -import qualified Algebra.ToInteger as ToInteger -import qualified Algebra.ToRational as ToRational -import qualified Algebra.RealField as RealField +import Misc ( partition ) +import NumericPrelude hiding ( abs ) +import qualified Algebra.Field as Field ( C ) +import qualified Algebra.ToInteger as ToInteger ( C ) +import qualified Algebra.ToRational as ToRational ( C ) +import qualified Algebra.RealField as RealField ( C ) -- | A single iteration of Euler's method over the interval -- [$x0$, $x0$+$h$]. @@ -31,7 +34,7 @@ import qualified Algebra.RealField as RealField -- >>> eulers_method1 x0 y0 f h -- 2.0 -- -eulers_method1 :: (Field.C a, ToRational.C a, Field.C b) +eulers_method1 :: forall a b. (Field.C a, ToRational.C a, Field.C b) => a -- ^ x0, the initial point -> b -- ^ y0, the initial value at x0 -> (a -> b -> b) -- ^ The function f(x,y) @@ -40,7 +43,7 @@ eulers_method1 :: (Field.C a, ToRational.C a, Field.C b) eulers_method1 x0 y0 f h = y0 + h'*y' where - h' = fromRational'$ toRational h + h' = fromRational'$ toRational h :: b y' = (f x0 y0)