Expand - Maple Help

Algebraic

 Expand
 expand expressions containing algebraic numbers

 Calling Sequence Expand(p, options)

Parameters

 p - any Maple object; typically an expression containing algebraic numbers options - (optional) equation(s) of the form keyword = value, where keyword is one of 'symbolic', 'characteristic', 'makeindependent', or 'recursive'.

Options

 • If the option 'symbolic'=true is given and a RootOf whose minimal polynomial factors nontrivially is detected, Expand will reduce it to a RootOf of lower degree by picking one of the factors arbitrarily. The default is 'symbolic'=false.
 • If the option 'characteristic'=p is given, where p is a nonnegative integer, the expansion is performed over an extension of the ring ${\mathrm{ℤ}}_{p}$ of integers modulo p. The default is 'characteristic'=0 and means that the expansion is performed over an extension of the rational numbers.
 • Note that if p is positive but not a prime, then ${\mathrm{ℤ}}_{p}$ is not a field, and Expand may not be able to expand the input. If it does not succeed because it encounters an integer that has no inverse modulo p, it issues the error "zero divisor modulo p detected".
 • If the option 'makeindependent'=true is given, then Expand will always try to find a field representation for algebraic numbers in the input, regardless of how many algebraic objects the input contains. If the input contains many RootOfs, then this can be a very expensive calculation. If 'makeindependent'=false is given, then no independence checking is performed. The default is 'makeindependent'=FAIL, in which case algebraic dependencies will only be checked for if there are $4$ or fewer algebraic objects in the input.
 • If the option 'recursive'=false is given, then Expand will not map itself recursively over non-algebraic subexpressions. The default is 'recursive'=true.

Description

 • This command expands products and powers of (multivariate) rational functions with algebraic number coefficients. Powers of algebraic numbers are also reduced.
 • The input p may contain algebraic number coefficients. These may be represented by radicals or with the RootOf notation (see type,algnum, type,radnum). In general, algebraic numbers will be returned in the same representation as they were received in. Nested radicals and RootOfs are also supported.
 • Non-algebraic subexpressions such as $\mathrm{sin}\left(x\right)$ that are neither variables, rational numbers, or algebraic objects will first be mapped over recursively (unless the option 'recursive'=false is given; see below). Then they are frozen and temporarily replaced by new local variables, which are not considered to be constant in what follows.
 • All radicals and powers of RootOfs in the result are reduced with respect to their respective minimal polynomials.  That is, every radical is of the form ${a}^{r}$, where $0 is a rational number, and every integer exponent in a power of the form ${\mathrm{RootOf}\left(f,\mathrm{...}\right)}^{n}$ satisfies $0 .
 • Partial factorizations in denominators of the input are preserved, but the factors themselves will be recursively expanded.
 • Expand can be used to normalize polynomials over algebraic number fields. However, if p is not a polynomial, then Expand cannot be used to determine if p is mathematically equivalent to zero. In this case, use Normal.
 • If, after freezing non-algebraic subexpressions, the input contains floating point numbers, only expand will be applied to it.
 • Expand will check algebraic objects for dependencies if there are at most $4$ of them in the input (unless option 'makeindependent' is given; see below). If there are more than $4$ algebraic objects in the input, then expansion will be performed anyway, but not all of the properties of the expanded form given above may be satisfied.

Examples

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

Introductory examples:

 > $\mathrm{Expand}\left(\left(x-\mathrm{sqrt}\left(2\right)I\right)\left(y+\mathrm{sqrt}\left(8\right)I\right)\right)$
 ${x}{}{y}{+}{2}{}{I}{}{x}{}\sqrt{{2}}{-}{I}{}\sqrt{{2}}{}{y}{+}{4}$ (1)
 > $\mathrm{Expand}\left({\left(x+\mathrm{RootOf}\left({\mathrm{_Z}}^{2}-3\mathrm{_Z}+1\right)\right)}^{2}\right)$
 ${2}{}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{3}{}{\mathrm{_Z}}{+}{1}\right){}{x}{+}{{x}}^{{2}}{+}{3}{}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{3}{}{\mathrm{_Z}}{+}{1}\right){-}{1}$ (2)
 > $\mathrm{Expand}\left(\frac{\left(x+1\right)\left(x+2\right)}{y+z}\right)$
 $\frac{{{x}}^{{2}}}{{y}{+}{z}}{+}\frac{{3}{}{x}}{{y}{+}{z}}{+}\frac{{2}}{{y}{+}{z}}$ (3)

