3
$\begingroup$

Using the Euler continued fraction for the exponent, which is convergent everywhere on the complex plane:

$$e^{-z}=1-\cfrac{z}{1+z-\cfrac{z}{2+z-\cfrac{2z}{3+z-\cfrac{3z}{4+z-\cdots}}}}$$

We can theoretically compute any trigonometric function in the same way (usually, continued fractions only used to compute $\tan(x)$ since it can be expressed as a ratio).

For example, using the trigonometric representation of the golden ratio, we can express it as:

$$\phi=2 \cos \left( \frac{\pi}{5} \right)=\Re (e^{-i \frac{\pi}{5}})$$

The convergents of $e^{-i \frac{\pi}{5}}$ can be calculated with the following procedure:

$$ \begin{bmatrix}p_n \\ q_n \end{bmatrix} = \begin{bmatrix}1 & 1 \\1 & 0 \end{bmatrix} \begin{bmatrix}1-i \frac{\pi}{5} & 1 \\i \frac{\pi}{5} & 0 \end{bmatrix} \dots \begin{bmatrix}n-1-i \frac{\pi}{5} & 1 \\(n-2)i \frac{\pi}{5} & 0 \end{bmatrix} \begin{bmatrix}n-i \frac{\pi}{5} \\(n-1)i \frac{\pi}{5} \end{bmatrix} $$

$$\phi \approx \Re (\frac{p_n}{q_n})$$

Curiously, this continued fraction converges much faster, than the simple continued fraction for $\phi$:

$$\phi=1+\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{1+\cdots}}}$$

For $20$ iterations we obtain the following error and computation time (in Mathematica).

For Euler's continued fraction:

$$t=0.00191546~s$$ $$\delta= 2.1295 \cdot 10^{-24}$$

For a simple continued fraction:

$$t=0.000310476~s$$ $$\delta= -3.7325 \cdot 10^{-9}$$

As you can see despite the longer computation, Euler's continued fraction gives almost triple precision for the same number of terms compared to the simple continued fraction.

Is this way of computing trigonometric functions used anywhere? Is there some continued fraction for trigonometric functions with faster convergence, or is this the best one? Maybe there is a way to further increase the convergence by some transformations?


Edit

I figured it out - I don't have to use Euler's fraction for the exponential function, I can just use Euler's fraction for $\cos(x)$, which can be made directly from its Taylor series.

$$\cos(x)=\cfrac{1}{1+\cfrac{x^2}{2-x^2+\cfrac{2x^2}{12-x^2+\cfrac{12x^2}{30-x^2+\cdots}}}}$$

It obviously converges much faster, because it contains $x^2$, not $x$. The $n^{th}$ coefficient is defined by the rule:

$$\frac{(2n)!}{(2n-2)!}$$

As a result for $\phi$ we get:

$$\phi=\cfrac{2}{1+\cfrac{\pi^2/25}{2-\pi^2/25+\cfrac{2\pi^2/25}{12-\pi^2/25+\cfrac{12\pi^2/25}{30-\pi^2/25+\cdots}}}}$$

I'm not able to use Mathematica right now, but I will check how speed and error compares to the other two continued fractions. But at least up to $n=4$ we have $\phi=1.618034$ which is correct for $5$ digits.

As for the comment below due to Thomas Andrews "...it is not surprising that continued fractions that allow coefficients outside the positive integers "converge faster." I put that in quotes because you are still going to be dealing with expressions in terms of $\pi$..." - can someone clarify what he means?

$\endgroup$
  • $\begingroup$ What do you mean by "simple continued fractions?" Do you just mean "with positive integer terms?" Then it is not surprising that continued fractions that allow coefficients outside the positive integers "converge faster." I put that in quotes because you are still going to be dealing with expressions in terms of $\pi$... $\endgroup$ – Thomas Andrews Feb 14 '16 at 19:23
  • $\begingroup$ I mean the fraction $[1;1,1,1,...]$ $\endgroup$ – Yuriy S Feb 14 '16 at 19:25
  • $\begingroup$ If you are planning on closing this, please don't, as it is a wonderful addition to this site and I would hope others may find it useful. $\endgroup$ – Simply Beautiful Art Feb 17 '16 at 2:01
  • $\begingroup$ Of course, you're gonna need to know the effect of your precision for $\pi$ to know your precision for $\phi$. The simple continued fraction for $\phi$ requires simple integer arithmetic. It is quite possible as the precision desired gets greater that the "Euler" expansion is costly. And $\frac{(2n)!}{(2n-2)!}=2n(2n-1)$, so why write that ratio? $\endgroup$ – Thomas Andrews Jan 4 '17 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.