Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: bilyp on November 15, 2011, 01:10:55 am

Title: Trigonometric functions (tan, arctan) in axe
Post by: bilyp on November 15, 2011, 01:10:55 am
How would you go about doing trigonometric functions in axe, like the arctan (tan-1()), to calculate the reverse of the tangent or sine of an angle.
I looked all over the internet, but all I could find was that tan(X) = sin(X)/cos(X), nothing about calculating the arctangent. :(
Title: Re: Trigonometric functions (tan, arctan) in axe
Post by: Quigibo on November 15, 2011, 06:17:58 am
A surprisingly accurate approximation for arctangent is:

Code: [Select]
atan(x) ≈ (π/2)*x/(abs(x)+1)
Which, when converted from radians, can be implemented in fixed point notation as x*64//(abs(x)+256) however this has overflow problems in the numerator.  Fortunately you can perform long division to reduce it to 64-(16384//(abs(x)+256)) which accounts for everything except the sign.  This can be done with a simple if statement:

Code: [Select]
:Lbl atan
:64-(16384//(abs(r1)+256))→r2
:If r1<<0
:  Return -r2
:End
:Return r2
Title: Re: Trigonometric functions (tan, arctan) in axe
Post by: bilyp on November 15, 2011, 07:34:51 pm
 :o  Wow. That is perfect, exactly what I needed! Thank you for this, it answers my question!