
subsop - substitution of operands

Calling sequence:

subsop(expr, subsequation... [ , Unsimplified ])
subsequation  --->  integer = expr_1
subsequation  --->  [ integer ...]  = expr_1

Parameter:
expr           --  expression
integer        --  non-negative integer
expr_1         --  expression
Unsimplified   --  option

Overloading:

1

Summary:

subsop substitutes subexpressions of the expressionexpr whereby the subexpressions
are given by their position in the expression as in the function op. Due to
the position being given directly subsop is faster as subs or subsex .

The simplest call of subsop is in the form subsop(expr, i = expr_1) with
the substitution equation i = expr_1. With this the i-th subexpression in
the expression expr is substituted by the expression expr_1.

The operand to be substituted can also be specified through a path, as with
the function op.  E.g. with subsop(a+b*c, [2, 1]=x*y) the first operand
b of the second operand b*c in the expression a+b*c is substituted by x*y.
Thus the result is a+c*x*y.  In contrast to the function op no ranges are

permitted as operands.

The arguments of subsop are processed in sequence from left to right: The
substitution is carried out and the result is processed further with the next
argument. Parallel substitution as in subs or subsex is not possible.

In general, after substitution the expression is simplified.  Sometimes it is
desirable to avoid this simplification.  This can be achieved by using the
option Unsimplified. subsop uses a copy of expr, thus the argument expr
remains unchanged.

If access of the specified operand is not possible, e.g. with the entry subsop(expr,
nops(expr) + 1 = x), an error occursif ERRORLEVEL equals 3. If the ERRORLEVEL
is lesser than 3 then FAIL is the result. subsop is a kernel function.

>>  subsop(2*c+a^2, 2=d^5);

      c*2 + d^5

>>  subsop(a+b, 0=_mult);

      a*b

>>  subsop(b+a^2, [2,2]=4, 1=x*y);

      x*y + a^4

>>  subsop(a*b+c^2, 1=x*y, [1,2]=z);

      x*z + c^2

>>  subsop(a+b+c, 1=0, 3=2, Unsimplified);

      0 + b + 2

See also:  op, subs, subsex

