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

Use MATLAB please! The Maclaurin series can be used to represent certain functio

ID: 3831374 • Letter: U

Question

Use MATLAB please!

The Maclaurin series can be used to represent certain functions such as the one below. cos x = Sigma^infinity_k=0 (-1)^kx^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.95_0 x cos x dx Use a for loop to construct the first 15 terms of the Maclaurin series: Sigma^15_n = 0 (-1)^kx^2k/(2k)! Integrate the Maclaurin series: integral^0.95_0 x(1 - x^2/2! + x^4/4! - x^6/6! + ...) dx 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

Explanation / Answer

syms x

%1
f1 = x*cos(x);

%2 Definite Integrals

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