# How do people calculate values for trig functions?

This may sound like a stupid question, but I'm wondering how people originally calculated specific values for trig functions before calculators existed. Did they just draw circles and manually measure the ratios, or was there some more clever method they could use?

• The Taylor Series? For small values. – S.C.B. Mar 17 '16 at 6:36
• This is not a stupid question! – Mhenni Benghorbal Mar 17 '16 at 6:37
• A Google search reveals this – shardulc Mar 17 '16 at 6:42
• Calculators have existed for a long time. In the old days, they were people who knew how to add, subtract, multiply, and divide. One could make a modest living by being a calculator. – André Nicolas Mar 17 '16 at 6:51
• Wikipedia also has a few methods for finding the values of trigonometric functions – shardulc Mar 17 '16 at 6:57

## 2 Answers

I'd have to say that all you need is either to calculate sine or cosine and you can get all other trig functions.

$$\sin(x)=\cos(x-\frac{\pi}2)$$

So you can get sine from cosine and vice versa.

You can make use of the fact that trig functions are periodic.

$$\sin(x)=\sin(x\pm2\pi n),n=0,1,2,3,\dots$$

Lastly, in radians, we can use a Taylor series expansion:

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

And with approximating small angles where $x\approx0$, we have $\sin(x)=\frac{x^1}{1!}-\frac{x^3}{3!}+\frac{x^5}{5!}+O(x^7)$, where error is represented in the $x^7$th term.

If you need to increase accuracy, right out the Taylor Series to make it longer. Preferably, calculate $x$ values close to $0$ and get all other values using trig functions period of $2\pi$.

In How calculators do trigonometry I present a program that computes a close approximation to $\sin(x)$ using the Taylor series about $x=0$. I also use some trig identities to reduce the relevant domain, so that we can choose a truncation that doesn't depend on $x$. This procedure could be done by hand: once the coefficients are tabulated, it takes about 20 additions and multiplications to get a result out of this. In a hand calculation, probably less precision would be required, so fewer terms could be used. (For example, $x-x^3/6+x^5/120$ gives four correct digits for $\sin(x)$ when $x$ is between $0$ and $\pi/4$, while $1-x^2/2+x^4/24$ gives four correct digits for $\cos(x)$ when $x$ is between $0$ and $\pi/4$.)

However, as I discuss at How would you reduce roundoff error in "mod" when implementing a periodic function? this approach has a problem: the "mod" operation has a large numerical error when the dividend is large. As a result, my program gives no correct digits with an input of $10^{16}$, and actually always returns zero once the input is larger than $10^{19}$ or so. This can be alleviated, but not really corrected by raising the precision of the mod calculation and then doing the rest of the calculation back in the lower precision. But then you can just make the argument bigger to break it again. To make things work no matter what you put in, you need more sophisticated techniques; you can search "periodic functions large arguments" to find papers on the subject. One can be found at http://www.csee.umbc.edu/~phatak/645/supl/Ng-ArgReduction.pdf

One of the methods used by "real world" programs is in a similar spirit, but uses an approximation whose error is more uniform. This tends to save work, because my approach uses the same number of terms regardless of the input, even though the method is much more accurate, say, near $0$ than it is near $\pi/2$.