4 ms·
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
by freemint 4y ago
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.
- deleted 4y ago[deleted]
- texaslonghorn5 4y agoThe 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! + ...