Powers of radicals and RootOfs are reduced. Nested and mixed radicals and RootOfs are handled as well:

 > $p≔\left[{\mathrm{RootOf}\left({x}^{2}-x-1\right)}^{5}+2{\mathrm{RootOf}\left({x}^{2}-x-1\right)}^{3},{\left(\mathrm{sqrt}\left(3\right)\right)}^{5}\right]$
 ${p}{≔}\left[{{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{\mathrm{_Z}}{-}{1}\right)}^{{5}}{+}{2}{}{{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{\mathrm{_Z}}{-}{1}\right)}^{{3}}{,}{9}{}\sqrt{{3}}\right]$ (4)
 > $\mathrm{Expand}\left(p\right)$
 $\left[{9}{}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{\mathrm{_Z}}{-}{1}\right){+}{5}{,}{9}{}\sqrt{{3}}\right]$ (5)
 > $\mathrm{Expand}\left({\left(1+\mathrm{sqrt}\left(2\right)\right)}^{\frac{5}{4}}\right)$
 ${\left({1}{+}\sqrt{{2}}\right)}^{{1}}{{4}}}{+}{\left({1}{+}\sqrt{{2}}\right)}^{{1}}{{4}}}{}\sqrt{{2}}$ (6)
 > $\mathrm{Expand}\left({\mathrm{RootOf}\left({x}^{2}-x+\mathrm{RootOf}\left({x}^{2}-2\right)\right)}^{2}\right)$
 ${\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{\mathrm{_Z}}{+}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{2}\right)\right){-}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{2}\right)$ (7)
 > $\mathrm{Expand}\left({\mathrm{RootOf}\left({x}^{2}-\mathrm{sqrt}\left(3\right)\right)}^{5}\right)$
 ${3}{}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}\sqrt{{3}}\right)$ (8)
 > $\mathrm{Expand}\left(\frac{x+y}{{\mathrm{RootOf}\left({\mathrm{_Z}}^{2}+\mathrm{_Z}+2\right)}^{8}}\right)$
 $\frac{{x}}{{3}{}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{+}{\mathrm{_Z}}{+}{2}\right){-}{14}}{+}\frac{{y}}{{3}{}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{+}{\mathrm{_Z}}{+}{2}\right){-}{14}}$ (9)

Algebraic functions in the coefficients are not accepted:

 > $\mathrm{Expand}\left(\left(x+\mathrm{sqrt}\left(y\right)\right)\left(x-\mathrm{sqrt}\left(y\right)\right)\right)$

Non-algebraic subexpressions are first handled recursively (unless option 'recursive'=false is present) and then temporarily replaced by new variables:

 > $\mathrm{Expand}\left(\mathrm{foo}\left(\left(x+\mathrm{sqrt}\left(2\right)\right)\left(y+\mathrm{RootOf}\left({\mathrm{_Z}}^{2}-2,\mathrm{index}=1\right)\right)\right)\right)$
 ${\mathrm{foo}}{}\left({x}{}{y}{+}{x}{}\sqrt{{2}}{+}\sqrt{{2}}{}{y}{+}{2}\right)$ (10)
 > $\mathrm{Expand}\left(\mathrm{foo}\left(\left(x+\mathrm{sqrt}\left(2\right)\right)\left(y+\mathrm{RootOf}\left({\mathrm{_Z}}^{2}-2,\mathrm{index}=1\right)\right)\right),'\mathrm{recursive}'=\mathrm{false}\right)$
 ${\mathrm{foo}}{}\left(\left({x}{+}\sqrt{{2}}\right){}\left({y}{+}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{2}{,}{\mathrm{index}}{=}{1}\right)\right)\right)$ (11)

