How to do a very long division: continued fraction for tan
I want to compute $$\tan(r) = \cfrac{r}{1 - \cfrac{r^2}{3 - \cfrac{r^2}{5 - \cfrac{r^2}{7 - {}\ddots}}}}$$ by dividing the power series for sin and cos as it is said can be done in http://arxiv.org/abs/0911.1929.
When I try it I get $$\frac{\sin(r)}{\cos(r)} = \frac{r}{1 + r^2\cdot\frac{\frac{2}{3!} - r^2 \frac{4}{5!} + r^4 \frac{6}{7!} - r^6 \frac{8}{9!} + \cdots}{\cos(r)}}$$ which has sign wrong and the series in the numerator gets mor and more complicated. The next term of the continued fraction comes up as $\frac{2}{3!}$ instead of $3$ and the next series is even more complicated (3 factorials in each summand).
I was using $A = BQ+R$ for the long division and picking $Q$ the leading coefficient of the series.
Solution 1:
After looking at my previous hint, I was unable to proceed as easily as I thought. Instead, I have here expanded the division of power series in detail.
Start with $$ \begin{align} \frac{\cos(x)}{\sin(x)/x} &=\frac{\sum\limits_{k=0}^\infty(-x^2)^k\dfrac1{(2k)!}} {\sum\limits_{k=0}^\infty(-x^2)^k\dfrac1{(2k+1)!}}\\[12pt] &=\frac{\sum\limits_{k=0}^\infty(-x^2)^k\dfrac{2k+1}{(2k+1)!}} {\sum\limits_{k=0}^\infty(-x^2)^k\dfrac1{(2k+1)!}}\\[12pt] &=1+\frac{\sum\limits_{k=0}^\infty(-x^2)^k\dfrac{2k}{(2k+1)!}} {\sum\limits_{k=0}^\infty(-x^2)^k\dfrac1{(2k+1)!}}\\[12pt] &=1+\frac{\sum\limits_{k=0}^\infty(-x^2)^{k+1}\dfrac{2k+2}{(2k+3)!}} {\sum\limits_{k=0}^\infty(-x^2)^k\dfrac1{(2k+1)!}}\\[12pt] &=1-x^2\left/\left(\frac{\sum\limits_{k=0}^\infty(-x^2)^k\dfrac1{(2k+1)!}} {\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{2k+2}{(2k+3)!}}\right)\right.\\[12pt] \end{align} $$ Then note that the ratio of sums is the case $j=0$ of $$ \begin{align} &\frac{\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j)}{(2k+2j+1)!}} {\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+2)}{(2k+2j+3)!}}\\[12pt] &=\frac{\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j)(2k+2j+2)(2k+2j+3)}{(2k+2j+3)!}} {\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+2)}{(2k+2j+3)!}}\\[12pt] &=(2j+3)+\frac{\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j)(2k+2j+2)(2k)}{(2k+2j+3)!}} {\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+2)}{(2k+2j+3)!}}\\[12pt] &=(2j+3)+\frac{\sum\limits_{k=0}^\infty(-x^2)^{k+1}\dfrac{(2k+4)(2k+6)\dots(2k+2j+2)(2k+2j+4)(2k+2)}{(2k+2j+5)!}} {\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+2)}{(2k+2j+3)!}}\\[12pt] &=(2j+3)-x^2\frac{\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+4)}{(2k+2j+5)!}} {\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+2)}{(2k+2j+3)!}}\\[12pt] &=(2j+3)-x^2\left/\left(\frac{\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+2)}{(2k+2j+3)!}} {\sum\limits_{k=0}^\infty(-x^2)^{k}\dfrac{(2k+2)(2k+4)\dots(2k+2j+4)}{(2k+2j+5)!}}\right)\right.\\[12pt] \end{align} $$ and this justifies the continued fraction. That is, if we define $$ 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} $$ we have shown that $$ \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)}}}}} $$
Solution 2:
I found this http://www.pi314.net/eng/lambert.php and it works: here it is worked out with details for 3 iterations
$$\begin{eqnarray} \tan(r) &=& r \Big/ \frac {1 - \frac{r^2}{2!} + \frac{r^4}{4!} - \frac{r^6}{6!} + \frac{r^8}{8!}+\cdots} {1 - \frac{r^2}{3!} + \frac{r^4}{5!} - \frac{r^6}{7!} + \frac{r^8}{9!}+\cdots} \\ &=& r \Big/ 1 - r^2 \Big/ \frac {1 - \frac{r^2}{3!} + \frac{r^4}{5!} - \frac{r^6}{7!} + \frac{r^8}{9!}+\cdots} {\frac{2}{3!} + \frac{4 \cdot r^2}{5!} - \frac{6\cdot r^4}{7!} + \frac{8\cdot r^6}{9!} + \frac{10\cdot r^8}{11!}+\cdots} &\text{by (1)} \\ &=& r \Big/ 1 - r^2 \Big/ 3 - r^2 \Big/ \frac {\frac{2}{3!} + \frac{4 \cdot r^2}{5!} - \frac{6\cdot r^4}{7!} + \frac{8\cdot r^6}{9!} + \frac{10\cdot r^8}{11!} +\cdots} {\frac{2 \cdot 4}{5!} + \frac{4 \cdot 6 \cdot r^2}{7!} - \frac{6\cdot 8 \cdot r^4}{9!} + \frac{8 \cdot 10 \cdot r^6}{11!}+ \frac{10 \cdot 12 \cdot r^6}{13!}+\cdots} &\text{by (2)} \\ &=& r \Big/ 1 - r^2 \Big/ 3 - r^2 \Big/ 5 - r^2 \Big/ \frac {\frac{2 \cdot 4}{5!} + \frac{4 \cdot 6 \cdot r^2}{7!} - \frac{6\cdot 8 \cdot r^4}{9!} + \frac{8 \cdot 10 \cdot r^6}{11!}+ \frac{10 \cdot 12 \cdot r^6}{13!}+\cdots} {\frac{2 \cdot 4 \cdot 6}{7!} - \frac{4 \cdot 6 \cdot 8 \cdot r^2}{9!} + \frac{6 \cdot 8 \cdot 10 \cdot r^4}{11!} - \frac{8 \cdot 10 \cdot 12 \cdot r^6}{13!} + \frac{10 \cdot 12 \cdot 14 \cdot r^8}{15!} + \cdots} &\text{by (3)} \\ \end{eqnarray}$$
and you can see the next will be $7 - r^2$ by $\frac{2 \cdot 4}{5!} - 7 \cdot \frac{2 \cdot 4 \cdot 6}{5! \cdot 6 \cdot 7} = 0$
For each of the divisions we are doing $A/B = Q + R/B$ we pick $Q$ to make the unit terms 0 and find $R = A - QB$ then use it to get the next part of the continued fraction.
$(1)$ $Q=1$
$$\begin{eqnarray} 1 - 1 &=& 0 \\ -r^2 [\frac{1}{2!} - \frac{1}{3!}] && -r^2 \cdot \frac{2}{3!} \\ +r^4 [\frac{1}{4!} - \frac{1}{5!}] && +r^4 \cdot \frac{4}{5!} \\ -r^6 [\frac{1}{6!} - \frac{1}{7!}] && -r^6 \cdot \frac{6}{7!} \\ &\vdots& \end{eqnarray} $$
$(2)$ $Q=3$
$$\begin{eqnarray} 1 - 3\cdot\frac{2}{3!} &=& 0 \\ -r^2 [\frac{1}{3!} - \frac{3\cdot 4}{5!}] && -r^2 \cdot \frac{2 \cdot 4}{5!} \\ +r^4 [\frac{1}{5!} - \frac{3\cdot 6}{7!}] && +r^4 \cdot \frac{4 \cdot 6}{7!} \\ -r^6 [\frac{1}{7!} - \frac{3 \cdot 8}{9!}] && -r^6 \cdot \frac{6 \cdot 8}{9!} \\ &\vdots& \end{eqnarray} $$
$(3)$ $Q=5$
$$\begin{eqnarray} \frac{2}{3!} - \frac{2 \cdot 4 \cdot 5}{2\cdot 3 \cdot 4 \cdot 5} &=& 0 \\ -r^2 [\frac{4}{5!} - \frac{5 \cdot 4 \cdot 6}{7!}] && -r^2 \cdot \frac{2 \cdot 4 \cdot 6}{7!} \\ +r^4 [\frac{6}{7!} - \frac{5 \cdot 6 \cdot 8}{9!}] && +r^4 \cdot \frac{4 \cdot 6 \cdot 8}{9!} \\ -r^6 [\frac{8}{9!} - \frac{5 \cdot 8 \cdot 10}{11!}] && -r^6 \cdot \frac{6 \cdot 8 \cdot 10}{11!} \\ &\vdots& \end{eqnarray} $$
and continue to infinty.