In: Advanced Math
This is a engineering analysis hw question please show your work I will use it to study
PROBLEM 1 (20PT) Perform the following tasks for the function, f(x), shown below.
f(x) := x*cos(pie*x/2.4)-3*x2+ex/1.5 (use this function to answer the following parts a, b, c . there is no figure given) (the work you give me I will use to plug it into Mathcad which is the program we use to show our work) (if you feel like you are unfamiliar with the Taylor series process please pass this question on to someone who does. thanks)
(a) Use a Taylor series expansion, keeping up to the third
derivative term, to approximate the function about the point xo =
2. Plot the function, f(x), and the approximated Taylor Series
function, fTay(x), in a single graph. Display x-axis from -2 to 8.
Show a marker at x = xo.
(b) Re-do the Taylor series expansion, fTay2(x), to show an
expansion up to the third derivative term about the point xo = 4.
Show the function, f(x), and the approximated function, fTay2(x) on
a new plot. Display x-axis from -2 to 8. Show a marker at x = xo.
(c) Do the Maclaurin series expansion, fTay3(x), to show an
expansion up to the third derivative term. Show the function, f(x),
and the approximated function, fTay3(x) on a new plot. Display
xaxis from -2 to 8. Show a marker at x = xo.
%%Matlab code for Taylor series
clear all
close all
%function for Tylor series
f=@(x) x.*cos(pi.*x/2.4)-3.*x.^2+exp(x)./1.5;
fprintf('function for Taylor series f(x)=')
disp(f)
xx=linspace(-2,8);
yy=f(xx);
figure(1)
hold on
plot(xx,yy)
figure(2)
hold on
plot(xx,yy)
figure(3)
hold on
plot(xx,yy)
syms x
%Question 1.
tty=taylor(f,2,3);
fprintf('\n\tTaylor series for x0=2\n')
disp(vpa(tty,2))
yy1=double(tty(xx));
figure(1)
plot(xx,yy1)
plot(2,f(2),'r*')
hold off
box on; grid on
legend('Actual','Taylor series','x0=2')
%Question 2.
tty=taylor(f,4,3);
fprintf('\n\tTaylor series for x0=4\n')
disp(vpa(tty,2))
yy1=double(tty(xx));
figure(2)
plot(xx,yy1)
plot(4,f(4),'r*')
hold off
box on; grid on
legend('Actual','Taylor series','x0=4')
%Question 3.
tty=taylor(f,0,3);
fprintf('\n\tTaylor series for x0=0\n')
disp(vpa(tty,2))
yy1=double(tty(xx));
figure(3)
plot(xx,yy1)
plot(0,f(0),'r*')
hold off
box on; grid on
legend('Actual','Taylor series','x0=0')
%Matlab function for Taylor polynomial for any function
function tty=taylor(f,a,N)
%Taylor polynomial of log(1-x)
%here x is number of terms
%here N is total number of Taylor sum
%loop for taylor sum
syms x
val=f(a);
for k=1:N
ff(x)=diff(f,x,k);
ff_val=(ff(a))/factorial(k);
val=val+ff_val*(x-a)^k;
end
tty(x)=val;
end
%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%