Given any natural number $m\gt2$, let $z$,$k$ be complex numbers, where $i=\sqrt{-1}$ and consider the general continued fraction
$$\Theta(k,z,m)=\cfrac{(m+1)}{km+\cfrac{z(0m-1)(2m+1)} {3km+\cfrac{z(m-1)(3m+1)}{5km +\cfrac{z(2m-1)(4m+1)}{7km+\cfrac{z(3m-1)(5m+1)}{9km+\ddots}}}}}$$
The variable $\Theta$ has the property of satisfying the polynomial equation of $m$th degree
$$\frac{(i+\Theta\sqrt{z})^m}{(i-\Theta\sqrt{z})^m}=\frac{(ik+\sqrt{z})^{m+1}}{(ik-\sqrt{z})^{m+1}}\tag1$$
$k\neq\pm i$ , $k\neq 0$ ,$z\neq-k^2$,$z\neq 0$
Both continued fractions in this post are just the special cases $z =\pm 1$.
It also obeys a very fundamental transformation property
$$\Theta(k,z,m)=\frac{1}{\sqrt{z}}\Theta(\frac{k}{\sqrt{z}},1,m)\tag2$$
P.S.:After applying property $(1)$ and $(2)$,we arrive at the elegant solution
$$\Theta(k,z,m)=\frac{1}{\sqrt{z}}\dfrac{-\frac{ik}{\sqrt{z}}\left(\dfrac{\frac{k}{\sqrt{z}}+i}{\frac{k}{\sqrt{z}}-i}\right)^{1/m}+\left(\dfrac{\frac{k}{\sqrt{z}}+i}{\frac{k}{\sqrt{z}}-i}\right)^{1/m}+\frac{ik}{\sqrt{z}}+1}{\frac{k}{\sqrt{z}}\left(\dfrac{\frac{k}{\sqrt{z}}+i}{\frac{k}{\sqrt{z}}-i}\right)^{1/m}+i\left(\dfrac{\frac{k}{\sqrt{z}}+i}{\frac{k}{\sqrt{z}}-i}\right)^{1/m}+\frac{k}{\sqrt{z}}-i}$$
Q: How do we prove rigorously that the continued fraction does satisfy the polynomial equation?
For simplicity, we will start with the case $z = 1$.
We will assume $k > 0$ and let $\cot\theta = k$ and $\mu_{\pm} = k \pm \sqrt{k^2+1}$.
The CF at hand has the form $$ \def\CF{\mathop{\LARGE\mathrm K}} \CF_{\ell=1}^{\infty} \frac{\alpha_\ell\gamma_{\ell-1}}{\beta_\ell} \quad\text{ where }\quad \gamma_0 = 1\quad\text { and }\quad \begin{cases} \alpha_\ell &= \ell m + 1\\ \beta_\ell &= k m (2\ell - 1)\\ \gamma_\ell &= \ell m - (m+1) \end{cases} \quad\text{ for }\quad\ell > 0 $$ Consider the associated linear recurrence relation:
$$\alpha_\ell f_{\ell-1} - \beta_\ell f_\ell = \gamma_\ell f_{\ell + 1}\quad\text{ for }\ell > 0\tag{*1}$$ Let $(u_\ell)_{\ell=0}^\infty$ and $(v_\ell)_{\ell=0}^\infty$ be the two solutions satisfying $(u_0,u_1) = (1,0)$ and $(v_0,v_1) = (0,1)$.
In terms of $u$ and $v$, it is easy to verify the convergents of CF satisfy $$L_n \stackrel{def}{=} \CF_{\ell=1}^n \frac{\alpha_\ell\gamma_{\ell-1}}{\beta_{\ell}} = -\frac{u_{n+1}}{v_{n+1}} \quad\implies\quad L_\infty \stackrel{def}{=} \CF_{\ell=1}^\infty \frac{\alpha_\ell\gamma_{\ell-1}}{\beta_{\ell}} = -\lim_{n\to\infty} \frac{u_n}{v_n}$$ Notice $\alpha_\ell,\gamma_\ell \ne 0$ for all $\ell$ and following limits exist $$ \alpha \stackrel{def}{=} \lim\limits_{\ell\to\infty}\frac{\alpha_\ell}{\ell m} = 1, \quad \beta \stackrel{def}{=} \lim\limits_{\ell\to\infty}\frac{\beta_\ell}{\ell m} = 2k \quad\text{ and }\quad \gamma \stackrel{def}{=} \lim\limits_{\ell\to\infty}\frac{\gamma_\ell}{\ell m} = 1 $$ Furthermore, the associated polynomial $$\alpha - \beta\lambda - \gamma\lambda^2 = 0 \quad\iff\quad \lambda^2 +2k\lambda - 1 = 0$$ have roots $\lambda_{\pm} = -k \pm \sqrt{k^2+1} = \frac{1}{\mu_{\pm}}$ whose modulus are distinct. By Poincare-Perron theorem${}^{\color{blue}{[1]}}$, $(*1)$ has a pair of fundamental solutions $(p^{+}_\ell)_{\ell=0}^\infty$ and $(p^{-}_\ell)_{\ell=0}^\infty$ satisfying $\lim\limits_{n\to\infty} \frac{p^{\pm}_{\ell+1}}{p^{\pm}_{\ell}} = \lambda_{\pm}$.
Expanding $u$, $v$ in terms of $p^{\pm}$ and notice $|\lambda_{-}| > 1 > |\lambda_{+}|$, we have
$$\begin{cases} u_\ell &= A p^{+}_\ell + B p^{-}_\ell\\ v_\ell &= C p^{+}_\ell + D p^{-}_\ell \end{cases} \quad\implies\quad L_\infty = -\lim_{n\to\infty} \frac{A p^{+}_\ell + B p^{-}_\ell}{C p^{+}_\ell + D p^{-}_\ell} = -\frac{B}{D}$$ Construct a solution $(w_\ell)_{\ell=0}^\infty$ of $(*1)$ by setting $w_\ell = u_\ell + L_\infty v_\ell$, we have
$$w_\ell = ( A p^{+}_\ell + B p^{-}_\ell ) - \frac{B}{D}( C p^{+}_\ell + D p^{-}_\ell ) = \frac{AD-BC}{D} p^{+}_\ell \quad\implies\quad \lim_{\ell\to\infty} \frac{w_{\ell+1}}{w_\ell} = \lambda_{+} $$ The corresponding OGF $\displaystyle\;\quad w(t) \stackrel{def}{=} \sum_{\ell=0}^\infty w_\ell t^\ell\quad$ will be analytic for $t < |\mu_{+}|$.
Let $a = \frac{1}{m}$, one can rescale $(*1)$ to the form: $$(\ell + a) w_{\ell-1} - k(2\ell-1) w_{\ell} + (a + 1 - \ell) w_{\ell+1} = 0\quad\text{ for }\quad \ell > 0\tag{*2}$$
Let us first treat $a$ as a complex parameter with $-\frac32 < \Re a < -1$.
Multiply the $\ell^{th}$ entry of $(*2)$ by $t^\ell$ and start to sum from $\ell = 1$. If we let $g(t) = w(t) - 1$, we find
$$\begin{align} & \left[t\frac{d}{dt} + a\right]\big\{t(1+g(t))\big\} -k\left[2t\frac{d}{dt} - 1\right]g(t) + \left[a+1 - t\frac{d}{dt}\right]\left\{\frac{g(t)}{t} - L_{\infty}\right\} = 0\\ \iff & (t^2 - 2kt - 1)g'(t) + \left((a+1)t + k + \frac{a+2}{t}\right) g(t) + (a+1)(t - L_\infty) = 0\\ \iff & g'(t) + \left[ -\frac{a+2}{t} + \frac{a+\frac32}{t - \mu_{+}} + \frac{a + \frac32}{t - \mu_{-}}\right] g(t) = (a+1)\frac{t - L_\infty}{1+2kt - t^2}\\ \iff & \frac{d}{dt}\left[\frac{(1+2kt-t^2)^{a+\frac32}}{t^{a+2}} g(t)\right] = (a+1)\frac{(1+2kt-t^2)^{a+\frac12}}{t^{a+2}}(t-L_\infty)\\ \implies & w(t) = 1 + (a+1)\frac{t^{a+2}}{(1+2kt-t^2)^{a+\frac32}}\left[\int_0^t \frac{(1+2ks-s^2)^{a+\frac12}}{s^{a+2}}(s-L_\infty) ds\right] \end{align} $$ For the range of choice of $a$, the coefficient in front of the square bracket is singular at $t = \mu_{-}$. Since $|\mu_{-}| < |\mu_{+1}|$, $w(t)$ is regular there. This means the integral in the square bracket need to vanish at $t = \mu_{-}$. From this, we can deduce
$$L_{\infty} = \frac{\Lambda(a,-a)}{\Lambda(a,-a-1)} \quad\text{ where }\quad \Lambda(a,b) \stackrel{def}{=} \int_0^{\mu_{-}} s^{b-1}(1+2ks-s^2)^{a+\frac12} ds $$ Let $c = a + b + \frac32$ and $\eta = \frac{\mu_{-}}{\mu_{+}}$, the integral $\Lambda(a,b)$ can be evaluated as
$$\begin{align}\Lambda(a,b) & = \int_0^{\mu_{-}} s^{b-1}\left(1 - \frac{s}{\mu_{+}}\right)^{a+\frac12}\left(1 - \frac{s}{\mu_{-}}\right)^{a+\frac12} ds\\ &= \mu_{-}^b \int_0^1 s^{b-1}(1-s)^{c-b-1}\left(1-\eta s\right)^{a+\frac12} ds\\ &=^{\color{blue}{[2]}} \mu_{-}^b \frac{\Gamma(b)\Gamma(c-b)}{\Gamma(c)}{}_2F_1\left(-a-\frac12,b;c; \eta\right)\\ &=^{\color{blue}{[3]}} \mu_{-}^b(1 - \eta)^{-b} \frac{\Gamma(b)\Gamma(c-b)}{\Gamma(c)} {}_2F_1\left(c+a+\frac12,b;c; \frac{\eta}{\eta - 1}\right)\\ \end{align} $$ Substitute this back into expression of $L_\infty$ and simplify, we get
$$L_\infty = -\frac{2(a+1)\mu_{-}}{1 - \eta} \frac{ {}_2F_1\left(a+2,-a;\frac32; \frac{\eta}{\eta-1}\right) }{ {}_2F_1\left(a+1,-(a+1);\frac12; \frac{\eta}{\eta-1}\right) } $$ Notice $$ \frac{\mu_{-}}{1-\eta} = -\frac{1}{2\sqrt{k^2+1}} = -\frac{\sin\theta}{2} \quad\text{ and }\quad \frac{\eta}{\eta - 1} = \frac{\sqrt{k^2+1}-k}{2\sqrt{k^2+1}} = \frac{1-\cos\theta}{2} $$ We get $$L_\infty = \frac{(a+1)\sin\theta {}_2F_1\left(a+2,-a;\frac32; \frac{1-\cos\theta}{2}\right) }{ {}_2F_1\left(a+1,-a-1,\frac12; \frac{1-\cos\theta}{2}\right) } $$ Compare this with following representation of generalized Chebyshev's polynomial in terms of hypergeometric functions.
$$\begin{cases} T_a(\cos x) &= {}_2F_1\left(a,-a; \frac12; \frac12(1-\cos x)\right) = \cos(a x)\\ U_a(\cos x) &= (a+1){}_2F_1\left(a+2,-a; \frac32; \frac12(1 - \cos x)\right) = \frac{\sin((a+1)x)}{\sin x} \end{cases} $$ We find $$L_\infty = \tan((a+1)\theta) = \tan\left((a+1)\tan^{-1}\frac{1}{k}\right)$$
Up to what I see, there is nothing to stop us from analytic continuing this result back to $a \in (0,1)$. This implies $$\Theta(k,1,m) = \tan\left(\frac{m+1}{m}\tan^{-1}\frac1k\right)$$
Back to the case $z \ne 1$. The CF can be obtained by scaling $\alpha_\ell, \gamma_\ell$ by $\sqrt{z}$ for all $\ell > 0$ and $\gamma_0$ by $\frac{1}{\sqrt{z}}$. Since $(*1)$ is invariant when one rescale $\alpha_\ell, \beta_\ell, \gamma_\ell$ by same factor, scaling $\alpha_\ell, \gamma_\ell$ by $\sqrt{z}$ is equivalent to replace the $k$ in $\beta_\ell$ by $\frac{k}{\sqrt{z}}$. As long as $z \in \mathbb{C} \setminus (-\infty, 0 ]$, we have $\Re \sqrt{z} > 0$. One can verify the corresponding $\lambda_{\pm}$ have distinct modulus and above arguments remain valid.
As a result, the CF at hand has following closed form expression:
The rest is obvious.
Notes
$\color{blue}{[1]}$ - For more details of Poincare-Perron theorem and a proof of it, please consult Chapter 8 of Saber Elaydi's book An Introduction to Difference Equations.
$\color{blue}{[2]}$ - For $|t| < 1$ and $\Re c > \Re b > 0$, we have following integral formula by Euler $$\int_0^1 x^{b-1}(1-x)^{c-b-1}(1-tx)^{-a} dx = \frac{\Gamma(b)\Gamma(c-b)}{\Gamma(c)} {}_2F_1(a,b;c;t)$$
$\color{blue}{[3]}$ - We are using following Pfaff transformation here.
$${}_2F_1(a,b;c;t) = (1-t)^{-b} {}_2F_1\left(c-a,b;c;\frac{t}{t-1}\right)$$