How was the Sine function programmed? The actual equation?

  • Context: Undergrad 
  • Thread starter Thread starter christian0710
  • Start date Start date
  • Tags Tags
    Function Sine
Click For Summary

Discussion Overview

The discussion centers around the mathematical foundations and algorithms used to compute the sine function in calculators. Participants explore various methods, including Taylor series and CORDIC algorithms, while seeking to understand the underlying equations that allow for precise calculations of sine values for given angles.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses curiosity about how calculators derive sine values with high precision, suggesting there must be an underlying mathematical equation.
  • Another participant proposes that Taylor's theorem can approximate sine values, providing a series expansion but notes that it requires the angle to be in radians.
  • A later reply critiques the efficiency of using Taylor series for calculations and introduces the CORDIC algorithm as a more effective method for evaluating trigonometric functions.
  • Another participant mentions that calculators may use Chebyshev polynomials for approximations, especially in older computing systems.
  • One participant shares historical context about a Fortran implementation that reduced angles and used polynomial approximations for sine calculations.
  • Several participants express a desire for more accessible resources to understand these methods better, indicating a need for clarification on specific points from the articles referenced.

Areas of Agreement / Disagreement

Participants present multiple competing views on the methods used to compute sine values, including Taylor series and CORDIC algorithms, without reaching a consensus on which is the most effective or accurate approach.

Contextual Notes

Some participants note that the efficiency of different algorithms may vary based on the processing speed of calculators, and there are unresolved questions about the convergence of Taylor series for practical use.

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   Reactions: 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   Reactions: 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   Reactions: 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.
 

Similar threads

Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K