summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/binomexp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-01-12 01:30:54 +0000
committerKarl Berry <karl@freefriends.org>2007-01-12 01:30:54 +0000
commit0c2102d58a913cd6d2487c947a9cedb4b872d698 (patch)
treec95b74407b9d2cadfebac27dc58817c2de14a03f /Master/texmf-dist/tex/latex/binomexp
parentc4a18cc35b13311ec9424f499268be12a8b09eb6 (diff)
new package binomexp
git-svn-id: svn://tug.org/texlive/trunk@3355 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/binomexp')
-rw-r--r--Master/texmf-dist/tex/latex/binomexp/binomexp.sty156
1 files changed, 156 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/binomexp/binomexp.sty b/Master/texmf-dist/tex/latex/binomexp/binomexp.sty
new file mode 100644
index 00000000000..1e17b5747ab
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/binomexp/binomexp.sty
@@ -0,0 +1,156 @@
+%%
+%% This is file `binomexp.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% binomexp.dtx (with options: `package')
+%% This is a generated file.
+%% Copyright (C) 2006 by David Roderick
+%% This file may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.2 of this license or (at your option) any later
+%% version. The latest version of this license is in:
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.2 or later is part of all distributions of
+%% LaTeX version 1999/12/01 or later.
+\NeedsTeXFormat{LaTeX2e}[2005/12/01]
+\ProvidesPackage{binomexp}
+ [2007/01/07 v1.0 My first attempt]
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%%
+\RequirePackage{calc,ifthen}
+\newcommand\binomexp@replicate[2]{%
+ \ifnum#1>\z@ \expandafter\@firstofone
+ \else
+ \expandafter\@gobble
+ \fi
+ {#2\expandafter\binomexp@replicate\expandafter{\number\numexpr#1-1\relax}{#2}}%
+}
+\newcommand{\binomexp@call}[1]{\rule[-0.125cm]{0mm}{0.5cm}\mbox{$#1$}}
+\newcounter{binomexp@up}
+\newcommand{\binomexp@up}{\number\value{binomexp@up}
+\addtocounter{binomexp@up}{1}}
+\newcounter{binomexp@down}
+\newcommand{\binomexp@down}{\number\value{binomexp@down}
+\addtocounter{binomexp@down}{-1}}
+\newcounter{binomexp@columns}
+\newcounter{binomexp@power}
+\newcounter{binomexp@pascalstart}
+\newcounter{binomexp@pascalstop}
+\newcounter{binomexp@emptytimes}
+\newcounter{binomexp@variable1}
+\newcounter{binomexp@variable2}
+\newcounter{binomexp@answervar}
+\newcounter{binomexp@sub}
+\protect\newcommand*{\binomexp@printpascal}{
+\addtocounter{binomexp@power}{1}
+\expandafter\edef\csname
+binomexp@morten\roman{binomexp@power}exporti\endcsname{1}
+\setcounter{binomexp@sub}{2}
+\setcounter{binomexp@variable1}{\numexpr\number\value{binomexp@power}+1\relax}
+\whiledo{\number\numexpr\number\value{binomexp@power}+1\relax>
+\value{binomexp@sub}}{
+\setcounter{binomexp@variable1}{\numexpr\number\value{binomexp@sub}-1\relax}
+\setcounter{binomexp@variable2}{\value{binomexp@sub}}
+\setcounter{binomexp@answervar}{\number\numexpr\csname
+binomexp@x\roman{binomexp@variable1}\endcsname\relax+\number\numexpr\csname
+binomexp@x\roman{binomexp@variable2}\endcsname\relax}
+\expandafter\edef\csname binomexp@y\roman{binomexp@sub}\endcsname
+{\number\value{binomexp@answervar}}\relax
+\addtocounter{binomexp@sub}{1}
+}
+\setcounter{binomexp@sub}{2}
+\whiledo{\numexpr\number\value{binomexp@power}+1\relax>\value{binomexp@sub}}{
+\setcounter{binomexp@answervar}{\number\numexpr\csname
+binomexp@y\roman{binomexp@sub}\endcsname\relax}
+\expandafter\edef\csname binomexp@x\roman{binomexp@sub}\endcsname
+{\number\value{binomexp@answervar}}
+\expandafter\edef\csname
+binomexp@morten\roman{binomexp@power}export\roman{binomexp@sub}\endcsname
+{\number\value{binomexp@answervar}}
+\addtocounter{binomexp@sub}{1}
+}
+\setcounter{binomexp@variable1}
+{\numexpr\number\value{binomexp@power}+1\relax}
+\expandafter\edef\csname
+binomexp@x\roman{binomexp@variable1}\endcsname{1}
+\expandafter\edef\csname
+binomexp@morten\roman{binomexp@power}export\roman{binomexp@variable1}\endcsname{1}
+}
+\newcommand*\binomexp@putpascal[6]{\par
+\expandafter\edef\csname binomexp@xi\endcsname{1}
+\expandafter\edef\csname binomexp@mortenexporti\endcsname{1}
+\setcounter{binomexp@power}{0}
+\setcounter{binomexp@pascalstart}{#1}
+\setcounter{binomexp@pascalstop}{#2+1}
+\setcounter{binomexp@emptytimes}{\value{binomexp@pascalstop}}
+\whiledo{\value{binomexp@emptytimes}>1}{
+\binomexp@printpascal \addtocounter{binomexp@emptytimes}{-1}
+}
+\setcounter{binomexp@columns}
+{\numexpr\number\value{binomexp@pascalstop}+2\relax}
+\begin{math} \begin{array}{@{}|c|*{\value{binomexp@columns}}{|c}|@{}}
+\whiledo{\value{binomexp@pascalstart}<
+\numexpr\number\value{binomexp@pascalstop}-1\relax}{
+\setcounter{binomexp@up}{0}
+\setcounter{binomexp@down}{\value{binomexp@pascalstart}}
+\binomexp@call{(#3+#4)^{\number\numexpr\number\value{binomexp@pascalstart}\relax}}
+\binomexp@replicate{\numexpr\number\value{binomexp@pascalstart}+1\relax}
+{&\binomexp@call{\csname
+binomexp@morten\romannumeral\numexpr\value{binomexp@pascalstart}\relax
+export\romannumeral\numexpr\value{binomexp@up}+1\relax\endcsname
+#5^{\binomexp@down} #6^{\binomexp@up}}}\\
+\addtocounter{binomexp@pascalstart}{1}
+}
+\setcounter{binomexp@up}{0}
+\setcounter{binomexp@down}{\value{binomexp@pascalstart}}
+\binomexp@call{(#3+#4)^{\number\numexpr\number\value{binomexp@pascalstart}\relax}}
+\binomexp@replicate{\numexpr\number\value{binomexp@pascalstart}+1\relax}
+{&\binomexp@call{\csname
+binomexp@morten\romannumeral\numexpr\value{binomexp@pascalstart}\relax
+export\romannumeral\numexpr\value{binomexp@up}+1\relax\endcsname
+#5^{\binomexp@down} #6^{\binomexp@up}}}
+ \end{array} \end{math}
+}
+\newcommand{\binomexp@proof}[2]{
+\[ 7!=7\cdot6\cdot5\cdot4\cdot3\cdot2\cdot1 \hspace*{5em}
+{#1 \choose #2} = \frac{#1!}{(#1-#2)!\cdot #2!}=
+\frac{#1!}{(#1-#2)!\cdot(#1-(#1-#2))!}={#1 \choose #1-#2}
+\]
+\begin{eqnarray*} {#1 - 1 \choose #2 - 1} + {#1 - 1 \choose #2}
+&=& \frac{(#1 - 1)!}{(#2 - 1)!\cdot[(#1 - 1) - (#2 - 1)]!} +
+\frac{(#1 - 1)!}{#2!\cdot[(#1 - 1) - #2)]!}\\
+&=& (#1 - 1)!\cdot\left(\frac{1}{(#2 - 1)!\cdot(#1 - #2)!} +
+\frac{1}{#2!\cdot[(#1 - #2) - 1)]!}\right) \\
+&=& (#1 - 1)! \cdot\frac{#2 + (#1 - #2)}{#2! (#1 - #2)!} \\
+&=& \frac{#1!}{#2!(#1 - #2)!} = {#1 \choose #2}
+ \end{eqnarray*}
+\[ \frac{#2}{#2!\cdot(#1-#2)!} = \frac{1}{(#2-1)!\cdot(#1-#2)!}
+\hspace*{5em} \mbox{because} \hspace*{5em} \\
+ \frac{6}{6!\cdot(#1-#2)!} = \frac{1}{5!\cdot(#1-#2)!} \]
+\begin{eqnarray*}
+(#2 + 1)\cdot {#1 + 1 \choose #2 + 1} &=& (#2 + 1)\cdot
+\frac{(#1 + 1)!}{((#2 + 1)!\cdot ((#1 + 1) - (#2 + 1))!}\\
+&=& (#2 + 1)\cdot \frac{(#1 + 1)!}{(#2 + 1)!\cdot (#1 - #2)!}\\
+&=& (#1 + 1)\cdot \frac{#1!}{#2!\cdot (#1 - #2)!} = (#1 + 1)\cdot
+{#1 \choose #2}\\
+\end{eqnarray*}
+}
+\endinput
+%%
+%% End of file `binomexp.sty'.