Substitute - Maple Help

MultivariatePowerSeries

 Substitute
 substitute values into a power series

 Calling Sequence Substitute(x = s, p) Substitute(ls, p)

Parameters

 x - variable s - polynomial or power series generated by this package p - power series generated by this package ls - list or set of substitutions, each of the form x = s

Description

 • The command Substitute(x = s, p) computes the result of substituting the expression s for the variable x in the power series p. The expression s can be a polynomial or a power series generated by this package.
 • The calling sequence Substitute(ls, p), where ls is a list or set of equations of the form x = s above, applies all of the given substitutions simultaneously. More precisely, if ls contains the equations x[i] = s[i] where i runs from 1 to n, then it returns an answer equivalent to what would be obtained from the following process:
 – For each variable v[i,j] occurring in s[i], replace it with a variable u[i,j] that does not occur anywhere else (it should also not occur as u[i,j] in previous such replacements). Call the result t[i].
 – Perform the substitutions x[i] = t[i] in any order. Call the result q.
 – Replace each u[i, j] in q with the original v[i, j].
 • An error is signaled if the same variable x occurs more than once as a left hand side in ls.
 • If s is not a unit, that is, if its constant coefficient is zero, then the result of the substitution is easily defined by just substituting one power series into another; one need consider only finitely many terms to find any homogeneous component of the result. However, if s is a unit, then the result of the substitution is a priori not well-defined. In these cases, Maple uses the analytic expression specified for p in a computation that gives a result that is correct in a formal sense. If the analytic expression for p is not specified, Maple signals an error. If a list or set of substitutions is specified and some of the right hand sides s are unit power series, then this computation only works if p and at least all but one of these unit power series have their analytic expression specified.
 • When using the MultivariatePowerSeries package, do not assign anything to the variables occurring in the power series, Puiseux series, and univariate polynomials over these series. If you do, you may see invalid results.

Examples

 > $\mathrm{with}\left(\mathrm{MultivariatePowerSeries}\right):$

Consider the simplest case: polynomial substitution, with polynomials that are not units (that is, their constant coefficient is zero).

 > $\mathrm{p1}≔{x}^{2}+yz+z$
 ${\mathrm{p1}}{≔}{{x}}^{{2}}{+}{y}{}{z}{+}{z}$ (1)
 > $\mathrm{p2}≔{y}^{2}+zx+x$
 ${\mathrm{p2}}{≔}{z}{}{x}{+}{{y}}^{{2}}{+}{x}$ (2)
 > $\mathrm{p3}≔{z}^{2}+xy+y$
 ${\mathrm{p3}}{≔}{x}{}{y}{+}{{z}}^{{2}}{+}{y}$ (3)
 > $\mathrm{ps1},\mathrm{ps2},\mathrm{ps3}≔\mathrm{seq}\left(\mathrm{PowerSeries}\left(p\right),p\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\mathrm{p1},\mathrm{p2},\mathrm{p3}\right]\right)$
 ${\mathrm{ps1}}{,}{\mathrm{ps2}}{,}{\mathrm{ps3}}{≔}\left[{PowⅇrSⅇriⅇs:}{z}{+}{{x}}^{{2}}{+}{y}{}{z}\right]{,}\left[{PowⅇrSⅇriⅇs:}{x}{+}{z}{}{x}{+}{{y}}^{{2}}\right]{,}\left[{PowⅇrSⅇriⅇs:}{y}{+}{x}{}{y}{+}{{z}}^{{2}}\right]$ (4)
 > $\mathrm{result}≔\mathrm{Substitute}\left(\left\{x=\mathrm{ps1},y=\mathrm{ps2}\right\},\mathrm{ps3}\right)$
 ${\mathrm{result}}{≔}\left[{PowⅇrSⅇriⅇs of}\left({{x}}^{{2}}{+}{y}{}{z}{+}{z}\right){}\left({z}{}{x}{+}{{y}}^{{2}}{+}{x}\right){+}{{z}}^{{2}}{+}{z}{}{x}{+}{{y}}^{{2}}{+}{x}{:}{0}{+}{\dots }\right]$ (5)

