I am writing worksheets with polynomial division using area models (often called "box method"):
The process is very slow for making dozens of problems, especially when the problems are bigger, like dividing a 5th degree polynomial by a 3rd degree polynomial. Is there a way to automate the creation of these box divisions in the future?
I would like to be able to type something like \polyboxdiv{6x^3+25x^2-24x+11}{x+5}
(similar to \polylongdiv{6x^3+25x^2-24x+11}{x+5}
from the polynom
package) to automatically generate the box division representation.
Here is a link to the MWE:
\documentclass[addpoints]{exam}
\usepackage[utf8]{inputenc}
\usepackage[margin=.75 in]{geometry}
\usepackage{amsmath,amsfonts,amssymb,amsthm,color,srcltx,enumitem,bm,cancel,thmtools,physics}
\usepackage{multicol} %see http://stackoverflow.com/questions/1398127/breaking-a-list-into-multiple-columns-in-latex
\usepackage{multirow,array} %Used for the "hand-made" payoff matrix
\usepackage{hhline}
\usepackage{float}
\usepackage{polynom} %for polynomial long division and synthetic division, see http://texdoc.net/texmf-dist/doc/latex/polynom/polynom.pdf
\usepackage[table]{xcolor}
%For solution tables, see https://tex.stackexchange.com/questions/133397/printanswer-in-table-in-exam-class
\makeatletter
\newcommand{\st}[1]{\ifprintanswers\begingroup\Solution@Emphasis#1\if@shadedsolutions%
{\cellcolor{white}}
\else
\fi\endgroup\else\phantom{#1}\fi}
\makeatother
\SolutionEmphasis{\color{black}} %color font solutions
%\unframedsolutions %Not necessary for table environment
%\shadedsolutions %gives background color to solutions
\printanswers
\begin{document}
\section{Polynomials Division Test}
\begin{questions}
\question[40]
For the division problem
\begin{equation*}
(6x^3+25x^2-24x+11) \divisionsymbol (x+5)
\end{equation*}
\begin{parts}
\begin{multicols}{2}
\part Divide using an area model with a left divisor.
{\renewcommand{\arraystretch}{2}
\begin{table}[H]
\centering
\begin{tabular}{*{1}{>{\centering\arraybackslash}m{1.25cm}}|*{4}{>{\centering\arraybackslash}m{1.25cm}|}}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$\st{6x^2}$} & \multicolumn{1}{c}{$\st{-5x}$} & \multicolumn{1}{c}{$\st{+1}$} & \multicolumn{1}{c}{} \\ \hhline{~----}
\multirow{2}*{} $\st{x}$ & $\st{6x^3}$ & $\st{-5x^2}$ & $\st{x}$ & $\st{6}$ \\ \hhline{~----}
$\st{+5}$ & $\st{30x^2}$ & $\st{-25x}$ & $\st{5}$ & \cellcolor{black!10} \\ \hhline{~----}
\end{tabular}
\end{table}}
\columnbreak
\part Divide using an area model with an upper divisor.
{\renewcommand{\arraystretch}{2}
\begin{table}[H]
\centering
\begin{tabular}{*{1}{>{\centering\arraybackslash}m{1.25cm}}|*{2}{>{\centering\arraybackslash}m{1.25cm}|}}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$\st{x}$} & \multicolumn{1}{c}{$\st{+5}$} \\ \hhline{~--}
\multirow{2}*{} $\st{6x^2}$ & $\st{6x^3}$ & $\st{30x^2}$ \\ \hhline{~--}
$\st{-5x}$ & $\st{-5x^2}$ & $\st{-25x}$ \\ \hhline{~--}
$\st{+1}$ & $\st{x}$ & $\st{5}$ \\ \hhline{~--}
& $\st{6}$ & \cellcolor{black!10} \\ \hhline{~--}
\end{tabular}
\end{table}}
\end{multicols}
\vspace*{\stretch{1}}
\begin{multicols}{2}
\part Divide using the classic long-division algorithm.
\begin{solution}
\begin{center}
\polylongdiv{6x^3+25x^2-24x+11}{x+5}
\end{center}
\end{solution}
\columnbreak
\part Divide using Horner's method of synthetic division.
\begin{solution}
\begin{center}
\polyhornerscheme[x=-5]{6x^3+25x^2-24x+11}
\end{center}
\end{solution}
\end{multicols}
\vspace*{\stretch{1}}
\end{parts}
\end{questions}
\end{document}
Thank you!
\usepackage[table]{xcolor}
\vln
is just being used in the content of cells rather than between them.sagetex
package lets you incorporate a computer algebra system into your LaTeX. This helps with automation and with many other math problems you are working with. See, for example, my answer to the question here.