expand - Maple Help

expand

expand an expression

 Calling Sequence expand(expr, expr1, expr2, ..., exprn)

Parameters

 expr - any algebraic expression expr[1], expr[2], ..., expr[n] - (optional) expressions

Description

 • The expand command distributes products over sums. This is done for all polynomials.  For quotients of polynomials, only sums in the numerator are expanded; products and powers are left alone. See the normal command for dealing with quotients of polynomials.
 •
 • The optional arguments expr1, expr2, ..., exprn are used to prevent particular sub-expressions in expr from being expanded. To prevent all expressions from being expanded, use the frontend command: frontend(expand, [expr]);
 • The expand command is extensible: if the procedure expand/f is defined, then the call expand(f(x)); calls expand/f(x);

Examples

 > $\mathrm{expand}\left(\left(x+1\right)\left(x+2\right)\right)$
 ${{x}}^{{2}}{+}{3}{}{x}{+}{2}$ (1)
 > $\mathrm{expand}\left(\frac{x+1}{x+2}\right)$
 $\frac{{x}}{{x}{+}{2}}{+}\frac{{1}}{{x}{+}{2}}$ (2)
 > $\mathrm{expand}\left(\frac{1}{\left(x+1\right)x}\right)$
 $\frac{{1}}{\left({x}{+}{1}\right){}{x}}$ (3)
 > $\mathrm{expand}\left(\mathrm{sin}\left(x+y\right)\right)$
 ${\mathrm{sin}}{}\left({x}\right){}{\mathrm{cos}}{}\left({y}\right){+}{\mathrm{cos}}{}\left({x}\right){}{\mathrm{sin}}{}\left({y}\right)$ (4)
 > $\mathrm{expand}\left(\mathrm{cos}\left(2x\right)\right)$
 ${2}{}{{\mathrm{cos}}{}\left({x}\right)}^{{2}}{-}{1}$ (5)
 > $\mathrm{expand}\left({ⅇ}^{a+\mathrm{ln}\left(b\right)}\right)$
 ${{ⅇ}}^{{a}}{}{b}$ (6)
 > $\mathrm{expand}\left(\left(x+1\right)\left(y+z\right)\right)$
 ${x}{}{y}{+}{x}{}{z}{+}{y}{+}{z}$ (7)

Do not fully expand an expression.

 > $\mathrm{expand}\left(\left(x+1\right)\left(y+z\right),x+1\right)$
 $\left({x}{+}{1}\right){}{y}{+}\left({x}{+}{1}\right){}{z}$ (8)

The expand command will only expand an expression if it is possible.

 > $\mathrm{expand}\left(\mathrm{ln}\left(\frac{x}{{\left(1-x\right)}^{2}}\right)\right)$
 ${\mathrm{ln}}{}\left(\frac{{x}}{{\left({1}{-}{x}\right)}^{{2}}}\right)$ (9)
 > $\mathrm{assume}\left(x,\mathrm{real}\right)$
 > $\mathrm{expand}\left(\mathrm{ln}\left(\frac{x}{{\left(1-x\right)}^{2}}\right)\right)$
 ${\mathrm{ln}}{}\left(\frac{{1}}{{\left({1}{-}{\mathrm{x~}}\right)}^{{2}}}\right){+}{\mathrm{ln}}{}\left({\mathrm{x~}}\right)$ (10)

