Main Topics
Browse All TopicsHi, I have a tricky question. I need an algorithm to calculate the inverse tangent (tan ^ -1) for a specific floating-point x (-inf < x < inf). It has to converge fast or at least there must be a mechanism to calculate it to a specific number of digits ?
I've tried many algorithms (Wiki, MathWorld) but don't feel constraint by any of them (I probably got them wrong).. the priority is a functional one.. You can use almost any approach but try to avoid complex numbers, other inverse functions (I intend to use ArcTan to calculate the others).
So the priorities are:
1) functioning algorithm (customizable digit precision)
2) fast algorithm
3) less complex algorithm to implement or one using less special constants and operations (Bernoulli numbers or other specialities)
thanks in advance and best regards,
Kate
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks for the answer but I need an arbitrary precision to a specific digit. This only returns the "standard" double format (exponential format) I should use Math.Atan(x) for this. I need an algorithm to calculate ArcTan to 1 - (2^32-1) floating-point digits (at least theoretically). Basically I need an algorithm from the Windows Calculator :P
regards,
Kate
P.S.: I forgot to mention I prefer these languages C#, Pascal, Object pascal, C, C++, Python, VB.NET or just plain explanation using meta-language (maybe even the equation in format ArcTan(x) = ..)
note that this does not converge for |x|>1
and it converges slowly for x near 1
so you can use the method of http://www.netlib.org/fdli
or
arctan(x) = 2*arctan[(sqrt[1+x^2]-1)/x
to get it in a range where x is small
Ok, I was able to implement the algorithm for the interval [-1, 1] suddenly the Taylor series started to give the useful results. So what I need now is an ArcTan for the rest of the values (-, -1) and (1, ).
The used Taylor series for {XR | -1 e x e 1}
(-1 ^ n) ((x ^ (2n + 1)) / (2n + 1))
I tried to lower the x by this rule:
ArcTan(x) = (À / 2) - ArcTan(1 / x)
But it doesn't converge quickly enough. I hope someone will enlight me.
regards,
Kate
Hi.. the normalization..
ArcTan(x) = 2 * ArcTan((Sqrt(1 + x ^ 2) - 1) / x)
..was working fine but doesn't converged fast enough for me.. I searched the old normalizations I tried before when the main loop wasn't working (from what I know now) and one of them satisfied the rate of convergence.
ArcTan(x) = PI / 6 + ArcTan((Sqrt(3)*x - 1) / (Sqrt(3) + x)) for x > 2 - Sqrt(3)
thanks anyway.. somehow you pushed me in the right direction..
regards,
Kate
Business Accounts
Answer for Membership
by: ozoPosted on 2008-05-09 at 16:12:07ID: 21536959
http://www.netlib.org/fdli bm/k_tan.c