LargeExpressions - Maple Help

Home : Support : Online Help : Programming : Input and Output : Output : LargeExpressions : LargeExpressions/Veil

LargeExpressions

 Veil
 hide a complicated expression
 Unveil
 show a hidden complicated expression

 Calling Sequence Veil[K]( complicated_expression ) Unveil[K]( expressions_with_Ks, n ) LastUsed

Parameters

 K - unassigned name to use as a label complicated_expression - expression expressions_with_Ks - expression that has been veiled n - positive integer representing the level of unveiling, or infinity, meaning all levels

Description

 • During a long calculation, it is sometimes useful to explicitly control Maple evaluation of expressions by hiding their values under user-defined labels.  This allows compact representation of the results as a computation sequence, generated from the natural hierarchy of the problem.
 • The Veil command is used to hide information, Unveil to reveal the hidden information.  Both commands take an index that specifies the label to use; multiple labels can be present in an expression and manipulated independently.  If no label is specified, $\mathrm{_V}$ is used.
 • You can use these commands as a functional argument to collect, replacing complicated coefficients in a sum of terms by simple labels.
 • The protected variable LastUsed contains a table of indices pointing to the last used label index in each variable.

Examples

Treat a polynomial in $x,y,z$ as a polynomial in $z$ with hidden coefficients depending on $x,y$.

 > $\mathrm{with}\left(\mathrm{LargeExpressions}\right):$
 > $p≔\mathrm{randpoly}\left(\left[x,y,z\right],\mathrm{degree}=5,\mathrm{dense}\right)$
 ${p}{:=}{-}{7}{}{{x}}^{{5}}{+}{22}{}{{x}}^{{4}}{}{y}{-}{55}{}{{x}}^{{4}}{}{z}{+}{87}{}{{x}}^{{3}}{}{{y}}^{{2}}{-}{56}{}{{x}}^{{3}}{}{y}{}{z}{-}{62}{}{{x}}^{{3}}{}{{z}}^{{2}}{-}{4}{}{{x}}^{{2}}{}{{y}}^{{3}}{-}{83}{}{{x}}^{{2}}{}{{y}}^{{2}}{}{z}{+}{62}{}{{x}}^{{2}}{}{y}{}{{z}}^{{2}}{-}{44}{}{{x}}^{{2}}{}{{z}}^{{3}}{-}{10}{}{x}{}{{y}}^{{4}}{-}{7}{}{x}{}{{y}}^{{3}}{}{z}{+}{42}{}{x}{}{{y}}^{{2}}{}{{z}}^{{2}}{+}{75}{}{x}{}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}{{K}}_{{1}}{-}{{z}}^{{3}}{}{{K}}_{{2}}{-}{{z}}^{{2}}{}{{K}}_{{3}}{-}{z}{}{{K}}_{{4}}{-}{{K}}_{{5}}$ (2)
 > $\mathrm{zero}≔\mathrm{normal}\left(\mathrm{Unveil}[K]\left(\mathrm{compact},\mathrm{∞}\right)-p\right)$
 ${\mathrm{zero}}{:=}{0}$ (3)

