Question

Small computers often use table to estimate the cosine curve, but if high precision is needed,...

Small computers often use table to estimate the cosine curve, but if high precision is needed, a series solution can be used instead. A Taylor series solution for cosine is presented below

cosx=1-x^2/2!+x^4/4!-x^6/6!+x^8/8!

  1. Create a Matlab function that can calculate an estimate for cos(x) given X and the number of terms. Test it for cos(2) with 10 terms in the series and cos(7) with 200 terms.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
function result = myCos(x, n)
    result = 0;
    sign = 1;
    for i=0:n-1
        if factorial(2*i) ~= Inf
            result = result + (sign*(x^(2*i))/factorial(2*i));
            sign = -1*sign;
        end
    end
end

myCos(2, 10)
myCos(7, 200)
Add a comment
Know the answer?
Add Answer to:
Small computers often use table to estimate the cosine curve, but if high precision is needed,...
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