 Trig Identity question - 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: Trig Identity question (/thread-239958.html) Trig Identity question - Namir - 03-03-2013 Hi All, Anyone knows of a trig identity between the arc tangent of an angle and it's multiples, like: arctan(2x) = function of arctan(x) Thanks! Namir PS: I have found a polynomial approximation by Eurler to calculate arctan very accurately, but I require tens of thousands of terms!!!!! Ouch! Re: Trig Identity question - Thomas Klemm - 03-03-2013 Used WolframAlpha with: ```Taylor[arctan[2*tan[y]],y] ``` The result is: ```2 y-2 y^3+4 y^5-(142 y^7)/15+(4612 y^9)/189-(312644 y^11)/4725+O(y^12) ``` But that's probably not what you are looking for: a simple formula. HTH Thomas If you do it with the inverse order of the functions: ```Taylor[tan[2*arctan[y]],y] ``` The result is: ```2 y+2 y^3+2 y^5+2 y^7+2 y^9+2 y^11+O(y^12) (converges when abs(y)<1) ``` This geometric series leads to the well known result: Edited: 3 Mar 2013, 1:08 p.m. Re: Trig Identity question - Namir - 03-03-2013 I am looking for an equation that is similar to the one for tan(2x) but expressed in terms of arctan(2x) and arctan(x). I have a good Pade Approximant for tan(x). Ultimately, I can can use the Pade approximant for tan(x) in an iterative process. That would still be much faster than calculating 3000 to 4000 terms in a slow converging polynomial. Namir Edited: 3 Mar 2013, 4:22 p.m. Re: Trig Identity question - Gerson W. Barbosa - 03-03-2013 Quote: I am looking for an equation that is similar to the one for tan(2x) but expressed in terms of arctan(2x) and arctan(x). This doesn't appear to be possible. From the identity #1 here I've obtained and None of which will serve your purpose, though. Edited to correct a typo in the second equation Edited: 3 Mar 2013, 7:07 p.m. Re: Trig Identity question - Thomas Klemm - 03-03-2013 It may not be clear from my answer but the solution is: ```arctan(2x) = 2 arctan(x) - 2 arctan3(x) + 4 arctan5(x) + ... ``` This is not the formula you are looking for but its Taylor expansion. So all you need to do is find a closed formula of this series. I didn't made any attempts to find it but just from looking at the coefficients of the higher orders I doubt that there is any. It's not that you can expect that there is a closed formula in general. In the case of tan(x) it is related to the multiplication of complex numbers. Sorry for the bad news. Cheers Thomas Re: Trig Identity question - Namir - 03-04-2013 I found the following useful identity: arctan(x) = pi/2 - arctan(1/x) This identity allows me to calculate the arctan for high values (just below 90 degrees) by calculating the arctan of 1/x. I can calculate arctan with good accuracy for low x values using polynomial approximations or iteratively. Either way, I get good results for high x values! Namir Edited: 4 Mar 2013, 7:22 a.m. Re: Trig Identity question - Namir - 03-04-2013 I found an efficient algorithm to calculate arctan(x). ```EPS = 1e-8 A1 = 1/SQRT(1+x*x) B1 = 1 Do A0 = A1 B0 = B1 A1 = (A0+B0)/2 B1 = SQRT(A1*B0) Loop until |A1-A0|<=EPS and |B1-B0|<=EPS arctan(x) = x/(SQRT(1+x*x)*A1) ``` Algorithm works as efficiently for small and large values of x. Number of iterations for the above loop range from 11 to 15. Edited: 4 Mar 2013, 11:08 a.m. Re: Trig Identity question - Thomas Klemm - 03-04-2013 I'm glad you found something useful. That's an interesting algorithm which reminds me of the arithmetic–geometric mean. However there's a slight difference: ```B1 = SQRT(A1*B0) ``` instead of ```B1 = SQRT(A0*B0) ``` In the Wikipedia article is a reference to the article: B. C. Carlson (1972). "An algorithm for computing logarithms and arctangents". Math.Comp. 26 (118): 543–549. Was that your source? Kind regards Thomas Re: Trig Identity question - Paul Dale - 03-04-2013 Without coding and testing anything, I wonder if the difference is significant. The AGM converges pretty quickly which would mean A0 -> A1. - Pauli Re: Trig Identity question - Paul Dale - 03-04-2013 A quick check and they do converge different after all. - Pauli Re: Trig Identity question - Eric Smith - 03-04-2013 The CORDIC algorithm is another efficient way of computing arctangents with few iterations, but it requires a precomputed table of coefficients. In another post you mentioned wanting the arctan of high values. If what you need is the angle given an x and y coordinate, i.e., the atan2(y,x) function, CORDIC is very good for that as well, since you don't have to do the y/x division, which can lose a lot of precision. Re: Trig Identity question - Namir - 03-04-2013 My source was the Wolfram web site. Edited: 4 Mar 2013, 7:59 p.m. Re: Trig Identity question - Thomas Klemm - 03-04-2013 Acton, F. S. "The Arctangent." In Numerical Methods that Work, upd. and rev. Washington, DC: Math. Assoc. Amer., pp. 6-10, 1990. Unfortunately without further explanations. Cheers Thomas Re: Trig Identity question - Namir - 03-04-2013 That's the same algorithm I found on the Wolfram web site. It works well even for large values of x. There is no need to use the trick: arctan(x) = pi/2 - arctan(1/x) Namir Edited: 4 Mar 2013, 11:09 p.m.