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

1. The Maclaurin series can be used to represent certain functions such as the o

ID: 3578321 • Letter: 1

Question

1. The Maclaurin series can be used to represent certain functions such as the one below. kv2k COS X (2k)! 2! For this compare the accuracy of the Maclaurin series to a definite integral. To problem write a script that will do this: Create a symbolic expression fo x cos x Integrate the symbolic expression: 0.95 x cos x ax Jo Use a for loop to construct the first 15 terms of the Maclaurin series: k 2k (-1) x (2k)! n 0 Integrate the Maclaurin series: x2 x4 x6 r 0.95 x 1 2! 4! 6! Find the absolute value of the difference between the two results. Part 2 Now instead of doing the 15 terms, use a while loop and figure out how many terms you need to get error 10

Explanation / Answer

syms x
a = int(x*sin(x),x, 0, 0.95);
val1=eval(a);
n = 15;
x = 1;
s = [1];
for k=1:n
s(end+1)= (((-1).^k)*x.^(2*k))/factorial(2*k);
end
fun = @(x) sum(s)*x;
val2=integral(fun,0,0.95);
val1
val2