Non-algebraic subexpressions may evaluate to something algebraic after recursive treatment:

 > $\mathrm{Expand}\left(\left(x+\mathrm{cos}\left(I+\mathrm{RootOf}\left({\mathrm{_Z}}^{2}+1,\mathrm{index}=2\right)\right)\right)\left(x-1\right)\right)$
 ${{x}}^{{2}}{-}{1}$ (12)

Products and powers of polynomials in denominators will not be expanded, but other expressions in denominators will be expanded recursively:

 > $\mathrm{Expand}\left(\frac{x}{\left(x+1\right){\left(x+2\right)}^{2}}\right)$
 $\frac{{x}}{\left({x}{+}{1}\right){}{\left({x}{+}{2}\right)}^{{2}}}$ (13)
 > $\mathrm{Expand}\left(\frac{x}{\left(x+1\right)\left(x+2\right)+3}\right)$
 $\frac{{x}}{{{x}}^{{2}}{+}{3}{}{x}{+}{5}}$ (14)
 > $\mathrm{Expand}\left(\frac{a+b}{c+\frac{d+e}{f+g}}\right)$
 $\frac{{a}}{{c}{+}\frac{{d}}{{f}{+}{g}}{+}\frac{{e}}{{f}{+}{g}}}{+}\frac{{b}}{{c}{+}\frac{{d}}{{f}{+}{g}}{+}\frac{{e}}{{f}{+}{g}}}$ (15)

If the input has floating point coefficients, only expand is applied to it:

 > $\mathrm{Expand}\left(1.5\left(x+{\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\right)}^{3}\right)\left(x-{\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\right)}^{3}\right)\right)$
 ${-}{1.5}{}{{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{3}\right)}^{{6}}{+}{1.5}{}{{x}}^{{2}}$ (16)
 > $\mathrm{Expand}\left(\frac{3}{2}\left(x+{\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\right)}^{3}\right)\left(x-{\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\right)}^{3}\right)\right)$
 $\frac{{3}{}{{x}}^{{2}}}{{2}}{-}\frac{{27}}{{2}}$ (17)

If there is a RootOf in the input whose leading coefficient is not invertible, the output may not satisfy all of the properties listed above. By using option 'symbolic'=true, Expand can be forced to eliminate the zero divisor by making a substitution:

 > $\mathrm{Expand}\left({\mathrm{RootOf}\left(\mathrm{RootOf}\left({\mathrm{_Z}}^{2}-\mathrm{_Z}\right){\mathrm{_Z}}^{2}-1\right)}^{2}\right)$
 ${{\mathrm{RootOf}}{}\left({\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{\mathrm{_Z}}\right){}{{\mathrm{_Z}}}^{{2}}{-}{1}\right)}^{{2}}$ (18)
 > $\mathrm{Expand}\left({\mathrm{RootOf}\left(\mathrm{RootOf}\left({\mathrm{_Z}}^{2}-\mathrm{_Z}\right){\mathrm{_Z}}^{2}-1\right)}^{2},'\mathrm{symbolic}'=\mathrm{true}\right)$
 ${1}$ (19)

Using option 'characteristic', expansion can be performed over finite fields:

 > $\mathrm{Expand}\left({\left(x+1\right)}^{10},'\mathrm{characteristic}'=2\right)$
 ${{x}}^{{10}}{+}{{x}}^{{8}}{+}{{x}}^{{2}}{+}{1}$ (20)
 > $\mathrm{Expand}\left({\left(x+\mathrm{RootOf}\left({\mathrm{_Z}}^{2}-5,\mathrm{index}=1\right)\right)}^{2},'\mathrm{characteristic}'=3\right)$
 ${2}{}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{+}{1}{,}{\mathrm{index}}{=}{1}\right){}{x}{+}{{x}}^{{2}}{+}{2}$ (21)
 > $\mathrm{Expand}\left(\left(x-6I\right)\left(x+6I\right),'\mathrm{characteristic}'=7\right)$
 ${{x}}^{{2}}{+}{1}$ (22)

The polynomial defining a RootOf will also be reduced modulo the characteristic:

 > $\mathrm{Expand}\left(\mathrm{RootOf}\left({\mathrm{_Z}}^{2}-3\right),'\mathrm{characteristic}'=7\right)$
 ${\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{+}{4}\right)$ (23)

