constants - Maple Help

type/constant

check for a constant

 Calling Sequence type(x, constant) constants constants := constants, y

Parameters

 x - any expression y - a symbol

Description

 • The call type(x, constant) verifies whether x is a constant.
 • The global variable constants is an expression sequence of all names which are initially known as symbolic constants in Maple.  These are: false, gamma, infinity, true, Catalan, FAIL and Pi.
 • The values undefined and Float(undefined) do not appear on this list because neither is a constant.
 • The user can declare any symbol other than undefined to be a constant by appending it to constants. In order to make the evalf command evaluate such a constant to a floating-point number, define a procedure of the form evalf/constant/y, where y is the name of the constant. This process is described on the detailed evalf help page.
 • The numeric constants in Maple are integers, fractions, floating-point numbers, and complex numbers whose real and imaginary parts are any of these types of numbers.
 • The expression (-1)^(1/2) is implemented as Complex(1).
 • More generally, a Maple expression is of type constant if it is an unevaluated function with all arguments of type constant, or a sum, product, or power with all operands of type constant.
 • Additionally, the RootOf function can be a constant. This is determined by calling the indets command on it. Suppose r is of the form RootOf(...). If indets(r, name) only returns entries that occur in constants, then it r is a constant, and otherwise it is not.

Examples

 > $\mathrm{type}\left(5,\mathrm{constant}\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{type}\left(0.05,\mathrm{constant}\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{type}\left(\mathrm{ln}\left(-\mathrm{\pi }\right),\mathrm{constant}\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{type}\left(\mathrm{\infty },\mathrm{constant}\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{type}\left(g\left(1\right),\mathrm{constant}\right)$
 ${\mathrm{true}}$ (5)
 > $\mathrm{type}\left(\mathrm{false},\mathrm{constant}\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{type}\left({x}^{2},\mathrm{constant}\right)$
 ${\mathrm{false}}$ (7)
 > $\mathrm{constants}$
 ${\mathrm{false}}{,}{\mathrm{\gamma }}{,}{\mathrm{\infty }}{,}{\mathrm{true}}{,}{\mathrm{Catalan}}{,}{\mathrm{FAIL}}{,}{\mathrm{\pi }}$ (8)
 > $\mathrm{type}\left(f\left(\mathrm{exp}\left(\mathrm{\gamma }\right)+3\right)+\frac{1}{4},\mathrm{constant}\right)$
 ${\mathrm{true}}$ (9)
 > $\mathrm{type}\left(f\left(\mathrm{exp}\left(\mathrm{\gamma }\right)+x\right)+\frac{1}{4},\mathrm{constant}\right)$
 ${\mathrm{false}}$ (10)
 > $\mathrm{constants}≔\mathrm{constants},x$
 ${\mathrm{constants}}{≔}{\mathrm{false}}{,}{\mathrm{\gamma }}{,}{\mathrm{\infty }}{,}{\mathrm{true}}{,}{\mathrm{Catalan}}{,}{\mathrm{FAIL}}{,}{\mathrm{\pi }}{,}{x}$ (11)
 > $\mathrm{type}\left(f\left(\mathrm{exp}\left(\mathrm{\gamma }\right)+x\right)+\frac{1}{4},\mathrm{constant}\right)$
 ${\mathrm{true}}$ (12)

Here are two examples of RootOf calls, one a constant, the other not:

 > $\mathrm{r1}≔\mathrm{RootOf}\left(\mathrm{sin}\left(z+\frac{\mathrm{\pi }}{6}\right)-{z}^{2},z\right)$
 ${\mathrm{r1}}{≔}{\mathrm{RootOf}}{}\left({-}{\mathrm{sin}}{}\left({\mathrm{_Z}}{+}\frac{{\mathrm{\pi }}}{{6}}\right){+}{{\mathrm{_Z}}}^{{2}}\right)$ (13)
 > $\mathrm{indets}\left(\mathrm{r1},\mathrm{name}\right)$
 $\left\{{\mathrm{\pi }}\right\}$ (14)
 > $\mathrm{type}\left(\mathrm{r1},\mathrm{constant}\right)$
 ${\mathrm{true}}$ (15)
 > $\mathrm{r2}≔\mathrm{RootOf}\left(\mathrm{sin}\left(z+y\right)-{z}^{2},z\right)$
 ${\mathrm{r2}}{≔}{\mathrm{RootOf}}{}\left({-}{\mathrm{sin}}{}\left({\mathrm{_Z}}{+}{y}\right){+}{{\mathrm{_Z}}}^{{2}}\right)$ (16)
 > $\mathrm{indets}\left(\mathrm{r2},\mathrm{name}\right)$
 $\left\{{y}\right\}$ (17)
 > $\mathrm{type}\left(\mathrm{r2},\mathrm{constant}\right)$
 ${\mathrm{false}}$ (18)