type/with_unit
check for a Maple unit
Calling Sequence
Parameters
Description
Examples
type(expr, with_unit(typ, coeff, unit))
expr
-
expression
typ
(optional) Maple type
coeff, unit
(optional) names
A Maple expression expr is of type with_unit if:
expr is the function Units[Unit] applied to some arguments;
expr is a rational power of such a function call;
expr is a product of such function calls, potentially raised to rational powers, potentially also with another Maple expression;
a call to the function Units[Unit] is present anywhere in expr (in the sense of the command has) and combine(expr, units) is of one of the three earlier forms described above.
The function call type(expr, with_unit) returns true if expr is of type with_unit. Otherwise, false is returned.
In the remainder of this help page, we will refer to the product of the powers of the Units[Unit] function as the unit of the expression, and the product of the remaining factors (if any) as the multiplier. If there are no other factors, the multiplier is 1. If expr is not of one of the first three forms above and calling combine(expr, units) is necessary to get it in that form, then the unit and multiplier of expr are those of combine(expr, units).
If an optional type typ is given and expr is of the form described above, it additionally checks that the multiplier is of the type typ. The function returns true if this additional condition is satisfied. Otherwise, false is returned.
If optional arguments coeff and unit are given and type(expr, with_unit(typ)) returns true, then the unit of expr is assigned to unit and the multiplier is assigned to coeff.
Notes:
To enter a unit in 2-D Math input, select the unit from the appropriate Units palette. If the unit you want is not there, select unit and then enter the unit.
When you edit a unit, double brackets appear around it.
with⁡UnitsStandard:
3⁢Unit⁡m
3⁢m
type⁡3⁢Unit⁡m,with_unit
true
type⁡3⁢Unit⁡m,with_unit⁡integer
type⁡3⁢x2⁢Unit⁡m,with_unit⁡integer,a,b
false
a,b
type⁡3⁢x2⁢Unit⁡m,with_unit⁡anything,a,b
3⁢x2,m
type⁡2⁢Unit⁡m,with_unit⁡integer,a,b
2,m
with⁡UnitsNatural:
type⁡3⁢m,with_unit
type⁡3⁢m,with_unit⁡integer
type⁡3⁢x2⁢m,with_unit⁡integer,a,b
type⁡3⁢x2⁢m,with_unit⁡anything,a,b
type⁡2⁢m,with_unit⁡integer,a,b
In the following cases, expr is detected as being of type with_unit only after the call combine(expr, units).
restart
expr≔x⁢Unit⁡m+y⁢Unit⁡ft
expr≔x⁢m+y⁢ft
type⁡expr,with_unit⁡anything,a,b
x+381⁢y1250,m
In this case, the call combine(expr, units) combines the units for expr by converting to the SI system of units. Because this is a necessary step in determining the unit and multiplier for this expression, the unit and multiplier found by with_unit are in the SI system.
expr≔5⁢Unit⁡ft+x⁢Unit⁡ft
expr≔5⁢ft+x⁢ft
combine⁡expr,units
381250+381⁢x1250⁢m
381250+381⁢x1250,m
See Also
type
Units
Units/Index
Units/Natural
Units/Standard
verify/structured
Download Help Document