Maximum of numbers
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
max(x1
,x2
,, …
) max({x1, x2, …}
) max([x1, x2, …]
) max(A
)
max(x1, x2, ...)
returns the maximum of the
numbers x_{1}, x_{2},
….
If the arguments of max
are either integers, rational
numbers, or floatingpoint numbers,
then max
returns the numerical maximum of these
arguments.
Exact numerical expressions such as PI + sqrt(2)
etc.
are internally converted to floatingpoint
intervals using the current value of DIGITS
. After comparison,
the exact expression is restored in the return value. If the current
value of DIGITS
does
not suffice to determine the maximum of several expressions, a symbolic
call of max
is returned. Cf. Example 2.
The call max()
is illegal and leads to an
error message. If there is only one argument x1
,
then max
evaluates x1
and returns
it. Cf. Example 3.
If one of the arguments is infinity
, then max
returns infinity
. If an argument
is infinity
, then it is removed from the argument
list. Cf. Example 4.
max
returns an error when one of its arguments
is a complex number or a floating point
interval with nonzero imaginary part. Cf. Example 3.
If one of the arguments is not a number, then
a symbolic max
call with the maximum of the numerical
arguments and the remaining evaluated arguments may be returned. Cf. Example 1.
Nested max
calls with symbolic arguments
are rewritten as a single max
call, i.e., they
are flattened.
Cf. Example 5.
max
reacts to a very limited set of properties of
identifiers set via assume
.
Use simplify
to
handle more general assumptions. Cf. Example 5.
When called with exact numerical expressions such as PI
, sqrt(2)
etc.,
the function is sensitive to the environment variable DIGITS
,
which determines the numerical working precision.
max
computes the maximum of integers, rational
numbers, and floatingpoint values:
max(3/2, 7, 1.4)
Floating point intervals are interpreted as "any number
within this range" and may thus cause symbolic max
calls
to be returned:
max(2...3 union 6...7, 4)
max(2...3, 6...7, 4)
max(2...3, PI)
If the argument list contains symbolic expressions, then a symbolic max
call
may be returned:
delete b: max(4, b + 2, 1, 3)
In the following two examples, max
is able
to determine the maximum despite getting symbolic arguments (contrast
this with <
):
max(sqrt(2), 1)
assume(x > 0): max(exp(x), exp(x))
The following rational number pi
approximates π to
about 20 decimal places:
pi := 314159265358979323846/10^20:
With the default value DIGITS = 10
, the function max
cannot
distinguish between PI
and pi
via
floatingpoint approximations:
max(pi, PI)
With an increased value of DIGITS
, the floatingpoint interval approximation
of PI
considered by max
allows
to decide that PI
is larger than pi
:
DIGITS := 20: max(pi, PI)
delete pi, DIGITS:
max
with one argument returns the evaluated
argument:
delete a: max(a), max(sin(2*PI)), max(2)
Complex numbers lead to an error message:
max(0, 1, I)
Error: The argument is invalid. [max]
infinity
is
always the maximum of arbitrary arguments:
delete x: max(100000000000, infinity, x)
infinity
is
removed from the argument list:
max(100000000000, infinity, x)
max
reacts only to very few properties of
identifiers set via assume
:
delete a, b, c: assume(a > 0 and b > a and c > b): max(a, max(b, c), 0)
An application of simplify
yields
the desired result:
simplify(%)

Arbitrary MuPAD^{®} objects 

An array of domain
type 
One of the arguments, a floatingpoint number, or a symbolic max
call.