Question

In: Advanced Math

Use matlab to plot Taylor approximation for f(x) for x near 0 Given f(x) = exp(x)...

Use matlab to plot Taylor approximation for f(x) for x near 0 Given f(x) = exp(x)

Use subpots to plot and its absolute and realative erros for N= 1,2,3

PLease give matlab code for Taylor and explain in detail, Thank you

Solutions

Expert Solution

syms x
f = exp(x);
T1 = taylor(f, x,'Order',1)
T2 = taylor(f, x, 'Order', 2)
T3 = taylor(f, x, 'Order', 3)


fplot([T1 T2 T3 f])
xlim([-4 4])
grid on

legend('approximation of exp(x) up to O(x)',...
       'approximation of exp(x) up to O(x^2)',...
       'approximation of exp(x) up to O(x^{3})',...
       'exp(x)','Location','Best')
title('Taylor Series Expansion')

or one can paste the code given below

syms x
f = exp(x);
T1 = taylor(f, x,'Order',1)
T2 = taylor(f, x, 'Order', 2)
T3 = taylor(f, x, 'Order', 3)
subplot(4,1,1);
x = linspace(0,10);
y1 = exp(x);
fplot([T1 f])
xlim([-4 4])
grid on
legend('approximation of exp(x) up to O(x)')
title('Taylor Series Expansion')

subplot(4,1,2);
x = linspace(0,10);
f = exp(x);
fplot([T2 f])
xlim([-4 4])
grid on
legend('approximation of exp(x) up to O(x^2)')
title('Taylor Series Expansion')
subplot(4,1,3);
x= linspace(0,10);
f= exp(x);
fplot([T3 f])
xlim([-4 4])
grid on
legend('approximation of exp(x) up to O(x^3)')
title('Taylor Series Expansion')

subplot(4,1,4);
x = linspace(0,10);
f = exp(x);
fplot([T4 f])
xlim([-4 4])
grid on
legend('approximation of exp(x) ')
title('Taylor Series Expansion')


Related Solutions

Matlab Consider f(x) = x^3 - x. Plot it. (a) Use Newton's method with p_0 =1.5...
Matlab Consider f(x) = x^3 - x. Plot it. (a) Use Newton's method with p_0 =1.5 to find an approximation to a root with tolerance TOL = 0.01. (b) Use secant method with p_0 = 0.5 , p_1 =1.5, to answer same question as (a). (c) Use Method of False position with initial approximate roots as in (b).
Compute the Taylor polynomial indicated. f(x) = cos(x), a = 0 T5(x) = Use the error...
Compute the Taylor polynomial indicated. f(x) = cos(x), a = 0 T5(x) = Use the error bound to find the maximum possible size of the error. Round your answer to nine decimal places. cos(0.4) − T5(0.4) ≤
Write the Taylor series for f(x) = cos x about x = 0.
P1. Write the Taylor series for f(x) = cos x about x = 0. State the Taylor polynomials T2(x), T4(x), and T6(x) (note that T3(x) will be the same as T2(x), and T5(x) will be the same as T4(x)). Plot f(x), T2(x), T4(x), and T6(x), together on one graph, using demos or similar (cut-and-paste or reproduce below).
Write a MATLAB function that uses my_sine(x,n) to plot the approximation of the sinefunction from−3π/2 to...
Write a MATLAB function that uses my_sine(x,n) to plot the approximation of the sinefunction from−3π/2 to 3π/2 with increments equal to Δx,where Δx and n(the number ofterms used in the series approximation) should be input arguments of the function andshould be specified by the user.
Given the plot of y=f(x) below, find the plot of y=f−1(x). A coordinate plane has a...
Given the plot of y=f(x) below, find the plot of y=f−1(x). A coordinate plane has a horizontal x-axis labeled from negative 7 to 7 in increments of 1 and a vertical y-axis labeled from negative 7 to 7 in increments of 1. A curve starts at the point left-parenthesis negative 1 comma 0 right-parenthesis, rises at an increasing rate from left to right and passes through left-parenthesis 1 comma 1 right-parenthesis and left-parenthesis 4 comma 6 right-parenthesis. Select the correct...
Find the Taylor series for f ( x ) centered at the given value of a...
Find the Taylor series for f ( x ) centered at the given value of a . (Assume that f has a power series expansion. Do not show that R n ( x ) → 0 . f ( x ) = 2 /x , a = − 4
Find the Taylor series of f(x)=ln(3+2x) about x=0.
Find the Taylor series of f(x)=ln(3+2x) about x=0.
Fourier Series Approximation Matlab HW1:     You are given a finite step function   x(t)=-1, 0<t<4...
Fourier Series Approximation Matlab HW1:     You are given a finite step function   x(t)=-1, 0<t<4          1, 4<t<8 .           Hand calculate the FS coefficients of x(t) by assuming half- range expansion,  for each case below and modify the code. Approximate x(t) by cosine series only (This is even-half range expansion). Modify the below code and plot the approximation showing its steps changing by included number of FS terms in the approximation. Approximate x(t) by sine series only (This...
Given Fxy(x,y)=u(x)u(y)[1-Exp(-x/2)-Exp(-y/2)+Exp(-(x+y)/2)]. Note: The step functions mean that Fxy(x,y)=0 for either or both x<0 and y<0....
Given Fxy(x,y)=u(x)u(y)[1-Exp(-x/2)-Exp(-y/2)+Exp(-(x+y)/2)]. Note: The step functions mean that Fxy(x,y)=0 for either or both x<0 and y<0. Any x or y argument range below zero must be truncated at zero. Determine: a) P{X<=1,Y<=2} Ans: 0.2487 b) P{0.5<X<1.5} Ans: 0.3064 c) P{-1.5<X<=2, 1<Y<=3} Ans: 0.2423
Calculate the second-order Taylor approximation to f(x, y) = 3 cos(x) sin(y) at the point (pi,...
Calculate the second-order Taylor approximation to f(x, y) = 3 cos(x) sin(y) at the point (pi, pi/2)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT