[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
11.1 Introduction to Maximas Database | ||
11.2 Functions and Variables for Properties | ||
11.3 Functions and Variables for Facts | ||
11.4 Functions and Variables for Predicates |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Assigns the atom or list of atoms a_i the property or list of properties p_i. When a_i and/or p_i are lists, each of the atoms gets all of the properties.
declare
quotes its arguments.
declare
always returns done
.
As noted in the description for each declaration flag, for some flags
featurep(object, feature)
returns true
if object
has been declared to have feature. However, featurep
does not
recognize some flags; this is a bug.
See also features
.
declare
recognizes the following properties:
evfun
Makes a_i known to ev
so that the function named by a_i
is applied when a_i appears as a flag argument of ev
.
See evfun
.
evflag
Makes a_i known to the ev
function so that a_i is bound to
true
during the execution of ev
when a_i appears as a flag
argument of ev
. See evflag
.
bindtest
Tells Maxima to trigger an error when a_i is evaluated unbound.
noun
Tells Maxima to parse a_i as a noun. The effect of this is to replace
instances of a_i with 'a_i
or nounify(a_i)
,
depending on the context.
constant
Tells Maxima to consider a_i a symbolic constant.
scalar
Tells Maxima to consider a_i a scalar variable.
nonscalar
Tells Maxima to consider a_i a nonscalar variable. The usual application is to declare a variable as a symbolic vector or matrix.
nonarray
Tells Maxima to consider a_i not an array. This declaration prevents multiple evaluation of a subscripted variable name.
mainvar
Tells Maxima to consider a_i a "main variable". A main variable succeeds
all other constants and variables in the canonical ordering of Maxima
expressions, as determined by ordergreatp
.
alphabetic
Tells Maxima to recognize all characters in a_i (which must be a string) as alphabetic characters.
feature
Tells Maxima to recognize a_i as the name of a feature. Other atoms may then be declared to have the a_i property.
rassociative
, lassociative
Tells Maxima to recognize a_i as a right-associative or left-associative function.
nary
Tells Maxima to recognize a_i as an n-ary function.
The nary
declaration is not the same as calling the nary
function.
The sole effect of declare(foo, nary)
is to instruct the Maxima
simplifier to flatten nested expressions, for example, to simplify
foo(x, foo(y, z))
to foo(x, y, z)
.
symmetric
, antisymmetric
, commutative
Tells Maxima to recognize a_i as a symmetric or antisymmetric function.
commutative
is the same as symmetric
.
oddfun
, evenfun
Tells Maxima to recognize a_i as an odd or even function.
outative
Tells Maxima to simplify a_i expressions by pulling constant factors out of the first argument.
When a_i has one argument, a factor is considered constant if it is a literal or declared constant.
When a_i has two or more arguments, a factor is considered constant if the second argument is a symbol and the factor is free of the second argument.
multiplicative
Tells Maxima to simplify a_i expressions by the substitution
a_i(x * y * z * ...)
-->
a_i(x) * a_i(y) * a_i(z) * ...
.
The substitution is carried out on the first argument only.
additive
Tells Maxima to simplify a_i expressions by the substitution
a_i(x + y + z + ...)
-->
a_i(x) + a_i(y) + a_i(z) + ...
.
The substitution is carried out on the first argument only.
linear
Equivalent to declaring a_i both outative
and additive
.
integer
, noninteger
Tells Maxima to recognize a_i as an integer or noninteger variable.
even
, odd
Tells Maxima to recognize a_i as an even or odd integer variable.
rational
, irrational
Tells Maxima to recognize a_i as a rational or irrational real variable.
real
, imaginary
, complex
Tells Maxima to recognize a_i as a real, pure imaginary, or complex variable.
increasing
, decreasing
Tells Maxima to recognize a_i as an increasing or decreasing function.
posfun
Tells Maxima to recognize a_i as a positive function.
integervalued
Tells Maxima to recognize a_i as an integer-valued function.
Examples:
evfun
and evflag
declarations.
(%i1) declare (expand, evfun); (%o1) done (%i2) (a + b)^3; 3 (%o2) (b + a) (%i3) (a + b)^3, expand; 3 2 2 3 (%o3) b + 3 a b + 3 a b + a (%i4) declare (demoivre, evflag); (%o4) done (%i5) exp (a + b*%i); %i b + a (%o5) %e (%i6) exp (a + b*%i), demoivre; a (%o6) %e (%i sin(b) + cos(b))
bindtest
declaration.
(%i1) aa + bb; (%o1) bb + aa (%i2) declare (aa, bindtest); (%o2) done (%i3) aa + bb; aa unbound variable -- an error. Quitting. To debug this try debugmode(true); (%i4) aa : 1234; (%o4) 1234 (%i5) aa + bb; (%o5) bb + 1234
noun
declaration.
(%i1) factor (12345678); 2 (%o1) 2 3 47 14593 (%i2) declare (factor, noun); (%o2) done (%i3) factor (12345678); (%o3) factor(12345678) (%i4) ''%, nouns; 2 (%o4) 2 3 47 14593
constant
, scalar
, nonscalar
, and mainvar
declarations.
alphabetic
declaration.
(%i1) xx\~yy\`\@ : 1729; (%o1) 1729 (%i2) declare ("~`@", alphabetic); (%o2) done (%i3) xx~yy`@ + @yy`xx + `xx@@yy~; (%o3) `xx@@yy~ + @yy`xx + 1729 (%i4) listofvars (%); (%o4) [@yy`xx, `xx@@yy~]
feature
declaration.
(%i1) declare (FOO, feature); (%o1) done (%i2) declare (x, FOO); (%o2) done (%i3) featurep (x, FOO); (%o3) true
rassociative
and lassociative
declarations.
nary
declaration.
(%i1) H (H (a, b), H (c, H (d, e))); (%o1) H(H(a, b), H(c, H(d, e))) (%i2) declare (H, nary); (%o2) done (%i3) H (H (a, b), H (c, H (d, e))); (%o3) H(a, b, c, d, e)
symmetric
and antisymmetric
declarations.
(%i1) S (b, a); (%o1) S(b, a) (%i2) declare (S, symmetric); (%o2) done (%i3) S (b, a); (%o3) S(a, b) (%i4) S (a, c, e, d, b); (%o4) S(a, b, c, d, e) (%i5) T (b, a); (%o5) T(b, a) (%i6) declare (T, antisymmetric); (%o6) done (%i7) T (b, a); (%o7) - T(a, b) (%i8) T (a, c, e, d, b); (%o8) T(a, b, c, d, e)
oddfun
and evenfun
declarations.
(%i1) o (- u) + o (u); (%o1) o(u) + o(- u) (%i2) declare (o, oddfun); (%o2) done (%i3) o (- u) + o (u); (%o3) 0 (%i4) e (- u) - e (u); (%o4) e(- u) - e(u) (%i5) declare (e, evenfun); (%o5) done (%i6) e (- u) - e (u); (%o6) 0
outative
declaration.
(%i1) F1 (100 * x); (%o1) F1(100 x) (%i2) declare (F1, outative); (%o2) done (%i3) F1 (100 * x); (%o3) 100 F1(x) (%i4) declare (zz, constant); (%o4) done (%i5) F1 (zz * y); (%o5) zz F1(y)
multiplicative
declaration.
(%i1) F2 (a * b * c); (%o1) F2(a b c) (%i2) declare (F2, multiplicative); (%o2) done (%i3) F2 (a * b * c); (%o3) F2(a) F2(b) F2(c)
additive
declaration.
(%i1) F3 (a + b + c); (%o1) F3(c + b + a) (%i2) declare (F3, additive); (%o2) done (%i3) F3 (a + b + c); (%o3) F3(c) + F3(b) + F3(a)
linear
declaration.
(%i1) 'sum (F(k) + G(k), k, 1, inf); inf ==== \ (%o1) > (G(k) + F(k)) / ==== k = 1 (%i2) declare (nounify (sum), linear); (%o2) done (%i3) 'sum (F(k) + G(k), k, 1, inf); inf inf ==== ==== \ \ (%o3) > G(k) + > F(k) / / ==== ==== k = 1 k = 1
Categories: Declarations and inferences
Maxima recognizes certain mathematical properties of functions and variables. These are called "features".
declare (x, foo)
gives the property foo
to the function or variable x.
declare (foo, feature)
declares a new feature foo.
For example,
declare ([red, green, blue], feature)
declares three new features, red
, green
, and blue
.
The predicate featurep (x, foo)
returns true
if x has the foo property,
and false
otherwise.
The infolist features
is a list of known features. These are
integer noninteger even odd rational irrational real imaginary complex analytic increasing decreasing oddfun evenfun posfun commutative lassociative rassociative symmetric antisymmetric
plus any user-defined features.
features
is a list of mathematical features. There is also a list of
non-mathematical, system-dependent features. See status
.
Categories: Declarations and inferences
Retrieves the user property indicated by i associated with
atom a or returns false
if a doesn't have property i.
get
evaluates its arguments.
(%i1) put (%e, 'transcendental, 'type); (%o1) transcendental (%i2) put (%pi, 'transcendental, 'type)$ (%i3) put (%i, 'algebraic, 'type)$ (%i4) typeof (expr) := block ([q], if numberp (expr) then return ('algebraic), if not atom (expr) then return (maplist ('typeof, expr)), q: get (expr, 'type), if q=false then errcatch (error(expr,"is not numeric.")) else q)$ (%i5) typeof (2*%e + x*%pi); x is not numeric. (%o5) [[transcendental, []], [algebraic, transcendental]] (%i6) typeof (2*%e + %pi); (%o6) [transcendental, [algebraic, transcendental]]
Categories: Declarations and inferences
The command declare(a, nonarray)
tells Maxima to consider a not
an array. This declaration prevents multiple evaluation, if a is a
subscripted variable.
Example:
(%i1) a:'b$ b:'c$ c:'d$ (%i4) a[x]; (%o4) d x (%i5) declare(a, nonarray); (%o5) done (%i6) a[x]; (%o6) a x
Categories: Expressions
declare (f, posfun)
declares f
to be a positive function.
is (f(x) > 0)
yields true
.
Categories: Declarations and inferences · Operators
Displays the property with the indicator i associated with the atom
a. a may also be a list of atoms or the atom all
in which
case all of the atoms with the given property will be used. For example,
printprops ([f, g], atvalue)
. printprops
is for properties that
cannot otherwise be displayed, i.e. for atvalue
,
atomgrad
,
gradef
,
and matchdeclare
.
Categories: Declarations and inferences · Display functions
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Activates the contexts context_1, …, context_n.
The facts in these contexts are then available to
make deductions and retrieve information.
The facts in these contexts are not listed by facts ()
.
The variable activecontexts
is the list
of contexts which are active by way of the activate
function.
Categories: Declarations and inferences
Default value: []
activecontexts
is a list of the contexts which are active
by way of the activate
function, as opposed to being active because
they are subcontexts of the current context.
Categories: Declarations and inferences
When asksign
is called,
askexp
is the expression asksign
is testing.
At one time, it was possible for a user to inspect askexp
by entering a Maxima break with control-A.
Categories: Declarations and inferences
askinteger (expr, integer)
attempts to determine from the
assume
database whether expr is an integer.
askinteger
prompts the user if it cannot tell otherwise,
and attempt to install the information in the database if possible.
askinteger (expr)
is equivalent to
askinteger (expr, integer)
.
askinteger (expr, even)
and askinteger (expr, odd)
likewise attempt to determine if expr is an even integer or odd integer,
respectively.
Categories: Declarations and inferences
First attempts to determine whether the specified
expression is positive, negative, or zero. If it cannot, it asks the
user the necessary questions to complete its deduction. The user's
answer is recorded in the data base for the duration of the current
computation. The return value of asksign
is one of pos
,
neg
, or zero
.
Categories: Declarations and inferences
Adds predicates pred_1, …, pred_n to the current context.
If a predicate is inconsistent or redundant with the predicates in the current
context, it is not added to the context. The context accumulates predicates
from each call to assume
.
assume
returns a list whose elements are the predicates added to the
context or the atoms redundant
or inconsistent
where applicable.
The predicates pred_1, …, pred_n can only be expressions
with the relational operators < <= equal notequal >=
and >
.
Predicates cannot be literal equality =
or literal inequality #
expressions, nor can they be predicate functions such as integerp
.
Compound predicates of the form pred_1 and ... and pred_n
are recognized, but not pred_1 or ... or pred_n
.
not pred_k
is recognized if pred_k is a relational predicate.
Expressions of the form not (pred_1 and pred_2)
and not (pred_1 or pred_2)
are not recognized.
Maxima's deduction mechanism is not very strong;
there are many obvious consequences which cannot be determined by is
.
This is a known weakness.
assume
does not handle predicates with complex numbers. If a predicate
contains a complex number assume
returns inconsistent
or
redunant
.
assume
evaluates its arguments.
See also is
, facts
, forget
, context
, and
declare
.
Examples:
(%i1) assume (xx > 0, yy < -1, zz >= 0); (%o1) [xx > 0, yy < - 1, zz >= 0] (%i2) assume (aa < bb and bb < cc); (%o2) [bb > aa, cc > bb] (%i3) facts (); (%o3) [xx > 0, - 1 > yy, zz >= 0, bb > aa, cc > bb] (%i4) is (xx > yy); (%o4) true (%i5) is (yy < -yy); (%o5) true (%i6) is (sinh (bb - aa) > 0); (%o6) true (%i7) forget (bb > aa); (%o7) [bb > aa] (%i8) prederror : false; (%o8) false (%i9) is (sinh (bb - aa) > 0); (%o9) unknown (%i10) is (bb^2 < cc^2); (%o10) unknown
Categories: Declarations and inferences
Default value: true
assumescalar
helps govern whether expressions expr
for which nonscalarp (expr)
is false
are assumed to behave like scalars for certain transformations.
Let expr
represent any expression other than a list or a matrix,
and let [1, 2, 3]
represent any list or matrix.
Then expr . [1, 2, 3]
yields [expr, 2 expr, 3 expr]
if assumescalar
is true
, or scalarp (expr)
is
true
, or constantp (expr)
is true
.
If assumescalar
is true
, such
expressions will behave like scalars only for commutative
operators, but not for noncommutative multiplication .
.
When assumescalar
is false
, such
expressions will behave like non-scalars.
When assumescalar
is all
, such expressions will behave like
scalars for all the operators listed above.
Categories: Declarations and inferences
Default value: false
When assume_pos
is true
and the sign of a parameter x
cannot be determined from the current context
or other considerations,
sign
and asksign (x)
return true
.
This may forestall some automatically-generated asksign
queries,
such as may arise from integrate
or other computations.
By default, a parameter is x such that symbolp (x)
or subvarp (x)
.
The class of expressions considered parameters can be modified to some extent
via the variable assume_pos_pred
.
sign
and asksign
attempt to deduce the sign of expressions
from the sign of operands within the expression.
For example, if a
and b
are both positive,
then a + b
is also positive.
However, there is no way to bypass all asksign
queries.
In particular, when the asksign
argument is a
difference x - y
or a logarithm log(x)
,
asksign
always requests an input from the user,
even when assume_pos
is true
and assume_pos_pred
is
a function which returns true
for all arguments.
Categories: Declarations and inferences
Default value: false
When assume_pos_pred
is assigned the name of a function
or a lambda expression of one argument x,
that function is called to determine
whether x is considered a parameter for the purpose of assume_pos
.
assume_pos_pred
is ignored when assume_pos
is false
.
The assume_pos_pred
function is called by sign
and asksign
with an argument x
which is either an atom, a subscripted variable, or a function call expression.
If the assume_pos_pred
function returns true
,
x is considered a parameter for the purpose of assume_pos
.
By default, a parameter is x such that symbolp (x)
or subvarp (x)
.
See also assume
and assume_pos
.
Examples:
(%i1) assume_pos: true$ (%i2) assume_pos_pred: symbolp$ (%i3) sign (a); (%o3) pos (%i4) sign (a[1]); (%o4) pnz (%i5) assume_pos_pred: lambda ([x], display (x), true)$ (%i6) asksign (a); x = a (%o6) pos (%i7) asksign (a[1]); x = a 1 (%o7) pos (%i8) asksign (foo (a)); x = foo(a) (%o8) pos (%i9) asksign (foo (a) + bar (b)); x = foo(a) x = bar(b) (%o9) pos (%i10) asksign (log (a)); x = a Is a - 1 positive, negative, or zero? p; (%o10) pos (%i11) asksign (a - b); x = a x = b x = a x = b Is b - a positive, negative, or zero? p; (%o11) neg
Categories: Declarations and inferences
Default value: initial
context
names the collection of facts maintained by assume
and
forget
. assume
adds facts to the collection named by
context
, while forget
removes facts.
Binding context
to a name foo changes the current context to
foo. If the specified context foo does not yet exist,
it is created automatically by a call to newcontext
.
The specified context is activated automatically.
See contexts
for a general description of the context mechanism.
Categories: Declarations and inferences
Default value: [initial, global]
contexts
is a list of the contexts which
currently exist, including the currently active context.
The context mechanism makes it possible for a user to bind together and name a collection of facts, called a context. Once this is done, the user can have Maxima assume or forget large numbers of facts merely by activating or deactivating their context.
Any symbolic atom can be a context, and the facts contained in that
context will be retained in storage until destroyed one by one
by calling forget
or destroyed as a whole by calling kill
to destroy the context to which they belong.
Contexts exist in a hierarchy, with the root always being
the context global
, which contains information about Maxima that some
functions need. When in a given context, all the facts in that
context are "active" (meaning that they are used in deductions and
retrievals) as are all the facts in any context which is a subcontext
of the active context.
When a fresh Maxima is started up, the user is in a
context called initial
, which has global
as a subcontext.
See also facts
, newcontext
, supcontext
, killcontext
,
activate
, deactivate
, assume
, and forget
.
Categories: Declarations and inferences
Deactivates the specified contexts context_1, …, context_n.
Categories: Declarations and inferences
If item is the name of a context, facts (item)
returns a
list of the facts in the specified context.
If item is not the name of a context, facts (item)
returns a
list of the facts known about item in the current context. Facts that
are active, but in a different context, are not listed.
facts ()
(i.e., without an argument) lists the current context.
Categories: Declarations and inferences
Removes predicates established by assume
.
The predicates may be expressions equivalent to (but not necessarily identical
to) those previously assumed.
forget (L)
, where L is a list of predicates,
forgets each item on the list.
Categories: Declarations and inferences
Attempts to determine whether the predicate expr is provable from the
facts in the assume
database.
If the predicate is provably true
or false
, is
returns
true
or false
, respectively. Otherwise, the return value is
governed by the global flag prederror
. When prederror
is
true
, is
complains with an error message. Otherwise, is
returns unknown
.
ev(expr, pred)
(which can be written expr, pred
at
the interactive prompt) is equivalent to is(expr)
.
See also assume
, facts
, and maybe
.
Examples:
is
causes evaluation of predicates.
(%i1) %pi > %e; (%o1) %pi > %e (%i2) is (%pi > %e); (%o2) true
is
attempts to derive predicates from the assume
database.
(%i1) assume (a > b); (%o1) [a > b] (%i2) assume (b > c); (%o2) [b > c] (%i3) is (a < b); (%o3) false (%i4) is (a > c); (%o4) true (%i5) is (equal (a, c)); (%o5) false
If is
can neither prove nor disprove a predicate from the assume
database, the global flag prederror
governs the behavior of is
.
(%i1) assume (a > b); (%o1) [a > b] (%i2) prederror: true$ (%i3) is (a > 0); Maxima was unable to evaluate the predicate: a > 0 -- an error. Quitting. To debug this try debugmode(true); (%i4) prederror: false$ (%i5) is (a > 0); (%o5) unknown
Categories: Predicate functions · Declarations and inferences
Kills the contexts context_1, …, context_n.
If one of the contexts is the current context, the new current context will
become the first available subcontext of the current context which has not been
killed. If the first available unkilled context is global
then
initial
is used instead. If the initial
context is killed, a
new, empty initial
context is created.
killcontext
refuses to kill a context which is
currently active, either because it is a subcontext of the current
context, or by use of the function activate
.
killcontext
evaluates its arguments.
killcontext
returns done
.
Categories: Declarations and inferences
Attempts to determine whether the predicate expr is provable from the
facts in the assume
database.
If the predicate is provably true
or false
, maybe
returns
true
or false
, respectively. Otherwise, maybe
returns
unknown
.
maybe
is functionally equivalent to is
with
prederror: false
, but the result is computed without actually assigning
a value to prederror
.
See also assume
, facts
, and is
.
Examples:
(%i1) maybe (x > 0); (%o1) unknown (%i2) assume (x > 1); (%o2) [x > 1] (%i3) maybe (x > 0); (%o3) true
Categories: Predicate functions · Declarations and inferences
Creates a new, empty context, called name, which
has global
as its only subcontext. The newly-created context
becomes the currently active context.
newcontext
evaluates its argument.
newcontext
returns name.
Categories: Declarations and inferences
Attempts to determine the sign of expr on the basis of the facts in the
current data base. It returns one of the following answers: pos
(positive), neg
(negative), zero
, pz
(positive or zero),
nz
(negative or zero), pn
(positive or negative), or pnz
(positive, negative, or zero, i.e. nothing known).
Categories: Declarations and inferences
Creates a new context, called name, which has context as a subcontext. context must exist.
If context is not specified, the current context is assumed.
Categories: Declarations and inferences
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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]
Categories: Mathematical functions
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.
Categories: Declarations and inferences
declare (a, constant)
declares a to be a constant.
See declare
.
Categories: Declarations and inferences · Constants
Returns true
if expr is a constant expression, otherwise returns
false
.
An expression is considered a constant expression if its arguments are
numbers (including rational numbers, as displayed with /R/
),
symbolic constants such as %pi
,
%e
,
and %i
,
variables bound to a constant or declared constant by declare
,
or functions whose arguments are constant.
constantp
evaluates its arguments.
Examples:
(%i1) constantp (7 * sin(2)); (%o1) true (%i2) constantp (rat (17/29)); (%o2) true (%i3) constantp (%pi * sin(%e)); (%o3) true (%i4) constantp (exp (x)); (%o4) false (%i5) declare (x, constant); (%o5) done (%i6) constantp (exp (x)); (%o6) true (%i7) constantp (foo (x) + bar (%e) + baz (2)); (%o7) false (%i8)
Categories: Predicate functions · Constants
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
Categories: Operators
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
Categories: Operators
Returns true
if and only if expr contains an operator or function
not recognized by the Maxima simplifier.
Categories: Predicate functions · Simplification functions
Tests whether the expression expr in the variable v is equivalent
to zero, returning true
, false
, or dontknow
.
zeroequiv
has these restrictions:
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
.
Categories: Predicate functions
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Robert Dodier on July, 31 2011 using texi2html 1.76.