How to put the variable in a certain order after using “Solve[]”












5














I have this code:



eq1 = 4 x1 + 5 x2 - 9 x11 == 5;
eq2 = 5 x1 - 3 x2 + 3 x11 == 99;
eq3 = 2 x1 + 5 x2 - 4 x11 == 7;
system = {eq1, eq2, eq3};
solution = Solve[system]


and the output is:



{{x1 -> 2574/161, x11 -> 1094/161, x2 -> 71/161}}


I would like the output to go in order i.e. x1, x2, and then x11, but I cannot figure out how.










share|improve this question
























  • Use x[1],x[2],x[1,1] (or x[1],x[2],x[11]) instead of x1,x2,x11.
    – AccidentalFourierTransform
    Nov 13 '18 at 2:17










  • Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
    – Chris K
    Nov 13 '18 at 2:39










  • BTW, you can even suppress the output of x11 by using Solve[system, {x1, x2}, {x11}], if you want to.
    – Αλέξανδρος Ζεγγ
    Nov 13 '18 at 7:06


















5














I have this code:



eq1 = 4 x1 + 5 x2 - 9 x11 == 5;
eq2 = 5 x1 - 3 x2 + 3 x11 == 99;
eq3 = 2 x1 + 5 x2 - 4 x11 == 7;
system = {eq1, eq2, eq3};
solution = Solve[system]


and the output is:



{{x1 -> 2574/161, x11 -> 1094/161, x2 -> 71/161}}


I would like the output to go in order i.e. x1, x2, and then x11, but I cannot figure out how.










share|improve this question
























  • Use x[1],x[2],x[1,1] (or x[1],x[2],x[11]) instead of x1,x2,x11.
    – AccidentalFourierTransform
    Nov 13 '18 at 2:17










  • Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
    – Chris K
    Nov 13 '18 at 2:39










  • BTW, you can even suppress the output of x11 by using Solve[system, {x1, x2}, {x11}], if you want to.
    – Αλέξανδρος Ζεγγ
    Nov 13 '18 at 7:06
















5












5








5







I have this code:



eq1 = 4 x1 + 5 x2 - 9 x11 == 5;
eq2 = 5 x1 - 3 x2 + 3 x11 == 99;
eq3 = 2 x1 + 5 x2 - 4 x11 == 7;
system = {eq1, eq2, eq3};
solution = Solve[system]


and the output is:



{{x1 -> 2574/161, x11 -> 1094/161, x2 -> 71/161}}


I would like the output to go in order i.e. x1, x2, and then x11, but I cannot figure out how.










share|improve this question















I have this code:



eq1 = 4 x1 + 5 x2 - 9 x11 == 5;
eq2 = 5 x1 - 3 x2 + 3 x11 == 99;
eq3 = 2 x1 + 5 x2 - 4 x11 == 7;
system = {eq1, eq2, eq3};
solution = Solve[system]


and the output is:



{{x1 -> 2574/161, x11 -> 1094/161, x2 -> 71/161}}


I would like the output to go in order i.e. x1, x2, and then x11, but I cannot figure out how.







equation-solving core-language






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 7:08









Αλέξανδρος Ζεγγ

4,1441929




4,1441929










asked Nov 13 '18 at 2:00









Jose CastellanosJose Castellanos

283




283












  • Use x[1],x[2],x[1,1] (or x[1],x[2],x[11]) instead of x1,x2,x11.
    – AccidentalFourierTransform
    Nov 13 '18 at 2:17










  • Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
    – Chris K
    Nov 13 '18 at 2:39










  • BTW, you can even suppress the output of x11 by using Solve[system, {x1, x2}, {x11}], if you want to.
    – Αλέξανδρος Ζεγγ
    Nov 13 '18 at 7:06




















  • Use x[1],x[2],x[1,1] (or x[1],x[2],x[11]) instead of x1,x2,x11.
    – AccidentalFourierTransform
    Nov 13 '18 at 2:17










  • Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
    – Chris K
    Nov 13 '18 at 2:39










  • BTW, you can even suppress the output of x11 by using Solve[system, {x1, x2}, {x11}], if you want to.
    – Αλέξανδρος Ζεγγ
    Nov 13 '18 at 7:06


















