Defining and Using a Custom Operator

You can define an operator in much the same way you define a function. Typically, it's best to use a special symbol for the operator name, but otherwise the process is the same. The difference is in the way you apply a custom operator. Mathcad gives you special operators for calling functions so that they can have operator-like notation: infix, prefix, or postfix.

Defining a Custom Operator

Custom operators can be unary, with one argument, or binary, with two arguments. For example, ! (factorial) is a unary operator, while + (addition) is a binary operator. To define a unary operator:

  1. Define the operator as a function.

    The not operator

  2. Type [:] to see the definition symbol, :=. A placeholder appears.

    not(x) := placeholder

  3. In the placeholder, type an expression involving the operand.

    not(x) := if(x=0,0,1)

To define a binary operator, make a function of two variables instead of one.

Using a Custom Operator

To use the function as an operator, open the Evaluation toolbar containing the custom operator notation buttons. If your function is unary, you need to choose whether you wish to see the operator before the operand (prefix notation), or after (postfix notation).

In the remaining placeholder, type the operand.

Example:

Using the not operator in prefix notation

If your function is binary, you can choose to use the operator between the operands (infix notation), or above them in a tree structure (treefix notation).

Examples:

example of infix and treefix notation

Infix

Treefix

QuickSheet

Related Topics