This is the Message Centre for Insight

Excell

Post 1

moke_paranoidandroid

Hi Insight. since you're a computer programmer, I was wondering if you could help me with a technical question. Why does Microsoft Excell give some value for cosine of 90 degrees, when my calculator & common sence tell me the answer is zero? I have converted to radiens first.
Gotasmiley - run.


Excell

Post 2

Insight

When I type the formula =COS(90*(PI()/180)) (multiplying it by pi/180 to convert to radians) into excel, I get 6.12574E-17, which is pretty close to zero.
It even comes up with this number if you enter =COS(ACOS(0)), so evidently it's just an inaccuracy in the way the computer calculates cosines.

If I remember correctly, the formula for a cosine is 1-((x^2)/2!)+((x^4)/4!)-((x^6)/6!)+((x^8)/8!)... and so on forever - of course the computer will only calculate a finite number of these terms, so it won't get the exact answers.


Excell

Post 3

moke_paranoidandroid

Yeah, I kinda worked it out after. If you do it in seperate cells, you can see that it only converts to radiens to about 10 or 15 decimal places, but give cos to an acuracy demanding E-17. this is obviously going to lead to problems. But I clicked on the comma so it only displayed zero, which made me feel much better about it!smiley - smiley

I think we worked out that formula in maths once. Does it come from the McLauren series?


Excell

Post 4

Insight

McLauren series rings a bell. I don't really know how the formula is worked out, I just remember it. (I kind of figured it out knowing that the small angle approximation is 1-((x^2)/2))

Maybe I'll look it up on mathworld.wolfram.com, see if I can find how the formula is derived.


Key: Complain about this post

More Conversations for Insight

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more