# Continued fraction for $\tan(nx)$

I found this beautiful continued fraction expansion of $$\tan(nx)$$, $$n$$ being a positive integer, online but I don't remember the source now:

$$\displaystyle \tan(nx) = \cfrac{n\tan x}{1 -\cfrac{(n^{2} - 1^{2})\tan^{2}x}{3 -\cfrac{(n^{2} - 2^{2})\tan^{2}x}{5 -\cfrac{(n^{2} - 3^{2})\tan^{2}x}{7 -\cdots}}}}$$

the last term in the continued fraction being $$\dfrac{(n^{2} - (n - 1)^{2})\tan^{2}x}{(2n - 1)} = \tan^{2}x$$. For example for $$n = 3$$ we have

$$\displaystyle \tan 3x = \cfrac{3\tan x}{1 -\cfrac{8\tan^{2}x}{3-\cfrac{5\tan^{2}x}{5}}}$$

which is correct and can be verified easily. I would like to know a simple proof via elementary trigonometry and algebra.

I had asked this question long back on NRICH(https://nrich.maths.org/discus/messages/153904/145455.html) but did not get any helpful answer. The reason I wish to know the proof is that it will lead me to an elementary proof of continued fraction expansion of $$\tan z$$. Putting $$nx = z$$ where $$z$$ is kept constant and $$n$$ is made to tend to $$\infty$$ (so that $$x \to 0$$) we get

$$\displaystyle \tan z = \cfrac{z}{1-\cfrac{z^{2}}{3 -\cfrac{z^{2}}{5-\cfrac{z^{2}}{7-\cdots}}}}$$

instead of the complicated proof by Lambert given in my blog http://paramanands.blogspot.com/2011/04/continued-fraction-expansion-of-tanx.html

I have got another formula from an exercise in "A Course of Pure Mathematics" by G. H. Hardy: $$\cos nx = 1 - \frac{n^{2}}{2!}\sin^{2}x - \frac{n^{2}(2^{2} - n^{2})}{4!}\sin^{4}x - \frac{n^{2}(2^{2} - n^{2})(4^{2} - n^{2})}{6!}\sin^{6}x - \cdots$$

I will try to find out if this formula can be used to prove the continued fraction expansion of $$\tan(nx)$$.

Update: This question was originally posed by Euler in 1813. See Chrystal's Algebra Vol 2 (page 526, problem 31).

Further Update: The following approach looks promising but I don't know how to complete it.

We have $$\tan nx=A/B$$ where $$A=\binom{n} {1}\tan x-\binom{n}{3}\tan ^3x+\dots$$ and $$B=\binom{n} {0}-\binom{n}{2}\tan ^2x+\dots$$ and thus $$\frac{\tan nx} {n\tan x} =\frac{C} {B} =\dfrac{1}{1+\dfrac{B-C}{C}}$$ where $$C=1-\frac{(n-1)(n-2)}{3!}\tan^2x+\dots$$ Next $$B-C=-\frac{n^2-1^2}{1!3}\tan^2x+\frac{(n^2-1^2)(n-2)(n-3)}{3!5}\tan^4x-\dots$$ and this can be rewritten as $$-\frac{n^2-1^2}{3}\tan^2x\left(1-\frac{(n-2)(n-3)}{2!5}\tan^2x+\dots\right)$$ If the expression in large parentheses above is $$D$$ then we have $$\frac{\tan nx} {n\tan x} =\dfrac{1}{1-\dfrac{(n^2-1^2) \tan^2x}{3+\dfrac{3C-3D}{D}}}$$ The problem now is to put $$B, C, D$$ into a common pattern so that we can easily get the next expressions like $$E, F, \dots$$.

Thanks to user Paul Enta (and his wonderful answer) the above approach is completed via the use of hypergeometric series. See my answer for details.

• i think you can help me with this as i am having same background as you are having (B.Tech Degree) .If possible please contact me on my email math.stackexchange.com/questions/1134510/… Commented Feb 5, 2015 at 6:46
• This formula is amazing, have you found the proof since? Commented Oct 12, 2018 at 20:25
• @YuriyS: unfortunately not! Commented Oct 13, 2018 at 3:48
• The recent downvote probably indicates some issue with my question. Let me know if it can be improved in anyway. Commented Oct 18, 2018 at 14:54

In this answer, I got this continued fraction $$\tan(x)=\cfrac{x}{1-\cfrac{x^2}{3-\cfrac{x^2}{\ddots\lower{6pt}{(2n+1)-\cfrac{x^2}{P_n(x)/P_{n+1}(x)}}}}}$$ where $$P_n(x)=\sum_{k=0}^\infty(-x^2)^k\dfrac{2^n(k+n)!/k!}{(2k+2n+1)!}=\left(\frac1x\frac{\mathrm{d}}{\mathrm{d}x}\right)^n\frac{\sin(x)}{x}$$ I don't know if my proof is any simpler or harder than the one you are considering.

• This is awesome.
– Pedro
Commented Jul 1, 2013 at 19:02
• Thanks robjohn, for a wonderful proof of the continued fraction for $\tan(x)$. I will put a link to your answer in my blog. I had got the proof from Chrystal's "Algebra" (which is by the way Lambert's original proof) and presented in my blog. However I am still trying to prove the continued fraction expansion for $\tan(nx)$. Commented Jul 2, 2013 at 4:23

