Documentation Center

  • Trial Software
  • Product Updates

sysorder

Compare objects according to the internal order

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

sysorder(object1, object2)

Description

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.

    Note:   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.

Examples

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
            return(-procname(-x))
       else return(procname(x))
       end_if;
     end_proc:

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:

Parameters

object1, object2

Arbitrary MuPAD objects

Return Values

TRUE or FALSE.

See Also

MuPAD Functions

Was this topic helpful?