Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MatLab Project Lab assignmen Dr.Taoufik Ben Jabeur &Mr.; Samir Naqos Objective:

ID: 3283125 • Letter: M

Question

MatLab Project Lab assignmen Dr.Taoufik Ben Jabeur &Mr.; Samir Naqos Objective: To investigate the approximation of functions by Taylor series using MatLab In this project, we investigate the approximation of (x)-sinhx)where n is the maximum value of the student ID Define a vector v contains your ID numbers (ex: v[ 5789 D Computed the maximum n of v using the command "max Declare your variable x (as your symbolic variable with matlab) Consider the function (x)= sinh (x)-- a. Define the function f(x) (using the command inline) b. Initiate a vector u with size L- 20 (using the command zeros(L) c. Implement the following algorithm: Vector u ( initiate) From 1-1 to Compute the Taylor approximation gofthe function f with order I (using taylor command Compute the area between I and 10 for the function f (using the command int) Compute the area between 1 and 10 for the function g (using the command int Compute the diferent of these areas and put the result in the vector u End of loop d. Compute the Taylor approximation g of the function f with order n (using taylor command) e. Sketch the function f f. Sketch the function g g. New figure (figure h. Sketch the vector u that corresponds to difference between areas of the function f and g versus of Taylor order k. Find the lowest degree in which the difference between the areas of f and g is less or equal to 10-3

Explanation / Answer

clc;

clear all;

syms x;

n=8;

v= [ 2 0 1 5 0 7 5 5 0];

max(v);

f= inline((sin(x)/x)-((x^n)/factorial(n)));

%ezplot(f(x));

res=zeroes(20,1);

for i1=1:20

g=taylor(f(x),0,5);

hold on

%explot(g);

r1=int(f(x),0,5);

r2=int(f(x),0,5);

res(ii)=r1-r2;

end

g=taylor(f(x), 'order',5);

figure

ezplot(f)

hold on

expolt(g)

xlabel('fig1')

%plot(max v)

figure

semilogy(res) % to plot the diffrence between area

legend (' diffrence area');

xlim(0,20) %the range of x axis

ylim(0,20) %the range of y axis