(maxima.info)Functions and Variables for Predicates
11.4 Functions and Variables for Predicates
===========================================
-- Function: charfun (<p>)
Return 0 when the predicate <p> evaluates to 'false'; return 1 when
the predicate evaluates to 'true'. When the predicate evaluates to
something other than 'true' or 'false' (unknown), return a noun
form.
Examples:
(%i1) charfun (x < 1);
(%o1) charfun(x < 1)
(%i2) subst (x = -1, %);
(%o2) 1
(%i3) e : charfun ('"and" (-1 < x, x < 1))$
(%i4) [subst (x = -1, e), subst (x = 0, e), subst (x = 1, e)];
(%o4) [0, 1, 0]
-- Function: compare (<x>, <y>)
Return a comparison operator <op> ('<', '<=', '>', '>=', '=', or
'#') such that 'is (<x> <op> <y>)' evaluates to 'true'; when either
<x> or <y> depends on '%i' and '<x> # <y>', return 'notcomparable';
when there is no such operator or Maxima isn't able to determine
the operator, return 'unknown'.
Examples:
(%i1) compare (1, 2);
(%o1) <
(%i2) compare (1, x);
(%o2) unknown
(%i3) compare (%i, %i);
(%o3) =
(%i4) compare (%i, %i + 1);
(%o4) notcomparable
(%i5) compare (1/x, 0);
(%o5) #
(%i6) compare (x, abs(x));
(%o6) <=
The function 'compare' doesn't try to determine whether the real
domains of its arguments are nonempty; thus
(%i1) compare (acos (x^2 + 1), acos (x^2 + 1) + 1);
(%o1) <
The real domain of 'acos (x^2 + 1)' is empty.
-- Function: equal (<a>, <b>)
Represents equivalence, that is, equal value.
By itself, 'equal' does not evaluate or simplify. The function
'is' attempts to evaluate 'equal' to a Boolean value.
'is(equal(<a>, <b>))' returns 'true' (or 'false') if and only if
<a> and <b> are equal (or not equal) for all possible values of
their variables, as determined by evaluating 'ratsimp(<a> - <b>)';
if 'ratsimp' returns 0, the two expressions are considered
equivalent. Two expressions may be equivalent even if they are not
syntactically equal (i.e., identical).
When 'is' fails to reduce 'equal' to 'true' or 'false', the result
is governed by the global flag 'prederror'. When 'prederror' is
'true', 'is' complains with an error message. Otherwise, 'is'
returns 'unknown'.
In addition to 'is', some other operators evaluate 'equal' and
'notequal' to 'true' or 'false', namely 'if', 'and', 'or', and
'not'.
The negation of 'equal' is 'notequal'.
Examples:
By itself, 'equal' does not evaluate or simplify.
(%i1) equal (x^2 - 1, (x + 1) * (x - 1));
2
(%o1) equal(x - 1, (x - 1) (x + 1))
(%i2) equal (x, x + 1);
(%o2) equal(x, x + 1)
(%i3) equal (x, y);
(%o3) equal(x, y)
The function 'is' attempts to evaluate 'equal' to a Boolean value.
'is(equal(<a>, <b>))' returns 'true' when 'ratsimp(<a> - <b>)'
returns 0. Two expressions may be equivalent even if they are not
syntactically equal (i.e., identical).
(%i1) ratsimp (x^2 - 1 - (x + 1) * (x - 1));
(%o1) 0
(%i2) is (equal (x^2 - 1, (x + 1) * (x - 1)));
(%o2) true
(%i3) is (x^2 - 1 = (x + 1) * (x - 1));
(%o3) false
(%i4) ratsimp (x - (x + 1));
(%o4) - 1
(%i5) is (equal (x, x + 1));
(%o5) false
(%i6) is (x = x + 1);
(%o6) false
(%i7) ratsimp (x - y);
(%o7) x - y
(%i8) is (equal (x, y));
(%o8) unknown
(%i9) is (x = y);
(%o9) false
When 'is' fails to reduce 'equal' to 'true' or 'false', the result
is governed by the global flag 'prederror'.
(%i1) [aa : x^2 + 2*x + 1, bb : x^2 - 2*x - 1];
2 2
(%o1) [x + 2 x + 1, x - 2 x - 1]
(%i2) ratsimp (aa - bb);
(%o2) 4 x + 2
(%i3) prederror : true;
(%o3) true
(%i4) is (equal (aa, bb));
Maxima was unable to evaluate the predicate:
2 2
equal(x + 2 x + 1, x - 2 x - 1)
-- an error. Quitting. To debug this try debugmode(true);
(%i5) prederror : false;
(%o5) false
(%i6) is (equal (aa, bb));
(%o6) unknown
Some operators evaluate 'equal' and 'notequal' to 'true' or
'false'.
(%i1) if equal (y, y - 1) then FOO else BAR;
(%o1) BAR
(%i2) eq_1 : equal (x, x + 1);
(%o2) equal(x, x + 1)
(%i3) eq_2 : equal (y^2 + 2*y + 1, (y + 1)^2);
2 2
(%o3) equal(y + 2 y + 1, (y + 1) )
(%i4) [eq_1 and eq_2, eq_1 or eq_2, not eq_1];
(%o4) [false, true, true]
Because 'not <expr>' causes evaluation of <expr>, 'not equal(<a>,
<b>)' is equivalent to 'is(notequal(<a>, <b>))'.
(%i1) [notequal (2*z, 2*z - 1), not equal (2*z, 2*z - 1)];
(%o1) [notequal(2 z, 2 z - 1), true]
(%i2) is (notequal (2*z, 2*z - 1));
(%o2) true
-- Function: notequal (<a>, <b>)
Represents the negation of 'equal(<a>, <b>)'.
Examples:
(%i1) equal (a, b);
(%o1) equal(a, b)
(%i2) maybe (equal (a, b));
(%o2) unknown
(%i3) notequal (a, b);
(%o3) notequal(a, b)
(%i4) not equal (a, b);
(%o4) notequal(a, b)
(%i5) maybe (notequal (a, b));
(%o5) unknown
(%i6) assume (a > b);
(%o6) [a > b]
(%i7) equal (a, b);
(%o7) equal(a, b)
(%i8) maybe (equal (a, b));
(%o8) false
(%i9) notequal (a, b);
(%o9) notequal(a, b)
(%i10) maybe (notequal (a, b));
(%o10) true
-- Function: unknown (<expr>)
Returns 'true' if and only if <expr> contains an operator or
function not recognized by the Maxima simplifier.
-- Function: zeroequiv (<expr>, <v>)
Tests whether the expression <expr> in the variable <v> is
equivalent to zero, returning 'true', 'false', or 'dontknow'.
'zeroequiv' has these restrictions:
1. Do not use functions that Maxima does not know how to
differentiate and evaluate.
2. If the expression has poles on the real line, there may be
errors in the result (but this is unlikely to occur).
3. If the expression contains functions which are not solutions
to first order differential equations (e.g. Bessel functions)
there may be incorrect results.
4. The algorithm uses evaluation at randomly chosen points for
carefully selected subexpressions. This is always a somewhat
hazardous business, although the algorithm tries to minimize
the potential for error.
For example 'zeroequiv (sin(2 * x) - 2 * sin(x) * cos(x), x)'
returns 'true' and 'zeroequiv (%e^x + x, x)' returns 'false'. On
the other hand 'zeroequiv (log(a * b) - log(a) - log(b), a)'
returns 'dontknow' because of the presence of an extra parameter
'b'.
automatically generated by info2www version 1.2.2.9