# [OS X TeX] Binomial Expansion

Claus Gerhardt gerhardt at math.uni-heidelberg.de
Thu Nov 23 13:59:29 EST 2006

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}

Claus

On Nov 23, 2006, at 19:36, Claus Gerhardt wrote:

> Try this one
>
> \newcommand{\expa}[2]{#1 #2=\polyprint{#1#2}}
>
> Claus
>
> On Nov 23, 2006, at 19:31, Claus Gerhardt wrote:
>
>> No round brackets necessary, e.g., one could write
>>
>> \Expand{(x+1)(x^3+6)^5+9+x^2}
>>
>> Claus
>>
>> On Nov 23, 2006, at 19:28, Claus Gerhardt wrote:
>>
>>> Here is a variant
>>>
>>> \newcommand{\Expand}[1]{\polyprint{#1}}
>>>
>>> Example
>>>
>>> \Expand{(x+1)(x^3+6)^5}
>>>
>>> Claus
>>>
>>>
>>> On Nov 23, 2006, at 19:11, Claus Gerhardt wrote:
>>>
>>>> Alain,
>>>>
>>>> Here is my  little birthday present:
>>>>
>>>> \newcommand{\expand}[2]{\polyprint{#1#2}}
>>>>
>>>> Notice that the polynomials have to be delimited by round
>>>> brackets like
>>>>
>>>> \expand{(x+1)}{(x+8)^3}
>>>>
>>>> This will gives you the fully expanded polynomial. A reverse
>>>> long division scheme is a bit more difficult, and frankly, I
>>>> can't see its necessity.
>>>>
>>>> Claus
>>>>
>>>>
>>>> On Nov 23, 2006, at 18:11, Alain Schremmer wrote:
>>>>
>>>>> Claus Gerhardt wrote:
>>>>>
>>>>>> Happy Birthday Alain!
>>>>>
>>>>> Thank you!
>>>>>
>>>>>> I had a look at the polynom.sty manual. It is only 6 pages and
>>>>>> well  written. You should give it a try.
>>>>>
>>>>> I did about a year ago and I have been using \polylongdiv ever
>>>>> since. That was not the point of my post. What I wanted to do
>>>>> over the Christmas break was to learn a little bit about
>>>>> programming in LaTeX. The idea was to write, in the spirit of
>>>>> polylongdiv, a command
>>>>>
>>>>>    \Expand{a}{b}{some degree}
>>>>>
>>>>> that would expand and typeset (a+b)^n. I am still going, The
>>>>> TeX Book in hand, to try.
>>>>>
>>>>>> If \Expand{a}{b}{some degree} should represent polynomial
>>>>>> division, then
>>>>>>
>>>>>> \polylongdiv[stage=3] {(X-1)(X-1)(X^2+1)^4} {(X-1)(X+1)(X+1)}
>>>>>>
>>>>>> might be what you want.
>>>>>
>>>>> Not really since I can expand (a+b)^n in my head and
>>>>> polylongdiv gives me the output but no source to copy-paste.
>>>>>
>>>>> Nevertheless, \polylongdiv{(x+a)^{n}}{1}(with an actual value
>>>>> for n) is indeed very neat and I will try to cut some more from
>>>>> polynom.sty to get rid of the division (I already got rid of
>>>>> Horner but that was a bit of trial and error.)
>>>>>
>>>>> What I wanted was to learn a bit about LaTeX along the theme of
>>>>> writing the command.
>>>>>
>>>>> But, indeed, I hadn't realized that polylongdiv could multiply
>>>>> which of course was dumb since it has to multiply in order to
>>>>> divide (not quite as in "we had to destroy the city in order to
>>>>> save it" of everlasting fame.)
>>>>>
>>>>> Of course, what I would kill for is a polylongdiv in ascending
>>>>> order. But, as I wrote, Heinz didn't respond to my two requests
>>>>> so I think she or he has better things to do.
>>>>>
>>>>> Very grateful 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/
>>>>>
>>>>
>>>> ------------------------- 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/
>>>>
>>>
>>> ------------------------- 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/
>>>
>>
>> ------------------------- 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/
>>
>
> ------------------------- 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/
>

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