# How was the Sine function programmed? The actual equation?

Tags:
1. Jun 4, 2015

### christian0710

Hi, I understand that Sine (angle) = opposite/Hypothenus is the ratio of the length of 2 sides in the triangle. However something i never understood and REALLY want to understand is. When you type in some angle in degree in a calculator like sin(14,123221) the calculator spits out a ratio that matches that angle with many descimal points. How can the calculator do this so exact and with so many descimal points? I wouldn't believe that people who invented the sine function manually put in all these values into the calculator, so there must be an underlying mathenmatical equation built into the sine function that converts each degree into specific ratio. What is this equation?

I'd really appreciate some help on this one :)

2. Jun 4, 2015

### micromass

That would be Taylor's theorem (although I guess there are others): http://en.wikipedia.org/wiki/Taylor_series#List_of_Maclaurin_series_of_some_common_functions

In our example, given an angle $\theta$, we can approximate $\sin(x)$ by

$$x - \frac{x^3}{3\cdot 2\cdot 1} + \frac{x^5}{5\cdot 4\cdot 3\cdot 2\cdot 1} - ..... + (-1)^n \frac{x^{2n+1}}{(2n+1)\cdot (2n)\cdot ...\cdot 3\cdot 2\cdot 1}$$

The higher you take $n$, the better you will get to $\sin(x)$. There is even an easy way to point out how much error you are making.

Edit: The above formula assumes that $x$ is in radians, so you need to transform $x$ from degrees to radians first!

3. Jun 4, 2015

### SteamKing

Staff Emeritus
Evaluating a Taylor series to calculate a trig function like sin (x) is a horribly inefficient way to make this calculation.

There is a special algorithm which is programmed into most calculators to evaluate trig and hyperbolic functions:

http://en.wikipedia.org/wiki/CORDIC

4. Jun 4, 2015

### scientific601

The Taylor series may not converge quickly enough for a low processing speed calculator.
I believe a calculator uses a CORDIC algorithm. This other Wiki link about CORDIC shows that there are some tables of coefficients that are used as a basis. On a mini computer I used to use in the mid 70s without any math hardware, their trig library used Chebyshev polynomials.

5. Jun 5, 2015

### bhillyard

Many years ago I read the Fortran Technical manual fora UNIVAC1108. The routines implemented reduced the angle to 0-90 and then split to four ranges. Then it used a 5th degree polynomial in the square of the angle, different coefficients in each of the four ranges.
The function doesn't have to return the sine of the angle, just a value correct to the required number of bits.

6. Jun 5, 2015

### christian0710

Thank you so much for the reference, I want to learn how to do it. Do any of you know a thr0rough reference manual or something with a bit more detail (easier to read) than wikipedia?

7. Jun 5, 2015

### SteamKing

Staff Emeritus
Perhaps if you would tell us what you don't understand about the article or the method, we could help clarify it for you.

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook