
私はpolynom
多項式の長除算を説明するためにこのパッケージを使用しています。通常、これらの問題を手作業で解く場合、商の最初の項を被除数の最初の項に揃えます。ただし、以下のコードが示すように、この揃えは基本的に必要なことです。
\documentclass{article}
\usepackage{polynom}
\begin{document}
\polylongdiv{2x^4+7x^3+8x^2+5x+4}{x^3+x^2+x+1}
\end{document}
商の 2 を被除数の 2 と揃える方法はありますか?
答え1
短い答え
\documentclass{article}
\usepackage{polynom}
\begin{document}
\makeatletter
\let\oldpld@SplitQuotient\pld@SplitQuotient
\def\pld@SplitQuotient{\oldpld@SplitQuotient\def\pld@pattern{}}
\polylongdiv{X^9-X^8-X^5+X^4+X+1}{X-1}
\end{document}
長い回答
polynom
いくつかの実験を行った後、非連続の単項式を印刷するときにいくつかの穴が残ることに気付くかもしれません。
その仕組みpolynom
は\pld@pattern
、プレースホルダー被除数は 9 次なので、は(ある意味)\pld@pattern
です。X^9+X^8+...+1
\pld@quotient
次に、と が一致し始めます\pld@pattern
。この場合、X^8
は になりX^8
、-X^4
になります。が被除数を印刷しようとするX^4
と、同じことが起こります。これが、 in 商がin 被除数と揃う理由です。polynom
X^8
-X^8
これを解決するには、プレースホルダーをより短いものに置き換える必要があります。
しかし、それはあまり賢くないプレースホルダーを手動で割り当てる必要がある場合。幸いなことに、プレースホルダーを何も置かなければ、polynom
より短いプレースホルダーが強制的に(再)生成されます。これで、希望どおりのプレースホルダーになるはずです。
残る問題は、それをどこに置き換えるかです。ここでは、商を印刷しようとしているので、\def\pld@pattern{}
後にを追加します。\pld@SplitQuotient
polynom
\documentclass{article}
\usepackage{polynom}
\usepackage[active,floats,tightpage]{preview}
\begin{document}
\makeatletter
\let\oldpld@SplitQuotient\pld@SplitQuotient
\begin{figure}
\polylongdiv{X^9-X^8-X^5+X^4+X+1}{X-1}
\end{figure}
\begin{figure}
\def\pld@SplitQuotient{\oldpld@SplitQuotient\def\pld@pattern{}}
\polylongdiv{X^9-X^8-X^5+X^4+X+1}{X-1}
\end{figure}
\begin{figure}
\def\pld@SplitQuotient{\oldpld@SplitQuotient
\def\pld@quotient{\pld@V{X}{9}+\pld@V{X}{8}+\pld@V{X}{7}+\pld@V{X}{6}+\pld@V{X}{5}+\pld@V{X}{4}+\pld@V{X}{3}+\pld@V{X}{2}+\pld@V{X}{1}+\pld@R 11}}
\polylongdiv{X^9-X^8-X^5+X^4+X+1}{X-1}
\end{figure}
\begin{figure}
\def\pld@SplitQuotient{\oldpld@SplitQuotient\def\pld@pattern{}
\def\pld@quotient{\pld@V{X}{8}+\pld@V{X}{7}+\pld@V{X}{6}+\pld@V{X}{5}+\pld@V{X}{4}+\pld@V{X}{3}+\pld@V{X}{2}+\pld@V{X}{1}+\pld@R 11}}
\polylongdiv{X^9-X^8-X^5+X^4+X+1}{X-1}
\end{figure}
\end{document}