```6 Feb 01

Okay, a while back (August 25th 2000), in this general vicinity (of this
directory), I had a =little= tirade on the use of technology in the math
curriculum.  I said I would have something more constructive later, and I
don't think I ever got around to it.  So in email yesterday, someone asked
me about calculating sine by hand, and because the network went down while
i was composing the email, I decided to give everybody the benefit of my
experience and put up the techniques here.

I am going to tell of two basic ways to calculate sin(x) "by hand"; the
first is how most calculators give results (and it turns out, Maple isn't
any more sophisticated than this) -- using Taylor series
approximations.  This technique involves only +, -, *, and / (which I
assume you can do by hand, but I recommend doing using calculator.  If you
don't have a calculator that works with stacks (aka an HP calculator), you
should write down individual terms so that you don't screw yourself up
with order of operations and parentheses).

I'm not going to explain the math behind Taylor series, other than to
recommend two particular "pre-processing" steps:

1. Make sure the angle of interest is in radians.  Radians are the
"natural" (non)-units of angles, because they relate the angle measurement
to the length of arc the angle cuts off on a unit circle.  So 2*Pi radians
are equivalent to 360 degrees.  Basically, if you have that sucker in
degrees, multiply it by 2 * Pi / 360.  Unit conversion is done.

2. Make sure the angle is between -Pi and Pi.  Because sine is a periodic
function, with period 2*Pi, just subtract or add 2*Pi enough times to get
the angle between those two points.

sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ... +
+ (-1)^(n-1)*x^(2n-1)/(2n-1)! + ....

(and on to infinity!  More about infinity later)

Definitions:  x^n is the regular power function: x * x * .... * x
(n x's multiplied together)
k! is the factorial function: k * (k-1) * (k-2) * ... * 2 *1
(example: 5! = 5*4*3*2*1 = 120)

Obviously, you have to stop at some point.  You can't keep calculating
forever.  However, this series converges rather rapidly (which is why you
see physics profs using the sin(x) = x approximation all the time..it
works well for angles as large as 10 degrees (remember to have it in
radians!)).  And after a certain point, the terms are guaranteed to
decrease - so just stop adding (or subtracting) on terms once the next
term is smaller than the level of precision desired.

Example: I want to calculate sin(15 degrees)

Step 2: I need Pi/12 in decimal (let's see, Pi=3.14159 (memorize that
much, it's pretty easy... "Pi when calculating sine, 3 point 1 4 1 5 9!"))
Pi/12 approx = .261799 (we only had 6 sig figs, so we can't add
and more than that)

Now to the series:
first term:  x=.261799 		  1st estimate: .261799
second term: -x^3/3! = -.0029905  2nd estimate: .258809
third term: x^5/5! = .0000102     3rd estimate: .258819
fourth term: -x^7/7! = -.167*10^-7  stop here - past precision

Look - only three terms to get the sine to 6 decimal places!

Let's check against the Maple calculator:
>evalf(sin(Pi/12));
.2588190451

This is an incredibly fast way to calculate sine, and you can calculate to
any level of precision desired.  This is how computers and calculators do
it, more or less.

However, that method was based on recognizing radians as a natural unit,
and, even more importantly, needs the development of calculus.  This is
not how Ptolemy and the other ancient Greeks made their trig tables to the
half degree.  They had to do =everything= by hand (and everything by
fractions -- they had no decimal-type system!) -- If you wish to see pure
trigonometric and calculating virtuosity, look no further than Archimedes,
my main man, the greatest applied mathematician who ever lived, in my
opinion.

Anyway, back to the Greeks.  For this next method, using trigonometric
identities, one needs one extra operation allowed: taking square
roots.  Taking square roots can be done "by hand" using Newton's method
(and a couple of other clever, iterative methods).  I do not wish to go
into it here, because almost any introduction to Newton's method involves
finding the square root of any number.

So let's say you have a calculator that does square roots, adds,
subtracts, multiplies, and divides.  And you have a big sheet of paper,
or, more to the point, a good programmable spreadsheet.  You are about to
create tables for both sine and cosine to the half degree in the first
quadrant.  (You can do it by radians as well, if you wish, but we're
simply going to follow in the Greeks' footsteps).  To tell the truth, the
following is not =exactly= what Ptolemy did.  To find that, look at:
http://hypertextbook.com/eworld/chords.shtml

These are the identities we shall use:
[cos(x)]^2 + [sin(x)]^2 = 1
sin(x+y) = sin(x)cos(y) + sin(y)cos(x)
cos(x+y) = cos(x)cos(y) - sin(x)sin(y)
sin(-x) = -sin(x)	[sine is odd]
cos(-x) = cos(x)	[cosine is even]

So let us start at the very beginning (a very good place to start):
You need to know the sine & cosine of a few values - say, 0 degrees, 30
degrees, 45 degrees, 60 degrees, and 90 degrees.  If you're a good little
math student, you should have these values memorized (just like Pi).  So
put their values in appropriate places in the table (and you may wish to
keep them exact for right now - sqrt(3)/2 might be easier to deal with
than .866...).

So let's get chugging.  What might be the next value easy to
calculate?  How about sin(15 degrees?) (Hmm, that sounds familiar).  No
problem, 15 degrees = 45 degrees - 30 degrees, so:

sin(15) = sin(45-30) = sin(45)cos(30) - cos(45)sin(30)
= 1/sqrt(2)*sqrt(3)/2 - 1/sqrt(2)*1/2
= sqrt(2)/4*(sqrt(3)-1)
=.2588190453

(In a like manner, calculate cos(15), sin(75) and cos(75))

Now we have covered all possible sums and differences, where to go from
here?  Simply to use a special form of the sum of angles formula, called
the double-angle (or half-angle) formula:

sin(2x) = sin(x+x) = 2*sin(x)*cos(x)
cos(2x) = 2*cos(x)^2 - 1

If you solve for sin(x) and cos(x):
sin(x) = sqrt( (1-cos(2x))/2)
cos(x) = sqrt((1+cos(2x))/2)

So, say we have cos(15); then I can get sine and cosine for 7.5, 3.75,
1.875, .9375.

From the info from 45 degrees, we can get sine and cosine for 22.5, 11.25,
5.625, 2.8125, 1.40625.

Now what helps at this point is to be able to get sine & cosine for 72
degrees, which comes from a regular pentagon.  [cos(72) = (sqrt(5) -1)/4,
all the rest follows]

Then from 72 degrees, one can get 36, 18, 9, 4.5, 2.25, 1.125, .5625.

One can also start using the differences: using 72 - 60 to get 12, then 6,
then 3, 1.5, .75, .375, .1875.

Still, this does not give us the half-degree increments we desire.  We
need sine and cosine of .5 to generate the full table: how to get it?  I
will admit at this point that Ptolemy did what any self-respecting applied
mathematician would do: he "cheated".  This means, rather than get "exact"
calculations for the values (which he couldn't do anyway, because you're
going to carry those square roots for only so far - he needed to
=calculate= with these amounts, not fiddle endlessly to see how all these
values related to each other) he used a geometric inequality that relates
angles and their sines.  I don't want to get into it right now, but what
we =can= do is implement linear interpolation (yeah!)

There are several ways we can do this; I'll just pick particular numbers.
We've got values at .9375 and 1.125 -- let's pretend that the sine
function is a line between those two points, and then find the value of
the line at x=1.  You can do that as well for cosine 1, but you may end up
with difficulties.  In any case, there are many ways you can adjust
calculations all through this procedure.

In any case, you're going to have to get used to linear interpolation if
you're creating a trig table.

Do you see why calculators do it the other way?  I would think it was
pretty obvious at this point.

In any case, when I took trigonometry and wasn't allowed to use a
calculator, I was given a trigonometric table of values for sine and
cosine in increments of 1 degree.  I had to use linear interpolation by
hand (meaning, long division and all that jazz, woo hoo).  I was not
amused.  The discipline this imposed on me was to do the least amount of
"function calls" possible.  So, instead of trying out sine, cosine,
tangent, etc. for every single angle given me, I would actually figure out
which function values I needed.  I could sometimes eschew looking up
multiple values for a single problem by using the law of sines or law of
cosines.  I'm not sure if the teacher was looking for that type of
efficiencies, but the pressure of time and the belief that there was no
grading on a curve really motivated me.  When I was still getting 70s
(because I couldn't finish in time), I got upset and complained to my
parents, who then talked to the teacher.  It seems the teacher was lying
about grading on a curve, because he wanted to prevent the seniors from
slacking off (And they were, indeed, the slackest in the class, excepting
that inebriated junior who kept trying to copy my homework for trig during
latin class.  That was so funny.  I don't know why he thought I would do
it.  Perhaps for the same reason he thought his aura of cologne would mask
the scent of alcohol.  But, yet again, I digress.)  So I ended up with my
habitual A, and a big lesson in why I hate arithmetic.

```
 Prev Year Next