This continued fraction can be obtained from the Gauss' continued fraction for the ratio of two hypergeometric fractions after some preparation. One can express $$$$\tan nx = \frac{\sin nx}{\sin x}\frac{\cos x}{\cos nx}\tan x$$$$ Using the Chebyshev polynomials of the first and of the second kind, with $$z=\cos x$$, \begin{align} T_n(z)&=\cos nx\\ U_{n-1}(z)&=\frac{\sin nx}{\sin x} \end{align} one may express $$$$\tan nx = n\tan x\frac{zU_{n-1}(z)}{nT_n(z)}$$$$ Denoting $$$$A=\frac{zU_{n-1}(z)}{nT_n(z)}$$$$ we introduce the representation of the polynomials in terms of hypergeometric functions here and here: $$$$A=z\frac{{}_2F_1\left(-n+1,n+1;\frac{3}{2};\frac{1-z}{2} \right)}{{}_2F_1\left(-n,n;\frac{1}{2};\frac{1-z}{2} \right)}$$$$ Now, to change the variable in order to obtain $$-\tan^2x$$, we use the quadratic transformation of the functions DLMF: $$$${}_2F_1\left(a,b;\frac{1}{2}(a+b+1);u\right)=(1-2u)^{-a}{}_2F_1\left(\frac{1}{2}a,% \frac{1}{2}a+\frac{1}{2};\frac{1}{2}(a+b+1);\frac{4u(u-1)}{(1-2u)^{2}}% \right)$$$$ and thus $$$$A=\frac{{}_2F_1\left( \frac{-n+1}{2},-\frac{n}{2}+1;\frac{3}{2};-\frac{1-z^2}{z^2} \right)}{{}_2F_1\left( \frac{-n}{2},\frac{-n+1}{2};\frac{1}{2};-\frac{1-z^2}{z^2} \right)}$$$$ which can be written as $$$$A=\frac{{}_2F_1\left( a,b+1;c+1;v \right)}{{}_2F_1\left(a,b;c;v\right)}$$$$ where $$a=(1-n)/2,b=-n/2,c=1/2,v=-\tan^2x$$. This ratio can be expressed as a Gauss's continued fraction: $$$$\frac{{}_2F_1\left(a,b;c;z\right)}{{}_2F_1\left(a,b+1;c+1;z\right)}=t_{0% }-\cfrac{u_{1}z}{t_{1}-\cfrac{u_{2}z}{t_{2}-\cfrac{u_{3}z}{t_{3}-\cdots}}}$$$$ where \begin{align} t_k&=c+k\\ u_{2k+1}&=(a+k)(c-b+k)\\ u_{2k}&=(b+k)(c-a+k) \end{align} Here \begin{align} t_k&=\frac{2k+1}{2}\\ u_{2k+1}&=\frac{1}{4}\left( (2k+1)^2 -n^2\right)\\ u_{2k}&=\frac{1}{4}\left( 4k^2 -n^2\right) \end{align} then $$u_p=\frac{1}{4}(p^2-n^2)$$. We can express $$$$A^{-1}=\frac{1}{2}-\cfrac{\frac{n^2-1^2}{4}\tan^2x}{\frac{3}{2}-\cfrac{(n^2-2^2)/4\tan^2x}{\frac{5}{2}-\cfrac{(n^2-3^2)/4\tan^2x}{\frac{7}{2}-\cdots}}}$$$$ or $$$$A^{-1}=1-\cfrac{(n^2-1^2)\tan^2x}{3-\cfrac{(n^2-2^2)\tan^2x}{5-\cfrac{(n^2-3^2)\tan^2x}{7-\cdots}}}$$$$ Finally, $$$$\tan nx=\cfrac{n\tan x}{1-\cfrac{(n^2-1^2)\tan^2x}{3-\cfrac{(n^2-2^2)\tan^2x}{5-\cfrac{(n^2-3^2)\tan^2x}{7-\cdots}}}}$$$$ EDIT: The quadratic transform is valid for $$(1-z)/2<1/2$$ or $$\cos x>0$$. However the decomposition $$\tan nx=An\tan x$$ shows that $$A$$ must be invariant through the change $$x\to \pi+x$$, so we can assume $$z>0$$ in the transform.

