How to substitute values from a list into a function?












3












$begingroup$


I was hoping to take pairs of numbers from a list and substitute them into a function. So if my list was



list = {{1,2}, {3,4}, {5,6}}


and my function was



function = a x^b


The output I'm hoping to get is



result =1x^2 + 3x^4 + 5x^6


How would I best do this?










share|improve this question







New contributor




Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    #1 x^#2 & @@@ {{1, 2}, {3, 4}, {5, 6}} // Total
    $endgroup$
    – Okkes Dulgerci
    20 mins ago
















3












$begingroup$


I was hoping to take pairs of numbers from a list and substitute them into a function. So if my list was



list = {{1,2}, {3,4}, {5,6}}


and my function was



function = a x^b


The output I'm hoping to get is



result =1x^2 + 3x^4 + 5x^6


How would I best do this?










share|improve this question







New contributor




Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    #1 x^#2 & @@@ {{1, 2}, {3, 4}, {5, 6}} // Total
    $endgroup$
    – Okkes Dulgerci
    20 mins ago














3












3








3





$begingroup$


I was hoping to take pairs of numbers from a list and substitute them into a function. So if my list was



list = {{1,2}, {3,4}, {5,6}}


and my function was



function = a x^b


The output I'm hoping to get is



result =1x^2 + 3x^4 + 5x^6


How would I best do this?










share|improve this question







New contributor




Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I was hoping to take pairs of numbers from a list and substitute them into a function. So if my list was



list = {{1,2}, {3,4}, {5,6}}


and my function was



function = a x^b


The output I'm hoping to get is



result =1x^2 + 3x^4 + 5x^6


How would I best do this?







list-manipulation functions






share|improve this question







New contributor




Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 1 hour ago









PineapplePineapple

161




161




New contributor




Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Pineapple is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • $begingroup$
    #1 x^#2 & @@@ {{1, 2}, {3, 4}, {5, 6}} // Total
    $endgroup$
    – Okkes Dulgerci
    20 mins ago


















  • $begingroup$
    #1 x^#2 & @@@ {{1, 2}, {3, 4}, {5, 6}} // Total
    $endgroup$
    – Okkes Dulgerci
    20 mins ago
















$begingroup$
#1 x^#2 & @@@ {{1, 2}, {3, 4}, {5, 6}} // Total
$endgroup$
– Okkes Dulgerci
20 mins ago




$begingroup$
#1 x^#2 & @@@ {{1, 2}, {3, 4}, {5, 6}} // Total
$endgroup$
– Okkes Dulgerci
20 mins ago










6 Answers
6






active

oldest

votes


















3












$begingroup$

This is not a Function:



function = a x^b


But this is:



function = {a,b} [Function] a x^b


You can Apply it to each element of



list = {{1,2}, {3,4}, {5,6}}


with



function @@@ list 



{x^3, 3 x^5, 5 x^7}




and sum it up with Total:



Total[ function @@@ list ]



x^3 + 3 x^5 + 5 x^7







share|improve this answer









$endgroup$













  • $begingroup$
    Why would you do 'function = {a,b} [Function] a x^b' instead of function[a_, b_, x_] = a*x^b?
    $endgroup$
    – Pineapple
    1 hour ago










  • $begingroup$
    Because [Function] is easily entered with the escape sequence esc f n esc . Also Function defines a pure function while function[a_, b_, x_] = a*x^b defines a replacement rule. However, they act the same way - most of the time. So it is a matter of taste.
    $endgroup$
    – Henrik Schumacher
    1 hour ago












  • $begingroup$
    @Pineapple Take a look at this tutorial on Defining Functions. Another good resource is the tutorial on Immediate and Delayed Definitions for the difference between Set (=) and SetDelayed (:=).
    $endgroup$
    – MarcoB
    1 hour ago





















2












$begingroup$

