checking identities



There are several ways of testing whether two expressions, a and b, are
equal.

The most straightforward is: is(equal(a,b)).  This uses ratsimp to check
whether a equals b.  Note that this is NOT the same as is(a=b), which
only checks if the *form* of a and b is alike:

   is( (x-1)*(x+1) = x^2-1 ) => false
   is(equal( (x-1)*(x+1), x^2-1 )) => true

All the remaining solutions test whether a-b is equal to zero, so let's
rename a-b as ex (short for expression).

1) ratsimp.  If ex is a rational function (involving only addition,
subtraction, multiplication, division, and integer powers), ratsimp will
always return 0 if the expression is zero.  One (minor) caveat: snce
ratsimp expands out powers, it might be slow (or overflow the stack) if
you have expressions like (x-y)^500.  (By the way, the "is" function
uses ratsimp.)

2) radcan.  This is good for expressions involving non-nested fractional
powers (radicals).

3) trigexpand/ratsimp, trigsimp, trigrat, exponentialize/logarc.  For
expressions involving trigonometric functions, there are several
approaches if (1) and (2) fail.  You might try trigexpand followed by
ratsimp.  Trigsimp and Trigrat are also useful (though trigrat can blow
up in many cases).  It is sometimes useful to convert to
exponential/logarithmic form using exponentialize and logarc, and then
apply radcan.

The methods so far never give incorrect results, though they don't
always reduce to zero.  There are a couple of methods that are not
infallible, but are still useful:

4) Expanding as a Taylor series -- if the expression is composed of
known, differentiable functions.  If taylor(ex,x,0,20) is zero, and ex
doesn't involve any high powers, then ex is almost certainly identically
zero.  This approach could be made more precise (analyzing what the
lowest non-zero term must be), but it's useful even without the full
analysis.

5) Another heuristic method is supplied by Maxima: zeroequiv.  Despite
its name, this is NOT usually the best general-purpose way to test an
expression for equivalence to zero.  First of all, it only works for
univariate expressions involving *only* smooth functions which Maxima
can evaluate numerically, e.g. sin, cosh, atan, etc. but not abs (not
smooth), f (that is, some unknown function), etc.  Secondly, it makes
mistakes (see bugs # 593530 and 626760).

Note that checking for equivalence to zero is actually a very hard
problem in general!  (see
http://mathworld.wolfram.com/RichardsonsTheorem.html)

       -s