The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

How a Calculator Determines Values of Trig Functions

Date: 03/19/2005 at 14:14:21
From: Adri
Subject: Powerseries

I'm interested in how my calculator finds the answer of sin(pi/4) or 
tan(pi/6).  I think it uses power series to calculate the answer, but
which ones?  There are several power series for sin, cos, tan, etc.
but which ones are being used by modern calculators (TI-83 for example)?

Date: 03/19/2005 at 17:40:44
From: Doctor Tom
Subject: Re: Powerseries

I can't say for sure exactly what's done in your calculator, but I 
know how such things are usually computed.

For something like sine, where the function is periodic, you really 
just need to compute sines of angles between, say, 0 and 90 degrees.  
What's done is to find a polynomial that approximates the sine curve 
"as well as possible" over that interval.  "As well as possible" may 
have different meanings, but a common one might be the polynomial with 
the smallest absolute error over the entire range.

As you consider polynomials of fixed degree, say 6, there is one that 
is the best fit.  If you go to eighth degree polynomials, you can do 
better, and so on.  Your calculator has a certain precision that it 
needs to obtain, so the designers find the polynomial of least degree 
that gives the required accuracy.  Many books on numerical methods or 
computer arithmetic list the coefficients for various functions and 
various degree polynomial approximants.

Other functions, like square-root, are done differently.  They do the 
exponent part and the mantissa part separately.  They work in base 2, 
so suppose you want to take the square root of: 

  111010.0110101 (in binary)

Shift the binary point to the left to get a number between 1 and 4:

  11.10100110101 x 2^4

that has an even exponent.  Then the square root will be the square 
root of the number on the left times 2^2.  To take the square root of 
a number between 1 and 4, just have a small table of exact square 
roots for, say, 128 equally-spaced values.  Find the closest one in 
the table and use it as a first guess.  Then use Newton's method an 
appropriate number of times to obtain the desired accuracy.  Newton's 
method roughly doubles the accuracy of your current guess with every 
iteration.  In other words, the number of accurate decimal (or binary) 
points doubles with each step.  So if you need 64 bit accuracy, and 
your table's initial guess gives 5 bits, then you get 10, 20, 40 and 
80 bits with 1, 2, 3 and 4 iterations.  A larger table reduces the 
number of iterations, but chews up more memory, so there's a trade-off 
for the calculator designers.

Other functions are computed with combinations of these ideas.

- Doctor Tom, The Math Forum 
Associated Topics:
High School Calculators, Computers
High School Calculus
High School Trigonometry

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.