Total[#*x^#2&@@@list]



x^2 + 3 x^4 + 5 x^6







share|improve this answer









$endgroup$





















    1












    $begingroup$

    Total[(#[[1]] x^#[[2]]) & /@ list]





    share|improve this answer









    $endgroup$













    • $begingroup$
      Amazing, thank you! Sorry - I'm very new to Mathematica.
      $endgroup$
      – Pineapple
      1 hour ago



















    0












    $begingroup$

    Another way, perhaps easier on the eyes. Use a pattern to deconstruct the pairs in a function definition.



    term[{a_, b_}] := a x^b


    Then, Map it to the list.



    Total[term /@ list]
    (* x^2 + 3 x^4 + 5 x^6 *)





    share|improve this answer









    $endgroup$





















      0












      $begingroup$

      Inner[#1 x^#2 &, Sequence @@ Transpose@list, Plus]



      x^2 + 3 x^4 + 5 x^6




      One could expand this a bit to allow for different variables:



      Clear[f]
      f[coefflist_][var_] := Inner[#1 var^#2 &, Sequence @@ Transpose@coefflist, Plus]


      so that



      f[list][x]



      x^2 + 3 x^4 + 5 x^6




      but then:



      f[list][t]



      t^2 + 3 t^4 + 5 t^6







      share|improve this answer











      $endgroup$





















        0












        $begingroup$

        ClearAll[fa, fb]
        fa = FromCoefficientRules[Thread[#[[All, 2;;]] -> #[[All, 1]]], #2] &;
        fb = Internal`FromCoefficientList[Normal@SparseArray[1 + #[[All, 2;;]]->#[[All, 1]]], #2] &;


        Examples:



        list1 = {{1, 2}, {3, 4}, {5, 6}};
        {fa[list1, x], fb[list1, x]}



        {x^2 + 3 x^4 + 5 x^6, x^2 + 3 x^4 + 5 x^6}




        list2 = {{1, 3, 0}, {3, 2, 1}, {3, 1, 2}, {1, 0, 3}};
        {fa[list2, {x, y}], fb[list2, {x, y}]}



        {x^3 + 3 x^2 y + 3 x y^2 + y^3, x^3 + 3 x^2 y + 3 x y^2 + y^3}







        share|improve this answer











        $endgroup$













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


          }
          });






          Pineapple is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192691%2fhow-to-substitute-values-from-a-list-into-a-function%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          6 Answers
          6






          active

          oldest

          votes








          6 Answers
          6






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3












          $begingroup$

          This is not a Function:



          function = a x^b


          But this is:



          function = {a,b} [Function] a x^b


          You can Apply it to each element of



          list = {{1,2}, {3,4}, {5,6}}


          with



          function @@@ list 



          {x^3, 3 x^5, 5 x^7}




          and sum it up with Total:



          Total[ function @@@ list ]



          x^3 + 3 x^5 + 5 x^7







          share|improve this answer









          $endgroup$













          • $begingroup$
            Why would you do 'function = {a,b} [Function] a x^b' instead of function[a_, b_, x_] = a*x^b?
            $endgroup$
            – Pineapple
            1 hour ago










          • $begingroup$
            Because [Function] is easily entered with the escape sequence esc f n esc . Also Function defines a pure function while function[a_, b_, x_] = a*x^b defines a replacement rule. However, they act the same way - most of the time. So it is a matter of taste.
            $endgroup$
            – Henrik Schumacher
            1 hour ago












          • $begingroup$
            @Pineapple Take a look at this tutorial on Defining Functions. Another good resource is the tutorial on Immediate and Delayed Definitions for the difference between Set (=) and SetDelayed (:=).
            $endgroup$
            – MarcoB
            1 hour ago


















          3












          $begingroup$

          This is not a Function:



          function = a x^b


          But this is:



          function = {a,b} [Function] a x^b


          You can Apply it to each element of



          list = {{1,2}, {3,4}, {5,6}}


          with



          function @@@ list 



          {x^3, 3 x^5, 5 x^7}




          and sum it up with Total:



          Total[ function @@@ list ]



          x^3 + 3 x^5 + 5 x^7







          share|improve this answer









          $endgroup$













          • $begingroup$
            Why would you do 'function = {a,b} [Function] a x^b' instead of function[a_, b_, x_] = a*x^b?
            $endgroup$
            – Pineapple
            1 hour ago










          • $begingroup$
            Because [Function] is easily entered with the escape sequence esc f n esc . Also Function defines a pure function while function[a_, b_, x_] = a*x^b defines a replacement rule. However, they act the same way - most of the time. So it is a matter of taste.
            $endgroup$
            – Henrik Schumacher
            1 hour ago












          • $begingroup$
            @Pineapple Take a look at this tutorial on Defining Functions. Another good resource is the tutorial on Immediate and Delayed Definitions for the difference between Set (=) and SetDelayed (:=).
            $endgroup$
            – MarcoB
            1 hour ago
















          3












          3








          3





          $begingroup$

          This is not a Function:



          function = a x^b


          But this is:



          function = {a,b} [Function] a x^b


          You can Apply it to each element of



          list = {{1,2}, {3,4}, {5,6}}


          with



          function @@@ list 



          {x^3, 3 x^5, 5 x^7}




          and sum it up with Total:



          Total[ function @@@ list ]



          x^3 + 3 x^5 + 5 x^7







          share|improve this answer









          $endgroup$



          This is not a Function:



          function = a x^b


          But this is:



          function = {a,b} [Function] a x^b


          You can Apply it to each element of



          list = {{1,2}, {3,4}, {5,6}}


          with



          function @@@ list 



          {x^3, 3 x^5, 5 x^7}




          and sum it up with Total:



          Total[ function @@@ list ]



          x^3 + 3 x^5 + 5 x^7








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Henrik SchumacherHenrik Schumacher

          55.4k576154




          55.4k576154












          • $begingroup$
            Why would you do 'function = {a,b} [Function] a x^b' instead of function[a_, b_, x_] = a*x^b?
            $endgroup$
            – Pineapple
            1 hour ago










          • $begingroup$
            Because [Function] is easily entered with the escape sequence esc f n esc . Also Function defines a pure function while function[a_, b_, x_] = a*x^b defines a replacement rule. However, they act the same way - most of the time. So it is a matter of taste.
            $endgroup$
            – Henrik Schumacher
            1 hour ago












          • $begingroup$
            @Pineapple Take a look at this tutorial on Defining Functions. Another good resource is the tutorial on Immediate and Delayed Definitions for the difference between Set (=) and SetDelayed (:=).
            $endgroup$
            – MarcoB
            1 hour ago




















          • $begingroup$
            Why would you do 'function = {a,b} [Function] a x^b' instead of function[a_, b_, x_] = a*x^b?
            $endgroup$
            – Pineapple
            1 hour ago










          • $begingroup$
            Because [Function] is easily entered with the escape sequence esc f n esc . Also Function defines a pure function while function[a_, b_, x_] = a*x^b defines a replacement rule. However, they act the same way - most of the time. So it is a matter of taste.
            $endgroup$
            – Henrik Schumacher
            1 hour ago












          • $begingroup$
            @Pineapple Take a look at this tutorial on Defining Functions. Another good resource is the tutorial on Immediate and Delayed Definitions for the difference between Set (=) and SetDelayed (:=).
            $endgroup$
            – MarcoB
            1 hour ago


















          $begingroup$
          Why would you do 'function = {a,b} [Function] a x^b' instead of function[a_, b_, x_] = a*x^b?
          $endgroup$
          – Pineapple
          1 hour ago




          $begingroup$
          Why would you do 'function = {a,b} [Function] a x^b' instead of function[a_, b_, x_] = a*x^b?
          $endgroup$
          – Pineapple
          1 hour ago












          $begingroup$
          Because [Function] is easily entered with the escape sequence esc f n esc . Also Function defines a pure function while function[a_, b_, x_] = a*x^b defines a replacement rule. However, they act the same way - most of the time. So it is a matter of taste.
          $endgroup$
          – Henrik Schumacher
          1 hour ago






          $begingroup$
          Because [Function] is easily entered with the escape sequence esc f n esc . Also Function defines a pure function while function[a_, b_, x_] = a*x^b defines a replacement rule. However, they act the same way - most of the time. So it is a matter of taste.
          $endgroup$
          – Henrik Schumacher
          1 hour ago














          $begingroup$
          @Pineapple Take a look at this tutorial on Defining Functions. Another good resource is the tutorial on Immediate and Delayed Definitions for the difference between Set (=) and SetDelayed (:=).
          $endgroup$
          – MarcoB
          1 hour ago






          $begingroup$
          @Pineapple Take a look at this tutorial on Defining Functions. Another good resource is the tutorial on Immediate and Delayed Definitions for the difference between Set (=) and SetDelayed (:=).
          $endgroup$
          – MarcoB
          1 hour ago













          2












          $begingroup$

          Total[#*x^#2&@@@list]



          x^2 + 3 x^4 + 5 x^6







          share|improve this answer









          $endgroup$


















            2












            $begingroup$

            Total[#*x^#2&@@@list]



            x^2 + 3 x^4 + 5 x^6







            share|improve this answer









            $endgroup$
















              2












              2








              2





              $begingroup$

              Total[#*x^#2&@@@list]



              x^2 + 3 x^4 + 5 x^6







              share|improve this answer









              $endgroup$



              Total[#*x^#2&@@@list]



              x^2 + 3 x^4 + 5 x^6








              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 1 hour ago









              J42161217J42161217

              3,935322




              3,935322























                  1












                  $begingroup$

                  Total[(#[[1]] x^#[[2]]) & /@ list]





                  share|improve this answer









                  $endgroup$













                  • $begingroup$
                    Amazing, thank you! Sorry - I'm very new to Mathematica.
                    $endgroup$
                    – Pineapple
                    1 hour ago
















                  1












                  $begingroup$

                  Total[(#[[1]] x^#[[2]]) & /@ list]





                  share|improve this answer









                  $endgroup$













                  • $begingroup$
                    Amazing, thank you! Sorry - I'm very new to Mathematica.
                    $endgroup$
                    – Pineapple
                    1 hour ago














                  1












                  1








                  1





                  $begingroup$

                  Total[(#[[1]] x^#[[2]]) & /@ list]





                  share|improve this answer









                  $endgroup$



                  Total[(#[[1]] x^#[[2]]) & /@ list]






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  David G. StorkDavid G. Stork

                  24.5k22153




                  24.5k22153












                  • $begingroup$
                    Amazing, thank you! Sorry - I'm very new to Mathematica.
                    $endgroup$
                    – Pineapple
                    1 hour ago


















                  • $begingroup$
                    Amazing, thank you! Sorry - I'm very new to Mathematica.
                    $endgroup$
                    – Pineapple
                    1 hour ago
















                  $begingroup$
                  Amazing, thank you! Sorry - I'm very new to Mathematica.
                  $endgroup$
                  – Pineapple
                  1 hour ago




                  $begingroup$
                  Amazing, thank you! Sorry - I'm very new to Mathematica.
                  $endgroup$
                  – Pineapple
                  1 hour ago











                  0












                  $begingroup$

                  Another way, perhaps easier on the eyes. Use a pattern to deconstruct the pairs in a function definition.



                  term[{a_, b_}] := a x^b


                  Then, Map it to the list.



                  Total[term /@ list]
                  (* x^2 + 3 x^4 + 5 x^6 *)





                  share|improve this answer









                  $endgroup$


















                    0












                    $begingroup$

                    Another way, perhaps easier on the eyes. Use a pattern to deconstruct the pairs in a function definition.



                    term[{a_, b_}] := a x^b


                    Then, Map it to the list.



                    Total[term /@ list]
                    (* x^2 + 3 x^4 + 5 x^6 *)





                    share|improve this answer









                    $endgroup$
















                      0












                      0








                      0





                      $begingroup$

                      Another way, perhaps easier on the eyes. Use a pattern to deconstruct the pairs in a function definition.



                      term[{a_, b_}] := a x^b


                      Then, Map it to the list.



                      Total[term /@ list]
                      (* x^2 + 3 x^4 + 5 x^6 *)





                      share|improve this answer









                      $endgroup$



                      Another way, perhaps easier on the eyes. Use a pattern to deconstruct the pairs in a function definition.



                      term[{a_, b_}] := a x^b


                      Then, Map it to the list.



                      Total[term /@ list]
                      (* x^2 + 3 x^4 + 5 x^6 *)






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 51 mins ago









                      John DotyJohn Doty

                      7,17311024




                      7,17311024























                          0












                          $begingroup$

                          Inner[#1 x^#2 &, Sequence @@ Transpose@list, Plus]



                          x^2 + 3 x^4 + 5 x^6




                          One could expand this a bit to allow for different variables:



                          Clear[f]
                          f[coefflist_][var_] := Inner[#1 var^#2 &, Sequence @@ Transpose@coefflist, Plus]


                          so that



                          f[list][x]



                          x^2 + 3 x^4 + 5 x^6




                          but then:



                          f[list][t]



                          t^2 + 3 t^4 + 5 t^6







                          share|improve this answer











                          $endgroup$


















                            0












                            $begingroup$

                            Inner[#1 x^#2 &, Sequence @@ Transpose@list, Plus]



                            x^2 + 3 x^4 + 5 x^6




                            One could expand this a bit to allow for different variables:



                            Clear[f]
                            f[coefflist_][var_] := Inner[#1 var^#2 &, Sequence @@ Transpose@coefflist, Plus]


                            so that



                            f[list][x]



                            x^2 + 3 x^4 + 5 x^6




                            but then:



                            f[list][t]



                            t^2 + 3 t^4 + 5 t^6







                            share|improve this answer











                            $endgroup$
















                              0












                              0








                              0





                              $begingroup$

                              Inner[#1 x^#2 &, Sequence @@ Transpose@list, Plus]



                              x^2 + 3 x^4 + 5 x^6




                              One could expand this a bit to allow for different variables:



                              Clear[f]
                              f[coefflist_][var_] := Inner[#1 var^#2 &, Sequence @@ Transpose@coefflist, Plus]


                              so that



                              f[list][x]



                              x^2 + 3 x^4 + 5 x^6




                              but then:



                              f[list][t]



                              t^2 + 3 t^4 + 5 t^6







                              share|improve this answer











                              $endgroup$



                              Inner[#1 x^#2 &, Sequence @@ Transpose@list, Plus]



                              x^2 + 3 x^4 + 5 x^6




                              One could expand this a bit to allow for different variables:



                              Clear[f]
                              f[coefflist_][var_] := Inner[#1 var^#2 &, Sequence @@ Transpose@coefflist, Plus]


                              so that



                              f[list][x]



                              x^2 + 3 x^4 + 5 x^6




                              but then:



                              f[list][t]



                              t^2 + 3 t^4 + 5 t^6








                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 46 mins ago

























                              answered 52 mins ago









                              MarcoBMarcoB

                              36.7k556113




                              36.7k556113























                                  0












                                  $begingroup$

                                  ClearAll[fa, fb]
                                  fa = FromCoefficientRules[Thread[#[[All, 2;;]] -> #[[All, 1]]], #2] &;
                                  fb = Internal`FromCoefficientList[Normal@SparseArray[1 + #[[All, 2;;]]->#[[All, 1]]], #2] &;


                                  Examples:



                                  list1 = {{1, 2}, {3, 4}, {5, 6}};
                                  {fa[list1, x], fb[list1, x]}



                                  {x^2 + 3 x^4 + 5 x^6, x^2 + 3 x^4 + 5 x^6}




                                  list2 = {{1, 3, 0}, {3, 2, 1}, {3, 1, 2}, {1, 0, 3}};
                                  {fa[list2, {x, y}], fb[list2, {x, y}]}



                                  {x^3 + 3 x^2 y + 3 x y^2 + y^3, x^3 + 3 x^2 y + 3 x y^2 + y^3}







                                  share|improve this answer











                                  $endgroup$


















                                    0












                                    $begingroup$

                                    ClearAll[fa, fb]
                                    fa = FromCoefficientRules[Thread[#[[All, 2;;]] -> #[[All, 1]]], #2] &;
                                    fb = Internal`FromCoefficientList[Normal@SparseArray[1 + #[[All, 2;;]]->#[[All, 1]]], #2] &;


                                    Examples:



                                    list1 = {{1, 2}, {3, 4}, {5, 6}};
                                    {fa[list1, x], fb[list1, x]}



                                    {x^2 + 3 x^4 + 5 x^6, x^2 + 3 x^4 + 5 x^6}




                                    list2 = {{1, 3, 0}, {3, 2, 1}, {3, 1, 2}, {1, 0, 3}};
                                    {fa[list2, {x, y}], fb[list2, {x, y}]}



                                    {x^3 + 3 x^2 y + 3 x y^2 + y^3, x^3 + 3 x^2 y + 3 x y^2 + y^3}







                                    share|improve this answer











                                    $endgroup$
















                                      0












                                      0








                                      0





                                      $begingroup$

                                      ClearAll[fa, fb]
                                      fa = FromCoefficientRules[Thread[#[[All, 2;;]] -> #[[All, 1]]], #2] &;
                                      fb = Internal`FromCoefficientList[Normal@SparseArray[1 + #[[All, 2;;]]->#[[All, 1]]], #2] &;


                                      Examples:



                                      list1 = {{1, 2}, {3, 4}, {5, 6}};
                                      {fa[list1, x], fb[list1, x]}



                                      {x^2 + 3 x^4 + 5 x^6, x^2 + 3 x^4 + 5 x^6}




                                      list2 = {{1, 3, 0}, {3, 2, 1}, {3, 1, 2}, {1, 0, 3}};
                                      {fa[list2, {x, y}], fb[list2, {x, y}]}



                                      {x^3 + 3 x^2 y + 3 x y^2 + y^3, x^3 + 3 x^2 y + 3 x y^2 + y^3}







                                      share|improve this answer











                                      $endgroup$



                                      ClearAll[fa, fb]
                                      fa = FromCoefficientRules[Thread[#[[All, 2;;]] -> #[[All, 1]]], #2] &;
                                      fb = Internal`FromCoefficientList[Normal@SparseArray[1 + #[[All, 2;;]]->#[[All, 1]]], #2] &;


                                      Examples:



                                      list1 = {{1, 2}, {3, 4}, {5, 6}};
                                      {fa[list1, x], fb[list1, x]}



                                      {x^2 + 3 x^4 + 5 x^6, x^2 + 3 x^4 + 5 x^6}




                                      list2 = {{1, 3, 0}, {3, 2, 1}, {3, 1, 2}, {1, 0, 3}};
                                      {fa[list2, {x, y}], fb[list2, {x, y}]}



                                      {x^3 + 3 x^2 y + 3 x y^2 + y^3, x^3 + 3 x^2 y + 3 x y^2 + y^3}








                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 42 mins ago

























                                      answered 54 mins ago









                                      kglrkglr

                                      187k10203422




                                      187k10203422






















                                          Pineapple is a new contributor. Be nice, and check out our Code of Conduct.










                                          draft saved

                                          draft discarded


















                                          Pineapple is a new contributor. Be nice, and check out our Code of Conduct.













                                          Pineapple is a new contributor. Be nice, and check out our Code of Conduct.












                                          Pineapple is a new contributor. Be nice, and check out our Code of Conduct.
















                                          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%2f192691%2fhow-to-substitute-values-from-a-list-into-a-function%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

                                          What are all the squawk codes?

                                          What are differences between VBoxVGA, VMSVGA and VBoxSVGA in VirtualBox?

                                          Hudsonelva