numeric-prelude- An experimental alternative hierarchy of numeric type classes

Safe HaskellNone



Lazy evaluation allows for the solution of differential equations in terms of power series. Whenever you can express the highest derivative of the solution as explicit expression of the lower derivatives where each coefficient of the solution series depends only on lower coefficients, the recursive algorithm will work.



solveDiffEq0 :: C a => [a]Source

Example for a linear equation: Setup a differential equation for y with

    y   t = (exp (-t)) * (sin t)
    y'  t = -(exp (-t)) * (sin t) + (exp (-t)) * (cos t)
    y'' t = -2 * (exp (-t)) * (cos t)

Thus the differential equation

    y'' = -2 * (y' + y)


The following function generates a power series for exp (-t) * sin t by solving the differential equation.

solveDiffEq1 :: (C a, C a) => [a]Source

We are not restricted to linear equations! Let the solution be y with y t = (1-t)^-1 y' t = (1-t)^-2 y'' t = 2*(1-t)^-3 then it holds y'' = 2 * y' * y

verifyDiffEq1 :: (C a, C a) => [a]Source