How to put the variable in a certain order after using “Solve[]”
$begingroup$
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
$endgroup$
add a comment |
$begingroup$
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
$endgroup$
$begingroup$
Usex[1],x[2],x[1,1]
(orx[1],x[2],x[11]
) instead ofx1,x2,x11
.
$endgroup$
– AccidentalFourierTransform
Nov 13 '18 at 2:17
$begingroup$
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!
$endgroup$
– Chris K
Nov 13 '18 at 2:39
$begingroup$
BTW, you can even suppress the output ofx11
by usingSolve[system, {x1, x2}, {x11}]
, if you want to.
$endgroup$
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06
add a comment |
$begingroup$
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
$endgroup$
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
equation-solving core-language
edited Nov 13 '18 at 7:08
Αλέξανδρος Ζεγγ
4,1541929
4,1541929
asked Nov 13 '18 at 2:00
Jose CastellanosJose Castellanos
283
283
$begingroup$
Usex[1],x[2],x[1,1]
(orx[1],x[2],x[11]
) instead ofx1,x2,x11
.
$endgroup$
– AccidentalFourierTransform
Nov 13 '18 at 2:17
$begingroup$
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!
$endgroup$
– Chris K
Nov 13 '18 at 2:39
$begingroup$
BTW, you can even suppress the output ofx11
by usingSolve[system, {x1, x2}, {x11}]
, if you want to.
$endgroup$
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06
add a comment |
$begingroup$
Usex[1],x[2],x[1,1]
(orx[1],x[2],x[11]
) instead ofx1,x2,x11
.
$endgroup$
– AccidentalFourierTransform
Nov 13 '18 at 2:17
$begingroup$
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!
$endgroup$
– Chris K
Nov 13 '18 at 2:39
$begingroup$
BTW, you can even suppress the output ofx11
by usingSolve[system, {x1, x2}, {x11}]
, if you want to.
$endgroup$
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06
$begingroup$
Use
x[1],x[2],x[1,1]
(or x[1],x[2],x[11]
) instead of x1,x2,x11
.$endgroup$
– AccidentalFourierTransform
Nov 13 '18 at 2:17
$begingroup$
Use
x[1],x[2],x[1,1]
(or x[1],x[2],x[11]
) instead of x1,x2,x11
.$endgroup$
– AccidentalFourierTransform
Nov 13 '18 at 2:17
$begingroup$
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!
$endgroup$
– Chris K
Nov 13 '18 at 2:39
$begingroup$
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!
$endgroup$
– Chris K
Nov 13 '18 at 2:39
$begingroup$
BTW, you can even suppress the output of
x11
by using Solve[system, {x1, x2}, {x11}]
, if you want to.$endgroup$
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06
$begingroup$
BTW, you can even suppress the output of
x11
by using Solve[system, {x1, x2}, {x11}]
, if you want to.$endgroup$
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
Solve
will return the solutions in the order requested:
solution = Solve[system, {x1, x2, x11}]
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
$endgroup$
$begingroup$
Thank you so much!
$endgroup$
– Jose Castellanos
Nov 13 '18 at 14:13
add a comment |
$begingroup$
SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution
{{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}
$endgroup$
add a comment |
$begingroup$
Try also this:
solution /. {a_, b_, c_} -> {a, c, b}
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
Have fun!
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%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
$begingroup$
Solve
will return the solutions in the order requested:
solution = Solve[system, {x1, x2, x11}]
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
$endgroup$
$begingroup$
Thank you so much!
$endgroup$
– Jose Castellanos
Nov 13 '18 at 14:13
add a comment |
$begingroup$
Solve
will return the solutions in the order requested:
solution = Solve[system, {x1, x2, x11}]
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
$endgroup$
$begingroup$
Thank you so much!
$endgroup$
– Jose Castellanos
Nov 13 '18 at 14:13
add a comment |
$begingroup$
Solve
will return the solutions in the order requested:
solution = Solve[system, {x1, x2, x11}]
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
$endgroup$
Solve
will return the solutions in the order requested:
solution = Solve[system, {x1, x2, x11}]
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
answered Nov 13 '18 at 2:52
Michael E2Michael E2
146k11197468
146k11197468
$begingroup$
Thank you so much!
$endgroup$
– Jose Castellanos
Nov 13 '18 at 14:13
add a comment |
$begingroup$
Thank you so much!
$endgroup$
– Jose Castellanos
Nov 13 '18 at 14:13
$begingroup$
Thank you so much!
$endgroup$
– Jose Castellanos
Nov 13 '18 at 14:13
$begingroup$
Thank you so much!
$endgroup$
– Jose Castellanos
Nov 13 '18 at 14:13
add a comment |
$begingroup$
SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution
{{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}
$endgroup$
add a comment |
$begingroup$
SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution
{{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}
$endgroup$
add a comment |
$begingroup$
SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution
{{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}
$endgroup$
SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution
{{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}
answered Nov 13 '18 at 2:31
kglrkglr
179k9198410
179k9198410
add a comment |
add a comment |
$begingroup$
Try also this:
solution /. {a_, b_, c_} -> {a, c, b}
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
Have fun!
$endgroup$
add a comment |
$begingroup$
Try also this:
solution /. {a_, b_, c_} -> {a, c, b}
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
Have fun!
$endgroup$
add a comment |
$begingroup$
Try also this:
solution /. {a_, b_, c_} -> {a, c, b}
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
Have fun!
$endgroup$
Try also this:
solution /. {a_, b_, c_} -> {a, c, b}
(* {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}} *)
Have fun!
answered Nov 13 '18 at 12:50
Alexei BoulbitchAlexei Boulbitch
21.4k2470
21.4k2470
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%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
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
$begingroup$
Use
x[1],x[2],x[1,1]
(orx[1],x[2],x[11]
) instead ofx1,x2,x11
.$endgroup$
– AccidentalFourierTransform
Nov 13 '18 at 2:17
$begingroup$
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!
$endgroup$
– Chris K
Nov 13 '18 at 2:39
$begingroup$
BTW, you can even suppress the output of
x11
by usingSolve[system, {x1, x2}, {x11}]
, if you want to.$endgroup$
– Αλέξανδρος Ζεγγ
Nov 13 '18 at 7:06