applyop - Maple Programming Help

Home : Support : Online Help : Programming : Operations : Operators : applyop

applyop

apply a function to specified operand(s) of an expression

 Calling Sequence applyop( f, i, e ) applyop( f, i, e, ..., xk, ...)

Parameters

 f - function i - specifies the operand(s) in e e - expression x[k] - optional arguments to f

Description

 • The applyop command manipulates the selected parts of an expression. The first argument, f, is applied to the operands of e specified by i.
 • If i is an integer, applyop( f, i, e) applies f to the ith operand of e. This is equivalent to subsop( i = f(op( i, e)), e). For example, if the value of e is the sum $x+y+z$, applyop( f, 2, e) computes $x+f\left(y\right)+z$.
 • If i is a list of integers, the call applyop( f, i, e) is equivalent to subsop( i = f(op( i, e)), e). This allows you to manipulate any suboperand of an expression.
 • If i is a set, f is applied simultaneously to all operands of e specified in the set. Note: applyop( f, {}, e) returns e.
 • Any additional arguments xk are passed as additional arguments to f in the order given.

Examples

 > $p≔{y}^{2}-2y-3$
 ${p}{≔}{{y}}^{{2}}{-}{2}{}{y}{-}{3}$ (1)
 > $\mathrm{applyop}\left(f,2,p\right)$
 ${{y}}^{{2}}{+}{f}{}\left({-}{2}{}{y}\right){-}{3}$ (2)
 > $\mathrm{applyop}\left(f,2,p,\mathrm{x1},\mathrm{x2}\right)$
 ${{y}}^{{2}}{+}{f}{}\left({-}{2}{}{y}{,}{\mathrm{x1}}{,}{\mathrm{x2}}\right){-}{3}$ (3)
 > $\mathrm{applyop}\left(f,\left[2,2\right],p\right)$
 ${{y}}^{{2}}{-}{2}{}{f}{}\left({y}\right){-}{3}$ (4)
 > $\mathrm{applyop}\left(f,\left\{2,3\right\},p\right)$
 ${{y}}^{{2}}{+}{f}{}\left({-}{2}{}{y}\right){+}{f}{}\left({-}{3}\right)$ (5)
 > $\mathrm{applyop}\left(\mathrm{abs},\left\{\left[2,1\right],3\right\},p\right)$
 ${{y}}^{{2}}{+}{2}{}{y}{+}{3}$ (6)
 > $e≔\left(z+1\right)\mathrm{ln}\left(z\left({z}^{2}-2\right)\right)$
 ${e}{≔}\left({z}{+}{1}\right){}{\mathrm{ln}}{}\left({z}{}\left({{z}}^{{2}}{-}{2}\right)\right)$ (7)
 > $\mathrm{expand}\left(e\right)$
 ${\mathrm{ln}}{}\left({z}{}\left({{z}}^{{2}}{-}{2}\right)\right){}{z}{+}{\mathrm{ln}}{}\left({z}{}\left({{z}}^{{2}}{-}{2}\right)\right)$ (8)

To expand the argument to the logarithm in e:

 > $\mathrm{applyop}\left(\mathrm{expand},\left[2,1\right],e\right)$
 $\left({z}{+}{1}\right){}{\mathrm{ln}}{}\left({{z}}^{{3}}{-}{2}{}{z}\right)$ (9)

To factor the argument to the logarithm in e over R:

 > $\mathrm{applyop}\left(\mathrm{factor},\left[2,1\right],e,\mathrm{real}\right)$
 $\left({z}{+}{1}\right){}{\mathrm{ln}}{}\left({z}{}\left({z}{+}{1.414213562}\right){}\left({z}{-}{1.414213562}\right)\right)$ (10)