# [OS X TeX] Binomial Expansion

Claus Gerhardt gerhardt at math.uni-heidelberg.de
Thu Nov 23 17:28:47 EST 2006

On Nov 23, 2006, at 22:40, Alain Schremmer wrote:

> Claus Gerhardt wrote:
>
>> My final recommendations are
>>
>> \newcommand{\expand}[1]{\polyprint{#1}}
>>
>> \newcommand{\expa}[1]{#1=\polyprint{#1}}
>>
>> Possible variant of the last one
>>
>> \newcommand{\expb}[1]{&#1=\\&\polyprint{#1}}
>>
>> using e.g. amsmath and
>>
>>
>> \begin{aligned}
>> \expb{(x+1)(x^3+6)^3+9}
>> \end{aligned}
>>
>
> ste.
>
> 3) I went through each one of your commands and I thought that you
> might be interested in the result:
>
>    \expand{(x+2)}{(x+3)} expands beautifully
>    \expand{(x+a)}{(x+b)} gives "(1a+1b)" as middle term.

Because polynom can only handle one variable.
>    \expand{(x+h)^{3}}{1} expands beautifully

This is not my final command
>    \expand{(x_{0}+h)^{3}}{1} gives an error that I assume is due to
>    polyprint not liking _{0}

It doesn't like "_"
>
>    \Expand{(x+a)(x+b)} gives "(1a+1b)" as middle term.

See above.
>    \Expand{(x+2)^{3}} expands beautifully
>    \Expand{(2+h)^{3}} expands but parentheses surround the ascending
>    expansion!
>    \Expand{(x+h)^{3}} expands beautifully
>    \Expand{(x_{0}+h)^{3}} gives the same error that I assume is due to
>    polyprint not liking _{0}
>
> I couldn't get expa[2] to work

Because this is the old definition and you probably defined the last
one later. Notice they have the same name.

>
> and, with expa[1]
>
>    \expa{(x+2)(x+3)} expands beautifully
>    \expa{(x+2)^{3}} error "!Missing $inserted" You have to use in dispaly equations. For in line math use expd, defined at the end, e.g.$\expd{(x+2)^3}$> \expa{(2+h)^{3}} error "!Missing$ inserted"
>
> With expb
>
>
>    \begin{aligned}
>    \expb{(x+2)(x+3)}
>    \end{aligned}
>    \end{equation writes the expansion under (x+2)(x+3) rather than
> after =.
Because I placed  & at the front thinking to use only for very large
expressions. You can set the & after =

> Because
>    \begin{align*}
>    \expb{(x+h)^{3}}
>    \end{align*} writes the expansion under (x+h)^{3} rather than
> after =

see above
If you want \polyprint command as inline command, not in a display
equation, use

\newcommand{\expd}[1]{#1=\ensuremath\polyprint{#1}}

usage: $\exp{(x+2)(x+3)}$

Claus
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/