# [OS X TeX] Binomial Expansion

Alain Schremmer Schremmer.Alain at gmail.com
Thu Nov 23 16:40:35 EST 2006

Claus Gerhardt wrote:

> My final recommendations are
>
> \newcommand{\expand}{\polyprint{#1}}
>
> \newcommand{\expa}{#1=\polyprint{#1}}
>
> Possible variant of the last one
>
> \newcommand{\expb}{&#1=\\&\polyprint{#1}}
>
> using e.g. amsmath and
>
> \begin{equation}
> \begin{aligned}
> \expb{(x+1)(x^3+6)^3+9}
> \end{aligned}
> \end{equation}

1) I am truly overwhelmed as this is no small present. I am most
grateful since \Expand will save me a lot of time when I rewrite the
last part of the magnum opus because I use (Laurent) polynomial
expansions (asymptotic expansions if you would) to investigate functions.

For example, given, say, f(x) = \frac{x^3 - 1}{x - 2},

- dividing in descending powers of x gives the behaviour near
infinity: x^2 + (…)

- letting x = 2+h and then dividing in ascending powers of h
gives the behaviour near 2: 7h^-1 + (…)

where (…) stands for the appropriate o[h^n] (the students for whom
this is don't need more at this point of their education).

So, now you can see better why I need both (x+2)^3 —which I now have
thanks to you—and division in ascending powers.

2) I see that polyprint is the crucial command and I was indeed trying
to isolate the crucial command … by commenting out code. I got rid of
the Horner stuff but, as your first email arrived, I was getting nowhere
fast. So, here too thanks for preventing me to waste more time than I
can afford to waste.

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.
\expand{(x+h)^{3}}{1} expands beautifully
\expand{(x_{0}+h)^{3}}{1} gives an error that I assume is due to
polyprint not liking _{0}

\Expand{(x+a)(x+b)} gives "(1a+1b)" as middle term.
\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 to work

and, with expa

\expa{(x+2)(x+3)} expands beautifully
\expa{(x+2)^{3}} error "!Missing $inserted" \expa{(2+h)^{3}} error "!Missing$ inserted"

With expb

\begin{equation}
\begin{aligned}
\expb{(x+2)(x+3)}
\end{aligned}
\end{equation writes the expansion under (x+2)(x+3) rather than after =.

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

\begin{align*}
\expb{(x+2)^{3}}
\end{align*} ditto

\begin{align*}
\expb{(2+h)^{3}}
\end{align*} ditto and here too parentheses surround the ascending
expansion

Well, that's it. Of course I couldn't fix anything but, other than the
issue of the parentheses surrounding expansions in ascending powers,
\Expand does exactly what I wanted (But expb is nice too). So, that's
what I will be using and as for the surronding parentheses I will just
put a footnote in the text saying that they are an artifact and that,
under the GPL, anyone is free to fix it.

Well, I wish I understood how you did it but, hopefully, that will come
later. In the meantime, thanks very much again.

Best regards
--schremmer

------------------------- 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/