• Very impressive. Commented Oct 20, 2018 at 22:20
• Thanks a lot!! +1 Commented Oct 21, 2018 at 3:01
• To be frank I was aware of the Chebyshev polynomials and the Gauss continued fraction. But I doubt if I could have added the missing links. Commented Oct 21, 2018 at 3:20
• After some thought I found that the approach mentioned in my question is same as yours. I have added the details in an answer. Commented Oct 21, 2018 at 9:41

This is not an answer, but just to get this question back into rotation, I'll offer another finite continued fraction for $$\tan nx$$, which does have elementary proof. Maybe it is connected to the one from the OP?

By the well known tangent addition formula:

$$\tan nx=\frac{\tan x+\tan (n-1) x}{1-\tan x \tan (n-1) x}$$

By simple algebra:

$$\tan x \tan nx=-1+\frac{1+\tan^2 x}{1-\tan x \tan (n-1) x}=-1+\cfrac{1+\tan^2 x}{2-\cfrac{1+\tan^2 x}{1-\tan x \tan (n-2) x}}$$

By the obvious recursion, we get a terminating continued fraction (it terminates because $$\tan(n-n)x=0$$).

By the usual forward recursion relation for continued fractions we have:

$$\tan x \tan n x=\frac{P_n}{Q_n}$$

$$P_{-1}=1 \qquad Q_{-1}=0 \\ P_0=-1 \qquad Q_0=1$$

$$P_1=2 P_0+(1+\tan^2 x) P_{-1} \\ Q_1=2 Q_0+(1+\tan^2 x) Q_{-1}$$

$$2 \leq k \leq n-1$$

$$P_k=2 P_{k-1}-(1+\tan^2 x) P_{k-2} \\ Q_k=2 Q_{k-1}-(1+\tan^2 x) Q_{k-2}$$

$$P_n=P_{n-1}-(1+\tan^2 x) P_{n-2} \\ Q_n= Q_{n-1}-(1+\tan^2 x) Q_{n-2}$$

Mathematica code to check if this is correct:

