Advice: Exact vs. floating-point computations
Maple can use exact arithmetic, where rational numbers are expressed as fractions and irrational numbers are expressed using symbolic expressions such as , or floating-point arithmetic, where numbers such as are expressed using a certain number of decimal places. It is often important to decide which of these is more appropriate in a particular problem. Often there is a tradeoff to consider: exact arithmetic avoids any problems of roundoff error, but can be much slower than floating-point and may result in very complicated expressions.
The following is an example of exact arithmetic. To save space, the result has been deleted from this help page: it is a fraction where both numerator and denominator have 15710 digits. This example should be no problem to calculate (except that it takes more than one screen to write), but it is easy to construct similar examples that will use up all available memory or take a very long time to compute.
Typically, however, all you really want is a few decimal places of the answer. For this purpose it is better to do the calculation in floating point. A numerical expression involving a number with a decimal point is evaluated in floating point (but see Forcing floating-point arithmetic ). Thus you could use
This is calculated very quickly, and the answer is in a much more convenient form.
The main disadvantage of floating point arithmetic is roundoff error. The calculation above is one in which the roundoff error is rather severe, due to the fact that we are adding a relatively small number ( 1./4321=.0002314279102 ) to a relatively large one ( 1 ), and losing significant digits in the process. This can be remedied by doing the calculation with a larger setting of the environment variable Digits , which controls the number of decimal digits used in the calculation.
There are some cases, however, in which even a very accurate floating-point approximation is no good, and exact arithmetic is necessary. Suppose, for example, we want to calculate where is some function and some number with as . Maple may be able to calculate it correctly if is given as an exact expression. But if instead you give Maple an inexact floating-point approximation of the correct , it will tell you that . This is in a sense perfectly correct (because approaches some finite number as ), but it is not what you wanted.
f:= x -> 1/sin(x):
limit(f(x)*(x-Pi), x = Pi);
> b:= evalf(Pi,20);
> limit(f(x)*(x-b), x = b);
See also: Automatic simplification and evalf , Digits , evalf , Forcing floating-point arithmetic , Roundoff error , The meaning of Digits
Maple Advisor Database, R. Israel 1997