DOM_EXPR

Type of “general expressions”

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.

Description

DOM_EXPR is the data type of symbolic function calls. This includes expressions such as a + b which is internally stored as _plus(a, b).

In MuPAD®, non-atomic symbolic expressions which are not elements of special domains have type DOM_EXPR.

Objects of type DOM_EXPR have a 0th operand which contains the functor (the function symbol, the f in f(x)). This operand is not counted in the result of nops. The subsequent operands can be of arbitrary type (although most functions will limit the number and type of operands when evaluated).

The 0th operand of a DOM_EXPR will be a procedure or function environment only in exceptional circumstances. In usual circumstances, expressions only have expressions, domain elements, or identifiers as their 0th operands.

Examples

Example 1

Function calls are of type DOM_EXPR:

domtype(sin(x))

The 0th operand of a function call is the function symbol:

op(sin(x), 0)

This operand is taken into account neither by nops nor by op if called with one argument:

nops(sin(x)), op(sin(x))

Function Calls

The effect of using an expression of type DOM_EXPR as a function to call depends on the 0th operand of the expression. For many system functions, the result is that of using all operands of the expression as functions, passing the unevaluated arguments. (These functions may in turn evaluate their arguments.)

Operations

Most MuPAD functions (documented as accepting “arithmetical expressions”) are built to work on elements of type DOM_EXPR.

Often, the operands of an expression will be expressions themselves. This creates a so-called “expression tree” which can be visualized using prog::exprtree.

Operands

All expressions are internally represented as function calls. The 0th operand is the function symbol of this call.

Evaluation

Evaluating an expression results in calling the 0th operand as a function. For library functions without option hold, the operands are evaluated first.