News for hackers. Stuff that matters.
Re:A lazy way to solve differential equations by freemint on Friday July 22, 2022 @12:03PM (#32193527)
I just noticed:

> For example, do you want to approximate some complicated integral? Just use the Stream x that we previously defined:

> ghci> erf = 0 :> exp (-x^2) > ghci> take 10 (toList erf) > [0.0,1.0,-0.0,-2.0,0.0,12.0,0.0,-120.0,0.0,1680.0]

This is not even close to the tailor series of the erf function. This to me looks more like x' = exp(-x^2) which is entirely unrelated to the integral.

Re:A lazy way to solve differential equations by texaslonghorn5 on Friday July 22, 2022 @12:48PM (#32194142)
The two are related because erf(x) is the integral of exp(-t^2) from 0 to x. So this is correct if you interpret coefficients in the basis {x^n/n!} and drop the scaling factor of 2/sqrt(pi).

The Taylor series of exp has a 1 in the zeroth coefficient, so integrating from 0 to x we get a 1 in the 1st coefficient of erf.

exp(-x^2) = 1 - x^2 + x^4/2 - x^6/6 + ...

= 1/0! - 2x^2/2! + 12x^4/4! - 120x^6/6! + ...

erf(x) = x/1! - 2x^3/3! + 12x^5/5! - 120x^7/7! + ...