Type::ConstantIdents
--
set of constant identifiers in MuPADType::ConstantIdents
is the set {
PI, EULER
, CATALAN
}.
contains(
Type::ConstantIdents, obj)
obj |
- | any MuPAD object |
see contains
contains
, indets
, Type::Constant
Type::ConstantIdents
is the set of identifiers that
represent constants. As of version 2.0, these are PI
, EULER
and CATALAN
. The constant E
is not in this set, because MuPAD replaces it directly after the
input by exp(1)
.indets
, but they cannot be treated
like other identifiers. For example, they cannot have properties or be the left-hand side of
an assignment.
See example 1 for an application.
Type::Constant
makes use of Type::ConstantIdents
, see example 2.MuPAD implements PI as the identifier
PI
.
>> domtype(PI)
DOM_IDENT
However, PI
is constant (although rumors
keep raising their heads that China, Alabama, or whoever it may be next
time had tried to change its value by means of a legislative
process):
>> testtype(PI, Type::Constant)
TRUE
Still, indets
regards PI
as an
identifier with no value (which is syntactically correct), and you can
even use PI
as an indeterminate of a polynomial:
>> indets(PI/2*x); poly(PI/2*x)
{x, PI} poly(1/2 PI x, [PI, x])
To find the ``real'' indeterminates, use the following call:
>> indets(PI/2*x) minus Type::ConstantIdents
{x}
Assume you want MuPAD to regard the identifier
KHINTCHINE
as a constant. (Probably, it should represent
the Khintchine constant K, which is approximately
2.685452, but we will not implement this.) First of all, you
should make sure that the identifier does not have a value yet and protect it:
>> testtype(KHINTCHINE, DOM_IDENT); protect(KHINTCHINE, Error)
TRUE None
Next, add KHINTCHINE
to
Type::ConstantIdents
(note that we have to unprotect the
identifier Type
, because Type::ConstantIdents
is a slot of it):
>> old_protection := unprotect(Type): Type::ConstantIdents := Type::ConstantIdents union {KHINTCHINE}: protect(Type, old_protection): Type::ConstantIdents
{PI, EULER, CATALAN, KHINTCHINE}
Now, MuPAD regards KHINTCHINE
as a
constant:
>> testtype(sin(PI + KHINTCHINE), Type::Constant)
TRUE
>> solve(x^2 = KHINTCHINE)
1/2 1/2 {[x = KHINTCHINE ], [x = - KHINTCHINE ]}
CATALAN
was added.