Eeeeeeeee... Functions often can be approximated by infinite series. The approximation becomes better as more terms are added in the series. The exponential function ex can be approximated by the series
The notation n! represents the factorial of number n, n!=1*2*3...*n, 0!=1. The MATLAB function factorial performs this computation.
Use the MATLAB function exp to calculate the "true" value of ex for a given value of x. The difference between the true and approximated values is the approximation error. The tolerance is the amount of error that we are willing to accept. Usually, we are willing to accept this error due to practical limitations on computing time or memory. The smaller the tolerance we choose, the more accurate the approximation becomes.
Write a program that uses the series shown above to approximate e0.5. The program should start by approximating e0.5 with just the first term of the series and add the additional terms one by one until a tolerance of 0.001 is satisfied. The program should show one line of output for each additional term used. This line of output should display the number of terms used, the approximated value of e0.5, and the approximation error. Below is an example of what the first few lines of output may look like:
No. of Terms Approximation Error
1 1.000000 0.648721
2 1.500000 0.148721
|