<
,
>
,
<=
,
>=
,
!=
,
=
,
Not
,
And
,
Or
,
IsFreeOf
,
IsZeroVector
,
IsNonObject
,
IsEven
,
IsOdd
,
IsFunction
,
IsAtom
,
IsString
,
IsNumber
,
IsList
,
IsNumericList
,
IsBound
,
IsBoolean
,
IsNegativeNumber
,
IsNegativeInteger
,
IsPositiveNumber
,
IsPositiveInteger
,
IsNotZero
,
IsNonZeroInteger
,
IsInfinity
,
IsPositiveReal
,
IsNegativeReal
,
IsConstant
,
IsGaussianInteger
,
IsGaussianPrime
,
MatchLinear
,
HasExpr, HasExprArith, HasExprSome
,
HasFunc, HasFuncArith, HasFuncSome
.
Predicates
A predicate is a function that returns a boolean value, i.e. True or False. Predicates are
often used in patterns, For instance, a rule that only holds for a
positive integer would use a pattern such as n_IsPositiveInteger.
< -- test for "less than"
Standard library
Calling format:
(prec. 9)
Parameters:
e1, e2 -- expressions to be compared
Description:
The two expression are evaluated. If both results are numeric, they
are compared. If the first expression is smaller than the second one,
the result is True and it is False otherwise. If either of the expression is not numeric, after
evaluation, the expression is returned with evaluated arguments.
The word "numeric" in the previous paragraph has the following
meaning. An expression is numeric if it is either a number (i.e. IsNumber returns True), or the
quotient of two numbers, or an infinity (i.e. IsInfinity returns True).
Examples:
In> 2 < 5;
Out> True;
In> Cos(1) < 5;
Out> Cos(1)<5;
In> N(Cos(1)) < 5;
Out> True
|
See also:
IsNumber
,
IsInfinity
,
N
.
> -- test for "greater than"
Standard library
Calling format:
(prec. 9)
Parameters:
e1, e2 -- expressions to be compared
Description:
The two expression are evaluated. If both results are numeric, they
are compared. If the first expression is larger than the second one,
the result is True and it is False otherwise. If either of the expression is not numeric, after
evaluation, the expression is returned with evaluated arguments.
The word "numeric" in the previous paragraph has the following
meaning. An expression is numeric if it is either a number (i.e. IsNumber returns True), or the
quotient of two numbers, or an infinity (i.e. IsInfinity returns True).
Examples:
In> 2 > 5;
Out> False;
In> Cos(1) > 5;
Out> Cos(1)>5;
In> N(Cos(1)) > 5;
Out> False
|
See also:
IsNumber
,
IsInfinity
,
N
.
<= -- test for "less or equal"
Standard library
Calling format:
(prec. 9)
Parameters:
e1, e2 -- expressions to be compared
Description:
The two expression are evaluated. If both results are numeric, they
are compared. If the first expression is smaller than or equals the
second one, the result is True and it is False otherwise. If either of the expression is not
numeric, after evaluation, the expression is returned with evaluated
arguments.
The word "numeric" in the previous paragraph has the following
meaning. An expression is numeric if it is either a number (i.e. IsNumber returns True), or the
quotient of two numbers, or an infinity (i.e. IsInfinity returns True).
Examples:
In> 2 <= 5;
Out> True;
In> Cos(1) <= 5;
Out> Cos(1)<=5;
In> N(Cos(1)) <= 5;
Out> True
|
See also:
IsNumber
,
IsInfinity
,
N
.
>= -- test for "greater or equal"
Standard library
Calling format:
(prec. 9)
Parameters:
e1, e2 -- expressions to be compared
Description:
The two expression are evaluated. If both results are numeric, they
are compared. If the first expression is larger than or equals the
second one, the result is True and it is False otherwise. If either of the expression is not
numeric, after evaluation, the expression is returned with evaluated
arguments.
The word "numeric" in the previous paragraph has the following
meaning. An expression is numeric if it is either a number (i.e. IsNumber returns True), or the
quotient of two numbers, or an infinity (i.e. IsInfinity returns True).
Examples:
In> 2 >= 5;
Out> False;
In> Cos(1) >= 5;
Out> Cos(1)>=5;
In> N(Cos(1)) >= 5;
Out> False
|
See also:
IsNumber
,
IsInfinity
,
N
.
!= -- test for "not equal"
Standard library
Calling format:
(prec. 9)
Parameters:
e1, e2 -- expressions to be compared
Description:
Both expressions are evaluated and compared. If they turn out to be
equal, the result is False. Otherwise, the result
is True.
The expression e1 != e2 is equivalent to Not(e1 = e2).
Examples:
In> 1 != 2;
Out> True;
In> 1 != 1;
Out> False;
|
See also:
=
.
= -- test for equality of expressions
Standard library
Calling format:
(prec. 9)
Parameters:
e1, e2 -- expressions to be compared
Description:
Both expressions are evaluated and compared. If they turn out to be equal, the
result is True. Otherwise, the result is False. The function Equals does
the same.
Note that the test is on syntactic equality, not mathematical equality. Hence
even if the result is False, the expressions can still be
mathematically equal; see the examples below. Put otherwise, this
function tests whether the two expressions would be displayed in the same way
if they were printed.
Examples:
In> e1 := (x+1) * (x-1);
Out> (x+1)*(x-1);
In> e2 := x^2 - 1;
Out> x^2-1;
In> e1 = e2;
Out> False;
In> Expand(e1) = e2;
Out> True;
|
See also:
!=
,
Equals
.
Not -- logical negation
Internal function
Calling format:
Parameters:
expr -- a boolean expression
Description:
Not returns the logical negation of the argument expr. If expr is
False it returns True, and if expr is True, Not expr returns False.
If the argument is neither True nor False, it returns the entire
expression with evaluated arguments.
Examples:
In> Not True
Out> False;
In> Not False
Out> True;
In> Not(a)
Out> Not a;
|
See also:
And
,
Or
.
And -- logical conjunction
Internal function
Calling format:
(prec. 100)
Parameters:
a1, ..., aN -- boolean values (may evaluate to True or False)
Description:
This function returns True if all arguments are true. The
And operation is "lazy", i.e. it returns False as soon as a False argument
is found (from left to right). If an argument other than True or
False is encountered a new And expression is returned with all
arguments that didn't evaluate to True or False yet.
Examples:
In> True And False
Out> False;
In> And(True,True)
Out> True;
In> False And a
Out> False;
In> True And a
Out> And(a);
In> And(True,a,True,b)
Out> b And a;
|
See also:
Or
,
Not
.
Or -- logical disjunction
Internal function
Calling format:
(prec. 101)
Parameters:
a1, ..., aN -- boolean expressions (may evaluate to True or False)
Description:
This function returns True if an argument is encountered
that is true (scanning from left to right). The
Or operation is "lazy", i.e. it returns True as soon as a True argument
is found (from left to right). If an argument other than True or
False is encountered, an unevaluated Or expression is returned with all
arguments that didn't evaluate to True or False yet.
Examples:
In> True Or False
Out> True;
In> False Or a
Out> Or(a);
In> Or(False,a,b,True)
Out> True;
|
See also:
And
,
Not
.
IsFreeOf -- test whether expression depends on variable
Standard library
Calling format:
IsFreeOf(var, expr)
IsFreeOf({var, ...}, expr)
|
Parameters:
expr -- expression to test
var -- variable to look for in "expr"
Description:
This function checks whether the expression "expr" (after being
evaluated) depends on the variable "var". It returns False if this is the case and True
otherwise.
The second form test whether the expression depends on any of
the variables named in the list. The result is True if none of the variables appear in the expression and False otherwise.
Examples:
In> IsFreeOf(x, Sin(x));
Out> False;
In> IsFreeOf(y, Sin(x));
Out> True;
In> IsFreeOf(x, D(x) a*x+b);
Out> True;
In> IsFreeOf({x,y}, Sin(x));
Out> False;
|
The third command returns True because the
expression D(x) a*x+b evaluates to a, which does not depend on x.
See also:
Contains
.
IsZeroVector -- test whether list contains only zeroes
Standard library
Calling format:
Parameters:
list -- list to compare against the zero vector
Description:
The only argument given to IsZeroVector should be
a list. The result is True if the list contains
only zeroes and False otherwise.
Examples:
In> IsZeroVector({0, x, 0});
Out> False;
In> IsZeroVector({x-x, 1 - D(x) x});
Out> True;
|
See also:
IsList
,
ZeroVector
.
IsNonObject -- test whether argument is not an Object()
Standard library
Calling format:
Parameters:
expr -- the expression to examine
Description:
This function returns True if "expr" is not of
the form Object(...) and False
otherwise.
Bugs
In fact, the result is always True.
See also:
Object
.
IsEven -- test for an even integer
Standard library
Calling format:
Parameters:
n -- integer to test
Description:
This function tests whether the integer "n" is even. An integer is
even if it is divisible by two. Hence the even numbers are 0, 2, 4, 6,
8, 10, etcetera, and -2, -4, -6, -8, -10, etcetera.
Examples:
In> IsEven(4);
Out> True;
In> IsEven(-1);
Out> False;
|
See also:
IsOdd
,
IsInteger
.
IsOdd -- test for an odd integer
Standard library
Calling format:
Parameters:
n -- integer to test
Description:
This function tests whether the integer "n" is odd. An integer is
odd if it is not divisible by two. Hence the odd numbers are 1, 3, 5,
7, 9, etcetera, and -1, -3, -5, -7, -9, etcetera.
Examples:
In> IsOdd(4);
Out> False;
In> IsOdd(-1);
Out> True;
|
See also:
IsEven
,
IsInteger
.
IsFunction -- test for a composite object
Internal function
Calling format:
Parameters:
expr -- expression to test
Description:
This function tests whether "expr" is a composite object, i.e. not an
atom. This includes not only obvious functions such as f(x), but also expressions such as x+5 and lists.
Examples:
In> IsFunction(x+5);
Out> True;
In> IsFunction(x);
Out> False;
|
See also:
IsAtom
,
IsList
,
Type
.
IsAtom -- test for an atom
Internal function
Calling format:
Parameters:
expr -- expression to test
Description:
This function tests whether "expr" is an atom. Numbers, strings, and
variables are all atoms.
Examples:
In> IsAtom(x+5);
Out> Falso;
In> IsAtom(5);
Out> True;
|
See also:
IsFunction
,
IsNumber
,
IsString
.
IsString -- test for an string
Internal function
Calling format:
Parameters:
expr -- expression to test
Description:
This function tests whether "expr" is a string. A string is a text
within quotes, eg. "duh".
Examples:
In> IsString("duh");
Out> True;
In> IsString(duh);
Out> False;
|
See also:
IsAtom
,
IsNumber
.
IsNumber -- test for a number
Internal function
Calling format:
Parameters:
expr -- expression to test
Description:
This function tests whether "expr" is a number. There are two kinds
of numbers, integers (e.g. 6) and reals (e.g. -2.75 or 6.0). Note that a
complex number is represented by the Complex
function, so IsNumber will return False.
Examples:
In> IsNumber(6);
Out> True;
In> IsNumber(3.25);
Out> True;
In> IsNumber(I);
Out> False;
In> IsNumber("duh");
Out> False;
|
See also:
IsAtom
,
IsString
,
IsInteger
,
IsPositiveNumber
,
IsNegativeNumber
,
Complex
.
IsList -- test for a list
Internal function
Calling format:
Parameters:
expr -- expression to test
Description:
This function tests whether "expr" is a list. A list is a sequence
between curly braces, e.g. {2, 3, 5}.
Examples:
In> IsList({2,3,5});
Out> True;
In> IsList(2+3+5);
Out> False;
|
See also:
IsFunction
.
IsNumericList -- test for a list of numbers
Standard library
Calling format:
Parameters:
{list} -- a list
Description:
Returns True when called on a list of numbers or expressions that evaluate to numbers using N(). Returns False otherwise.
See also:
N
,
IsNumber
.
IsBound -- test for a bound variable
Internal function
Calling format:
Parameters:
var -- variable to test
Description:
This function tests whether the variable "var" is bound, ie. whether
it has been assigned a value. The argument "var" is not evaluated.
Examples:
In> IsBound(x);
Out> False;
In> x := 5;
Out> 5;
In> IsBound(x);
Out> True;
|
See also:
IsAtom
.
IsBoolean -- test for a Boolean value
Standard library
Calling format:
Parameters:
expression -- an expression
Description:
IsBoolean returns True if the argument is of a boolean type.
This means it has to be either True, False, or an expression involving
functions that return a boolean result, e.g.
=, >, <, >=, <=, !=, And, Not, Or.
Examples:
In> IsBoolean(a)
Out> False;
In> IsBoolean(True)
Out> True;
In> IsBoolean(a And b)
Out> True;
|
See also:
True
,
False
.
IsNegativeNumber -- test for a negative number
Standard library
Calling format:
Parameters:
n -- number to test
Description:
IsNegativeNumber(n) evaluates to True if n is (strictly) negative, i.e.
if n<0. If n is not a number, the functions return False.
Examples:
In> IsNegativeNumber(6);
Out> False;
In> IsNegativeNumber(-2.5);
Out> True;
|
See also:
IsNumber
,
IsPositiveNumber
,
IsNotZero
,
IsNegativeInteger
,
IsNegativeReal
.
IsNegativeInteger -- test for a negative integer
Standard library
Calling format:
Parameters:
n -- integer to test
Description:
This function tests whether the integer n is (strictly)
negative. The negative integers are -1, -2, -3, -4, -5, etcetera. If
n is not a integer, the function returns False.
Examples:
In> IsNegativeInteger(31);
Out> False;
In> IsNegativeInteger(-2);
Out> True;
|
See also:
IsPositiveInteger
,
IsNonZeroInteger
,
IsNegativeNumber
.
IsPositiveNumber -- test for a positive number
Standard library
Calling format:
Parameters:
n -- number to test
Description:
IsPositiveNumber(n) evaluates to True if n is (strictly) positive, i.e.
if n>0. If n is not a number the function returns False.
Examples:
In> IsPositiveNumber(6);
Out> True;
In> IsPositiveNumber(-2.5);
Out> False;
|
See also:
IsNumber
,
IsNegativeNumber
,
IsNotZero
,
IsPositiveInteger
,
IsPositiveReal
.
IsPositiveInteger -- test for a positive integer
Standard library
Calling format:
Parameters:
n -- integer to test
Description:
This function tests whether the integer n is (strictly) positive. The
positive integers are 1, 2, 3, 4, 5, etcetera. If n is not a integer, the
function returns False.
Examples:
In> IsPositiveInteger(31);
Out> True;
In> IsPositiveInteger(-2);
Out> False;
|
See also:
IsNegativeInteger
,
IsNonZeroInteger
,
IsPositiveNumber
.
IsNotZero -- test for a nonzero number
Standard library
Calling format:
Parameters:
n -- number to test
Description:
IsNotZero(n) evaluates to True if n is not zero. In case n is not a
number, the function returns False.
Examples:
In> IsNotZero(3.25);
Out> True;
In> IsNotZero(0);
Out> False;
|
See also:
IsNumber
,
IsPositiveNumber
,
IsNegativeNumber
,
IsNonZeroInteger
.
IsNonZeroInteger -- test for a nonzero integer
Standard library
Calling format:
Parameters:
n -- integer to test
Description:
This function tests whether the integer n is not zero. If n is
not an integer, the result is False.
Examples:
In> IsNonZeroInteger(0)
Out> False;
In> IsNonZeroInteger(-2)
Out> True;
|
See also:
IsPositiveInteger
,
IsNegativeInteger
,
IsNotZero
.
IsInfinity -- test for an infinity
Standard library
Calling format:
Parameters:
expr -- expression to test
Description:
This function tests whether expr is an infinity. This is only the
case if expr is either Infinity or -Infinity.
Examples:
In> IsInfinity(10^1000);
Out> False;
In> IsInfinity(-Infinity);
Out> True;
|
See also:
Integer
.
IsPositiveReal -- test for a numerically positive value
Standard library
Calling format:
Parameters:
expr -- expression to test
Description:
This function tries to approximate "expr" numerically. It returns True if this approximation is positive. In case no
approximation can be found, the function returns False. Note that round-off errors may cause incorrect
results.
Examples:
In> IsPositiveReal(Sin(1)-3/4);
Out> True;
In> IsPositiveReal(Sin(1)-6/7);
Out> False;
In> IsPositiveReal(Exp(x));
Out> False;
|
The last result is because Exp(x) cannot be
numerically approximated if x is not known. Hence
Yacas can not determine the sign of this expression.
See also:
IsNegativeReal
,
IsPositiveNumber
,
N
.
IsNegativeReal -- test for a numerically negative value
Standard library
Calling format:
Parameters:
expr -- expression to test
Description:
This function tries to approximate expr numerically. It returns True if this approximation is negative. In case no
approximation can be found, the function returns False. Note that round-off errors may cause incorrect
results.
Examples:
In> IsNegativeReal(Sin(1)-3/4);
Out> False;
In> IsNegativeReal(Sin(1)-6/7);
Out> True;
In> IsNegativeReal(Exp(x));
Out> False;
|
The last result is because Exp(x) cannot be
numerically approximated if x is not known. Hence
Yacas can not determine the sign of this expression.
See also:
IsPositiveReal
,
IsNegativeNumber
,
N
.
IsConstant -- test for a constant
Standard library
Calling format:
Parameters:
expr -- some expression
Description:
IsConstant returns True if the
expression is some constant or a function with constant arguments. It
does this by checking that no variables are referenced in the
expression. Pi is considered a constant.
Examples:
In> IsConstant(Cos(x))
Out> False;
In> IsConstant(Cos(2))
Out> True;
In> IsConstant(Cos(2+x))
Out> False;
|
See also:
IsNumber
,
IsInteger
,
VarList
.
IsGaussianInteger -- test for a Gaussian integer
Standard library
Calling format:
Parameters:
z -- a complex or real number
Description:
This function returns a boolean value depending on whether or not
the argument is a Gaussian integer. A Gaussian integer is a generalization
of integers into the complex plane. A complex number a+b*I is a Gaussian
integer if and only if a and b are integers.
Examples:
In> IsGaussianInteger(5)
Out> True;
In> IsGaussianInteger(5+6*I)
Out> True;
In> IsGaussianInteger(1+2.5*I)
Out> False;
|
See also:
IsGaussianPrime
.
IsGaussianPrime -- test for a Gaussian prime
Standard library
Calling format:
Parameters:
z -- a complex or real number
Description:
This function returns a boolean value depending on whether or not the argument
is a Gaussian prime. Gaussian primes are Gaussian integers z=a+b*I
that satisfy one of the following properties. If Re(z) and Im(z) are nonzero then,
z is a Gaussian prime if and only if Re(z)^2+Im(z)^2 is an ordinary
prime. If Re(z)==0, then z is a Gaussian prime if and only if Im(z) is an
ordinary prime and Im(z):=Mod(3,4). If Im(z)==0, then z is a Gaussian prime
if and only if Re(z) is an ordinary prime and Re(z):=Mod(3,4).
Examples:
In> IsGaussianPrime(13)
Out> False;
In> IsGaussianPrime(2+2*I)
Out> False;
In> IsGaussianPrime(2+3*I)
Out> True;
In> IsGaussianPrime(3)
Out> True;
|
See also:
IsGaussianInteger
.
MatchLinear -- match an expression to a polynomial of degree one in a variable
Standard library
Calling format:
MatchLinear(variable,expression)
|
Parameters:
variable -- variable to express the univariate polynomial in
expression -- expression to match
Description:
MatchLinear tries to match an expression to a linear (degree less than
two) polynomial. The function returns True if it could match, and
it stores the resulting coefficients in the variables 'a' and 'b'
as a side effect. The function calling this predicate should declare
local variables 'a' and 'b' for this purpose.
MatchLinear tries to match to constant coefficients which don't
depend on the variable passed in, trying to find a form 'a*x+b'
with 'a' and 'b' not depending on 'x' if 'x' is given as the variable.
Examples:
In> MatchLinear(x,(R+1)*x+(T-1))
Out> True;
In> {a,b};
Out> {R+1,T-1};
In> MatchLinear(x,Sin(x)*x+(T-1))
Out> False;
|
See also:
Integrate
.
HasExpr, HasExprArith, HasExprSome -- check for expression containing a subexpression
Standard library
Calling format:
HasExpr(expr, x)
HasExprArith(expr, x)
HasExprSome(expr, x, list)
|
Parameters:
expr -- an expression
x -- a subexpression to be found
list -- list of function atoms to be considered "transparent"
Description:
The command HasExpr returns True if the expression expr contains a literal subexpression x. The expression is recursively traversed.
The command HasExprSome does the same, except it only looks at arguments of a given list of functions. All other functions become "opaque" (as if they do not contain anything).
HasExprArith is defined through HasExprSome to look only at arithmetic operations +, -, *, /.
Note that since the operators "+" and "-" are prefix as well as infix operators, it is currently required to use Atom("+") to obtain the unevaluated atom "+".
Examples:
In> HasExpr(x+y*Cos(Ln(z)/z), z)
Out> True;
In> HasExpr(x+y*Cos(Ln(z)/z), Ln(z))
Out> True;
In> HasExpr(x+y*Cos(Ln(z)/z), z/Ln(z))
Out> False;
In> HasExprArith(x+y*Cos(Ln(x)/x), z)
Out> False;
In> HasExprSome({a+b*2,c/d},c/d,{List})
Out> True;
In> HasExprSome({a+b*2,c/d},c,{List})
Out> False;
|
See also:
FuncList
,
VarList
,
HasFunc
.
HasFunc, HasFuncArith, HasFuncSome -- check for expression containing a function
Standard library
Calling format:
HasFunc(expr, func)
HasFuncArith(expr, func)
HasFuncSome(expr, func, list)
|
Parameters:
expr -- an expression
func -- a function atom to be found
list -- list of function atoms to be considered "transparent"
Description:
The command HasFunc returns True if the expression expr contains a function func. The expression is recursively traversed.
The command HasFuncSome does the same, except it only looks at arguments of a given list of functions. Arguments of all other functions become "opaque" (as if they do not contain anything).
HasFuncArith is defined through HasFuncSome to look only at arithmetic operations +, -, *, /.
Note that since the operators "+" and "-" are prefix as well as infix operators, it is currently required to use Atom("+") to obtain the unevaluated atom "+".
Examples:
In> HasFunc(x+y*Cos(Ln(z)/z), Ln)
Out> True;
In> HasFunc(x+y*Cos(Ln(z)/z), Sin)
Out> False;
In> HasFuncArith(x+y*Cos(Ln(x)/x), Cos)
Out> True;
In> HasFuncArith(x+y*Cos(Ln(x)/x), Ln)
Out> False;
In> HasFuncSome({a+b*2,c/d},/,{List})
Out> True;
In> HasFuncSome({a+b*2,c/d},*,{List})
Out> False;
|
See also:
FuncList
,
VarList
,
HasExpr
.