Reconstructing a polynomial from its coefficient array
Clash Royale CLAN TAG#URR8PPP
$begingroup$
A polynomial coefficient matrix:
mat =
CoefficientList[3 + 5 x^3 + 4 y^3 + 2 x + 6 x^2 y + 7 x y^2 + 8 x y, x, y];
beginequation
left(
beginarraycccc
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
endarray
right)
endequation
Another matrix:
list =
a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1,o1, p1;
whose matrix form is:
beginequation
left(
beginarraycccc
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
endarray
right)
endequation
How can I generate the following polynomial automatically?
$texta1+textd1 y^3+texte1 x+textf1 x y+textg1 x y^2+textj1 x^2 y+textm1 x^3$
list-manipulation algebraic-manipulation
$endgroup$
|
show 1 more comment
$begingroup$
A polynomial coefficient matrix:
mat =
CoefficientList[3 + 5 x^3 + 4 y^3 + 2 x + 6 x^2 y + 7 x y^2 + 8 x y, x, y];
beginequation
left(
beginarraycccc
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
endarray
right)
endequation
Another matrix:
list =
a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1,o1, p1;
whose matrix form is:
beginequation
left(
beginarraycccc
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
endarray
right)
endequation
How can I generate the following polynomial automatically?
$texta1+textd1 y^3+texte1 x+textf1 x y+textg1 x y^2+textj1 x^2 y+textm1 x^3$
list-manipulation algebraic-manipulation
$endgroup$
1
$begingroup$
Why are some entries of the matrix ignored? Maybe this, if that is a mistake:a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1.y^Range[0, 3].x^Range[0, 3]
$endgroup$
– Michael E2
Jan 13 at 0:41
$begingroup$
There's an example in the docs forCoefficientList
for how to recover the polynomial from the matrix: Look forFold[FromDigits[Reverse[#1], #2] &, %, x, y]
.
$endgroup$
– Michael E2
Jan 13 at 0:42
$begingroup$
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
$endgroup$
– Chandan Sharma
Jan 13 at 0:48
1
$begingroup$
Do you meanFold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, x, y]
?
$endgroup$
– Michael E2
Jan 13 at 1:43
$begingroup$
@MichaelE2 Exactly.
$endgroup$
– Chandan Sharma
Jan 13 at 1:53
|
show 1 more comment
$begingroup$
A polynomial coefficient matrix:
mat =
CoefficientList[3 + 5 x^3 + 4 y^3 + 2 x + 6 x^2 y + 7 x y^2 + 8 x y, x, y];
beginequation
left(
beginarraycccc
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
endarray
right)
endequation
Another matrix:
list =
a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1,o1, p1;
whose matrix form is:
beginequation
left(
beginarraycccc
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
endarray
right)
endequation
How can I generate the following polynomial automatically?
$texta1+textd1 y^3+texte1 x+textf1 x y+textg1 x y^2+textj1 x^2 y+textm1 x^3$
list-manipulation algebraic-manipulation
$endgroup$
A polynomial coefficient matrix:
mat =
CoefficientList[3 + 5 x^3 + 4 y^3 + 2 x + 6 x^2 y + 7 x y^2 + 8 x y, x, y];
beginequation
left(
beginarraycccc
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
endarray
right)
endequation
Another matrix:
list =
a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1,o1, p1;
whose matrix form is:
beginequation
left(
beginarraycccc
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
endarray
right)
endequation
How can I generate the following polynomial automatically?
$texta1+textd1 y^3+texte1 x+textf1 x y+textg1 x y^2+textj1 x^2 y+textm1 x^3$
list-manipulation algebraic-manipulation
list-manipulation algebraic-manipulation
edited Jan 13 at 1:25
m_goldberg
85.3k872196
85.3k872196
asked Jan 13 at 0:38
Chandan SharmaChandan Sharma
1246
1246
1
$begingroup$
Why are some entries of the matrix ignored? Maybe this, if that is a mistake:a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1.y^Range[0, 3].x^Range[0, 3]
$endgroup$
– Michael E2
Jan 13 at 0:41
$begingroup$
There's an example in the docs forCoefficientList
for how to recover the polynomial from the matrix: Look forFold[FromDigits[Reverse[#1], #2] &, %, x, y]
.
$endgroup$
– Michael E2
Jan 13 at 0:42
$begingroup$
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
$endgroup$
– Chandan Sharma
Jan 13 at 0:48
1
$begingroup$
Do you meanFold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, x, y]
?
$endgroup$
– Michael E2
Jan 13 at 1:43
$begingroup$
@MichaelE2 Exactly.
$endgroup$
– Chandan Sharma
Jan 13 at 1:53
|
show 1 more comment
1
$begingroup$
Why are some entries of the matrix ignored? Maybe this, if that is a mistake:a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1.y^Range[0, 3].x^Range[0, 3]
$endgroup$
– Michael E2
Jan 13 at 0:41
$begingroup$
There's an example in the docs forCoefficientList
for how to recover the polynomial from the matrix: Look forFold[FromDigits[Reverse[#1], #2] &, %, x, y]
.
$endgroup$
– Michael E2
Jan 13 at 0:42
$begingroup$
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
$endgroup$
– Chandan Sharma
Jan 13 at 0:48
1
$begingroup$
Do you meanFold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, x, y]
?
$endgroup$
– Michael E2
Jan 13 at 1:43
$begingroup$
@MichaelE2 Exactly.
$endgroup$
– Chandan Sharma
Jan 13 at 1:53
1
1
$begingroup$
Why are some entries of the matrix ignored? Maybe this, if that is a mistake:
a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1.y^Range[0, 3].x^Range[0, 3]
$endgroup$
– Michael E2
Jan 13 at 0:41
$begingroup$
Why are some entries of the matrix ignored? Maybe this, if that is a mistake:
a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1.y^Range[0, 3].x^Range[0, 3]
$endgroup$
– Michael E2
Jan 13 at 0:41
$begingroup$
There's an example in the docs for
CoefficientList
for how to recover the polynomial from the matrix: Look for Fold[FromDigits[Reverse[#1], #2] &, %, x, y]
.$endgroup$
– Michael E2
Jan 13 at 0:42
$begingroup$
There's an example in the docs for
CoefficientList
for how to recover the polynomial from the matrix: Look for Fold[FromDigits[Reverse[#1], #2] &, %, x, y]
.$endgroup$
– Michael E2
Jan 13 at 0:42
$begingroup$
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
$endgroup$
– Chandan Sharma
Jan 13 at 0:48
$begingroup$
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
$endgroup$
– Chandan Sharma
Jan 13 at 0:48
1
1
$begingroup$
Do you mean
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, x, y]
?$endgroup$
– Michael E2
Jan 13 at 1:43
$begingroup$
Do you mean
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, x, y]
?$endgroup$
– Michael E2
Jan 13 at 1:43
$begingroup$
@MichaelE2 Exactly.
$endgroup$
– Chandan Sharma
Jan 13 at 1:53
$begingroup$
@MichaelE2 Exactly.
$endgroup$
– Chandan Sharma
Jan 13 at 1:53
|
show 1 more comment
5 Answers
5
active
oldest
votes
$begingroup$
Using mat
as the template:
Plus @@ Flatten[Table[If[mat[[i, j]] == 0, 0, list[[i, j]] x^(i - 1) y^(j - 1)],
i, 1, 4, j, 1, 4]]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
add a comment |
$begingroup$
Internal`FromCoefficientList[mat, x, y]
3 + 2 x + 5 x^3 + 8 x y + 6 x^2 y + 7 x y^2 + 4 y^3
Internal`FromCoefficientList[list Unitize[mat], x, y]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
add a comment |
$begingroup$
Adapting an example from the documentation for CoefficientList
:
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat*list, x, y]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
add a comment |
$begingroup$
Terse:
Total[Array[x^# y^#2 &, 4, 4, 0] list Unitize@mat, 2]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
add a comment |
$begingroup$
You will have to tell Mathematica where the zero coefficients are, but if you do that it can be done like so:
list = a1, 0, 0, d1, e1, f1, g1, 0, 0, 0, 0, l1, m1, 0, 0, 0;
Fold[FromDigits[Reverse[#1], #2] &, list, x, y] // Expand
a1 + e1 x + m1 x^3 + f1 x y + g1 x y^2 + d1 y^3 + l1 x^2 y^3
This is discussed in the documentation of CoefficientList
in the section Properties & Relations.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
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%2fmathematica.stackexchange.com%2fquestions%2f189379%2freconstructing-a-polynomial-from-its-coefficient-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Using mat
as the template:
Plus @@ Flatten[Table[If[mat[[i, j]] == 0, 0, list[[i, j]] x^(i - 1) y^(j - 1)],
i, 1, 4, j, 1, 4]]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
add a comment |
$begingroup$
Using mat
as the template:
Plus @@ Flatten[Table[If[mat[[i, j]] == 0, 0, list[[i, j]] x^(i - 1) y^(j - 1)],
i, 1, 4, j, 1, 4]]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
add a comment |
$begingroup$
Using mat
as the template:
Plus @@ Flatten[Table[If[mat[[i, j]] == 0, 0, list[[i, j]] x^(i - 1) y^(j - 1)],
i, 1, 4, j, 1, 4]]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
Using mat
as the template:
Plus @@ Flatten[Table[If[mat[[i, j]] == 0, 0, list[[i, j]] x^(i - 1) y^(j - 1)],
i, 1, 4, j, 1, 4]]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
answered Jan 13 at 1:35
John DotyJohn Doty
6,7591924
6,7591924
add a comment |
add a comment |
$begingroup$
Internal`FromCoefficientList[mat, x, y]
3 + 2 x + 5 x^3 + 8 x y + 6 x^2 y + 7 x y^2 + 4 y^3
Internal`FromCoefficientList[list Unitize[mat], x, y]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
add a comment |
$begingroup$
Internal`FromCoefficientList[mat, x, y]
3 + 2 x + 5 x^3 + 8 x y + 6 x^2 y + 7 x y^2 + 4 y^3
Internal`FromCoefficientList[list Unitize[mat], x, y]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
add a comment |
$begingroup$
Internal`FromCoefficientList[mat, x, y]
3 + 2 x + 5 x^3 + 8 x y + 6 x^2 y + 7 x y^2 + 4 y^3
Internal`FromCoefficientList[list Unitize[mat], x, y]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
Internal`FromCoefficientList[mat, x, y]
3 + 2 x + 5 x^3 + 8 x y + 6 x^2 y + 7 x y^2 + 4 y^3
Internal`FromCoefficientList[list Unitize[mat], x, y]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
answered Jan 13 at 2:41
kglrkglr
181k10200413
181k10200413
add a comment |
add a comment |
$begingroup$
Adapting an example from the documentation for CoefficientList
:
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat*list, x, y]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
add a comment |
$begingroup$
Adapting an example from the documentation for CoefficientList
:
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat*list, x, y]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
add a comment |
$begingroup$
Adapting an example from the documentation for CoefficientList
:
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat*list, x, y]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
$endgroup$
Adapting an example from the documentation for CoefficientList
:
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat*list, x, y]
(* a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3 *)
answered Jan 13 at 2:08
Michael E2Michael E2
146k12197469
146k12197469
add a comment |
add a comment |
$begingroup$
Terse:
Total[Array[x^# y^#2 &, 4, 4, 0] list Unitize@mat, 2]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
add a comment |
$begingroup$
Terse:
Total[Array[x^# y^#2 &, 4, 4, 0] list Unitize@mat, 2]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
add a comment |
$begingroup$
Terse:
Total[Array[x^# y^#2 &, 4, 4, 0] list Unitize@mat, 2]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
$endgroup$
Terse:
Total[Array[x^# y^#2 &, 4, 4, 0] list Unitize@mat, 2]
a1 + e1 x + m1 x^3 + f1 x y + j1 x^2 y + g1 x y^2 + d1 y^3
answered Jan 13 at 4:21
Mr.Wizard♦Mr.Wizard
231k294751042
231k294751042
add a comment |
add a comment |
$begingroup$
You will have to tell Mathematica where the zero coefficients are, but if you do that it can be done like so:
list = a1, 0, 0, d1, e1, f1, g1, 0, 0, 0, 0, l1, m1, 0, 0, 0;
Fold[FromDigits[Reverse[#1], #2] &, list, x, y] // Expand
a1 + e1 x + m1 x^3 + f1 x y + g1 x y^2 + d1 y^3 + l1 x^2 y^3
This is discussed in the documentation of CoefficientList
in the section Properties & Relations.
$endgroup$
add a comment |
$begingroup$
You will have to tell Mathematica where the zero coefficients are, but if you do that it can be done like so:
list = a1, 0, 0, d1, e1, f1, g1, 0, 0, 0, 0, l1, m1, 0, 0, 0;
Fold[FromDigits[Reverse[#1], #2] &, list, x, y] // Expand
a1 + e1 x + m1 x^3 + f1 x y + g1 x y^2 + d1 y^3 + l1 x^2 y^3
This is discussed in the documentation of CoefficientList
in the section Properties & Relations.
$endgroup$
add a comment |
$begingroup$
You will have to tell Mathematica where the zero coefficients are, but if you do that it can be done like so:
list = a1, 0, 0, d1, e1, f1, g1, 0, 0, 0, 0, l1, m1, 0, 0, 0;
Fold[FromDigits[Reverse[#1], #2] &, list, x, y] // Expand
a1 + e1 x + m1 x^3 + f1 x y + g1 x y^2 + d1 y^3 + l1 x^2 y^3
This is discussed in the documentation of CoefficientList
in the section Properties & Relations.
$endgroup$
You will have to tell Mathematica where the zero coefficients are, but if you do that it can be done like so:
list = a1, 0, 0, d1, e1, f1, g1, 0, 0, 0, 0, l1, m1, 0, 0, 0;
Fold[FromDigits[Reverse[#1], #2] &, list, x, y] // Expand
a1 + e1 x + m1 x^3 + f1 x y + g1 x y^2 + d1 y^3 + l1 x^2 y^3
This is discussed in the documentation of CoefficientList
in the section Properties & Relations.
answered Jan 13 at 1:14
m_goldbergm_goldberg
85.3k872196
85.3k872196
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica 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.
Use MathJax to format equations. MathJax reference.
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%2fmathematica.stackexchange.com%2fquestions%2f189379%2freconstructing-a-polynomial-from-its-coefficient-array%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
1
$begingroup$
Why are some entries of the matrix ignored? Maybe this, if that is a mistake:
a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1.y^Range[0, 3].x^Range[0, 3]
$endgroup$
– Michael E2
Jan 13 at 0:41
$begingroup$
There's an example in the docs for
CoefficientList
for how to recover the polynomial from the matrix: Look forFold[FromDigits[Reverse[#1], #2] &, %, x, y]
.$endgroup$
– Michael E2
Jan 13 at 0:42
$begingroup$
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
$endgroup$
– Chandan Sharma
Jan 13 at 0:48
1
$begingroup$
Do you mean
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, x, y]
?$endgroup$
– Michael E2
Jan 13 at 1:43
$begingroup$
@MichaelE2 Exactly.
$endgroup$
– Chandan Sharma
Jan 13 at 1:53