Approximate with precision settings of 15, 25, and 35 digits |
The given real number is close to zero; it is initially unclear whether it is positive or negative.
Maple will hold symbolically unless floating point conversion is forced in some way.
Maple's rounding function round() does not force floating point conversion.
Results obtained using floating point arithmetic (computerized emulation of real number arithmetic) may vary. Control of precision is, therefore, important.
Floating point calculations below do not match those usually obtained on machines in the classroom.
Using x-n below with evalf() is not significantly
different from repeatedly using
exp(Pi*sqrt(163))-262537412640768744.
For a real number its continued fraction expansion is a sequence , having finite or infinite length, of integers . Usually it is assumed that for . How is defined?
First, one observes that may be written uniquely in the form where is an integer and . One defines and If is an integer, then is an integer sequence of length one whose sole entry is . If is not an integer, then , and is defined recursively by pre-pending to the sequence .
If turns out to be a finite sequence , then and, therefore, must be a rational number (i.e., must be the quotient of two integers). Conversely if is rational, then by the Euclidean algorithm (applied to its numerator and denominator), its continued fraction must have finite length.
When , one sometimes writes and in the case of a sequence of infinite length one has
When for all , the sequence of “partial” continued fractions, which are called the convergents of the continued fraction, is guaranteed to be a convergent sequence, i.e., the limit above always exists.
For more see Wikipedia: http://en.wikipedia.org/wiki/Continued_fraction
|
The convergents of the continued fraction expansion of a real number are known to provide “best rational approximations” to the real number in a certain sense that may be made precise. (See, for example, Wikipedia.)
Convergents may be obtained with a call to the confrac regime of the convert facility by supplying a third argument for the length of the desired initial segment of the continued fraction expansion and a fourth argument for the user-supplied (and case sensitive) name of a variable in which to store the corresponding convergents.
Conclude that the best rational approximation to of the kind provided by the convergents of its continued fraction expansion, with denominator smaller than , is