evansjr@marlin.NOSC.MIL (John R. Evans) (11/01/90)
I would like to use the "arccos" function---but it is not standard pascal. Is there a simple way to do this using standard pascal functions such as arctan,sin, or cos?
Alan_T._Cote.OSBU_South@xerox.com (11/02/90)
"John R. Evans" <evansjr@marlin.nosc.mil> writes: >I would like to use the "arccos" function---but it is >not standard pascal. > >Is there a simple way to do this using standard pascal >functions such as arctan,sin, or cos? Yes. Use the identity, arccos(x) = arctan( ( 1 - ( x * x ) ) / x )
dslg0849@uxa.cso.uiuc.edu (Daniel S. Lewart) (11/02/90)
evansjr@marlin.NOSC.MIL (John R. Evans) writes: > I would like to use the "arccos" function---but it is > not standard pascal. > Is there a simple way to do this using standard pascal > functions such as arctan,sin, or cos? function ArcCos(x: Real): Real; begin if x > 0 then ArcCos := ArcTan( Sqrt(1-Sqr(x))/x ) else if x < 0 then ArcCos := ArcTan( Sqrt(1-Sqr(x))/x ) + Pi else ArcCos := Pi/2; end; Daniel Lewart d-lewart@uiuc.edu
TMoore@massey.ac.nz (T. Moore) (11/02/90)
I would like to use the "arccos" function---but it is not standard pascal. Is there a simple way to do this using standard pascal functions such as arctan,sin, or cos? If cos(theta) = x then tan(theta) = sqrt(1-x*x)/x by simple trigonometry. Therefore arccos(x) = arctan(sqrt(1-x*x)/x) if x > 0 (arccos(0) = pi/2) I assume you want the principal value which is between 0 and pi. (If x < 0 then the principal value of arctan is between -pi/2 and 0 so you must add pi - I think: check with the manual). If x is too close to zero you can find arctan(x/sqrt(1-x*x)) and add pi/2. -- Terry Moore <T.Moore@massey.ac.nz> Department of Mathematics and Statisics, Massey University, Palmerston North, New Zealand Kroneker: "God made the natural numbers, the rest is the work of man." Zermelo: "But I can construct the natural from the empty set alone." Bystander: "Who said 'You can't get something for nothing.'?"