Reconstructing a polynomial from its coefficient array












1















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$










share|improve this question




















  • 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
    3 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






  • 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
















1















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$










share|improve this question




















  • 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
    3 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






  • 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














1












1








1








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$










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago









m_goldberg

84.5k872196




84.5k872196










asked 3 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
    3 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






  • 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














  • 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
    3 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






  • 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








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
3 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
3 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










4 Answers
4






active

oldest

votes


















1














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 *)





share|improve this answer































    2














    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 *)





    share|improve this answer































      1














      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.






      share|improve this answer































        1














        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







        share|improve this answer























          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          1














          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 *)





          share|improve this answer




























            1














            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 *)





            share|improve this answer


























              1












              1








              1







              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 *)





              share|improve this answer













              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 *)






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 2 hours ago









              John DotyJohn Doty

              6,6641924




              6,6641924























                  2














                  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 *)





                  share|improve this answer




























                    2














                    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 *)





                    share|improve this answer


























                      2












                      2








                      2







                      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 *)





                      share|improve this answer













                      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 *)






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 1 hour ago









                      Michael E2Michael E2

                      146k11195466




                      146k11195466























                          1














                          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.






                          share|improve this answer




























                            1














                            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.






                            share|improve this answer


























                              1












                              1








                              1







                              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.






                              share|improve this answer













                              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.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 2 hours ago









                              m_goldbergm_goldberg

                              84.5k872196




                              84.5k872196























                                  1














                                  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







                                  share|improve this answer




























                                    1














                                    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







                                    share|improve this answer


























                                      1












                                      1








                                      1







                                      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







                                      share|improve this answer













                                      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








                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 1 hour ago









                                      kglrkglr

                                      178k9198409




                                      178k9198409






























                                          draft saved

                                          draft discarded




















































                                          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.




                                          draft saved


                                          draft discarded














                                          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





















































                                          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







                                          Popular posts from this blog

                                          Eastern Orthodox Church

                                          Zagreb

                                          Understanding the information contained in the Deep Space Network XML data?