Question

MATLABUse the Taylor series cos(x)-1-to compute cos(x) to four decimal places (by comparing the value with the matlab built-in func

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


angle=180 % use an example 180

x=pi*angle/180; % converting degrees to radians
sum=0;
sum1 =cos(x); % using function cos to calculate
i=1;
while abs(sum1-sum)>0.0001 % erroe upto 4 decimal points

sum=sum+((-1)^(i-1)*x^(2*(i-1)))/(factorial(2*(i-1)));
i=i+1;
end

disp(sum)
disp(sum1)
fprintf('Number of iterations required is %d',i)

  

MATLAB R2015a HOME EDITOR Find Files Run Section Go To ▼ Comment New Open Save Breakpoints Run Run and Advance Advance Run an

Add a comment
Know the answer?
Add Answer to:
MATLAB Use the Taylor series cos(x)-1-to compute cos(x) to four decimal places (by comparing the value...
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
ADVERTISEMENT