Compare objects according to the internal order

MuPAD® notebooks will be removed in a future release. 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.


sysorder(object1, object2)


sysorder(object1, object2) returns TRUE if the MuPAD® internal order of object1 is less than or equal to the order of object2. Otherwise, FALSE is returned.


The exceptions are domains.

One should not try and use the internal order to sort objects according to specific criteria. E.g., its does not necessarily reflect the natural ordering of numbers or strings. Further, the internal order may differ between different MuPAD versions.

The only feature one may rely upon is its uniqueness. Cf. Example 2.


Example 1

We give some examples how sysorder behaves in the current MuPAD version. For numbers, the internal order is equal to the natural order:

sysorder(3, 4) = bool(3 <= 4),
sysorder(45, 33) = bool(45 <= 33),
sysorder(0, 4) = bool(0 <= 4)

sysorder(1/3, 1/4) = bool(1/3 <= 1/4),
sysorder(-4, 2) = bool(-4 <= 2),
sysorder(-4, -2) =  bool(-4 <= -2)

Example 2

We give a simple application of sysorder. Suppose, we want to implement a function f, say, whose only known property is its skewness f(-x) = -f(x). Expressions involving f should be simplified automatically, e.g., f(x) + f(-x) should yield zero for any argument x. To achieve this, we use sysorder to decide, whether a call f(x) should return f(x) or -f(-x):

f := proc(x) begin
       if sysorder(x, -x) then
       else return(procname(x))

For numerical arguments, f prefers to rewrite itself with positive arguments:

f(-3), f(3), f(-4.5), f(4.5), f(-2/3), f(2/3)

For other arguments, the result is difficult to predict:

f(x), f(-x), f(sqrt(2) + 1), f(-sqrt(2) - 1)

With this implementation, expressions involving f simplify automatically:

f(x) + f(-x) - f(3)*f(x) + f(-3)*f(-x) + sin(f(7)) + sin(f(-7))

delete f:


object1, object2

Arbitrary MuPAD objects

Return Values


See Also

MuPAD Functions