The functions described here are predicates, that is, they return a
true/false value where `nil`

means false and anything else means
true. These predicates are expanded by `defmath`

, for example,
from `zerop`

to `math-zerop`

. In many cases they correspond
to native Lisp functions by the same name, but are extended to cover
the full range of Calc data types.

__Function:__ **zerop** *x*

Returns true if `x` is numerically zero, in any of the Calc data
types. (Note that for some types, such as error forms and intervals,
it never makes sense to return true.) In `defmath`

, the expression
``(= x 0)'` will automatically be converted to ``(math-zerop x)'`,
and ``(/= x 0)'` will be converted to ``(not (math-zerop x))'`.

__Function:__ **negp** *x*

Returns true if `x` is negative. This accepts negative real numbers
of various types, negative HMS and date forms, and intervals in which
all included values are negative. In `defmath`

, the expression
``(< x 0)'` will automatically be converted to ``(math-negp x)'`,
and ``(>= x 0)'` will be converted to ``(not (math-negp x))'`.

__Function:__ **posp** *x*

Returns true if `x` is positive (and non-zero). For complex
numbers, none of these three predicates will return true.

__Function:__ **looks-negp** *x*

Returns true if `x` is "negative-looking." This returns true if
`x` is a negative number, or a formula with a leading minus sign
such as ``-a/b'`. In other words, this is an object which can be
made simpler by calling `(- `

.
`x`)

__Function:__ **integerp** *x*

Returns true if `x` is an integer of any size.

__Function:__ **fixnump** *x*

Returns true if `x` is a native Lisp integer.

__Function:__ **natnump** *x*

Returns true if `x` is a nonnegative integer of any size.

__Function:__ **fixnatnump** *x*

Returns true if `x` is a nonnegative Lisp integer.

__Function:__ **num-integerp** *x*

Returns true if `x` is numerically an integer, i.e., either a
true integer or a float with no significant digits to the right of
the decimal point.

__Function:__ **messy-integerp** *x*

Returns true if `x` is numerically, but not literally, an integer.
A value is `num-integerp`

if it is `integerp`

or
`messy-integerp`

(but it is never both at once).

__Function:__ **num-natnump** *x*

Returns true if `x` is numerically a nonnegative integer.

__Function:__ **evenp** *x*

Returns true if `x` is an even integer.

__Function:__ **looks-evenp** *x*

Returns true if `x` is an even integer, or a formula with a leading
multiplicative coefficient which is an even integer.

__Function:__ **oddp** *x*

Returns true if `x` is an odd integer.

__Function:__ **ratp** *x*

Returns true if `x` is a rational number, i.e., an integer or a
fraction.

__Function:__ **realp** *x*

Returns true if `x` is a real number, i.e., an integer, fraction,
or floating-point number.

__Function:__ **anglep** *x*

Returns true if `x` is a real number or HMS form.

__Function:__ **floatp** *x*

Returns true if `x` is a float, or a complex number, error form,
interval, date form, or modulo form in which at least one component
is a float.

__Function:__ **complexp** *x*

Returns true if `x` is a rectangular or polar complex number
(but not a real number).

__Function:__ **rect-complexp** *x*

Returns true if `x` is a rectangular complex number.

__Function:__ **polar-complexp** *x*

Returns true if `x` is a polar complex number.

__Function:__ **numberp** *x*

Returns true if `x` is a real number or a complex number.

__Function:__ **scalarp** *x*

Returns true if `x` is a real or complex number or an HMS form.

__Function:__ **vectorp** *x*

Returns true if `x` is a vector (this simply checks if its argument
is a list whose first element is the symbol `vec`

).

__Function:__ **numvecp** *x*

Returns true if `x` is a number or vector.

__Function:__ **matrixp** *x*

Returns true if `x` is a matrix, i.e., a vector of one or more vectors,
all of the same size.

__Function:__ **square-matrixp** *x*

Returns true if `x` is a square matrix.

__Function:__ **objectp** *x*

Returns true if `x` is any numeric Calc object, including real and
complex numbers, HMS forms, date forms, error forms, intervals, and
modulo forms. (Note that error forms and intervals may include formulas
as their components; see `constp`

below.)

__Function:__ **objvecp** *x*