x = E;
n = 27;
P0 = 1;
P1 = -1;
Q0 = 0;
Q1 = 1;
P2 = 2 P1 + (1 + Tan[x]^2) P0;
Q2 = 2 Q1 + (1 + Tan[x]^2) Q0;
P0 = P1;
Q0 = Q1;
P1 = P2;
Q1 = Q2;
Do[P2 = N[2 P1 - (1 + Tan[x]^2) P0, 100];
Q2 = N[2 Q1 - (1 + Tan[x]^2) Q0, 100];
P0 = P1;
Q0 = Q1;
P1 = P2;
Q1 = Q2, {j, 1, n - 2}];
P2 = P1 - (1 + Tan[x]^2) P0;
Q2 = Q1 - (1 + Tan[x]^2) Q0;
N[P2/Q2, 30]
N[Tan[x] Tan[n x], 30]


Output:

-0.972583586120160317233394921301

-0.972583586120160317233394921301


Edit

If we use another form of the same formula:

$$\frac{\tan nx}{\tan x}=\frac{1+\frac{\tan (n-1)x}{\tan x}}{1-\tan^2 x \frac{\tan (n-1)x}{\tan x}}$$

And the obvious recurrence:

$$f_n=\frac{1+f_{n-1}}{1-\tan^2 x f_{n-1}}$$

It's not hard to derive the general continued fraction for this case (through the forward recurrence for the numerators and denominators), which turns out to be similar, but much more simple:

$$\frac{\tan nx}{\tan x}=\frac{P_n}{Q_n}$$

$$P_0=0 \qquad Q_0=1 \\ P_1=1 \qquad Q_1=1$$

$$2 \leq k \leq n$$

$$P_k=2 P_{k-1}-(1+\tan^2 x) P_{k-2} \\ Q_k=2 Q_{k-1}-(1+\tan^2 x) Q_{k-2}$$

Again, checking with Mathematica:

x = E;
n = 27;
P0 = 0;
P1 = 1;
Q0 = 1;
Q1 = 1;
Do[P2 = N[2 P1 - (1 + Tan[x]^2) P0, 100];
Q2 = N[2 Q1 - (1 + Tan[x]^2) Q0, 100];
P0 = P1;
Q0 = Q1;
P1 = P2;
Q1 = Q2, {j, 1, n - 1}];
N[P2/Q2, 30]
N[Tan[n x]/Tan[x], 30]

-4.79117292722386719363535903451

-4.79117292722386719363535903451

• Your interest in this question got me motivated to think a bit more. See my update at the end in the question. Commented Oct 14, 2018 at 3:18
• @ParamanandSingh, I have seen the update, very interesting. I'm pretty sure someone had to have published the full proof since Euler times Commented Oct 18, 2018 at 11:02
• Let's see if a bounty helps! Commented Oct 18, 2018 at 11:32

After the answer from Paul Enta it appears that the approach at the end of my question is also the same. The denominator of $$\dfrac{\tan nx} {n\tan x}$$ is $$1+\sum_{r=1}^{\infty} (-\tan^2x)^{r}\binom{n}{2r}$$ and ignoring first term the ratio of $$(r+1)$$'th term to $$r$$'th term is $$-\frac{(n-2r)(n-2r-1)}{2(2r+1)(r+1)}\tan^2x$$ which is a rational function in $$r$$ so that the series can be expressed as a hypergeometric function. The above ratio can be rewritten as $$\dfrac{\left(r+\dfrac{-n}{2}\right)\left(r+\dfrac{-n+1}{2}\right)} {\left(r+\dfrac{1}{2}\right)(r+1)} (-\tan^2x)$$ and thus the denominator of $$\dfrac{\tan nx} {n\tan x}$$ is $${} _{2}F_{1}\left(\frac{-n}{2},\frac{-n+1}{2};\frac{1}{2};-\tan^2x\right)$$ and in similar fashion the numerator can be written as $${} _{2}F_{1}\left(\frac{-n}{2}+1,\frac{-n+1}{2};\frac{3}{2};-\tan^2x\right)$$ and the proof is now complete via Gauss' continued fraction.

• Indeed. This is neat. Thank's for the question. Commented Oct 21, 2018 at 10:14