| 1 |
% |
| 2 |
% This file is copyright 2004 Carsten Heinz. |
| 3 |
% |
| 4 |
% This file may be distributed and/or modified under the conditions |
| 5 |
% of the LaTeX Project Public License, either version 1.3 of this |
| 6 |
% license or (at your option) any later version. |
| 7 |
% The latest version of this license is in |
| 8 |
% http://www.latex-project.org/lppl.txt |
| 9 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 10 |
% version 2003/12/01 or later. |
| 11 |
% |
| 12 |
\documentclass[12pt]{article} |
| 13 |
\pagestyle{empty} |
| 14 |
|
| 15 |
\usepackage{geometry,hyperref,color,polynom} |
| 16 |
\geometry{screen} |
| 17 |
\hypersetup{pdfpagemode=FullScreen} |
| 18 |
|
| 19 |
%%%%%%%%%%%%% |
| 20 |
% |
| 21 |
% \tokentotext<csname>{<tokens>} |
| 22 |
% converts token sequence into a \texttt-printable form. |
| 23 |
% |
| 24 |
%%%%%%%%%%%%% |
| 25 |
\makeatletter % We'll use three internal LaTeX definitions |
| 26 |
\newcommand\tokentotext[2]{% |
| 27 |
\def#1{#2}% |
| 28 |
\edef#1{\expandafter\strip@prefix\meaning#1}% |
| 29 |
\edef#1{\expandafter\zap@space#1 \@empty}} |
| 30 |
\makeatother |
| 31 |
|
| 32 |
|
| 33 |
\newcounter{currentstage} |
| 34 |
%%%%%%%%%%%%% |
| 35 |
% |
| 36 |
% \dopolylongdiv{<page title>}{<loop min>}{<loop max>}{<key=value list for \polyset>} |
| 37 |
% |
| 38 |
%%%%%%%%%%%%% |
| 39 |
\newcommand\dopolylongdiv[4]{% |
| 40 |
\begingroup |
| 41 |
\tokentotext\keyvaluetext{#4}% |
| 42 |
\polyset{#4}% |
| 43 |
\setcounter{currentstage}{#2}\addtocounter{currentstage}{-1}% |
| 44 |
% |
| 45 |
\loop \ifnum \value{currentstage}<#3\relax |
| 46 |
\addtocounter{currentstage}{1}% |
| 47 |
\newpage |
| 48 |
\section*{\strut#1}\section*{\strut\texttt{\keyvaluetext}}% |
| 49 |
\[\polylongdiv[stage=\value{currentstage}]{x^3+x^2-1}{x+2}\] |
| 50 |
\repeat |
| 51 |
\endgroup} |
| 52 |
%%%%%%%%%%%%% |
| 53 |
% |
| 54 |
% \dopolyhornerscheme{<page title>}{<loop min>}{<loop max>}{<key=value list for \polyset>} |
| 55 |
% |
| 56 |
%%%%%%%%%%%%% |
| 57 |
\newcommand\dopolyhornerscheme[4]{% similar to \dopolylongdiv |
| 58 |
\begingroup |
| 59 |
\tokentotext\keyvaluetext{#4}% |
| 60 |
\polyset{#4}% |
| 61 |
\setcounter{currentstage}{#2}\addtocounter{currentstage}{-1}% |
| 62 |
% |
| 63 |
\loop \ifnum \value{currentstage}<#3\relax |
| 64 |
\addtocounter{currentstage}{1}% |
| 65 |
\newpage |
| 66 |
\section*{\strut#1}\section*{\strut\texttt{\keyvaluetext}}% |
| 67 |
\[\polyhornerscheme[x=-2,stage=\value{currentstage}]{x^3+x^2-1}\] |
| 68 |
\repeat |
| 69 |
\endgroup} |
| 70 |
|
| 71 |
%%%%%%%%%%%%% |
| 72 |
% |
| 73 |
% T H E D O C U M E N T |
| 74 |
% |
| 75 |
%%%%%%%%%%%%% |
| 76 |
\begin{document} |
| 77 |
|
| 78 |
\LARGE |
| 79 |
|
| 80 |
\dopolylongdiv{Polynomial long division -- Stages 1 to 10}{1}{10} |
| 81 |
{} |
| 82 |
|
| 83 |
\dopolylongdiv{Polynomial long division -- Stages 1 to 11}{1}{11} |
| 84 |
{style=B} |
| 85 |
|
| 86 |
\dopolylongdiv{Polynomial long division -- Stages 1 to 11}{1}{11} |
| 87 |
{style=C} |
| 88 |
|
| 89 |
\dopolylongdiv{Polynomial long division -- Stages 1 to 11}{1}{11} |
| 90 |
{style=D} |
| 91 |
|
| 92 |
\dopolyhornerscheme{Horner's scheme -- Stages 1 to 8}{1}{8} |
| 93 |
{} |
| 94 |
|
| 95 |
\dopolyhornerscheme{Horner's scheme -- Stages 1 to 8}{1}{8} |
| 96 |
{tutor=true,resultstyle=\color{blue}} |
| 97 |
|
| 98 |
\dopolyhornerscheme{Horner's scheme -- Rule the result}{8}{8} |
| 99 |
{resultbottomrule,resultleftrule,resultrightrule} |
| 100 |
|
| 101 |
\dopolyhornerscheme{Horner's scheme -- Stages 1 to 8}{1}{8} |
| 102 |
{tutor=true,tutorlimit=3} |
| 103 |
|
| 104 |
\dopolyhornerscheme{Horner's scheme: Some more options}{8}{8} |
| 105 |
{showbase=top,showbasesep=false} |
| 106 |
|
| 107 |
\end{document} |