Approximation of COSINE equation

I was given the approximation of COS formula where you get a value close to COS

Here it is:

cos = (1 - (1/2)*radians^2) + ((1/24)*radians^4) - ((1/720)*radians^6)) + ((1/40320)*radians^8)

I always get 1.0 as my answer:(

anyone know the formula to see if I have it correct?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Except for an extra ) it is correct assuming that ^ means exponentiation in the language that you are implementing it in
and that ^ has a higher precedence than *
ClaudeWalkerAuthor Commented:

sin = (radians - (1/6)*Math.pow(radians,3)) + ((1/120)*Math.pow(radians, 5)) - ((1/5040)*Math.pow(radians, 7) + ((1/362880)*Math.pow(radians,9);
cos = (1 - (1/2)*Math.pow(radians,2)) + ((1/24)*Math.pow(radians, 4)) - ((1/720)*Math.pow(radians, 6)) + ((1/40320)*Math.pow(radians,8);
MSSPs - Are you paying too much?

WEBINAR: Managed security service providers often deploy & manage products from a variety of solution vendors. But is this really the best approach when it comes to saving time AND money? Join us on Aug. 15th to learn how you can improve your total cost of ownership today!

ClaudeWalkerAuthor Commented:
There is a missing paranthese in the cos formula which has been corrected however I think the formula is wrong because the sin one works.
>> There is a missing paranthese in the cos formula which has been corrected

In your previous post there is still a ) missing at the end ... But I assume that's the one you fixed ?

        cos = (1 - (1/2)*Math.pow(radians,2)) + ((1/24)*Math.pow(radians, 4)) - ((1/720)*Math.pow(radians, 6)) + ((1/40320)*Math.pow(radians,8));

Looks fine to me, assuming that the fractions are accurate real values, and not rounded integer values. Try calculating one term at a time, and see what results you get for each.
cos = (1 - (1.0/2)*Math.pow(radians,2)) + ((1.0/24)*Math.pow(radians, 4)) - ((1.0/720)*Math.pow(radians, 6)) + ((1.0/40320)*Math.pow(radians,8));

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Math / Science

From novice to tech pro — start learning today.