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

The Maclaurin series can be used to represent certain functions such as the one

ID: 3837109 • Letter: T

Question

The Maclaurin series can be used to represent certain functions such as the one below. cos x = sigma_k=0^infinity (-1)^k x^2k/(2k)! = 1 - x^2/2! + x^4/4! - x^6/6! + ... For this problem write a script that will compare the accuracy of the Maclaurin series to a definite integral. To do this: Create a symbolic expression for: x cos x Integrate the symbolic expression: integral_0^0.95 x cos x dx Use a for loop to construct the first 15 terms of the Maclaurin series: sigma_n=0^15 (-1)^k x^2 k/(2k)! Integrate the Maclaurin series: integral_0^0.95 x (1 - x^2/2! + x^4/4! - x^6/6! + ...) dx Find the absolute value of the difference between the two results. Now instead of doing the 15 terms, use a while loop and figure out how many terms you need to get error

Explanation / Answer

syms x

%1
f1 = (x*cos(x));

%2 Definite Integrals

f1
I1 = integral(f1,0,0.95);

%3 Maclaurin series

for n=0:15
trems(n+1) = ((-1).^n + x.^(2*k))/factorial(2*n);
end

%4
I2 = integral(trems,0,0.95);

%5 absolute vlaue
result = abs(I1 - I2);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote