What algorithm do calculators follow to find sine values?

If someone gives me a tilt angle of 38 degrees, how do I know the value of the sine function for this value without actually using the right triangle with 38 degrees and measuring the sides? I know that I can use some trigonometric identities to close values, but that would be time consuming.

I am sure that the algorithms used in calculators and computers do not resort to this. For example, if I need to find pi, I will use the following algorithm:

A very efficient algorithm used to compute the value of pi

instead of getting a compass and a ruler and drawing circles.

However, I cannot find such an algorithm for a sine wave.

Can someone please help me with this?

+6
source share
3 answers

One of the most common algorithms for this is to take the first few members of the Taylor series for sine.

sin x = x - x3/3! + x5/5! - x7/7! + ...,

The more terms you get, the better the approximation. Here X is in radians, but you can easily get radians from degrees. And then, as you can see, only basic operations can be used to calculate the sine: +, -, *, /.

In machines with floating point coprocessor chips, the CORDIC algorithm (with several other modules) is used, since it can also be implemented in hardware.

+5
source

Improving John's answer:

Create a table sin (x) for x in different radians from 0 to pi / 2.

You can use interpolation as follows: sin (x + dx) = sin (x) + dx * cos (x)

cos (x) = sin (pi / 2-x).

Similarly, cos (x + dx) = cos (x) - dx * sin (x).

+2
source

I do not know what is actually used by any calculators, but the search table with linear (or higher, if you want) interpolation should be simple and accurate for three points of accuracy or more with a denser table. You will need a table in just a quarter of the cycle, and you can use it for all sine and cosine calculations with the corresponding transformations. If you have enough power and accuracy, you can try repeating the Taylor series or something like that, but rounding errors will accumulate on you.

+1
source

All Articles