Create another sequence using different labels. Note that the table of last used indices is keyed by the label name (in this case C).

 > $\mathrm{compact2}≔\mathrm{collect}\left(p,y,{\mathrm{Veil}}_{C}\right)$
 ${\mathrm{compact2}}{:=}{29}{}{{y}}^{{5}}{-}{{y}}^{{4}}{}{{C}}_{{1}}{-}{{y}}^{{3}}{}{{C}}_{{2}}{+}{{y}}^{{2}}{}{{C}}_{{3}}{+}{y}{}{{C}}_{{4}}{-}{{C}}_{{5}}$ (4)
 > $\mathrm{CS}≔\left[\mathrm{seq}\left({C}_{i}=\mathrm{Unveil}[C]\left({C}_{i}\right),i=1..{\mathrm{LastUsed}}_{C}\right)\right]$
 ${\mathrm{CS}}{:=}\left[{{C}}_{{1}}{=}{10}{}{x}{-}{98}{}{z}{+}{23}{,}{{C}}_{{2}}{=}{4}{}{{x}}^{{2}}{+}{7}{}{x}{}{z}{-}{10}{}{{z}}^{{2}}{+}{40}{}{x}{+}{61}{}{z}{+}{8}{,}{{C}}_{{3}}{=}{87}{}{{x}}^{{3}}{-}{83}{}{{x}}^{{2}}{}{z}{+}{42}{}{x}{}{{z}}^{{2}}{-}{29}{}{{z}}^{{3}}{-}{10}{}{{x}}^{{2}}{-}{50}{}{x}{}{z}{+}{95}{}{{z}}^{{2}}{+}{23}{}{x}{+}{11}{}{z}{-}{49}{,}{{C}}_{{4}}{=}{22}{}{{x}}^{{4}}{-}{56}{}{{x}}^{{3}}{}{z}{+}{62}{}{{x}}^{{2}}{}{{z}}^{{2}}{+}{75}{}{x}{}{{z}}^{{3}}{-}{47}{}{{z}}^{{4}}{-}{82}{}{{x}}^{{2}}{}{z}{-}{92}{}{x}{}{{z}}^{{2}}{+}{40}{}{{z}}^{{3}}{+}{80}{}{{x}}^{{2}}{+}{6}{}{x}{}{z}{-}{81}{}{{z}}^{{2}}{+}{74}{}{x}{+}{91}{}{z}{+}{68}{,}{{C}}_{{5}}{=}{7}{}{{x}}^{{5}}{+}{55}{}{{x}}^{{4}}{}{z}{+}{62}{}{{x}}^{{3}}{}{{z}}^{{2}}{+}{44}{}{{x}}^{{2}}{}{{z}}^{{3}}{-}{72}{}{x}{}{{z}}^{{4}}{+}{10}{}{{z}}^{{5}}{+}{94}{}{{x}}^{{4}}{-}{97}{}{{x}}^{{3}}{}{z}{-}{71}{}{{x}}^{{2}}{}{{z}}^{{2}}{-}{37}{}{x}{}{{z}}^{{3}}{-}{31}{}{{z}}^{{4}}{+}{73}{}{{x}}^{{3}}{+}{17}{}{{x}}^{{2}}{}{z}{+}{23}{}{x}{}{{z}}^{{2}}{+}{51}{}{{z}}^{{3}}{+}{75}{}{{x}}^{{2}}{-}{87}{}{x}{}{z}{-}{77}{}{{z}}^{{2}}{-}{44}{}{x}{-}{95}{}{z}{-}{1}\right]$ (5)
 > $\mathrm{CodeGeneration}[\mathrm{Fortran}]\left(\mathrm{CS}\right)$
 C(1) = 10 * x - 98 * z + 23       C(2) = 4 * x ** 2 + 7 * x * z - 10 * z ** 2 + 40 * x + 61 * z + 8       C(3) = 87 * x ** 3 - 83 * x ** 2 * z + 42 * x * z ** 2 - 29 * z **      # 3 - 10 * x ** 2 - 50 * x * z + 95 * z ** 2 + 23 * x + 11 * z - 49       C(4) = 22 * x ** 4 - 56 * x ** 3 * z + 62 * x ** 2 * z ** 2 + 75 *      # x * z ** 3 - 47 * z ** 4 - 82 * x ** 2 * z - 92 * x * z ** 2 + 40      # * z ** 3 + 80 * x ** 2 + 6 * x * z - 81 * z ** 2 + 74 * x + 91 *      #z + 68       C(5) = 7 * x ** 5 + 55 * x ** 4 * z + 62 * x ** 3 * z ** 2 + 44 *      #x ** 2 * z ** 3 - 72 * x * z ** 4 + 10 * z ** 5 + 94 * x ** 4 - 97      # * x ** 3 * z - 71 * x ** 2 * z ** 2 - 37 * x * z ** 3 - 31 * z **      # 4 + 73 * x ** 3 + 17 * x ** 2 * z + 23 * x * z ** 2 + 51 * z ** 3      # + 75 * x ** 2 - 87 * x * z - 77 * z ** 2 - 44 * x - 95 * z - 1