We can obtain the same result by substituting the actual polynomials in, rather than the polynomials converted to power series.

 > $\mathrm{ApproximatelyEqual}\left(\mathrm{result},\mathrm{Substitute}\left(\left\{x=\mathrm{p1},y=\mathrm{p2}\right\},\mathrm{ps3}\right),4\right)$
 ${\mathrm{true}}$ (6)

We can verify that the result is correct by comparing with the result of doing the substitution entirely in the domain of polynomials.

 > $\mathrm{expand}\left(\mathrm{Truncate}\left(\mathrm{result},4\right)-\mathrm{subs}\left(\left\{x=\mathrm{p1},y=\mathrm{p2}\right\},\mathrm{p3}\right)\right)$
 ${0}$ (7)

We can do the same with unit power series.

 > $\mathrm{q1},\mathrm{q2},\mathrm{q3}≔\mathrm{seq}\left(p+1,p\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\mathrm{p1},\mathrm{p2},\mathrm{p3}\right]\right)$
 ${\mathrm{q1}}{,}{\mathrm{q2}}{,}{\mathrm{q3}}{≔}{{x}}^{{2}}{+}{y}{}{z}{+}{z}{+}{1}{,}{z}{}{x}{+}{{y}}^{{2}}{+}{x}{+}{1}{,}{x}{}{y}{+}{{z}}^{{2}}{+}{y}{+}{1}$ (8)
 > $\mathrm{qs1},\mathrm{qs2},\mathrm{qs3}≔\mathrm{seq}\left(\mathrm{PowerSeries}\left(q\right),q\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\mathrm{q1},\mathrm{q2},\mathrm{q3}\right]\right)$
 ${\mathrm{qs1}}{,}{\mathrm{qs2}}{,}{\mathrm{qs3}}{≔}\left[{PowⅇrSⅇriⅇs:}{1}{+}{z}{+}{{x}}^{{2}}{+}{y}{}{z}\right]{,}\left[{PowⅇrSⅇriⅇs:}{1}{+}{x}{+}{z}{}{x}{+}{{y}}^{{2}}\right]{,}\left[{PowⅇrSⅇriⅇs:}{1}{+}{y}{+}{x}{}{y}{+}{{z}}^{{2}}\right]$ (9)
 > $\mathrm{qresult}≔\mathrm{Substitute}\left(\left\{x=\mathrm{qs1},y=\mathrm{qs2}\right\},\mathrm{qs3}\right)$
 ${\mathrm{qresult}}{≔}\left[{PowⅇrSⅇriⅇs of}\left({{x}}^{{2}}{+}{y}{}{z}{+}{z}{+}{1}\right){}\left({z}{}{x}{+}{\dots }{+}{\dots }\right){+}{{z}}^{{2}}{+}{z}{}{x}{+}{{y}}^{{2}}{+}{x}{+}{2}{:}{3}{+}{\dots }\right]$ (10)
 > $\mathrm{ApproximatelyEqual}\left(\mathrm{qresult},\mathrm{Substitute}\left(\left\{x=\mathrm{q1},y=\mathrm{q2}\right\},\mathrm{qs3}\right),4\right)$
 ${\mathrm{true}}$ (11)
 > $\mathrm{expand}\left(\mathrm{Truncate}\left(\mathrm{qresult},4\right)-\mathrm{subs}\left(\left\{x=\mathrm{q1},y=\mathrm{q2}\right\},\mathrm{q3}\right)\right)$
 ${0}$ (12)

