Horner's Method for polynomial long division
I am trying to do a polynomial division using Horner's Method of
Synthetic Division, as described on page 451 of the book, Elementary Algebra by Hall & Knight.
I wanted to perform the following division by the Horner's method:
I've managed to do this:
documentclassarticle
usepackagearydshln
begindocument
begincenter
begintabularrrr:rr
3 & 9 & 0 & 2 & 6 & -8 \
hline
-1 & & -3 & 6 & & \
2 & & & 1 & -2 & \
& & & & -3 & 6 \
hline
& 3 & -1 & 3 & 1 & -2 \
cdashline5-6
endtabular
endcenter
enddocument
But how can I draw the arrows as shown in the following picture?
tikz-pgf polynomials
add a comment |
I am trying to do a polynomial division using Horner's Method of
Synthetic Division, as described on page 451 of the book, Elementary Algebra by Hall & Knight.
I wanted to perform the following division by the Horner's method:
I've managed to do this:
documentclassarticle
usepackagearydshln
begindocument
begincenter
begintabularrrr:rr
3 & 9 & 0 & 2 & 6 & -8 \
hline
-1 & & -3 & 6 & & \
2 & & & 1 & -2 & \
& & & & -3 & 6 \
hline
& 3 & -1 & 3 & 1 & -2 \
cdashline5-6
endtabular
endcenter
enddocument
But how can I draw the arrows as shown in the following picture?
tikz-pgf polynomials
2
This seems like a job fortikz
to me.
– Derek
Aug 28 '18 at 1:13
add a comment |
I am trying to do a polynomial division using Horner's Method of
Synthetic Division, as described on page 451 of the book, Elementary Algebra by Hall & Knight.
I wanted to perform the following division by the Horner's method:
I've managed to do this:
documentclassarticle
usepackagearydshln
begindocument
begincenter
begintabularrrr:rr
3 & 9 & 0 & 2 & 6 & -8 \
hline
-1 & & -3 & 6 & & \
2 & & & 1 & -2 & \
& & & & -3 & 6 \
hline
& 3 & -1 & 3 & 1 & -2 \
cdashline5-6
endtabular
endcenter
enddocument
But how can I draw the arrows as shown in the following picture?
tikz-pgf polynomials
I am trying to do a polynomial division using Horner's Method of
Synthetic Division, as described on page 451 of the book, Elementary Algebra by Hall & Knight.
I wanted to perform the following division by the Horner's method:
I've managed to do this:
documentclassarticle
usepackagearydshln
begindocument
begincenter
begintabularrrr:rr
3 & 9 & 0 & 2 & 6 & -8 \
hline
-1 & & -3 & 6 & & \
2 & & & 1 & -2 & \
& & & & -3 & 6 \
hline
& 3 & -1 & 3 & 1 & -2 \
cdashline5-6
endtabular
endcenter
enddocument
But how can I draw the arrows as shown in the following picture?
tikz-pgf polynomials
tikz-pgf polynomials
edited Aug 28 '18 at 3:03
Henri Menke
76.9k8168283
76.9k8168283
asked Aug 28 '18 at 1:05
Luo KaisaLuo Kaisa
635
635
2
This seems like a job fortikz
to me.
– Derek
Aug 28 '18 at 1:13
add a comment |
2
This seems like a job fortikz
to me.
– Derek
Aug 28 '18 at 1:13
2
2
This seems like a job for
tikz
to me.– Derek
Aug 28 '18 at 1:13
This seems like a job for
tikz
to me.– Derek
Aug 28 '18 at 1:13
add a comment |
2 Answers
2
active
oldest
votes
This is just a very quick answer.
documentclass[border=5pt,tikz]standalone
usetikzlibrarymatrix,fit,arrows
begindocument
begintikzpicture[>=latex]
useasboundingbox (-5,-4) rectangle (5,4);
matrix (m) [row sep=1cm,column sep=1cm,matrix of nodes]
3 & 9 & 0 & 2 & 6 & -8 \
-1 & phantoma & -3 & 6 & phantoma & phantoma \
2 & phantoma & phantoma & -1 & -2 & phantoma \
phantoma & phantoma & phantoma & phantoma & -3 & 6 \
phantoma & 3 & -1 & 3 & 1 & -2 \
phantoma & $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw ([xshift=.2cm]m-1-1.north east) -- ([xshift=.2cm]m-6-1.south east);
draw[dashed] ([yshift=.2cm]m-1-5.north east) -- ([yshift=.2cm]m-6-5.south east);
draw ([yshift=-.2cm]m-1-1.south west) -- ([yshift=-.2cm]m-1-6.south east);
draw ([yshift=-.2cm]m-4-1.south west) -- ([yshift=-.2cm]m-4-6.south east);
node[fit=(m-1-2),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(m-1-3)(m-2-3)] (b) ;
node[draw,fit=(m-1-4)(m-3-4)] (c) ;
draw[->] (a) --+ (0,-1.1) --+ (-.5,-.6);
draw[->] (b) --+ (0,-2) --+ (-.5,-1.5);
draw[->] (c) --+ (0,-3) --+ (-.5,-2.5);
endtikzpicture
enddocument
1
Instead of usingphantoma
in empty cells, you could addnodes in empty cells
to the matrix options, and you could consider using amatrix of math nodes
instead of amatrix of nodes
. Good use offit
!
– Max
Aug 28 '18 at 5:22
1
Well those "tips" weren't very helpful, were they? Sorry for my ignorance.
– Max
Aug 28 '18 at 9:42
@Max: Thank you for your tips, I really appreciate them, but since I'm not working with TeXStudio anymore, I have to use TeXmaker now and I'm not very into it (seethe_real_deal
; I've got the same problem …).
– current_user
Aug 28 '18 at 13:49
add a comment |
This is actually an addition to the answer of current_user, because I placed a comment with some "tips" but after actually trying them myself they actually made placing the lines of the matrix harder.
The problem that I ran into was that I wanted to use the actual width of the column, and the actual height of the row to place the lines, but you still want to use the minimum size of the nodes for fit
ting nodes around them. To fix this, I added a new matrix style fixed matrix
that places a fixed size node in the background of the cell, that sets the height of the row and the width of the column, and placing an additional node with the real contents on top of it (that should be smaller than the desired dimensions, otherwise it still wouldn't work). These nodes are named <matrix name>-<row num>-<column num>-o
and <matrix name>-<row num>-<column num>-i
where o
and i
denote outer and inner respectively.
With this I can easily draw the following:
With only this code:
begintikzpicture[>=latex]
matrix [fixed matrix] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
Some additional functions are:
- The
fixed matrix
style accepts an argument that can be used to:- set the style for the inner nodes with
inner nodes=<style>
- set the style of the outer nodes with
outer nodes=<style>
- set the row height with
row height=<dimension>
(default is10mm
) - set the column width with
column width=<dimension>
(default is10mm
)
- set the style for the inner nodes with
Small downside, if you name the matrix
before calling the fixed matrix
style, you cannot refer to the individual nodes with your custom matrix name, but the default m
is used as matrix name.
When changing the fixed matrix
call in the previous code snippet to fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue
you can obtain the following image (just an example, definitely not a proposed improvement):
Complete code (many many thanks to current_user for his start on this):
documentclass[border=2mm,tikz]standalone
usetikzlibraryfit
tikzset
fixed matrix/.cd,
row height/.initial=10mm,
column width/.initial=10mm,
name/.initial=m,
inner node style/.style=,
outer node style/.style=,
inner nodes/.code=tikzsetfixed matrix/inner node style/.style=#1,
outer nodes/.code=tikzsetfixed matrix/outer node style/.style=#1,
tikzset
fixed matrix/.style=
inner sep=0pt,
nodes=inner sep=0.333em,
name/.forward to=/tikz/fixed matrix/name,
execute at begin cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);
node[fixed matrix/inner node style] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-i) bgroup,
execute at end cell=egroup;,
execute at empty cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);,
,
fixed matrix/.append code=tikzsetfixed matrix/.cd,#1,
begindocument
begintikzpicture[>=latex]
matrix [fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
enddocument
your code it's awesome. I should also mark your answer as accepted, but I can only mark one of them.
– Luo Kaisa
Aug 28 '18 at 20:55
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f448087%2fhorners-method-for-polynomial-long-division%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is just a very quick answer.
documentclass[border=5pt,tikz]standalone
usetikzlibrarymatrix,fit,arrows
begindocument
begintikzpicture[>=latex]
useasboundingbox (-5,-4) rectangle (5,4);
matrix (m) [row sep=1cm,column sep=1cm,matrix of nodes]
3 & 9 & 0 & 2 & 6 & -8 \
-1 & phantoma & -3 & 6 & phantoma & phantoma \
2 & phantoma & phantoma & -1 & -2 & phantoma \
phantoma & phantoma & phantoma & phantoma & -3 & 6 \
phantoma & 3 & -1 & 3 & 1 & -2 \
phantoma & $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw ([xshift=.2cm]m-1-1.north east) -- ([xshift=.2cm]m-6-1.south east);
draw[dashed] ([yshift=.2cm]m-1-5.north east) -- ([yshift=.2cm]m-6-5.south east);
draw ([yshift=-.2cm]m-1-1.south west) -- ([yshift=-.2cm]m-1-6.south east);
draw ([yshift=-.2cm]m-4-1.south west) -- ([yshift=-.2cm]m-4-6.south east);
node[fit=(m-1-2),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(m-1-3)(m-2-3)] (b) ;
node[draw,fit=(m-1-4)(m-3-4)] (c) ;
draw[->] (a) --+ (0,-1.1) --+ (-.5,-.6);
draw[->] (b) --+ (0,-2) --+ (-.5,-1.5);
draw[->] (c) --+ (0,-3) --+ (-.5,-2.5);
endtikzpicture
enddocument
1
Instead of usingphantoma
in empty cells, you could addnodes in empty cells
to the matrix options, and you could consider using amatrix of math nodes
instead of amatrix of nodes
. Good use offit
!
– Max
Aug 28 '18 at 5:22
1
Well those "tips" weren't very helpful, were they? Sorry for my ignorance.
– Max
Aug 28 '18 at 9:42
@Max: Thank you for your tips, I really appreciate them, but since I'm not working with TeXStudio anymore, I have to use TeXmaker now and I'm not very into it (seethe_real_deal
; I've got the same problem …).
– current_user
Aug 28 '18 at 13:49
add a comment |
This is just a very quick answer.
documentclass[border=5pt,tikz]standalone
usetikzlibrarymatrix,fit,arrows
begindocument
begintikzpicture[>=latex]
useasboundingbox (-5,-4) rectangle (5,4);
matrix (m) [row sep=1cm,column sep=1cm,matrix of nodes]
3 & 9 & 0 & 2 & 6 & -8 \
-1 & phantoma & -3 & 6 & phantoma & phantoma \
2 & phantoma & phantoma & -1 & -2 & phantoma \
phantoma & phantoma & phantoma & phantoma & -3 & 6 \
phantoma & 3 & -1 & 3 & 1 & -2 \
phantoma & $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw ([xshift=.2cm]m-1-1.north east) -- ([xshift=.2cm]m-6-1.south east);
draw[dashed] ([yshift=.2cm]m-1-5.north east) -- ([yshift=.2cm]m-6-5.south east);
draw ([yshift=-.2cm]m-1-1.south west) -- ([yshift=-.2cm]m-1-6.south east);
draw ([yshift=-.2cm]m-4-1.south west) -- ([yshift=-.2cm]m-4-6.south east);
node[fit=(m-1-2),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(m-1-3)(m-2-3)] (b) ;
node[draw,fit=(m-1-4)(m-3-4)] (c) ;
draw[->] (a) --+ (0,-1.1) --+ (-.5,-.6);
draw[->] (b) --+ (0,-2) --+ (-.5,-1.5);
draw[->] (c) --+ (0,-3) --+ (-.5,-2.5);
endtikzpicture
enddocument
1
Instead of usingphantoma
in empty cells, you could addnodes in empty cells
to the matrix options, and you could consider using amatrix of math nodes
instead of amatrix of nodes
. Good use offit
!
– Max
Aug 28 '18 at 5:22
1
Well those "tips" weren't very helpful, were they? Sorry for my ignorance.
– Max
Aug 28 '18 at 9:42
@Max: Thank you for your tips, I really appreciate them, but since I'm not working with TeXStudio anymore, I have to use TeXmaker now and I'm not very into it (seethe_real_deal
; I've got the same problem …).
– current_user
Aug 28 '18 at 13:49
add a comment |
This is just a very quick answer.
documentclass[border=5pt,tikz]standalone
usetikzlibrarymatrix,fit,arrows
begindocument
begintikzpicture[>=latex]
useasboundingbox (-5,-4) rectangle (5,4);
matrix (m) [row sep=1cm,column sep=1cm,matrix of nodes]
3 & 9 & 0 & 2 & 6 & -8 \
-1 & phantoma & -3 & 6 & phantoma & phantoma \
2 & phantoma & phantoma & -1 & -2 & phantoma \
phantoma & phantoma & phantoma & phantoma & -3 & 6 \
phantoma & 3 & -1 & 3 & 1 & -2 \
phantoma & $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw ([xshift=.2cm]m-1-1.north east) -- ([xshift=.2cm]m-6-1.south east);
draw[dashed] ([yshift=.2cm]m-1-5.north east) -- ([yshift=.2cm]m-6-5.south east);
draw ([yshift=-.2cm]m-1-1.south west) -- ([yshift=-.2cm]m-1-6.south east);
draw ([yshift=-.2cm]m-4-1.south west) -- ([yshift=-.2cm]m-4-6.south east);
node[fit=(m-1-2),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(m-1-3)(m-2-3)] (b) ;
node[draw,fit=(m-1-4)(m-3-4)] (c) ;
draw[->] (a) --+ (0,-1.1) --+ (-.5,-.6);
draw[->] (b) --+ (0,-2) --+ (-.5,-1.5);
draw[->] (c) --+ (0,-3) --+ (-.5,-2.5);
endtikzpicture
enddocument
This is just a very quick answer.
documentclass[border=5pt,tikz]standalone
usetikzlibrarymatrix,fit,arrows
begindocument
begintikzpicture[>=latex]
useasboundingbox (-5,-4) rectangle (5,4);
matrix (m) [row sep=1cm,column sep=1cm,matrix of nodes]
3 & 9 & 0 & 2 & 6 & -8 \
-1 & phantoma & -3 & 6 & phantoma & phantoma \
2 & phantoma & phantoma & -1 & -2 & phantoma \
phantoma & phantoma & phantoma & phantoma & -3 & 6 \
phantoma & 3 & -1 & 3 & 1 & -2 \
phantoma & $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw ([xshift=.2cm]m-1-1.north east) -- ([xshift=.2cm]m-6-1.south east);
draw[dashed] ([yshift=.2cm]m-1-5.north east) -- ([yshift=.2cm]m-6-5.south east);
draw ([yshift=-.2cm]m-1-1.south west) -- ([yshift=-.2cm]m-1-6.south east);
draw ([yshift=-.2cm]m-4-1.south west) -- ([yshift=-.2cm]m-4-6.south east);
node[fit=(m-1-2),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(m-1-3)(m-2-3)] (b) ;
node[draw,fit=(m-1-4)(m-3-4)] (c) ;
draw[->] (a) --+ (0,-1.1) --+ (-.5,-.6);
draw[->] (b) --+ (0,-2) --+ (-.5,-1.5);
draw[->] (c) --+ (0,-3) --+ (-.5,-2.5);
endtikzpicture
enddocument
edited Aug 28 '18 at 2:25
answered Aug 28 '18 at 2:06
current_usercurrent_user
3,4691737
3,4691737
1
Instead of usingphantoma
in empty cells, you could addnodes in empty cells
to the matrix options, and you could consider using amatrix of math nodes
instead of amatrix of nodes
. Good use offit
!
– Max
Aug 28 '18 at 5:22
1
Well those "tips" weren't very helpful, were they? Sorry for my ignorance.
– Max
Aug 28 '18 at 9:42
@Max: Thank you for your tips, I really appreciate them, but since I'm not working with TeXStudio anymore, I have to use TeXmaker now and I'm not very into it (seethe_real_deal
; I've got the same problem …).
– current_user
Aug 28 '18 at 13:49
add a comment |
1
Instead of usingphantoma
in empty cells, you could addnodes in empty cells
to the matrix options, and you could consider using amatrix of math nodes
instead of amatrix of nodes
. Good use offit
!
– Max
Aug 28 '18 at 5:22
1
Well those "tips" weren't very helpful, were they? Sorry for my ignorance.
– Max
Aug 28 '18 at 9:42
@Max: Thank you for your tips, I really appreciate them, but since I'm not working with TeXStudio anymore, I have to use TeXmaker now and I'm not very into it (seethe_real_deal
; I've got the same problem …).
– current_user
Aug 28 '18 at 13:49
1
1
Instead of using
phantoma
in empty cells, you could add nodes in empty cells
to the matrix options, and you could consider using a matrix of math nodes
instead of a matrix of nodes
. Good use of fit
!– Max
Aug 28 '18 at 5:22
Instead of using
phantoma
in empty cells, you could add nodes in empty cells
to the matrix options, and you could consider using a matrix of math nodes
instead of a matrix of nodes
. Good use of fit
!– Max
Aug 28 '18 at 5:22
1
1
Well those "tips" weren't very helpful, were they? Sorry for my ignorance.
– Max
Aug 28 '18 at 9:42
Well those "tips" weren't very helpful, were they? Sorry for my ignorance.
– Max
Aug 28 '18 at 9:42
@Max: Thank you for your tips, I really appreciate them, but since I'm not working with TeXStudio anymore, I have to use TeXmaker now and I'm not very into it (see
the_real_deal
; I've got the same problem …).– current_user
Aug 28 '18 at 13:49
@Max: Thank you for your tips, I really appreciate them, but since I'm not working with TeXStudio anymore, I have to use TeXmaker now and I'm not very into it (see
the_real_deal
; I've got the same problem …).– current_user
Aug 28 '18 at 13:49
add a comment |
This is actually an addition to the answer of current_user, because I placed a comment with some "tips" but after actually trying them myself they actually made placing the lines of the matrix harder.
The problem that I ran into was that I wanted to use the actual width of the column, and the actual height of the row to place the lines, but you still want to use the minimum size of the nodes for fit
ting nodes around them. To fix this, I added a new matrix style fixed matrix
that places a fixed size node in the background of the cell, that sets the height of the row and the width of the column, and placing an additional node with the real contents on top of it (that should be smaller than the desired dimensions, otherwise it still wouldn't work). These nodes are named <matrix name>-<row num>-<column num>-o
and <matrix name>-<row num>-<column num>-i
where o
and i
denote outer and inner respectively.
With this I can easily draw the following:
With only this code:
begintikzpicture[>=latex]
matrix [fixed matrix] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
Some additional functions are:
- The
fixed matrix
style accepts an argument that can be used to:- set the style for the inner nodes with
inner nodes=<style>
- set the style of the outer nodes with
outer nodes=<style>
- set the row height with
row height=<dimension>
(default is10mm
) - set the column width with
column width=<dimension>
(default is10mm
)
- set the style for the inner nodes with
Small downside, if you name the matrix
before calling the fixed matrix
style, you cannot refer to the individual nodes with your custom matrix name, but the default m
is used as matrix name.
When changing the fixed matrix
call in the previous code snippet to fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue
you can obtain the following image (just an example, definitely not a proposed improvement):
Complete code (many many thanks to current_user for his start on this):
documentclass[border=2mm,tikz]standalone
usetikzlibraryfit
tikzset
fixed matrix/.cd,
row height/.initial=10mm,
column width/.initial=10mm,
name/.initial=m,
inner node style/.style=,
outer node style/.style=,
inner nodes/.code=tikzsetfixed matrix/inner node style/.style=#1,
outer nodes/.code=tikzsetfixed matrix/outer node style/.style=#1,
tikzset
fixed matrix/.style=
inner sep=0pt,
nodes=inner sep=0.333em,
name/.forward to=/tikz/fixed matrix/name,
execute at begin cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);
node[fixed matrix/inner node style] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-i) bgroup,
execute at end cell=egroup;,
execute at empty cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);,
,
fixed matrix/.append code=tikzsetfixed matrix/.cd,#1,
begindocument
begintikzpicture[>=latex]
matrix [fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
enddocument
your code it's awesome. I should also mark your answer as accepted, but I can only mark one of them.
– Luo Kaisa
Aug 28 '18 at 20:55
add a comment |
This is actually an addition to the answer of current_user, because I placed a comment with some "tips" but after actually trying them myself they actually made placing the lines of the matrix harder.
The problem that I ran into was that I wanted to use the actual width of the column, and the actual height of the row to place the lines, but you still want to use the minimum size of the nodes for fit
ting nodes around them. To fix this, I added a new matrix style fixed matrix
that places a fixed size node in the background of the cell, that sets the height of the row and the width of the column, and placing an additional node with the real contents on top of it (that should be smaller than the desired dimensions, otherwise it still wouldn't work). These nodes are named <matrix name>-<row num>-<column num>-o
and <matrix name>-<row num>-<column num>-i
where o
and i
denote outer and inner respectively.
With this I can easily draw the following:
With only this code:
begintikzpicture[>=latex]
matrix [fixed matrix] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
Some additional functions are:
- The
fixed matrix
style accepts an argument that can be used to:- set the style for the inner nodes with
inner nodes=<style>
- set the style of the outer nodes with
outer nodes=<style>
- set the row height with
row height=<dimension>
(default is10mm
) - set the column width with
column width=<dimension>
(default is10mm
)
- set the style for the inner nodes with
Small downside, if you name the matrix
before calling the fixed matrix
style, you cannot refer to the individual nodes with your custom matrix name, but the default m
is used as matrix name.
When changing the fixed matrix
call in the previous code snippet to fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue
you can obtain the following image (just an example, definitely not a proposed improvement):
Complete code (many many thanks to current_user for his start on this):
documentclass[border=2mm,tikz]standalone
usetikzlibraryfit
tikzset
fixed matrix/.cd,
row height/.initial=10mm,
column width/.initial=10mm,
name/.initial=m,
inner node style/.style=,
outer node style/.style=,
inner nodes/.code=tikzsetfixed matrix/inner node style/.style=#1,
outer nodes/.code=tikzsetfixed matrix/outer node style/.style=#1,
tikzset
fixed matrix/.style=
inner sep=0pt,
nodes=inner sep=0.333em,
name/.forward to=/tikz/fixed matrix/name,
execute at begin cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);
node[fixed matrix/inner node style] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-i) bgroup,
execute at end cell=egroup;,
execute at empty cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);,
,
fixed matrix/.append code=tikzsetfixed matrix/.cd,#1,
begindocument
begintikzpicture[>=latex]
matrix [fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
enddocument
your code it's awesome. I should also mark your answer as accepted, but I can only mark one of them.
– Luo Kaisa
Aug 28 '18 at 20:55
add a comment |
This is actually an addition to the answer of current_user, because I placed a comment with some "tips" but after actually trying them myself they actually made placing the lines of the matrix harder.
The problem that I ran into was that I wanted to use the actual width of the column, and the actual height of the row to place the lines, but you still want to use the minimum size of the nodes for fit
ting nodes around them. To fix this, I added a new matrix style fixed matrix
that places a fixed size node in the background of the cell, that sets the height of the row and the width of the column, and placing an additional node with the real contents on top of it (that should be smaller than the desired dimensions, otherwise it still wouldn't work). These nodes are named <matrix name>-<row num>-<column num>-o
and <matrix name>-<row num>-<column num>-i
where o
and i
denote outer and inner respectively.
With this I can easily draw the following:
With only this code:
begintikzpicture[>=latex]
matrix [fixed matrix] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
Some additional functions are:
- The
fixed matrix
style accepts an argument that can be used to:- set the style for the inner nodes with
inner nodes=<style>
- set the style of the outer nodes with
outer nodes=<style>
- set the row height with
row height=<dimension>
(default is10mm
) - set the column width with
column width=<dimension>
(default is10mm
)
- set the style for the inner nodes with
Small downside, if you name the matrix
before calling the fixed matrix
style, you cannot refer to the individual nodes with your custom matrix name, but the default m
is used as matrix name.
When changing the fixed matrix
call in the previous code snippet to fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue
you can obtain the following image (just an example, definitely not a proposed improvement):
Complete code (many many thanks to current_user for his start on this):
documentclass[border=2mm,tikz]standalone
usetikzlibraryfit
tikzset
fixed matrix/.cd,
row height/.initial=10mm,
column width/.initial=10mm,
name/.initial=m,
inner node style/.style=,
outer node style/.style=,
inner nodes/.code=tikzsetfixed matrix/inner node style/.style=#1,
outer nodes/.code=tikzsetfixed matrix/outer node style/.style=#1,
tikzset
fixed matrix/.style=
inner sep=0pt,
nodes=inner sep=0.333em,
name/.forward to=/tikz/fixed matrix/name,
execute at begin cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);
node[fixed matrix/inner node style] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-i) bgroup,
execute at end cell=egroup;,
execute at empty cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);,
,
fixed matrix/.append code=tikzsetfixed matrix/.cd,#1,
begindocument
begintikzpicture[>=latex]
matrix [fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
enddocument
This is actually an addition to the answer of current_user, because I placed a comment with some "tips" but after actually trying them myself they actually made placing the lines of the matrix harder.
The problem that I ran into was that I wanted to use the actual width of the column, and the actual height of the row to place the lines, but you still want to use the minimum size of the nodes for fit
ting nodes around them. To fix this, I added a new matrix style fixed matrix
that places a fixed size node in the background of the cell, that sets the height of the row and the width of the column, and placing an additional node with the real contents on top of it (that should be smaller than the desired dimensions, otherwise it still wouldn't work). These nodes are named <matrix name>-<row num>-<column num>-o
and <matrix name>-<row num>-<column num>-i
where o
and i
denote outer and inner respectively.
With this I can easily draw the following:
With only this code:
begintikzpicture[>=latex]
matrix [fixed matrix] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
Some additional functions are:
- The
fixed matrix
style accepts an argument that can be used to:- set the style for the inner nodes with
inner nodes=<style>
- set the style of the outer nodes with
outer nodes=<style>
- set the row height with
row height=<dimension>
(default is10mm
) - set the column width with
column width=<dimension>
(default is10mm
)
- set the style for the inner nodes with
Small downside, if you name the matrix
before calling the fixed matrix
style, you cannot refer to the individual nodes with your custom matrix name, but the default m
is used as matrix name.
When changing the fixed matrix
call in the previous code snippet to fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue
you can obtain the following image (just an example, definitely not a proposed improvement):
Complete code (many many thanks to current_user for his start on this):
documentclass[border=2mm,tikz]standalone
usetikzlibraryfit
tikzset
fixed matrix/.cd,
row height/.initial=10mm,
column width/.initial=10mm,
name/.initial=m,
inner node style/.style=,
outer node style/.style=,
inner nodes/.code=tikzsetfixed matrix/inner node style/.style=#1,
outer nodes/.code=tikzsetfixed matrix/outer node style/.style=#1,
tikzset
fixed matrix/.style=
inner sep=0pt,
nodes=inner sep=0.333em,
name/.forward to=/tikz/fixed matrix/name,
execute at begin cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);
node[fixed matrix/inner node style] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-i) bgroup,
execute at end cell=egroup;,
execute at empty cell=
node[
inner sep=0pt,
minimum width=pgfkeysvalueof/tikz/fixed matrix/column width,
minimum height=pgfkeysvalueof/tikz/fixed matrix/row height,
fixed matrix/outer node style,
] (pgfkeysvalueof/tikz/fixed matrix/name-thepgfmatrixcurrentrow-thepgfmatrixcurrentcolumn-o);,
,
fixed matrix/.append code=tikzsetfixed matrix/.cd,#1,
begindocument
begintikzpicture[>=latex]
matrix [fixed matrix=row height=8mm,column width=8mm,inner nodes=draw=green,line width=1pt,outer nodes=dashed,draw=blue] (l)
3 & 9 & 0 & 2 & 6 & -8 \
-1 & & -3 & 6 & & \
2 & & & -1 & -2 & \
& & & & -3 & 6 \
& 3 & -1 & 3 & 1 & -2 \
& $x^2$ & $x$ & T.I & $x$ & T.I \
;
draw (l-1-1-o.north east) -- (l-6-1-o.south east);
draw[dashed] (l-1-5-o.north east) -- (l-6-5-o.south east);
draw (l-1-1-o.south west) -- (l-1-6-o.south east);
draw (l-4-1-o.south west) -- (l-4-6-o.south east);
node[fit=(l-1-2-i),draw,circle,inner sep=1pt] (a) ;
node[draw,fit=(l-1-3-i)(l-2-3-i)] (b) ;
node[draw,fit=(l-1-4-i)(l-3-4-i)] (c) ;
draw[->] (a.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (b.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
draw[->] (c.south) --++ (0,-0.6) node[right]$ div $ --+ (-0.4,0.4);
endtikzpicture
enddocument
answered Aug 28 '18 at 9:42
MaxMax
6,70321930
6,70321930
your code it's awesome. I should also mark your answer as accepted, but I can only mark one of them.
– Luo Kaisa
Aug 28 '18 at 20:55
add a comment |
your code it's awesome. I should also mark your answer as accepted, but I can only mark one of them.
– Luo Kaisa
Aug 28 '18 at 20:55
your code it's awesome. I should also mark your answer as accepted, but I can only mark one of them.
– Luo Kaisa
Aug 28 '18 at 20:55
your code it's awesome. I should also mark your answer as accepted, but I can only mark one of them.
– Luo Kaisa
Aug 28 '18 at 20:55
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f448087%2fhorners-method-for-polynomial-long-division%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
This seems like a job for
tikz
to me.– Derek
Aug 28 '18 at 1:13