HP Forums
atan - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: atan (/thread-34559.html)



atan - hugh steers - 05-22-2003

i see luiz has an article on trigs for the 16c (possibly also the 17bii). sorry, i missed this thread.

however, on the subject of inverses, i spent a while some time ago developing a fast arctan (but only single precision accuracy) using a limited pade approximation.
not sure whether this is accurate or compact enough to be useful when converted to a calculator program, but here it is:

(sorry about the bad formatting, it gets mangled)

#define M_PI 3.141592654f

#define A0X 0.2388229612f

#define A1X 2.445205396f

#define B1X 3.943529789f

#define A2X 1.314747223f

#define B2X 1.798249626f

float atan6(float x)
{
/* correct to 3e-7. 4 multiplies/divides */
float x2;
float v;
x2 = x*x;
if (x > 1.0f) v = M_PI/2 - (A0 - A1/(x2 + B1 - A2/(x2 + B2)))/x;
else if (x >= 0.0f) v = x*(A0X + A1X/(x2 + B1X - A2X/(x2 + B2X)));
else v = -atan6(-x);
return v;
}