How do calculators calculate the value of trigonometric functions?

2.3k Views Asked by At

I have an obsession about trig functions. I find them to be so mysterious, because I really don’t understand calculus (other then trying to make sense of it in a few YouTube videos, which doesn’t work for me).

Anyhow I was wondering if someone can explain how calculators find the ratios for sine and cosine by just typing in the degrees.

This seems impossible to me from a logical standpoint. I don’t see any pattern other then as the angle increase the ratio for cosine gets exponentially smaller. If anyone can tell me how you get an exact number for something that has no pattern, please explain it to me in the simplest possible way.

Pretend you're explaining it to your 10-year-old child. I am very visual so anything with pictures would work. If you start getting into Taylor series with calculus, I won’t understand.

I’m basically looking for a simple explanation of what the calculator is doing without getting deep into the math. Thanks in advance.

Cheers

2

There are 2 best solutions below

1
On

I think asking this question without really understanding Taylor Polynomials (or approximations in general) is a bit of a difficult task. What I would suggest if you like graphs and pictures for example, without actually computing the Taylor expansions is to go onto Desmos and plot the first few. Use this link

https://www.desmos.com/calculator/m8mw0nayab By the way, the pattern is $(-1)^n\frac{x^{1+2n}}{(1+2n)!}$ for n as integers including 0.

If you use enough terms in the approximation (other, more accurate approximations are usually used and the values are stored in a table), then you can get accurate values for each value from 0 to 360deg, and then you can just shift any other value (since sine & cosine are repeating functions every 360deg) to within that range.

Hope this helps, let me know if you want more detail.

2
On

Calculators, to my recollection, typically use special summation identities for the sine and cosine functions that take in some angle measure, sum up a bunch of things using that measure, and then pop out a measurement.

It's sort of like how you can approximate the exponential function $e^x$ through its power series, which is the infinite sum below. (I know, you said not to get into Taylor series or anything of the like. I'm not getting into the derivation or whatever - if you simply accept for now and take me at my word that this summation makes sense and is 100% valid, it might be easier for now.)

$$e^x = 1 + \frac{x}{1!} + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!} + ...$$

Imagine sort of stopping that summation at the 10th, or 20th, or 1000th, or 10,000th term - it won't exactly be $e^x$ but it will be an approximation. Not exact, but "close enough" - fractions of a percent off, depending on how far you go.

Lots of such identities exist for various functions - some that are crazy and wacky to look at when taken at first glance, but ones that converge very quickly to "close enough" to the actual value after only a few terms. For example, we can define these summations called "Taylor series" for functions. Their derivation involves the knowledge of calculus, but they have the same core idea as the summation above for $e^x$: take an infinite sum, truncate it at some point, and you have an approximation for the value, which is more accurate the later you truncate.

The Taylor series for sine/cosine and probably the simplest technique for approximation a calculator would use:

$$cos(x) = 1 - \frac{x^2}{2!} + \frac{x^4}{4!}- \frac{x^6}{6!} + \frac{x^8}{8!} - \frac{x^{10}}{10!} + ...$$

$$sin(x) = \frac{x}{1!} - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!} - ...$$

A sort of "refinement" of this idea - I guess anyhow, it's a bit above my head, but I imagine it has the same core principle - is used in some calculators called the "CORDIC algorithm." It's not quite just some basic summation like above, but it has the same core idea. You can probably read up on it here but it seems pretty high-level so don't be surprised - https://ieeexplore.ieee.org/document/7453811


In short, how calculators typically find cosine and sine of functions are by taking known series or algorithms, derived from calculus or even higher math, and using approximation techniques to try and get just "close enough."

The underlying details of why these methods make sense is probably a bit above your head for the time being - I'm not saying it to be rude, but you need a foundation in calculus and derivatives at least to understand the concept of Taylor series, and they're probably some of the more "basic" approximation techniques for stuff of this sort.