The expansion cannot always be performed in composite characteristic:

 > $\mathrm{Expand}\left(\frac{1}{{x}^{2}-1-\left(x+1\right)\left(x-1\right)+\frac{2}{x+2}},\mathrm{characteristic}=9\right)$
 ${5}{}{x}{+}{1}$ (24)
 > $\mathrm{Expand}\left(\frac{1}{{x}^{2}-1-\left(x+1\right)\left(x-1\right)+\frac{2}{x+2}},\mathrm{characteristic}=10\right)$

With option 'makeindependent'=true, the input will be checked for algebraic dependencies even if there are more than $4$ algebraic objects in the input:

 > $\mathrm{CubeRootOf}\left[-4\right]≔\mathrm{RootOf}\left({\mathrm{_Z}}^{3}+4,\mathrm{index}=1\right)$
 ${{\mathrm{CubeRootOf}}}_{{-4}}{≔}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{+}{4}{,}{\mathrm{index}}{=}{1}\right)$ (25)
 > $\mathrm{CubeRootOf}\left[-2\right]≔\mathrm{RootOf}\left({\mathrm{_Z}}^{3}+2,\mathrm{index}=1\right)$
 ${{\mathrm{CubeRootOf}}}_{{-2}}{≔}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{+}{2}{,}{\mathrm{index}}{=}{1}\right)$ (26)
 > $\mathrm{CubeRootOf}\left[2\right]≔\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-2,\mathrm{index}=1\right)$
 ${{\mathrm{CubeRootOf}}}_{{2}}{≔}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{2}{,}{\mathrm{index}}{=}{1}\right)$ (27)
 > $\mathrm{CubeRootOf}\left[3\right]≔\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3,\mathrm{index}=1\right)$
 ${{\mathrm{CubeRootOf}}}_{{3}}{≔}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{3}{,}{\mathrm{index}}{=}{1}\right)$ (28)
 > $\mathrm{CubeRootOf}\left[4\right]≔\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-4,\mathrm{index}=1\right)$
 ${{\mathrm{CubeRootOf}}}_{{4}}{≔}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{4}{,}{\mathrm{index}}{=}{1}\right)$ (29)
 > $\mathrm{CubeRootOf}\left[6\right]≔\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-6,\mathrm{index}=1\right)$
 ${{\mathrm{CubeRootOf}}}_{{6}}{≔}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{6}{,}{\mathrm{index}}{=}{1}\right)$ (30)
 > $\mathrm{Expand}\left(\mathrm{CubeRootOf}\left[4\right]\mathrm{CubeRootOf}\left[-2\right]\mathrm{CubeRootOf}\left[3\right]-\mathrm{CubeRootOf}\left[-4\right]\mathrm{CubeRootOf}\left[6\right]\right)$
 ${\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{+}{2}{,}{\mathrm{index}}{=}{1}\right){}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{3}{,}{\mathrm{index}}{=}{1}\right){}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{4}{,}{\mathrm{index}}{=}{1}\right){-}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{+}{4}{,}{\mathrm{index}}{=}{1}\right){}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{6}{,}{\mathrm{index}}{=}{1}\right)$ (31)
 > $\mathrm{Expand}\left(\mathrm{CubeRootOf}\left[4\right]\mathrm{CubeRootOf}\left[-2\right]\mathrm{CubeRootOf}\left[3\right]-\mathrm{CubeRootOf}\left[-4\right]\mathrm{CubeRootOf}\left[6\right],'\mathrm{makeindependent}'=\mathrm{true}\right)$
 ${0}$ (32)

With option 'makeindependent'=false, the input will never be checked for algebraic dependencies:

 > $\mathrm{Expand}\left(\mathrm{CubeRootOf}\left[2\right]\mathrm{CubeRootOf}\left[3\right]-\mathrm{CubeRootOf}\left[6\right],'\mathrm{makeindependent}'=\mathrm{false}\right)$
 ${\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{2}{,}{\mathrm{index}}{=}{1}\right){}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{3}{,}{\mathrm{index}}{=}{1}\right){-}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{6}{,}{\mathrm{index}}{=}{1}\right)$ (33)