The following Frobenius series solution to a differential equation has complicated coefficients, which obscure the structure of the solution.

 > $\mathrm{de}≔\mathrm{sin}\left(x\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}y\left(x\right)\right)-2\mathrm{cos}\left(x\right)\left(\frac{ⅆ}{ⅆx}y\left(x\right)\right)-a\mathrm{sin}\left(x\right)y\left(x\right)$
 ${\mathrm{de}}{:=}{\mathrm{sin}}{}\left({x}\right){}\left(\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}{}{y}{}\left({x}\right)\right){-}{2}{}{\mathrm{cos}}{}\left({x}\right){}\left(\frac{{ⅆ}}{{ⅆ}{x}}{}{y}{}\left({x}\right)\right){-}{a}{}{\mathrm{sin}}{}\left({x}\right){}{y}{}\left({x}\right)$ (6)
 > $\mathrm{Order}≔14$
 ${\mathrm{Order}}{:=}{14}$ (7)
 > $\mathrm{soln}≔\mathrm{dsolve}\left(\left\{\mathrm{de}\right\},y\left(x\right),'\mathrm{series}'\right):$
 > $\mathrm{algsol}≔\mathrm{convert}\left(\mathrm{eval}\left(y\left(x\right),\mathrm{soln}\right),\mathrm{polynom}\right):$
 > $\mathrm{collect}\left(\mathrm{algsol},x,{\mathrm{Veil}}_{L}\right)$
 $\frac{{1}}{{217945728000}}{}{{L}}_{{1}}{}{{x}}^{{15}}{+}\frac{{1}}{{518918400}}{}{{L}}_{{2}}{}{{x}}^{{13}}{-}\frac{{1}}{{39916800}}{}{{L}}_{{3}}{}{{x}}^{{12}}{+}\frac{{1}}{{6652800}}{}{{L}}_{{4}}{}{{x}}^{{11}}{-}\frac{{1}}{{302400}}{}{{L}}_{{5}}{}{{x}}^{{10}}{+}\frac{{1}}{{15120}}{}{{L}}_{{6}}{}{{x}}^{{9}}{-}\frac{{1}}{{3360}}{}{{L}}_{{7}}{}{{x}}^{{8}}{+}\frac{{1}}{{840}}{}{{L}}_{{8}}{}{{x}}^{{7}}{-}\frac{{1}}{{60}}{}{{L}}_{{9}}{}{{x}}^{{6}}{+}\frac{{1}}{{10}}{}{{L}}_{{10}}{}{{x}}^{{5}}{-}\frac{{1}}{{2}}{}{{L}}_{{11}}{}{{x}}^{{4}}{+}{\mathrm{_C1}}{}{{x}}^{{3}}{-}{6}{}{{L}}_{{12}}{}{{x}}^{{2}}{+}{12}{}{\mathrm{_C2}}$ (8)
 > $\mathrm{seq}\left({L}_{k}=\mathrm{Unveil}[L]\left({L}_{k}\right),k=1..{\mathrm{LastUsed}}_{L}\right)$
 ${{L}}_{{1}}{=}{\mathrm{_C1}}{}\left({7}{}{{a}}^{{6}}{-}{224}{}{{a}}^{{5}}{+}{2016}{}{{a}}^{{4}}{-}{7680}{}{{a}}^{{3}}{+}{14080}{}{{a}}^{{2}}{-}{12288}{}{a}{+}{4096}\right){,}{{L}}_{{2}}{=}{\mathrm{_C1}}{}\left({3}{}{{a}}^{{5}}{-}{70}{}{{a}}^{{4}}{+}{448}{}{{a}}^{{3}}{-}{1152}{}{{a}}^{{2}}{+}{1280}{}{a}{-}{512}\right){,}{{L}}_{{3}}{=}{\mathrm{_C2}}{}{a}{}\left({11}{}{{a}}^{{5}}{-}{220}{}{{a}}^{{4}}{+}{1232}{}{{a}}^{{3}}{-}{2816}{}{{a}}^{{2}}{+}{2816}{}{a}{-}{1024}\right){,}{{L}}_{{4}}{=}{\mathrm{_C1}}{}\left({5}{}{{a}}^{{4}}{-}{80}{}{{a}}^{{3}}{+}{336}{}{{a}}^{{2}}{-}{512}{}{a}{+}{256}\right){,}{{L}}_{{5}}{=}{\mathrm{_C2}}{}{a}{}\left({9}{}{{a}}^{{4}}{-}{120}{}{{a}}^{{3}}{+}{432}{}{{a}}^{{2}}{-}{576}{}{a}{+}{256}\right){,}{{L}}_{{6}}{=}{\mathrm{_C1}}{}\left({{a}}^{{3}}{-}{10}{}{{a}}^{{2}}{+}{24}{}{a}{-}{16}\right){,}{{L}}_{{7}}{=}{\mathrm{_C2}}{}{a}{}\left({7}{}{{a}}^{{3}}{-}{56}{}{{a}}^{{2}}{+}{112}{}{a}{-}{64}\right){,}{{L}}_{{8}}{=}{\mathrm{_C1}}{}\left({3}{}{{a}}^{{2}}{-}{16}{}{a}{+}{16}\right){,}{{L}}_{{9}}{=}{\mathrm{_C2}}{}{a}{}\left({5}{}{{a}}^{{2}}{-}{20}{}{a}{+}{16}\right){,}{{L}}_{{10}}{=}{\mathrm{_C1}}{}\left({a}{-}{2}\right){,}{{L}}_{{11}}{=}{\mathrm{_C2}}{}{a}{}\left({3}{}{a}{-}{4}\right){,}{{L}}_{{12}}{=}{\mathrm{_C2}}{}{a}$ (9)

Example based on content provided in Chapter 2 of Essential Maple 7.

References

 Corless, Robert M. Essential Maple 7. Springer-Verlag.