Date: Thu, 15 Feb 1996 10:05:27 -0800
Reply-To: Billy Kreuter <billyk@U.WASHINGTON.EDU>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Billy Kreuter <billyk@U.WASHINGTON.EDU>
Organization: University of Washington
Subject: Re: SAS and the value of PI
In-Reply-To: <1996Feb15.165528@vyh.fi>
> > Simple question: How do you represent the value PI in SAS?
> Isn't this the old trick that FORTRAN programmers use:
> PI = 4 * ATAN(1)
>
> ATAN is probably used because calculation of other inverse
> trigonometric functions are based on ATAN calculations.
I suspect that most hand calculators and compiler libraries which
include arsin and arcos use the Taylor expansions for those functions,
rather than converting from atan. The Taylor expansion for arcos is
pi minus arsin, which is why arcos is returned in the range 0 to pi.
Arsin returns minus pi/2 to plus pi/2.
The "old Fortran trick" is used because it's the simplest polynomial
series that returns pi. Consider that tan(45 degrees)=tan(pi/4
radians) is unity. No other rational number can be given as an
argument to any trigonometric function or inverse function, the result
of which is a rational multiple of pi, other than 1 (or -1) as the
argument to atan. You could, of course, use pi=4*arsin(sqrt(.5)) --
but that involves an irrational number and more computation.
Billy
billyk@u.washington.edu