The Math Forum

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

Arccos Algorithms and Computer Calculators

Date: 03/21/98 at 05:51:04
From: gilson
Subject: finding angle from cos

I need to use value of the angle in a computer program and I have the 
value for the cos and sin only. I need to know which formula or 
algorithm to use. I know it is ambiguous, but the first value only 
would solve my problem. What I need is the algorithm used when you 
press arccos button on the calculator. Thanks.

Date: 03/21/98 at 06:26:50
From: Doctor Mitteldorf
Subject: Re: finding angle from cos

Dear Gilson,

I don't know how standard the arccos calculation has become.  It 
probably is similar but not identical from one brand of calculator to 
the next.  

The basis of the calculation is a Taylor series:

     arcsin(x) = x + 1/2 (x^3/3) + (1/2)(3/4)(x^5/5) + 
                (1/2)(3/4)(5/6)(x^7/7) + ... 

This series converges fast when x is small, slow when x is large.  
(It doesn't converge at all when x>1, of course.) So the periodicity 
of the sin function is used to make the series give an accurate result 
with fewer terms. If x is small, then the series is taken for 
arcsin(x). If x is close to 1, then the series is evaluated for
sqrt(1 - x^2), giving the arccos, then the result is subtracted from 
pi/2. In other words, the calculator uses the facts that sin^2+cos^2=1 
and that sin(x)=cos(pi/2-x).

For in-between values, the calculator probably uses the trig sum 
and difference formulas so that arcsin(sqrt(2)/2)=pi/4 can be used as 
a first approximation.

So there are lots of ways to skin the cat, and since the computation 
is so common, it's probably been highly optimized for speed and 
accuracy way beyond the basic Taylor series.

-Doctor Mitteldorf,  The Math Forum
Associated Topics:
High School Calculators, Computers
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.