I'm trying to understand the types of numerical errors, to do this I want to calculate numerically. To do this I use the Taylor series of in 0:
To make the calcultaions I did the following Fortran program:
program main
implicit none
real*8 pi, x, res, error
pi=3.14159265
x = pi/2
res = x - x**3/6 + x**5/120 - x**7/5040
error = 1-res
print*, "Result: ",res
print*, "Error: ", error
end
And I get the following results depending of the degreee of the Taylor series and in the decimals of pi.
If
- Taylor 3rd Degree: 0.92501782114084341
- Taylor 5th Degree: 1.0045086615502121
- Taylor 7th Degree: 0.99984349522599403
- Taylor 9th Degree: 1.0000032059098956
- Taylor 11thDegree: 0.99999962708361323
If
- Taylor 3rd Degree: 0.92483221907327295
- Taylor 5th Degree: 1.0045248564076874
- Taylor 7th Degree: 0.99984310136039689
- Taylor 9th Degree: 1.0000035425853664
- Taylor 11thDegree: 0.99999994374102952
And I observe that the error gets bigger if I put more decimals in my approximation. Why is this happening? Edit: Adding more terms to the Taylor expansion (11th degree) makes adding more digits better.
Also, How can I make a better approximation? What method will be better to a problem like this one?
How can I predict the size of these errors?