How was the Sine function programmed? The actual equation?

In summary: Otherwise, you can try searching for a textbook on numerical methods that covers the CORDIC algorithm in depth.
  • #1
christian0710
409
9
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
  • #2
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

[tex]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}[/tex]

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
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

[tex]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}[/tex]

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
  • #4
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
  • #5
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
  • #6
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
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.
 

FAQ: How was the Sine function programmed? The actual equation?

1. How was the Sine function programmed?

The Sine function was programmed using a combination of mathematical principles and computer programming techniques. The equation for the Sine function is typically represented as sin(x), where x is the input variable. This equation is then translated into code using programming languages such as C++, Java, or Python. The code allows the computer to perform the necessary calculations and output the corresponding sine value for any given input.

2. What is the actual equation for the Sine function?

The actual equation for the Sine function is sin(x) = opposite/hypotenuse, where x is the angle in a right triangle and opposite and hypotenuse are the lengths of the sides of the triangle. In other words, the sine value of an angle is equal to the length of the side opposite the angle divided by the length of the hypotenuse.

3. How does the Sine function work in a computer?

In a computer, the Sine function is programmed using a series of calculations and approximations. The computer uses the input value (x) to calculate the corresponding angle in a right triangle, then uses the above equation to determine the sine value. This process is repeated for each input value to create a table of values that the computer can then use to graph the Sine function.

4. Are there any limitations to the accuracy of the Sine function?

Yes, there are limitations to the accuracy of the Sine function in a computer. Due to the use of approximations and rounding in the programming, the sine values may not be entirely accurate. Additionally, the precision of the input values and the limitations of the computer's hardware can also affect the accuracy of the Sine function.

5. Can the Sine function be used for other applications besides graphing?

Yes, the Sine function has various applications in fields such as mathematics, physics, and engineering. It is commonly used to model periodic phenomena, such as sound waves and electrical currents. It also has applications in signal processing and data analysis. The Sine function can also be used in trigonometric identities and equations to solve problems in math and science.

Similar threads

Replies
4
Views
2K
Replies
3
Views
1K
Replies
8
Views
2K
Replies
7
Views
2K
Replies
4
Views
2K
Replies
8
Views
9K
Replies
5
Views
2K
Back
Top