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

MATLAB creating an m file , show m file for Problem 3.5 Problem 3.5 Note : When

ID: 3670533 • Letter: M

Question

MATLAB creating an m file , show m file for Problem 3.5

Problem 3.5

Note : When posting please check the posting in case of errors in code Thank you

The sine function can be evaluated by the following infinite series: sin Create an M-file to implement this fomula so that it computes and displays the values of sin x as each sinx=x- 3!5! term in the series is added. In other words, compute and display in sequence the values for sinx = 3! sin x = x 3! 5! up to the order term of your choosing. For each of the preceding, compute and display the percent relative error as true - series approximation true %error x 100% As a test case, employ the program to compute sin 0.9) for up to and including eight terms the term x15/15! that is, up to

Explanation / Answer

program:

out = 0;
x=0.9;
y = sin(x);

for k = 0:8;
out = out + (-1)^k * x^(2*k+1)/factorial(2*k+1);
percenterror = (abs((out - y)/y))*100;
disp('k=');
disp(k);
disp('percenterror=');
disp(percenterror);
  
  
end

output:

k=
0

percenterror=
14.8946

k=
1

percenterror=
0.6162

k=
2

percenterror=
0.0120

k=
3

percenterror=
1.3530e-004

k=
4

percenterror=
9.9843e-007

k=
5

percenterror=
5.1911e-009

k=
6

percenterror=
2.0041e-011

k=
7

percenterror=
5.6693e-014

k=
8

percenterror=
0