Use x[1],x[2],x[1,1] (or x[1],x[2],x[11]) instead of x1,x2,x11.
– AccidentalFourierTransform
Nov 13 '18 at 2:17




Use x[1],x[2],x[1,1] (or x[1],x[2],x[11]) instead of x1,x2,x11.
– AccidentalFourierTransform
Nov 13 '18 at 2:17












Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
Nov 13 '18 at 2:39




Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
Nov 13 '18 at 2:39












BTW, you can even suppress the output of x11 by using Solve[system, {x1, x2}, {x11}], if you want to.
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06






BTW, you can even suppress the output of x11 by using Solve[system, {x1, x2}, {x11}], if you want to.
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06












3 Answers
3






active

oldest

votes


















12














Solve will return the solutions in the order requested:



solution = Solve[system, {x1, x2, x11}]
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)





share|improve this answer





















  • Thank you so much!
    – Jose Castellanos
    Nov 13 '18 at 14:13



















3














SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution 



{{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}







share|improve this answer





























    1














    Try also this:



    solution /. {a_, b_, c_} -> {a, c, b}

    (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)


    Have fun!






    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%2f185878%2fhow-to-put-the-variable-in-a-certain-order-after-using-solve%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      12














      Solve will return the solutions in the order requested:



      solution = Solve[system, {x1, x2, x11}]
      (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)





      share|improve this answer





















      • Thank you so much!
        – Jose Castellanos
        Nov 13 '18 at 14:13
















      12














      Solve will return the solutions in the order requested:



      solution = Solve[system, {x1, x2, x11}]
      (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)





      share|improve this answer





















      • Thank you so much!
        – Jose Castellanos
        Nov 13 '18 at 14:13














      12












      12








      12






      Solve will return the solutions in the order requested:



      solution = Solve[system, {x1, x2, x11}]
      (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)





      share|improve this answer












      Solve will return the solutions in the order requested:



      solution = Solve[system, {x1, x2, x11}]
      (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 13 '18 at 2:52









      Michael E2Michael E2

      145k11195465




      145k11195465












      • Thank you so much!
        – Jose Castellanos
        Nov 13 '18 at 14:13


















      • Thank you so much!
        – Jose Castellanos
        Nov 13 '18 at 14:13
















      Thank you so much!
      – Jose Castellanos
      Nov 13 '18 at 14:13




      Thank you so much!
      – Jose Castellanos
      Nov 13 '18 at 14:13











      3














      SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution 



      {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}







      share|improve this answer


























        3














        SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution 



        {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}







        share|improve this answer
























          3












          3








          3






          SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution 



          {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}







          share|improve this answer












          SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution 



          {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 2:31









          kglrkglr

          178k9198409




          178k9198409























              1














              Try also this:



              solution /. {a_, b_, c_} -> {a, c, b}

              (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)


              Have fun!






              share|improve this answer


























                1














                Try also this:



                solution /. {a_, b_, c_} -> {a, c, b}

                (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)


                Have fun!






                share|improve this answer
























                  1












                  1








                  1






                  Try also this:



                  solution /. {a_, b_, c_} -> {a, c, b}

                  (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)


                  Have fun!






                  share|improve this answer












                  Try also this:



                  solution /. {a_, b_, c_} -> {a, c, b}

                  (* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)


                  Have fun!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 12:50









                  Alexei BoulbitchAlexei Boulbitch

                  21.3k2470




                  21.3k2470






























                      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%2f185878%2fhow-to-put-the-variable-in-a-certain-order-after-using-solve%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







                      這個網誌中的熱門文章

                      Academy of Television Arts & Sciences

                      L'Équipe

                      1995 France bombings