How was the Sine function programmed? The actual equation?

  • Thread starter Thread starter christian0710
  • Start date Start date
  • Tags Tags
    Function Sine
AI Thread Summary
The sine function is calculated using mathematical equations that allow calculators to output precise values for angles. While the Taylor series can approximate sine values, it is inefficient for calculators, which typically use the CORDIC algorithm for faster computation. This algorithm employs pre-calculated coefficients and reduces angles to specific ranges for more accurate results. Additionally, older systems have utilized Chebyshev polynomials for similar purposes. Understanding these methods can enhance knowledge of how trigonometric functions are programmed in calculators.
christian0710
Messages
407
Reaction score
8
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 :)
 
Mathematics news on Phys.org
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!
 
micromass said:
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!
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
 
  • Like
Likes christian0710
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.
 
  • Like
Likes christian0710
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.
 
  • Like
Likes 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?
 
christian0710 said:
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?
Perhaps if you would tell us what you don't understand about the article or the method, we could help clarify it for you.
 
Back
Top