Mathematica has three useful functions related to Continued fraction
FromContinuedFraction[ list ]
ContinuedFraction[ x , n ]
Rationalize[ x ]
FromContinuedFraction[ list ] will produce the convergence of the continued fraction
Examples
Example : Compute continued fraction in Mathematica
In: FromContinuedFraction[{2, 3, 1, 2, 3, 1}]
Out:
Example : to compute the convergence of = in Mathematica we put another bracket for the periodic list, become
In: FromContinuedFraction[{1, {1, 2}}]
Out :
Mathematica function ContinuedFraction[ x , n ] will return the list of continued fraction up to n terms. This is exactly inverse procedure of FromContinuedFraction[ list ]
Example :
In:
Out: {1,{1,2}}
Example :
In:
Out: {2, 3, 1, 2, 4}
Rationalize[ x, accuracy ] will return rational approximation or decimal to fraction converter
Example :
In: Rationalize[Pi, 0.01]
Out: 22/7
Example :
In: Rationalize[Pi, 0.0001]
Out: 333/106
Example :
In: Rationalize[2.14567, 0.01]
Out: 15/7
This tutorial is copyrighted .
Preferable reference for this tutorial is
Teknomo, Kardi (2015) Continued Fraction. http://people.revoledu.com/kardi/tutorial/ContinuedFraction/index.html