{-# LANGUAGE NoImplicitPrelude #-}
module MathObj.PowerSeries.DifferentialEquation where
import qualified MathObj.PowerSeries.Core as PS
import qualified MathObj.PowerSeries.Example as PSE
import qualified Algebra.Field as Field
import qualified Algebra.ZeroTestable as ZeroTestable
import NumericPrelude.Numeric
import NumericPrelude.Base
solveDiffEq0 :: (Field.C a) => [a]
solveDiffEq0 =
let
y = PS.integrate 0 y'
y' = PS.integrate 1 y''
y'' = PS.scale (-2) (PS.add y' y)
in y
verifyDiffEq0 :: (Field.C a) => [a]
verifyDiffEq0 =
PS.mul (zipWith (*) (iterate negate 1) PSE.exp) PSE.sin
propDiffEq0 :: Bool
propDiffEq0 = solveDiffEq0 == (verifyDiffEq0 :: [Rational])
solveDiffEq1 :: (ZeroTestable.C a, Field.C a) => [a]
solveDiffEq1 =
let
y = PS.integrate 1 y'
y' = PS.integrate 1 y''
y'' = PS.scale 2 (PS.mul y' y)
in y
verifyDiffEq1 :: (ZeroTestable.C a, Field.C a) => [a]
verifyDiffEq1 = PS.divide [1] [1, -1]
propDiffEq1 :: Bool
propDiffEq1 = solveDiffEq1 == (verifyDiffEq1 :: [Rational])