In C and C++, you can test the sign of an integer or a floating-point number by simply using a comparison operator. This does not work in Maple:
[> if Pi > 0 then printf( "Pi is greater than zero\n" ); else printf( "Pi is less than or equal to zero\n" ); end if: Error, cannot determine if this expression is true or false: 0 < Pi
Now, clearly $\pi > 0$, so why can't Maple figure this out?
The reason is that comparison operators only work on numeric values, it does not try to determine if an arbitrary algebraic expression satisfies a comparison. Instead, you must come up with a different approach.
Your first thought may be to try to evaluate the expression to a floating- point number and then do a comparison. If you are already using Maple, this is a bad idea!
Question: is $e^{5 \pi}$ greater than, equal to, or less than $6635624$?
[> evalf( exp(5*Pi) - 6635624 );
$0.013$
Okay, so it must be greater, for when you subtract off the integer value, you get a positive number.
Only, it isn't, and that is because floating-point calculations introduce an error, and each calculation is performed at the specified number of digits. In fact,
$e^{5\pi} \approx 6635623.999341134233266264067099\cdots$
so, clearly, it is less than $6635624$. The problem is that first $\pi$ is converted to a floating-point number, and then it is multiplied by $5$, and then this, too, is rounded to 10 decimal digits of precision, and then subsequently, we calculate $e$ raised to this power.
Instead, we will introduce the signum(...) function. It is a function that takes an expression $x$ and for a non-zero argument tries to return a number on the complex unit circle such that that value equals $\frac{x}{|x|}$. If the expression is real, then it then tries to determine if the expression is positive, zero, or negative, in which case, it returns $1$, $0$ or $-1$, respectively.
[> _Envsignum0 := 0: # IMPORTANT: Save this to your Startup code [> expr := some maple expression...: sgn_expr := signum( expr ): if sgn_expr = -1 then printf( "The expression is negative\n" ); elif sgn_expr = 0 then printf( "The expression is zero\n" ); elif sgn_expr = 1 then printf( "The expression is positive\n" ); else printf( "The sign of the expression cannot be determined\n" ); end if:
I would strongly encourage you to append this assignment to your .mapleprofile:
_Envsignum0 := 0:
For example, you can now observe that:
[> signum( Pi );
$1$
[> signum( 1 + x^2 );
$1$
[> signum( x^2 );
$\textrm{signum}(x)^2$
[> signum( exp(5*Pi) - 6635624 );
$-1$
The last gives the correct answer: $e^{5 \pi}$ is less than $6635624$.
In some cases, you may need to use assumptions:
[> signum( exp(x) );
$e^{j \Im(x)}$
This is correct because $e^z = e^{\Re(z) + j\Im(z)} = e^{\Re(z)}e^{j\Im(z)}$, but by Euler's formula, $\left|e^{j\Im(z)}\right| = 1$ and $e^{\Re(z)} > 0$ for all $z$. Thus, if we want Maple to interpret $x$ as being real, we must use an assumption:
[> signum( exp(x) ) assuming x::'real';
$1$