Solve function not solving simultaneous equations





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















How do I solve a problem with 3 simultaneous equations? My code shown below is not giving the correct results.



I am attempting to find the maximum area (A) whilst both lengths x and y follow the following property: 2x + y = 960.



I have already looked at the documentation, and it seems that the format of my arguments is correct.



Solve[{2 x + y == 960, A == x*y, D[A] == 0}, {x, y}]


I am unsure of this, however it might be too complex for the Solve function to work, as it is getting the derivative of one of the variables (D[A]).



However I am able to do this question by hand:




  1. Rearrange 1st equation so that y = 960 - 2x


  2. Substitute y into 2nd equation so that A = x(960 - 2x) = 2x^2 + 960x


  3. Get the derivative: 4x + 960 and solve for 4x + 960 = 0


  4. x = 240


  5. Substitute x = 240 into y = 960 - 2x


  6. y = 960 - 2(240) = 960 - 480 = 480


  7. Therefore dimensions are 240 x 480.



I expect the output to be {240, 480}. Thanks :)



EDIT: Here is what I have typed into mathematica:



Clear[x, y, A]

Solve[{2 x + y == 960, A == x*y, D[A, x] == 0}, {x, y}]

OUT: {{x -> 1/2 (480 - Sqrt[2] Sqrt[115200 - A]),
y -> 480 + Sqrt[2] Sqrt[115200 - A]}, {x ->
1/2 (480 + Sqrt[2] Sqrt[115200 - A]),
y -> 480 - Sqrt[2] Sqrt[115200 - A]}

NMaximize[{x*y, 2 x + y == 960}, {x, y}]

OUT: {115200., {x -> 240., y -> 480.}}









share|improve this question































    0















    How do I solve a problem with 3 simultaneous equations? My code shown below is not giving the correct results.



    I am attempting to find the maximum area (A) whilst both lengths x and y follow the following property: 2x + y = 960.



    I have already looked at the documentation, and it seems that the format of my arguments is correct.



    Solve[{2 x + y == 960, A == x*y, D[A] == 0}, {x, y}]


    I am unsure of this, however it might be too complex for the Solve function to work, as it is getting the derivative of one of the variables (D[A]).



    However I am able to do this question by hand:




    1. Rearrange 1st equation so that y = 960 - 2x


    2. Substitute y into 2nd equation so that A = x(960 - 2x) = 2x^2 + 960x


    3. Get the derivative: 4x + 960 and solve for 4x + 960 = 0


    4. x = 240


    5. Substitute x = 240 into y = 960 - 2x


    6. y = 960 - 2(240) = 960 - 480 = 480


    7. Therefore dimensions are 240 x 480.



    I expect the output to be {240, 480}. Thanks :)



    EDIT: Here is what I have typed into mathematica:



    Clear[x, y, A]

    Solve[{2 x + y == 960, A == x*y, D[A, x] == 0}, {x, y}]

    OUT: {{x -> 1/2 (480 - Sqrt[2] Sqrt[115200 - A]),
    y -> 480 + Sqrt[2] Sqrt[115200 - A]}, {x ->
    1/2 (480 + Sqrt[2] Sqrt[115200 - A]),
    y -> 480 - Sqrt[2] Sqrt[115200 - A]}

    NMaximize[{x*y, 2 x + y == 960}, {x, y}]

    OUT: {115200., {x -> 240., y -> 480.}}









    share|improve this question



























      0












      0








      0








      How do I solve a problem with 3 simultaneous equations? My code shown below is not giving the correct results.



      I am attempting to find the maximum area (A) whilst both lengths x and y follow the following property: 2x + y = 960.



      I have already looked at the documentation, and it seems that the format of my arguments is correct.



      Solve[{2 x + y == 960, A == x*y, D[A] == 0}, {x, y}]


      I am unsure of this, however it might be too complex for the Solve function to work, as it is getting the derivative of one of the variables (D[A]).



      However I am able to do this question by hand:




      1. Rearrange 1st equation so that y = 960 - 2x


      2. Substitute y into 2nd equation so that A = x(960 - 2x) = 2x^2 + 960x


      3. Get the derivative: 4x + 960 and solve for 4x + 960 = 0


      4. x = 240


      5. Substitute x = 240 into y = 960 - 2x


      6. y = 960 - 2(240) = 960 - 480 = 480


      7. Therefore dimensions are 240 x 480.



      I expect the output to be {240, 480}. Thanks :)



      EDIT: Here is what I have typed into mathematica:



      Clear[x, y, A]

      Solve[{2 x + y == 960, A == x*y, D[A, x] == 0}, {x, y}]

      OUT: {{x -> 1/2 (480 - Sqrt[2] Sqrt[115200 - A]),
      y -> 480 + Sqrt[2] Sqrt[115200 - A]}, {x ->
      1/2 (480 + Sqrt[2] Sqrt[115200 - A]),
      y -> 480 - Sqrt[2] Sqrt[115200 - A]}

      NMaximize[{x*y, 2 x + y == 960}, {x, y}]

      OUT: {115200., {x -> 240., y -> 480.}}









      share|improve this question
















      How do I solve a problem with 3 simultaneous equations? My code shown below is not giving the correct results.



      I am attempting to find the maximum area (A) whilst both lengths x and y follow the following property: 2x + y = 960.



      I have already looked at the documentation, and it seems that the format of my arguments is correct.



      Solve[{2 x + y == 960, A == x*y, D[A] == 0}, {x, y}]


      I am unsure of this, however it might be too complex for the Solve function to work, as it is getting the derivative of one of the variables (D[A]).



      However I am able to do this question by hand:




      1. Rearrange 1st equation so that y = 960 - 2x


      2. Substitute y into 2nd equation so that A = x(960 - 2x) = 2x^2 + 960x


      3. Get the derivative: 4x + 960 and solve for 4x + 960 = 0


      4. x = 240


      5. Substitute x = 240 into y = 960 - 2x


      6. y = 960 - 2(240) = 960 - 480 = 480


      7. Therefore dimensions are 240 x 480.



      I expect the output to be {240, 480}. Thanks :)



      EDIT: Here is what I have typed into mathematica:



      Clear[x, y, A]

      Solve[{2 x + y == 960, A == x*y, D[A, x] == 0}, {x, y}]

      OUT: {{x -> 1/2 (480 - Sqrt[2] Sqrt[115200 - A]),
      y -> 480 + Sqrt[2] Sqrt[115200 - A]}, {x ->
      1/2 (480 + Sqrt[2] Sqrt[115200 - A]),
      y -> 480 - Sqrt[2] Sqrt[115200 - A]}

      NMaximize[{x*y, 2 x + y == 960}, {x, y}]

      OUT: {115200., {x -> 240., y -> 480.}}






      wolfram-mathematica






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 3 at 8:35







      Jordan Zdimirovic

















      asked Jan 3 at 7:41









      Jordan ZdimirovicJordan Zdimirovic

      134




      134
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Try this



          NMaximize[{x*y,2x+y==960},{x,y}]


          which is maximizing the area with your constraint expression and that instantly returns x->240, y->480



          The difficulty you were having was with the use of D[A] when Mathematica needs to know what variable you are differentiating with respect to.



          Perhaps something in this will help you understand what is happening with your derivative.



          EDIT



          Look at what Solve is going to be given:



          Clear[x,y,A];
          A == x*y;
          D[A, x]


          which gives 0. Why is that? You are taking the derivative of A with respect to x, but A has never been assigned any value, you have only declared that A and x*y are equal. Thus



          Clear[x,y,A];
          {2 x + y == 960, A == x*y, D[A, x] == 0}


          is handing



          {2*x + y == 960, A == x*y, True}


          to Solve and that is perhaps less puzzling when Solve returns something with A in it.



          When some function in Mathematica isn't giving you the result that you expect or that makes sense then checking exactly what is being given to that function as arguments is always a good first step.



          There are always several ways of doing anything in Mathematica and some of those seem to make no sense at all






          share|improve this answer


























          • Thanks for that. I found it interesting however that even after fixing up the 'respect to' issue I got solutions that included A.

            – Jordan Zdimirovic
            Jan 3 at 8:19











          • Perhaps my edit will help explain a bit. If not then we can try to keep at it until it is clear

            – Bill
            Jan 3 at 17:40












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f54018187%2fsolve-function-not-solving-simultaneous-equations%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Try this



          NMaximize[{x*y,2x+y==960},{x,y}]


          which is maximizing the area with your constraint expression and that instantly returns x->240, y->480



          The difficulty you were having was with the use of D[A] when Mathematica needs to know what variable you are differentiating with respect to.



          Perhaps something in this will help you understand what is happening with your derivative.



          EDIT



          Look at what Solve is going to be given:



          Clear[x,y,A];
          A == x*y;
          D[A, x]


          which gives 0. Why is that? You are taking the derivative of A with respect to x, but A has never been assigned any value, you have only declared that A and x*y are equal. Thus



          Clear[x,y,A];
          {2 x + y == 960, A == x*y, D[A, x] == 0}


          is handing



          {2*x + y == 960, A == x*y, True}


          to Solve and that is perhaps less puzzling when Solve returns something with A in it.



          When some function in Mathematica isn't giving you the result that you expect or that makes sense then checking exactly what is being given to that function as arguments is always a good first step.



          There are always several ways of doing anything in Mathematica and some of those seem to make no sense at all






          share|improve this answer


























          • Thanks for that. I found it interesting however that even after fixing up the 'respect to' issue I got solutions that included A.

            – Jordan Zdimirovic
            Jan 3 at 8:19











          • Perhaps my edit will help explain a bit. If not then we can try to keep at it until it is clear

            – Bill
            Jan 3 at 17:40
















          1














          Try this



          NMaximize[{x*y,2x+y==960},{x,y}]


          which is maximizing the area with your constraint expression and that instantly returns x->240, y->480



          The difficulty you were having was with the use of D[A] when Mathematica needs to know what variable you are differentiating with respect to.



          Perhaps something in this will help you understand what is happening with your derivative.



          EDIT



          Look at what Solve is going to be given:



          Clear[x,y,A];
          A == x*y;
          D[A, x]


          which gives 0. Why is that? You are taking the derivative of A with respect to x, but A has never been assigned any value, you have only declared that A and x*y are equal. Thus



          Clear[x,y,A];
          {2 x + y == 960, A == x*y, D[A, x] == 0}


          is handing



          {2*x + y == 960, A == x*y, True}


          to Solve and that is perhaps less puzzling when Solve returns something with A in it.



          When some function in Mathematica isn't giving you the result that you expect or that makes sense then checking exactly what is being given to that function as arguments is always a good first step.



          There are always several ways of doing anything in Mathematica and some of those seem to make no sense at all






          share|improve this answer


























          • Thanks for that. I found it interesting however that even after fixing up the 'respect to' issue I got solutions that included A.

            – Jordan Zdimirovic
            Jan 3 at 8:19











          • Perhaps my edit will help explain a bit. If not then we can try to keep at it until it is clear

            – Bill
            Jan 3 at 17:40














          1












          1








          1







          Try this



          NMaximize[{x*y,2x+y==960},{x,y}]


          which is maximizing the area with your constraint expression and that instantly returns x->240, y->480



          The difficulty you were having was with the use of D[A] when Mathematica needs to know what variable you are differentiating with respect to.



          Perhaps something in this will help you understand what is happening with your derivative.



          EDIT



          Look at what Solve is going to be given:



          Clear[x,y,A];
          A == x*y;
          D[A, x]


          which gives 0. Why is that? You are taking the derivative of A with respect to x, but A has never been assigned any value, you have only declared that A and x*y are equal. Thus



          Clear[x,y,A];
          {2 x + y == 960, A == x*y, D[A, x] == 0}


          is handing



          {2*x + y == 960, A == x*y, True}


          to Solve and that is perhaps less puzzling when Solve returns something with A in it.



          When some function in Mathematica isn't giving you the result that you expect or that makes sense then checking exactly what is being given to that function as arguments is always a good first step.



          There are always several ways of doing anything in Mathematica and some of those seem to make no sense at all






          share|improve this answer















          Try this



          NMaximize[{x*y,2x+y==960},{x,y}]


          which is maximizing the area with your constraint expression and that instantly returns x->240, y->480



          The difficulty you were having was with the use of D[A] when Mathematica needs to know what variable you are differentiating with respect to.



          Perhaps something in this will help you understand what is happening with your derivative.



          EDIT



          Look at what Solve is going to be given:



          Clear[x,y,A];
          A == x*y;
          D[A, x]


          which gives 0. Why is that? You are taking the derivative of A with respect to x, but A has never been assigned any value, you have only declared that A and x*y are equal. Thus



          Clear[x,y,A];
          {2 x + y == 960, A == x*y, D[A, x] == 0}


          is handing



          {2*x + y == 960, A == x*y, True}


          to Solve and that is perhaps less puzzling when Solve returns something with A in it.



          When some function in Mathematica isn't giving you the result that you expect or that makes sense then checking exactly what is being given to that function as arguments is always a good first step.



          There are always several ways of doing anything in Mathematica and some of those seem to make no sense at all







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 17:39

























          answered Jan 3 at 8:13









          BillBill

          2,396178




          2,396178













          • Thanks for that. I found it interesting however that even after fixing up the 'respect to' issue I got solutions that included A.

            – Jordan Zdimirovic
            Jan 3 at 8:19











          • Perhaps my edit will help explain a bit. If not then we can try to keep at it until it is clear

            – Bill
            Jan 3 at 17:40



















          • Thanks for that. I found it interesting however that even after fixing up the 'respect to' issue I got solutions that included A.

            – Jordan Zdimirovic
            Jan 3 at 8:19











          • Perhaps my edit will help explain a bit. If not then we can try to keep at it until it is clear

            – Bill
            Jan 3 at 17:40

















          Thanks for that. I found it interesting however that even after fixing up the 'respect to' issue I got solutions that included A.

          – Jordan Zdimirovic
          Jan 3 at 8:19





          Thanks for that. I found it interesting however that even after fixing up the 'respect to' issue I got solutions that included A.

          – Jordan Zdimirovic
          Jan 3 at 8:19













          Perhaps my edit will help explain a bit. If not then we can try to keep at it until it is clear

          – Bill
          Jan 3 at 17:40





          Perhaps my edit will help explain a bit. If not then we can try to keep at it until it is clear

          – Bill
          Jan 3 at 17:40




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


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


          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%2fstackoverflow.com%2fquestions%2f54018187%2fsolve-function-not-solving-simultaneous-equations%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

          Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

          Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

          A Topological Invariant for $pi_3(U(n))$