The expand command works on more advanced functions.

 > $\mathrm{expand}\left(\mathrm{BesselJ}\left(2,t\right)\right)$
 $\frac{{2}{}{\mathrm{BesselJ}}{}\left({1}{,}{t}\right)}{{t}}{-}{\mathrm{BesselJ}}{}\left({0}{,}{t}\right)$ (11)
 > $\mathrm{expand}\left(\mathrm{LegendreQ}\left(2,t\right)\right)$
 ${-}\frac{{1}}{{4}}{}{\mathrm{ln}}{}\left({t}{+}{1}\right){+}\frac{{1}}{{4}}{}{\mathrm{ln}}{}\left({t}{-}{1}\right){+}\frac{{3}}{{4}}{}{{t}}^{{2}}{}{\mathrm{ln}}{}\left({t}{+}{1}\right){-}\frac{{3}}{{4}}{}{{t}}^{{2}}{}{\mathrm{ln}}{}\left({t}{-}{1}\right){-}\frac{{3}}{{2}}{}{t}$ (12)
 > $\mathrm{expand}\left(\mathrm{JacobiP}\left(3,1,\frac{1}{4},t\right)\right)$
 ${-}\frac{{307}}{{1024}}{-}\frac{{2247}}{{1024}}{}{t}{+}\frac{{1575}}{{1024}}{}{{t}}^{{2}}{+}\frac{{5075}}{{1024}}{}{{t}}^{{3}}$ (13)

To selectively prevent expansions of subexpressions, it is frequently useful to use indets, to get subexpressions of certain type, and pass the operands of its output as extra arguments to expand.

 > $\mathrm{ee}≔\left(a+b\right)z+\mathrm{sin}\left(a+b\right)+{ⅇ}^{a+b}$
 ${\mathrm{ee}}{:=}\left({a}{+}{b}\right){}{z}{+}{\mathrm{sin}}{}\left({a}{+}{b}\right){+}{{ⅇ}}^{{a}{+}{b}}$ (14)

By default products and functions are expanded.

 > $\mathrm{expand}\left(\mathrm{ee}\right)$
 ${z}{}{a}{+}{z}{}{b}{+}{\mathrm{sin}}{}\left({a}\right){}{\mathrm{cos}}{}\left({b}\right){+}{\mathrm{cos}}{}\left({a}\right){}{\mathrm{sin}}{}\left({b}\right){+}{{ⅇ}}^{{a}}{}{{ⅇ}}^{{b}}$ (15)

Avoid expanding sin(a+b)

 > $\mathrm{expand}\left(\mathrm{ee},\mathrm{sin}\left(a+b\right)\right)$
 ${z}{}{a}{+}{z}{}{b}{+}{\mathrm{sin}}{}\left({a}{+}{b}\right){+}{{ⅇ}}^{{a}}{}{{ⅇ}}^{{b}}$ (16)

Avoid expanding the exponential function.

 > $\mathrm{expand}\left(\mathrm{ee},\mathrm{op}\left(\mathrm{indets}\left(\mathrm{ee},\mathrm{specfunc}\left(\mathrm{anything},\mathrm{exp}\right)\right)\right)\right)$
 ${z}{}{a}{+}{z}{}{b}{+}{\mathrm{sin}}{}\left({a}\right){}{\mathrm{cos}}{}\left({b}\right){+}{\mathrm{cos}}{}\left({a}\right){}{\mathrm{sin}}{}\left({b}\right){+}{{ⅇ}}^{{a}{+}{b}}$ (17)

Avoid expanding the exponential and sine functions.

 > $\mathrm{expand}\left(\mathrm{ee},\mathrm{op}\left(\mathrm{indets}\left(\mathrm{ee},\mathrm{specfunc}\left(\mathrm{anything},\left[\mathrm{exp},\mathrm{sin}\right]\right)\right)\right)\right)$
 ${z}{}{a}{+}{z}{}{b}{+}{{ⅇ}}^{{a}{+}{b}}{+}{\mathrm{sin}}{}\left({a}{+}{b}\right)$ (18)

Avoid expanding all functions.

 > $\mathrm{expand}\left(\mathrm{ee},\mathrm{op}\left(\mathrm{indets}\left(\mathrm{ee},\mathrm{function}\right)\right)\right)$
 ${z}{}{a}{+}{z}{}{b}{+}{{ⅇ}}^{{a}{+}{b}}{+}{\mathrm{sin}}{}\left({a}{+}{b}\right)$ (19)