The functions e^x, e^-x, e^(-x^2), erf(x) and Taylor Series
Accurate digits are highlighted in green. Calculations are used with a TI 84 Plus CE.
e^x = 1 + x + x^2/2! + x^3/3! + x^4/4 + … = Σ(x^n/n!, from n = 0 to ∞)
x = | e^x | 10 terms | 25 terms | 50 terms |
1 | 2.718281828 | 2.718281801 | 2.718281828 | 2.718281828 |
3 | 20.08553692 | 20.07966518 | 20.08553692 | 20.08553692 |
5 | 148.4131591 | 146.380601 | 148.4131591 | 148.4131591 |
9.9 | 19930.37044 | 11869.50538 | 19930.07221 | 19930.37044 |
e^(-x) = 1 – x + x^2/2! – x^3/3! + x^4/4 - … = Σ( (-x)^n/n!, from n = 0 to ∞)
x = | e^(-x) | 10 terms | 25 terms | 50 terms |
1 | 0.3678794412 | 0.3678794643 | 0.3678794412 | 0.3678794412 |
3 | 0.0497870684 | 0.0533258929 | 0.0497870684 | 0.0497870684 |
5 | 0.006737947 | 0.8640390763 | 0.0067379439 | 0.006737947 |
9.9 | 5.017468206E-5 | 1207.799663 | -0.1392914019 | 5.017463241E-5 |
I think you know where I’m going.
e^(-x^2) = 1 – x^2 + x^4/2! – x^6/3! + x^8/4! = Σ( (-x)^(2*n)/n!, from n = 0 to ∞)
x = | e^(-x^2) | 10 terms | 25 terms | 50 terms |
1 | 0.3678794412 | 0.3678794643 | 0.3678794412 | 0.3678794412 |
3 | 1.234098041E-4 | 442.2750223 | -0.0118646275 | 1.234194001E-4 |
5 | 1.38879439E-11 | 18613495.8 | -2834107793 | 85689.40174 |
9.9 | 2.72143414E-43 | 2.04347238E13 | -3.10254183E24 | 7.951057508E34 |
(Something really goes bonkers as x increases and n increases)
Error Function
erf(x) = 2/√π * ∫(e^(-t^2) dt, 0, x)
= 2/√π * (x – x^3/3 + x^5/(5*2!) – x^7/(7*3!) + x^9/(9*4!) - ...)
= 2/√π * Σ( (-x^(2n+1)/((2n+1)*n!) from n = 0 to ∞ )
x = | erf(x) | 10 terms | 25 terms | 50 terms |
1 | 0.8427007929 | 0.8427007941 | 0.8427007929 | 0.8427007929 |
3 | 0.9999779095 | 68.58627744 | 0.9992050426 | 0.9999779095 |
5 | 1 | 4853382.901 | -3070260210.4 | 4724.331354 |
9.9 | 1 | 1.076461715E13 | -6.7395908E23 | *overflows during calculation* (Result: 8.73442E33 from WolframAlpha) (erf(x) is practically 1 for x > 3) |
Note: 9.9^(2*50+1) ≈ 3.623E100
Thoughts:
* Taylor series are great when x is near its center point. In the all the cases above, the center point is x = 0.
* The more simple the expression, the better range of accuracy with less terms.
* Before you recommend a Taylor Series to approximate f(x), check the accuracy and the range. A cautionary tale.
Eddie
This blog is property of Edward Shore, 2016.
The functions e^x, e^-x, e^(-x^2), erf(x) and Taylor Series
Reviewed by Anonymous
on
07:12
Rating:
No comments: