rational conversion - Maple Help

convert/rational

convert float to an approximate rational

 Calling Sequence convert(float, rational, digits) convert(float, fraction, digits)

Parameters

 float - floating-point number digits - (optional) integer or the name exact

Description

 • The convert/rational function converts a floating-point number to an approximate rational number. The meaning of the type fraction is identical with rational in this context.
 • The accuracy of the conversion will depend on the value of the global variable Digits, or the value of digits if specified as an integer.
 • If the third argument digits is the name 'exact' then an exact conversion of float to a rational will be performed; thus Float(f, e) becomes simply f*10^e. Note that exact conversion executes much more quickly than the more sophisticated conversion.
 Note: See also the identify command to find a closed form for a decimal approximation of a number.

Examples

 > $\mathrm{convert}\left(0.125,\mathrm{rational}\right)$
 $\frac{{1}}{{8}}$ (1)
 > $\mathrm{convert}\left(2.345,\mathrm{rational}\right)$
 $\frac{{469}}{{200}}$ (2)
 > $\mathrm{convert}\left(0.3333333333,\mathrm{rational}\right)$
 $\frac{{1}}{{3}}$ (3)
 > $\mathrm{convert}\left(0.3333333333,\mathrm{rational},\mathrm{exact}\right)$
 $\frac{{3333333333}}{{10000000000}}$ (4)
 > $\mathrm{convert}\left(\mathrm{evalf}\left(\mathrm{\pi }\right),\mathrm{rational}\right)$
 $\frac{{104348}}{{33215}}$ (5)
 > $\mathrm{convert}\left(\mathrm{evalf}\left(\mathrm{\pi }\right),\mathrm{rational},3\right)$
 $\frac{{22}}{{7}}$ (6)
 > $\mathrm{convert}\left(\mathrm{evalf}\left(\mathrm{\pi }\right),\mathrm{rational},\mathrm{exact}\right)$
 $\frac{{1570796327}}{{500000000}}$ (7)