Computers and Trigonometric Functions
Date: 02/11/97 at 21:37:20 From: Brian Hicks Subject: Sine, Cosine, Tangent Hi Dr. Math, I was wondering, what actual functions find the values for sine, cosine, and tangent? Let's say that: sin 48 = 0.74314482547739 cos 48 = 0.66913060635886 tan 48 = 1.1106125148292 How does a calculator or computer come up with these numbers? What does the computer actually do to the number 48 (in this case) that produces these answers? Thanks for all your help. :) -Brian
Date: 02/13/97 at 14:15:43 From: Doctor Ceeks Subject: Re: Sine, Cosine, Tangent Hi, Nowadays, with computer memory so readily available, the values of sine, cosine, and tangent are often stored in a table in memory. (This memory is often located inside the same chip that carries the Central Processing Unit.) This makes it possible to produce answers very quickly. When the computer or calculator is asked to produce a value of sine, cosine, or tangent which is not in the table, the computer exploits the fact that small changes in the angle only create small changes in the value of the function to extrapolate an answer. Because computers and calculators are only expected to give approximate answers anyway (e.g. to 10 decimal places, or what have you), this extrapolation need be done only to the necessary accuracy. However, before there were tables, the functions had to be computed using some other method. Consider the function sin(x). Thanks in large part to Newton, and also his student Taylor, it was discovered that when x is measured in radians: sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... The equations for cosine and sine are similarly derived using Taylor series. Also, you can get cos(x) by taking the square root of 1 - sin^2(x). You can get tan(x) by dividing sin(x) by cos(x): cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ... tan(x) = x + 2x^3/3! + 16x^5/5! + 272x^7/7! + 7936x^9/9! + ... The explanation for why this is true is rather long, and I hope you don't mind if I refer you to a book. You can find this in any good calculus book, for instance, by Apostol or by Courant and John. You can think of this (infinite) sum as a series of correction factors. The first term (which is x) says: sin(x) is about equal to x. Well this is not very accurate, but if you want more accuracy, you can go to the next term: sin(x) is more like x - x^3/3!. The further you go, the more accurate you get. It's possible to know the error from the actual value of sin(x) if you stop at a certain point in the summation. Computers and calculators need only add out to the point where the error is smaller than the desired accuracy. One last thing: Note that for most values of x (i.e. most angles), the decimal value of sin(x) cannot be given in complete accuracy because, for most values of x, sin(x) will have a non-repeating decimal expansion. -Doctor Ceeks, The Math Forum Check out our web site! http://mathforum.org/dr.math/
Search the Dr. Math Library:
Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.