FromInert - Maple Help

ToInert

conversion to an inert representation

FromInert

conversion from an inert representation

 Calling Sequence ToInert( expr, exclude = { ... }, include = { ... } ) FromInert( inert_expr )

Parameters

 expr - expression inert_expr - valid Inert representation exclude - specifies a list or set of tags not to convert to inert form include - specifies the complete list or set of tags to convert to inert form

Description

 • It can be difficult to manipulate some Maple expressions because they may change form during evaluation.  Therefore, it is useful to convert an active form of an expression into an inert form that can be freely modified without worry of evaluation.  Once the changes are made, the expression can be converted back to an active form.
 • The ToInert routine converts any Maple expression into an inert form.  The FromInert routine converts any valid inert representation back to an active Maple object.
 • Inert forms closely mirror the Maple internal DAG data structure representation. For example, the expression ${x}^{y}$ is stored internally as a power of the name x and the name y.  The inert representation is a series of embedded function calls with "_Inert_XXX" names describing the structure of the given expression.  There are some differences between the internal representation and the inert representation, mostly in the cases of sums and products, as the internal representation is designed for fast polynomial arithmetic as opposed to convenient programmatic manipulation. For the exact internal representation, see dismantle.
 For a list of the various Maple DAGs, refer to the Appendix in the Maple Programming Guide.
 • The exclude and include options to ToInert allow you to prevent inertization of certain expressions.  If an identifier is part of the exclude list then whenever that kind of expression is encountered, an _Inert_VERBATIM tag is created containing the raw expression. Similarly, an include list restricts the tags to only those mentioned in the list.  You are allowed either an exclude list, or an include list, not both.
 Some expressions cannot be explicitly excluded.  Usually this happens for objects that do not make sense on their own (for example, a _Inert_HASHPAIR outside a _Inert_TABLE), or because they cannot be represented outside their context (for example, _INERT_NARGS).  Additionally, the _Inert_PROD tag may appear during expansion of a series or a SDMPolynom. Expressions that contain references to parameters and locals also cannot be excluded.

 • The ToInert and FromInert commands are thread-safe as of Maple 15.

Examples

Inspect structure of $5x$.

 > $\mathrm{ToInert}\left(5x\right)$
 ${\mathrm{_Inert_PROD}}{}\left({\mathrm{_Inert_NAME}}{}\left({"x"}\right){,}{\mathrm{_Inert_INTPOS}}{}\left({5}\right)\right)$ (1)

In a procedure, find all the global names that have no attributes.

 > f := proc(x) ASSERT(type(x,integer)); ifactor(x) end proc;
 ${f}{≔}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{ASSERT}}{}\left({\mathrm{type}}{}\left({x}{,}{\mathrm{integer}}\right)\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{ifactor}}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2)
 > $\mathrm{globals_f}≔\mathrm{indets}\left(\mathrm{op}\left(5,\mathrm{ToInert}\left(\mathrm{eval}\left(f,1\right)\right)\right),'\mathrm{_Inert_NAME}\left(\mathrm{anything}\right)'\right)$
 ${\mathrm{globals_f}}{≔}\left\{{\mathrm{_Inert_NAME}}{}\left({"ifactor"}\right){,}{\mathrm{_Inert_NAME}}{}\left({"protected"}\right)\right\}$ (3)

Rename the local variable i to j.

 > g := proc() local i; end proc;
 ${g}{≔}{\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (4)
 > $\mathrm{inert_g}≔\mathrm{ToInert}\left(\mathrm{eval}\left(g,1\right)\right)$
 ${\mathrm{inert_g}}{≔}{\mathrm{_Inert_PROC}}{}\left({\mathrm{_Inert_PARAMSEQ}}{}\left(\right){,}{\mathrm{_Inert_LOCALSEQ}}{}\left({\mathrm{_Inert_NAME}}{}\left({"i"}\right)\right){,}{\mathrm{_Inert_OPTIONSEQ}}{}\left(\right){,}{\mathrm{_Inert_EXPSEQ}}{}\left(\right){,}{\mathrm{_Inert_STATSEQ}}{}\left({\mathrm{_Inert_EXPSEQ}}{}\left(\right)\right){,}{\mathrm{_Inert_DESCRIPTIONSEQ}}{}\left(\right){,}{\mathrm{_Inert_GLOBALSEQ}}{}\left(\right){,}{\mathrm{_Inert_LEXICALSEQ}}{}\left(\right){,}{\mathrm{_Inert_EOP}}{}\left({\mathrm{_Inert_EXPSEQ}}{}\left(\right)\right)\right)$ (5)
 > $\mathrm{new_g}≔\mathrm{FromInert}\left(\mathrm{subsop}\left(2=\mathrm{subs}\left("i"="j",\mathrm{op}\left(2,\mathrm{inert_g}\right)\right),\mathrm{inert_g}\right)\right)$
 ${\mathrm{new_g}}{≔}{\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{j}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (6)

Convert to the inert form the expansion of (x+y)^10 without applying ToInert on products.

 > $\mathrm{ToInert}\left(\mathrm{expand}\left({\left(x+y\right)}^{10}\right),\mathrm{exclude}=\left\{\mathrm{_Inert_PROD}\right\}\right)$
 ${\mathrm{_Inert_SUM}}{}\left({\mathrm{_Inert_VERBATIM}}{}\left({{x}}^{{10}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({10}{}{{x}}^{{9}}{}{y}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({45}{}{{x}}^{{8}}{}{{y}}^{{2}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({120}{}{{x}}^{{7}}{}{{y}}^{{3}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({210}{}{{x}}^{{6}}{}{{y}}^{{4}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({252}{}{{x}}^{{5}}{}{{y}}^{{5}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({210}{}{{x}}^{{4}}{}{{y}}^{{6}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({120}{}{{x}}^{{3}}{}{{y}}^{{7}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({45}{}{{x}}^{{2}}{}{{y}}^{{8}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({10}{}{x}{}{{y}}^{{9}}\right){,}{\mathrm{_Inert_VERBATIM}}{}\left({{y}}^{{10}}\right)\right)$ (7)