Question: 1. In class, we wrote the code for successive taylor approximations of e^x . Now we want to do error analysis. I have given you

1. In class, we wrote the code for successive taylor approximations of e^x . Now we want to do error analysis. I have given you that code and an additional code for this problem. In one figure, plot the actual error and also plot the max error bound the remainder term in the Taylor series provides. In a second figure, plot the difference between these two. In your written document, briefly explain why there is a difference.

actual_errors = zeros(1,20); %this makes a 20 entry array to put your answers in error_term = zeros(1,20); x = [-4:.01:4]; x0 = 1; func = exp(x); T0 = exp(x0); T_approx = T0; for i = 1:20 T_i = exp(x0).*((x-x0).^i)/factorial(i); T_approx = T_approx + T_i; actual_errors(i) = max(abs(T_approx-func)); % for below, consider tthe above as being in the form coefficient.*((x-x0).^i)/factorial(i) % The Taylor error term is given by maximizing the % coefficient for the (i+1) term %T_coefficient = max(abs(___your term here____)); %put in the term for %the (i+1)th %coefficient %T_iplus = T_coefficient.*(____put the rest here___); %fill in the rest %of the (i+1)th term %T_iplus is the Taylor error Term. error_term(i) = max(abs(T_iplus)); end figure hold on plot(1:20, actual_errors, '*') % the asterisk makes it print a larger %* to make point plots more visible plot(1:20, error_term, '*')

2.Let f(x) = 1/(x+1) . Repeat the previous exercise for this function. (Hints: remember to limit your domain and pick an x0 so as not to explode 1 this function by division by zero. Also, division, as with multiplication, needs to be done elementwise using the .)

use Matlab

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!