ExpandSteps - Maple Help

Student[Basics]

 ExpandSteps
 generate core steps in expanding polynomial products

 Calling Sequence ExpandSteps( expr ) ExpandSteps( expr, implicitmultiply = true )

Parameters

 expr - string or expression implicitmultiply - (optional) truefalse

Description

 • The ExpandSteps command accepts a product of polynomials and displays the steps required to expand the expression.
 • If expr is a string, then it is parsed into an expression using InertForm:-Parse so that no automatic simplifications are applied, and thus no steps are missed.
 • The implicitmultiply option is only relevant when expr is a string.  This option is passed directly on to the InertForm:-Parse command and will cause things like 2x to be interpreted as 2*x, but also, xyz to be interpreted as x*y*z.
 • A step may show up where the expression is not obviously different from the previous step.  This can happen when the underlying data structure is transformed during the step, and it is not obvious that the resulting structure is the same as the original, but just expressed differently.  This becomes more apparent when looking at the inert form of the raw data.
 • The return value is a module that displays annotated steps by default.  This module also has callable methods and data members: data, numsteps, step, and toMathML.

data: a numsteps x 2 array where column 1 is the inert-form expression, and column 2 is the annotation.  R:-data[1,1] is the original expression in inert form.

numsteps: the number of steps in the solution, including the original expression.

step(i): a method for displaying individual steps.  Calling R:-step(i) displays the ith typeset expression and annotation.  Step 1 is the original expression.

toMathML(): a method for converting the sequence of steps and annotations into mathml.  The toMathML command optionally takes one or two arguments: (1) a filename, indicating the mathml should be written to the specified file, and (2) the option htmlheader=true, which also causes html tags to be written along with the mathml, thus generating a complete .html page that can be loaded in a browser.

 • This function is part of the Student:-Basics package.

Examples

 > $\mathrm{with}\left(\mathrm{Student}:-\mathrm{Basics}\right):$
 > $\mathrm{ExpandSteps}\left(\frac{{a}^{2}-1}{\frac{a}{3}+\frac{1}{3}}\right)$
 $\begin{array}{c}\frac{{{a}}^{{2}}{-}{1}}{\frac{{a}}{{3}}{+}\frac{{1}}{{3}}}\\ {=}\frac{\left({a}{+}{1}\right){\cdot }\left({a}{-}{1}\right)}{\left({a}{+}{1}\right){\cdot }\left(\frac{{1}}{{3}}\right)}& \left({\text{Factor}}\right)\\ {=}\frac{{a}{-}{1}}{\frac{{1}}{{3}}}& \left({\text{divide}}\right)\\ {=}\left({a}{-}{1}\right){\cdot }\left(\frac{{3}}{{1}}\right)& \left({\text{Rewrite division as multiplication by reciprocal}}\right)\\ {=}{3}{}{a}{-}{3}& \left({\text{Multiply fraction and reduce by gcd}}\right)\end{array}$ (1)

Note that the result is a module with callable methods

 > $\mathrm{ex}≔\mathrm{ExpandSteps}\left(3a\left(4a-y+42\right)\right)$
 ${\mathrm{ex}}{≔}\begin{array}{c}{3}{\cdot }{a}{\cdot }\left({4}{\cdot }{a}{-}{1}{\cdot }{y}{+}{42}\right)\\ {=}{12}{}{{a}}^{{2}}{-}{3}{}{a}{}{y}{+}{126}{}{a}& \left({\text{Multiply through:}}\phantom{\rule[-0.0ex]{1.0thickmathspace}{0.0ex}}{3}{}{a}{\cdot }\left({4}{}{a}{-}{y}{+}{42}\right)\phantom{\rule[-0.0ex]{1.0thickmathspace}{0.0ex}}{\text{=}}\phantom{\rule[-0.0ex]{1.0thickmathspace}{0.0ex}}{12}{}{{a}}^{{2}}{-}{3}{}{a}{}{y}{+}{126}{}{a}\right)\end{array}$ (2)
 > $\mathrm{ex}:-\mathrm{numsteps}$
 ${2}$ (3)
 > $\mathrm{ex}:-\mathrm{step}\left(2\right)$
 $\begin{array}{cc}{12}{}{{a}}^{{2}}{-}{3}{}{a}{}{y}{+}{126}{}{a}& \left({\text{Multiply through:}}\phantom{\rule[-0.0ex]{1.0thickmathspace}{0.0ex}}{3}{}{a}{\cdot }\left({4}{}{a}{-}{y}{+}{42}\right)\phantom{\rule[-0.0ex]{1.0thickmathspace}{0.0ex}}{\text{=}}\phantom{\rule[-0.0ex]{1.0thickmathspace}{0.0ex}}{12}{}{{a}}^{{2}}{-}{3}{}{a}{}{y}{+}{126}{}{a}\right)\end{array}$ (4)

The steps can be converted to MathML

 > $\mathrm{ex}:-\mathrm{toMathML}\left(\right)$
 $\left[\begin{array}{cc}{"3 a 4 a-1 y+42\left[/itex\right]"}& {"=12 a2-3 a y+126 a"}{‖}\left({"\left("}{‖}\left({\mathrm{_MTEXT}}{}\left({"Multiply through: %1 = %2"}{,}{3}{}{a}{\ast }\left({4}{}{a}{-}{y}{+}{42}\right){,}{12}{}{{a}}^{{2}}{-}{3}{}{a}{}{y}{+}{126}{}{a}\right)\right){‖}{"\right)"}\right){‖}{"\left[/itex\right]"}\end{array}\right]$ (5)

The input can be a string, which prevents automatic simplification

 > $\mathrm{ExpandSteps}\left("\left(1+1\right)*\left(3-1\right)"\right)$
 $\begin{array}{c}\left({1}{+}{1}\right){\cdot }\left({3}{-}{1}\right)\\ {=}{2}{\cdot }\left({3}{-}{1}\right)& \left({\text{Add terms}}\right)\\ {=}{2}{\cdot }{2}& \left({\text{Add terms}}\right)\\ {=}{4}& \left({\text{Multiply constants}}\right)\end{array}$ (6)

The implicitmultiply option allows shorthand for string input.

 > $\mathrm{ExpandSteps}\left("2.1yx^2/\left(4.3xy\right)",'\mathrm{implicitmultiply}'\right)$
 $\begin{array}{c}\frac{{2.1}{\cdot }{y}{\cdot }{{x}}^{{2}}}{{4.3}{\cdot }{x}{\cdot }{y}}\\ {=}\frac{{2.1}{\cdot }{{x}}^{{2}}}{{4.3}{\cdot }{x}}& \left({\text{divide out common terms}}\right)\\ {=}\frac{{2.100000000}{}{x}}{{4.3}}& \left({\text{divide out common terms}}\right)\\ {=}{0.4883720930}{}{x}& \left({\text{Divide constants}}\right)\end{array}$ (7)

Compatibility

 • The Student[Basics][ExpandSteps] command was introduced in Maple 18.