Continued fraction for $\tan(nx)$

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 continued fraction can be obtained from the Gauss' continued fraction for the ratio of two hypergeometric fractions after some preparation. One can express \begin{equation} \tan nx = \frac{\sin nx}{\sin x}\frac{\cos x}{\cos nx}\tan x \end{equation} 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 \begin{equation} \tan nx = n\tan x\frac{zU_{n-1}(z)}{nT_n(z)} \end{equation} Denoting \begin{equation} A=\frac{zU_{n-1}(z)}{nT_n(z)} \end{equation} we introduce the representation of the polynomials in terms of hypergeometric functions here and here: \begin{equation} 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)} \end{equation} Now, to change the variable in order to obtain $-\tan^2x$, we use the quadratic transformation of the functions DLMF: \begin{equation} {}_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) \end{equation} and thus \begin{equation} 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)} \end{equation} which can be written as \begin{equation} A=\frac{{}_2F_1\left( a,b+1;c+1;v \right)}{{}_2F_1\left(a,b;c;v\right)} \end{equation} 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: \begin{equation} \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}}} \end{equation} 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 \begin{equation} 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}}} \end{equation} or \begin{equation} 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}}} \end{equation} Finally, \begin{equation} \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}}}} \end{equation} 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.


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