The following example shows that simple arithmetic does not suffice to do the substitution operation: the input power series has rational coefficients, but the result has transcendental coefficients. We compute the power series for ${ⅇ}^{{ⅇ}^{x}}$ from that of ${ⅇ}^{x}$.

 > $\mathrm{exp_x}≔\mathrm{PowerSeries}\left(d↦\frac{{x}^{d}}{d!},\mathrm{analytic}=\mathrm{exp}\left(x\right)\right)$
 ${\mathrm{exp_x}}{≔}\left[{PowⅇrSⅇriⅇs of}{{ⅇ}}^{{x}}{:}{1}{+}{\dots }\right]$ (13)
 > $\mathrm{result}≔\mathrm{Substitute}\left(x=\mathrm{exp_x},\mathrm{exp_x}\right)$
 ${\mathrm{result}}{≔}\left[{PowⅇrSⅇriⅇs of}{{ⅇ}}^{{{ⅇ}}^{{x}}}{:}{ⅇ}{+}{\dots }\right]$ (14)
 > $\mathrm{Truncate}\left(\mathrm{result},4\right)$
 ${ⅇ}{+}{ⅇ}{}{x}{+}{ⅇ}{}{{x}}^{{2}}{+}\frac{{5}{}{ⅇ}{}{{x}}^{{3}}}{{6}}{+}\frac{{5}{}{ⅇ}{}{{x}}^{{4}}}{{8}}$ (15)
 > $\mathrm{series}\left(\mathrm{exp}\left(\mathrm{exp}\left(x\right)\right),x=0,5\right)$
 ${ⅇ}{+}{ⅇ}{}{x}{+}{ⅇ}{}{{x}}^{{2}}{+}\frac{{5}}{{6}}{}{ⅇ}{}{{x}}^{{3}}{+}\frac{{5}}{{8}}{}{ⅇ}{}{{x}}^{{4}}{+}{O}{}\left({{x}}^{{5}}\right)$ (16)

To underscore the necessity to have analytic expressions in the presence of unit power series, consider the following example, where we omit the analytic expression for the series of ${ⅇ}^{y}$.

 > $\mathrm{exp_y_no_a}≔\mathrm{PowerSeries}\left(d↦\frac{{y}^{d}}{d!},\mathrm{variables}=\left\{y\right\}\right)$
 ${\mathrm{exp_y_no_a}}{≔}\left[{PowⅇrSⅇriⅇs:}{1}{+}{\dots }\right]$ (17)

We want to substitute ${ⅇ}^{x}$ for $\mathrm{ex}$ and ${ⅇ}^{y}$ for $\mathrm{ey}$ in $\mathrm{ex}+\mathrm{ey}$. If we first substitute ${ⅇ}^{y}$ for $\mathrm{ey}$, then the resulting power series doesn't know its analytic expression, and we obtain an error when we substitute ${ⅇ}^{x}$ for $x$.

 > $\mathrm{base}≔\mathrm{PowerSeries}\left(\mathrm{ex}+\mathrm{ey}\right)$
 ${\mathrm{base}}{≔}\left[{PowⅇrSⅇriⅇs:}{\mathrm{ex}}{+}{\mathrm{ey}}\right]$ (18)
 > $\mathrm{step1}≔\mathrm{Substitute}\left(\mathrm{ey}=\mathrm{exp_y_no_a},\mathrm{base}\right)$
 ${\mathrm{step1}}{≔}\left[{PowⅇrSⅇriⅇs:}{1}{+}{\dots }\right]$ (19)
 > $\mathrm{step2}≔\mathrm{Substitute}\left(\mathrm{ex}=\mathrm{exp_x},\mathrm{step1}\right)$

In the other order, the process does work.

 > $\mathrm{alt_step1}≔\mathrm{Substitute}\left(\mathrm{ex}=\mathrm{exp_x},\mathrm{base}\right)$
 ${\mathrm{alt_step1}}{≔}\left[{PowⅇrSⅇriⅇs of}{{ⅇ}}^{{x}}{+}{\mathrm{ey}}{:}{1}{+}{\dots }\right]$ (20)
 > $\mathrm{alt_step2}≔\mathrm{Substitute}\left(\mathrm{ey}=\mathrm{exp_y_no_a},\mathrm{alt_step1}\right)$
 ${\mathrm{alt_step2}}{≔}\left[{PowⅇrSⅇriⅇs:}{2}{+}{\dots }\right]$ (21)

This is the order chosen by Maple when the two substitutions are given simultaneously.

 > $\mathrm{result}≔\mathrm{Substitute}\left(\left\{\mathrm{ex}=\mathrm{exp_x},\mathrm{ey}=\mathrm{exp_y_no_a}\right\},\mathrm{base}\right)$
 ${\mathrm{result}}{≔}\left[{PowⅇrSⅇriⅇs:}{2}{+}{\dots }\right]$ (22)
 > $\mathrm{ApproximatelyEqual}\left(\mathrm{result},\mathrm{alt_step2},4\right)$
 ${\mathrm{true}}$ (23)

Compatibility

 • The MultivariatePowerSeries[Substitute] command was introduced in Maple 2022.