Returns true if `x` is an object or a vector. This also accepts
incomplete objects, but it rejects variables and formulas (except as
mentioned above for `objectp`

).

__Function:__ **primp** *x*

Returns true if `x` is a "primitive" or "atomic" Calc object,
i.e., one whose components cannot be regarded as sub-formulas. This
includes variables, and all `objectp`

types except error forms
and intervals.

__Function:__ **constp** *x*

Returns true if `x` is constant, i.e., a real or complex number,
HMS form, date form, or error form, interval, or vector all of whose
components are `constp`

.

__Function:__ **lessp** *x y*

Returns true if `x` is numerically less than `y`. Returns false
if `x` is greater than or equal to `y`, or if the order is
undefined or cannot be determined. Generally speaking, this works
by checking whether `` x - y'` is

`negp`

. In
`defmath`

, the expression `>`

, `<=`

,
and `>=`

are similarly converted in terms of `lessp`

.
__Function:__ **beforep** *x y*

Returns true if `x` comes before `y` in a canonical ordering
of Calc objects. If `x` and `y` are both real numbers, this
will be the same as `lessp`

. But whereas `lessp`

considers
other types of objects to be unordered, `beforep`

puts any two
objects into a definite, consistent order. The `beforep`

function is used by the `V S` vector-sorting command, and also
by `a s` to put the terms of a product into canonical order:
This allows ``x y + y x'` to be simplified easily to ``2 x y'`.

__Function:__ **equal** *x y*

This is the standard Lisp `equal`

predicate; it returns true if
`x` and `y` are structurally identical. This is the usual way
to compare numbers for equality, but note that `equal`

will treat
0 and 0.0 as different.

__Function:__ **math-equal** *x y*

Returns true if `x` and `y` are numerically equal, either because
they are `equal`

, or because their difference is `zerop`

. In
`defmath`

, the expression ``(= x y)'` will automatically be
converted to ``(math-equal x y)'`.

__Function:__ **equal-int** *x n*

Returns true if `x` and `n` are numerically equal, where `n`
is a fixnum which is not a multiple of 10. This will automatically be
used by `defmath`

in place of the more general `math-equal`

whenever possible.

__Function:__ **nearly-equal** *x y*

Returns true if `x` and `y`, as floating-point numbers, are
equal except possibly in the last decimal place. For example,
314.159 and 314.166 are considered nearly equal if the current
precision is 6 (since they differ by 7 units), but not if the current
precision is 7 (since they differ by 70 units). Most functions which
use series expansions use `with-extra-prec`

to evaluate the
series with 2 extra digits of precision, then use `nearly-equal`

to decide when the series has converged; this guards against cumulative
error in the series evaluation without doing extra work which would be
lost when the result is rounded back down to the current precision.
In `defmath`

, this can be written ``(~= x y)'`.
The

__Function:__ **nearly-zerop** *x y*

Returns true if `x` is nearly zero, compared to `y`. This
checks whether `x` plus `y` would by be `nearly-equal`

to `y` itself, to within the current precision, in other words,
if adding `x` to `y` would have a negligible effect on `y`
due to roundoff error. `X` may be a real or complex number, but
`y` must be real.

__Function:__ **is-true** *x*

Return true if the formula `x` represents a true value in
Calc, not Lisp, terms. It tests if `x` is a non-zero number
or a provably non-zero formula.

__Function:__ **reject-arg** *val pred*

Abort the current function evaluation due to unacceptable argument values.
This calls ``(calc-record-why pred val)'`, then signals a
Lisp error which

`normalize`

will trap. The net effect is that the
function call which led here will be left in symbolic form.
__Function:__ **inexact-value**

If Symbolic Mode is enabled, this will signal an error that causes
`normalize`

to leave the formula in symbolic form, with the message
"Inexact result." (This function has no effect when not in Symbolic Mode.)
Note that if your function calls ``(sin 5)'` in Symbolic Mode, the
`sin`

function will call `inexact-value`

, which will cause your
function to be left unsimplified. You may instead wish to call
``(normalize (list 'calcFunc-sin 5))'`, which in Symbolic Mode will
return the formula ``sin(5)'` to your function.

__Function:__ **overflow**

This signals an error that will be reported as a floating-point overflow.

__Function:__ **underflow**

This signals a floating-point underflow.

Go to the first, previous, next, last section, table of contents.