By Kardi Teknomo, PhD .

< Previous | Next | Content >

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 Continued Fraction in Mathematica

In: FromContinuedFraction[{2, 3, 1, 2, 3, 1}]

Out: Continued Fraction

Example : to compute the convergence of Continued Fraction = Continued Fraction in Mathematica we put another bracket for the periodic list, become

In: FromContinuedFraction[{1, {1, 2}}]

Out : Continued Fraction

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: Continued Fraction

Out: {1,{1,2}}

Example :

In: Continued Fraction

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

< Previous | Next | Content >

This tutorial is copyrighted .

Preferable reference for this tutorial is

Teknomo, Kardi (2015) Continued Fraction. http://people.revoledu.com/kardi/tutorial/ContinuedFraction/index.html