Mathematical constants

Maple is aware of two constants: $\pi$ and the Euler $\gamma$ constants. Each of these can be used in algebraic expressions and equations:

[> Pi^2;

$Pi^2$

[> evalf( Pi^2 );

$9.869604404$

[> Digits := 20;

$Digits := 20$

[> evalf( Pi^2 );

$9.8696044010893586191$

This is your first lesson in floating-point computations: compare the first ten digits of the calculation made to 20 digits, and the ten digits in the first computation:

$9.869604404$
$9.869604401$

You will note that the last digit is significantly off. This is because:

  1. When the first operation is performed, $\pi$ is evaluated to ten decimal digits of precision, and only then is that 10-digit approximation squared, and the result is rounded to ten digits.
  2. When the second operation is performed, $\pi$ is evaluated to 20 decimal digits of precision, after which the result is squared and then rounded to 20 digits.

What you are seeing here is that the error of floating-point computations accumulate.

The other initially known constant is the Euler $\gamma$ (gamma) constant. You can look this up at Wikipedia.

[> evalf( gamma ); # Assuming Digits = 10

$0.5772156649$

For your info, $\gamma$ is the absolute error between the sum $\sum_{k = 1}^n \frac{1}{k}$ and the approximation of this sum by calculating $\int_1^n \frac{1}{x} dx = ln(n)$ as $n \rightarrow \infty$.

Normally, Maple leaves $\pi$ as an unevaluated constant; however, if $\pi$ appears in an algebraic expression where the other operand is a floating-point number, Maple will automatically evaluate $\pi$ to its corresponding floating-point approximation:

[> 2*Pi;

$2 \pi$

[> 2.0*Pi; # Assuming Digits = 10

$6.283185308$

Again, you will note that $2\pi$ approximated by a 10-digit number is best approximated by $6.283185307$, but as described before, Maple (and most programming languages, for that matter) approximate $\pi$ by a 10-digit number first, and then multiply that result by two.

Other constants include infinity, and undefined. The first represents the real infinity, and later an undefined value, such as, for example, the derivative of a function when that function is discontinuous.

There are also floating-point equivalents of infinity and undefined, but their semantics is slightly different: Float(infinity) represents all real numbers larger than the largest possibly floating-point number. Float(undefined) represents what is defined in IEEE 754 as not-a-number, or NAN.