Reconstructing a polynomial from its coefficient array
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}];
begin{equation}
left(
begin{array}{cccc}
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
end{array}
right)
end{equation}
Another matrix:
list =
{{a1, b1, c1, d1}, {e1, f1, g1, h1}, {i1, j1, k1, l1}, {m1, n1,o1, p1}};
whose matrix form is:
begin{equation}
left(
begin{array}{cccc}
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
end{array}
right)
end{equation}
How can I generate the following polynomial automatically?
$text{a1}+text{d1} y^3+text{e1} x+text{f1} x y+text{g1} x y^2+text{j1} x^2 y+text{m1} x^3$
list-manipulation algebraic-manipulation
add a comment |
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}];
begin{equation}
left(
begin{array}{cccc}
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
end{array}
right)
end{equation}
Another matrix:
list =
{{a1, b1, c1, d1}, {e1, f1, g1, h1}, {i1, j1, k1, l1}, {m1, n1,o1, p1}};
whose matrix form is:
begin{equation}
left(
begin{array}{cccc}
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
end{array}
right)
end{equation}
How can I generate the following polynomial automatically?
$text{a1}+text{d1} y^3+text{e1} x+text{f1} x y+text{g1} x y^2+text{j1} x^2 y+text{m1} x^3$
list-manipulation algebraic-manipulation
1
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]
– Michael E2
2 hours ago
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}]
.
– Michael E2
2 hours ago
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
– Chandan Sharma
2 hours ago
1
Do you meanFold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, {x, y}]
?
– Michael E2
1 hour ago
@MichaelE2 Exactly.
– Chandan Sharma
1 hour ago
add a comment |
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}];
begin{equation}
left(
begin{array}{cccc}
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
end{array}
right)
end{equation}
Another matrix:
list =
{{a1, b1, c1, d1}, {e1, f1, g1, h1}, {i1, j1, k1, l1}, {m1, n1,o1, p1}};
whose matrix form is:
begin{equation}
left(
begin{array}{cccc}
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
end{array}
right)
end{equation}
How can I generate the following polynomial automatically?
$text{a1}+text{d1} y^3+text{e1} x+text{f1} x y+text{g1} x y^2+text{j1} x^2 y+text{m1} x^3$
list-manipulation algebraic-manipulation
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}];
begin{equation}
left(
begin{array}{cccc}
3 & 0 & 0 & 4 \
2 & 8 & 7 & 0 \
0 & 6 & 0 & 0 \
5 & 0 & 0 & 0 \
end{array}
right)
end{equation}
Another matrix:
list =
{{a1, b1, c1, d1}, {e1, f1, g1, h1}, {i1, j1, k1, l1}, {m1, n1,o1, p1}};
whose matrix form is:
begin{equation}
left(
begin{array}{cccc}
a1 & b1 & c1 & d1 \
e1 & f1 & g1 & h1 \
i1 & j1 & k1 & l1 \
m1 & n1 & o1 & p1 \
end{array}
right)
end{equation}
How can I generate the following polynomial automatically?
$text{a1}+text{d1} y^3+text{e1} x+text{f1} x y+text{g1} x y^2+text{j1} x^2 y+text{m1} x^3$
list-manipulation algebraic-manipulation
list-manipulation algebraic-manipulation
edited 1 hour ago
m_goldberg
84.5k872196
84.5k872196
asked 2 hours ago
Chandan SharmaChandan Sharma
1075
1075
1
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]
– Michael E2
2 hours ago
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}]
.
– Michael E2
2 hours ago
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
– Chandan Sharma
2 hours ago
1
Do you meanFold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, {x, y}]
?
– Michael E2
1 hour ago
@MichaelE2 Exactly.
– Chandan Sharma
1 hour ago
add a comment |
1
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]
– Michael E2
2 hours ago
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}]
.
– Michael E2
2 hours ago
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
– Chandan Sharma
2 hours ago
1
Do you meanFold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, {x, y}]
?
– Michael E2
1 hour ago
@MichaelE2 Exactly.
– Chandan Sharma
1 hour ago
1
1
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]
– Michael E2
2 hours ago
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]
– Michael E2
2 hours ago
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}]
.– Michael E2
2 hours ago
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}]
.– Michael E2
2 hours ago
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
– Chandan Sharma
2 hours ago
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
– Chandan Sharma
2 hours ago
1
1
Do you mean
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, {x, y}]
?– Michael E2
1 hour ago
Do you mean
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, {x, y}]
?– Michael E2
1 hour ago
@MichaelE2 Exactly.
– Chandan Sharma
1 hour ago
@MichaelE2 Exactly.
– Chandan Sharma
1 hour ago
add a comment |
4 Answers
4
active
oldest
votes
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 *)
add a comment |
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.
add a comment |
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 *)
add a comment |
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
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
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 *)
add a comment |
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 *)
add a comment |
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 *)
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 1 hour ago
John DotyJohn Doty
6,6641924
6,6641924
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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 1 hour ago
m_goldbergm_goldberg
84.5k872196
84.5k872196
add a comment |
add a comment |
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 *)
add a comment |
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 *)
add a comment |
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 *)
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 55 mins ago
Michael E2Michael E2
146k11195466
146k11195466
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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 21 mins ago
kglrkglr
178k9198409
178k9198409
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
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]
– Michael E2
2 hours ago
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}]
.– Michael E2
2 hours ago
@MichaelE2 I am ignoring only those entries for which the constant is zero as in coefficientlist matrix.
– Chandan Sharma
2 hours ago
1
Do you mean
Fold[FromDigits[Reverse[#1], #2] &, Unitize@mat * list, {x, y}]
?– Michael E2
1 hour ago
@MichaelE2 Exactly.
– Chandan Sharma
1 hour ago