Question

# 2. Let f(x) = sin(2x) and x0 = 0. (A) Calculate the Taylor approximation T3(x) (B)....

2. Let f(x) = sin(2x) and x0 = 0.
(A) Calculate the Taylor approximation T3(x)
(B). Use the Taylor theorem to show that
|sin(2x) − T3(x)| ≤ (2/3)(x − x0)^(4).
(C). Write a Matlab program to compute the errors for x = 1/2^(k) for k = 1, 2, 3, 4, 5, 6, and verify that
|sin(2x) − T3(x)| = O(|x − x0|^(4)).

%%Matlab code for Taylor series T3(X)
clear all
close all
%function T3(x) around x0=0
T3= @(x) 2*x-(4/3)*x^3;
x0=0;
%loop for all x values and corresponding error for T3(x)
for k=1:6
%all x values
xx(k)=1/(2^k);
%all error abs(sin(2*x)-T3(x))
err_left(k)=abs(sin(2*xx(k))-T3(xx(k)));
%all error abs(x-x0))^4
err_rght(k)=(abs(xx(k)-x0))^4;
%Printing the result
str=sprintf('1/2^%d',k);
fprintf('For k=%d and x=%s, error =abs(sin(2*x)-T3(x)) is %e and error= abs(x-x0))^4 is %e ',k,str,err_left(k),err_rght(k))

end

%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%

#### Earn Coins

Coins can be redeemed for fabulous gifts.