Followers 0

# How are the trigonometric functions computed?

## 8 posts in this topic

There has been lurking in my mind a question for way too long, without being able to find a suitable, satisfying answer.

How are sin(), cos(), and tan() functions calculated on a calculator or computer?

I understand that mathematicians use the famous unit circle to define the trigonometric functions, but if

sin(?/4)=o/1

o= sin(?/4)*1

a=cos(?/4)*1

tan(?/4)=sin(?/4)

_______

cos(?/4)

So we are still left with the question, how is sine, cosine and tangent computed?

All the books and references that I read basically just suggest to use the calculator, in other words computed by magic or dogma.

Edit: I now remember that they use the Pythagorean theorem.

h²=o²+a²

?=?/4

o=a

1²=2o²

___

?1/2 = o

___

a= ?1/2

___

sin(?/4)=?1/2

_____

1

___

cos(?/4)=?1/2

_____

1

___

tan(?/4)=?1/2

_____

?1/2

But how do they compute the rest of angles?

Edited by gasto
0

##### Share on other sites
Another interesting approach is CORDIC.
2

##### Share on other sites

Some hardware also uses interpolation (linear, quadratic, cubic, whatever) between lookup table entries.

0

##### Share on other sites

Another interesting approach is CORDIC.

I implemented all the trig/power/hyperbolic/ect... functions for my fixed point math library using CORDIC math.  Its simple, brilliant, and ridiculously fast.  I know it was used in older hardware, whether its still used to this day I am unsure of.  But if you like math its well worth learning.

edit: wrote float originall, meant fixed

Edited by Ryan_001
0

##### Share on other sites

Or you could go really old-school and try and figure out Ptolemy's Table of Chords. I only got to the first paragraph of the Special Angles section before I decided I have better things to do.

0

##### Share on other sites

I understand that mathematicians use the famous unit circle to define the trigonometric functions, but if [...]

Just to make things clear: The trigonometric functions are usually defined analytically. See the
Wiki page.
It can then be shown that these functions give you all the nice properties you already know.
The important point to make is: you _can_ get the value of sin(x) by _computing_ the value of a series!
You're not restricted to fix points and drawings on unit circles!
Most answers above present techniques to approximate the costly computation of the exact values.
0

##### Share on other sites

Mathematically, the easiest way is using a truncated infinite series and precomputing all the factorials and coefficients you'll need.

Actual computation is highly system-dependent. There are software implementations, like this IBM implementation (the code is complex and divided up into angle intervals with if/then/else statements to be fast) or this fdlibm code (which is easier to read). x86 processors have trig functions implemented in assembly and the FPU uses it's fsin() function.

0

## Create an account

Register a new account