Question

In MATLAB

The value of cos(x) can be approximated using a Maclaurin series + +... cos(x)=1-1 2! 4! 6! Which can be expressed compactly

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc;
clear;
close all;
x = 2;
k = 1;
sum = 0;
while (k <= 5)
sum = sum + (-1)^(k-1)*(x^(2*(k-1)))/factorial(2*(k-1));
k = k+1;
end
val = cos(2);
fprintf('Using the Maclaurin series cos(2.0) with 5 terms is %0.4f \n',sum);
fprintf('The value of cos(x) using the built-in cos function is %0.4f \n',val);

Find Files Run Section Compare Go To Insert fx Fil Comment % 9 % Indent 5 New Open Save Breakpoints Run Advance Run and AdvanCommand Window Using the Maclaurin series cos (2.0) with 5 terms is -0.4159 The value of cos(x) using the built-in cos functi

Add a comment
Know the answer?
Add Answer to:
In MATLAB The value of cos(x) can be approximated using a Maclaurin series + +... cos(x)=1-1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT