4.5 Maple: Numeric Values

Maple can calculate with integers of arbitrary size:
> 100!;

All 158 digits of 100! are returned, and the answer is exact. (The backslashes mean that the line breaks have been artificially introduced in order to make the answer fit on screen, and they are not part of the answer.)

Likewise, Maple fractions have numerator and denominator of arbitrary precision, so in theory any given rational number can be exactly represented by Maple (subject only to the size of your computer's memory!).

Most results in Maple are exact. Even irrational numbers are returned in terms of their definition, and not as truncated decimal expansions:

> arctan(1);

				1/4 Pi

> sqrt(2);

Sometimes you may want to know the answer in floating-point form. The function evalf() (think: "evaluate as floating point") achieves this:
> sqrt(2);


> evalf(");


The precision of the answer (number of significant digits) is 10 by default, but you can request a floating point approximation of any precision by giving a second argument to evalf():

> sqrt(2);


> evalf(", 30);


As an extreme example, try evalf(Pi, 5000);.

The built-in variable Digits holds the default precision for floating point approximations, initially 10. You can change the default precision to 40 by assigning Digits := 40 for example.

Maple often gives an answer in partly unevaluated form, either because certain of the quantities are variables whose value is not known, or because Maple couldn't find a closed form answer. On occasion, you may want to ask Maple to evaluate such an expression and give a numeric approximation. evalf() can do this too. For example:

> int( exp(x^x), x=0..1);

			     |       x
			     |  exp(x ) dx

> evalf(");

Maple had a hard time simplifying the integral, so it returned a symbolic expression--the unevaluated integral. evalf() uses one of the various techniques of numerical integration, and returns the result.

evalf() does the best it can, however if there are symbols in the expression whose value is unknown or non-numeric, then the result will still depend on these symbols:

> evalf(Pi + cos(t));

			3.141592654 + cos(t)

Keith Orpen, who is still writing this, would like to hear your comments and suggestions.