subsop - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

subsop

substitute for specified operands in an expression

 Calling Sequence subsop(eq1, eq2, ..., eqn, expr)

Parameters

 eq[i] - (optional) equation of the form $\mathrm{speci}=\mathrm{expri}$, where each $\mathrm{speci}$ is an integer or list of integers, and each $\mathrm{expri}$ is an expression expr - expression

Description

 • The subsop function is used to replace specified operands of an expression with new values. It will do the simultaneous substitutions specified by the eqi equation arguments in the last argument expr. The result is obtained by replacing op(spec1, expr) by $\mathrm{expr1}$, op(spec2, expr) by $\mathrm{expr2}$, ..., and op(specn, expr) by $\mathrm{exprn}$ in expr.
 • Each $\mathrm{speci}$ can be either an integer, or a list of integers. If a list of integers is specified, the integers refer to sub-operands of expr at increasing nesting levels. See op for further details.
 • The integer(s) comprising each $\mathrm{speci}$ must lie in the range $-\mathrm{nops}\left(\mathrm{expr}\right)..\mathrm{nops}\left(\mathrm{expr}\right)$.  A $\mathrm{speci}$ of 0 is allowed only for function, indexed expression, and series exprs.
 • If an integer n in a $\mathrm{speci}$ is negative, it is considered equivalent to $\mathrm{nops}\left(\mathrm{expr}\right)+n+1$.
 • If no eqi are specified, subsop returns its argument with no substitutions.
 • See also the applyop command which can be used to apply a function to specified operands of an expression.
 • The action of substitution is not followed by evaluation. In cases where full evaluation is desired, the eval command should be used.

Thread Safety

 • The subsop command is thread-safe as of Maple 15.
 • For more information on thread safety, see index/threadsafe.

Examples

 > $p≔{x}^{7}+8{x}^{6}+{x}^{2}-9$
 ${p}{≔}{{x}}^{{7}}{+}{8}{}{{x}}^{{6}}{+}{{x}}^{{2}}{-}{9}$ (1)
 > $\mathrm{op}\left(2,p\right)$
 ${8}{}{{x}}^{{6}}$ (2)
 > $\mathrm{subsop}\left(2=y,p\right)$
 ${{x}}^{{7}}{+}{{x}}^{{2}}{+}{y}{-}{9}$ (3)
 > $\mathrm{subsop}\left(2=-\mathrm{op}\left(2,p\right),p\right)$
 ${{x}}^{{7}}{-}{8}{}{{x}}^{{6}}{+}{{x}}^{{2}}{-}{9}$ (4)
 > $\mathrm{subsop}\left(1=0,p\right)$
 ${8}{}{{x}}^{{6}}{+}{{x}}^{{2}}{-}{9}$ (5)
 > $\mathrm{subsop}\left(1=1,xyz\right)$
 ${y}{}{z}$ (6)
 > $\mathrm{subsop}\left(1=\mathrm{NULL},2=z,3=y,\left[x,y,z\right]\right)$
 $\left[{z}{,}{y}\right]$ (7)
 > $\mathrm{subsop}\left(0=g,f\left[a,b,c\right]\right)$
 ${{g}}_{{a}{,}{b}{,}{c}}$ (8)
 > $p≔f\left(x,g\left(x,y,z\right),x\right)$
 ${p}{≔}{f}{}\left({x}{,}{g}{}\left({x}{,}{y}{,}{z}\right){,}{x}\right)$ (9)
 > $\mathrm{subsop}\left(\left[2,3\right]=w,p\right)$
 ${f}{}\left({x}{,}{g}{}\left({x}{,}{y}{,}{w}\right){,}{x}\right)$ (10)
 > $\mathrm{subsop}\left(\left[2,0\right]=h,\left[2,3\right]=w,3=a,p\right)$
 ${f}{}\left({x}{,}{h}{}\left({x}{,}{y}{,}{w}\right){,}{a}\right)$ (11)
 > $\mathrm{subsop}\left(p\right)$
 ${f}{}\left({x}{,}{g}{}\left({x}{,}{y}{,}{z}\right){,}{x}\right)$ (12)

An example involving integrals

 You can use subsop and applyop to perform a change of variables in an integral step-by-step.
 > Int(sin(sqrt(x)),x=0..t);
 ${{\int }}_{{0}}^{{t}}{\mathrm{sin}}{}\left(\sqrt{{x}}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}$ (13)
 Apply the change of variable u = x^(1/2)
 > subsop( [1,1]=u, (13) );
 ${{\int }}_{{0}}^{{t}}{\mathrm{sin}}{}\left({u}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}$ (14)
 We have dx = 2*u*du
 > subsop( 1=2*u*op(1,(14)), [2,1]=u, (14) );
 ${{\int }}_{{0}}^{{t}}{2}{}{u}{}{\mathrm{sin}}{}\left({u}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{u}$ (15)
 > applyop( sqrt, [2,2,2], (15) );
 ${{\int }}_{{0}}^{\sqrt{{t}}}{2}{}{u}{}{\mathrm{sin}}{}\left({u}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{u}$ (16)

 See Also