how to set variables in mathematicaAre there high performance computing applications for symbolic integration?null space of a specific 4x4 symbolic matrixDivision by factorized polynomials in Macaulay2Practical applications of computer algebra systemsHow to express the following in mathematical symbols?When to rationalize to repair continuity, and why does it work?What CAS / solver / math. software to learn & use for PDE systems arising from LQ dynamic optimization?How to solving equation of fluid vortexesSolving algebraic equations by optimisationCheck if the expression is not equal zero with modular arithmetic

Tikz: place node leftmost of two nodes of different widths

Is a party consisting of only a bard, a cleric, and a warlock functional long-term?

Hausdorff dimension of the boundary of fibres of Lipschitz maps

Recruiter wants very extensive technical details about all of my previous work

Unfrosted light bulb

Bash - pair each line of file

Existence of a celestial body big enough for early civilization to be thought of as a second moon

What is the relationship between relativity and the Doppler effect?

How do hiring committees for research positions view getting "scooped"?

Probably overheated black color SMD pads

If "dar" means "to give", what does "daros" mean?

Does the attack bonus from a Masterwork weapon stack with the attack bonus from Masterwork ammunition?

PTIJ What is the inyan of the Konami code in Uncle Moishy's song?

Do US professors/group leaders only get a salary, but no group budget?

What can I do if I am asked to learn different programming languages very frequently?

The average age of first marriage in Russia

Practical application of matrices and determinants

In Aliens, how many people were on LV-426 before the Marines arrived​?

Why is indicated airspeed rather than ground speed used during the takeoff roll?

What exactly term 'companion plants' means?

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Knife as defense against stray dogs

Suggestions on how to spend Shaabath (constructively) alone

Light propagating through a sound wave



how to set variables in mathematica


Are there high performance computing applications for symbolic integration?null space of a specific 4x4 symbolic matrixDivision by factorized polynomials in Macaulay2Practical applications of computer algebra systemsHow to express the following in mathematical symbols?When to rationalize to repair continuity, and why does it work?What CAS / solver / math. software to learn & use for PDE systems arising from LQ dynamic optimization?How to solving equation of fluid vortexesSolving algebraic equations by optimisationCheck if the expression is not equal zero with modular arithmetic













1












$begingroup$


I have this optimization problem that Mathematica solves correctly:



NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0,
x0 + x1* + x2 == 0.0, x0, x1, x2]



0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484



My problem is I want x0, x1 and x2 to have these values from here on and I dont know how to do (set) this. For example, if i try to plot



Plot[x0 + x1*x + x2*x^2,x,-1,1]



it gives me an empty plot because it does not know what x0, x1,and x2 are.



Thanks for your help.



S










share|cite|improve this question









$endgroup$
















    1












    $begingroup$


    I have this optimization problem that Mathematica solves correctly:



    NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0,
    x0 + x1* + x2 == 0.0, x0, x1, x2]



    0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484



    My problem is I want x0, x1 and x2 to have these values from here on and I dont know how to do (set) this. For example, if i try to plot



    Plot[x0 + x1*x + x2*x^2,x,-1,1]



    it gives me an empty plot because it does not know what x0, x1,and x2 are.



    Thanks for your help.



    S










    share|cite|improve this question









    $endgroup$














      1












      1








      1





      $begingroup$


      I have this optimization problem that Mathematica solves correctly:



      NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0,
      x0 + x1* + x2 == 0.0, x0, x1, x2]



      0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484



      My problem is I want x0, x1 and x2 to have these values from here on and I dont know how to do (set) this. For example, if i try to plot



      Plot[x0 + x1*x + x2*x^2,x,-1,1]



      it gives me an empty plot because it does not know what x0, x1,and x2 are.



      Thanks for your help.



      S










      share|cite|improve this question









      $endgroup$




      I have this optimization problem that Mathematica solves correctly:



      NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0,
      x0 + x1* + x2 == 0.0, x0, x1, x2]



      0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484



      My problem is I want x0, x1 and x2 to have these values from here on and I dont know how to do (set) this. For example, if i try to plot



      Plot[x0 + x1*x + x2*x^2,x,-1,1]



      it gives me an empty plot because it does not know what x0, x1,and x2 are.



      Thanks for your help.



      S







      symbolic-computation






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Oct 14 '13 at 15:28









      user89699user89699

      563




      563




















          1 Answer
          1






          active

          oldest

          votes


















          1












          $begingroup$

          Give your solution a name, such as sol:



          sol = NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0, 
          x0 + x1*+x2 == 0.0, x0, x1, x2]



          0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




          You want to grab the second part of this solution namely sol[[2]]:



          sol[[2]]



          x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




          and substitute those values into your expression:



          expr = x0 + x1*x + x2*x^2 /. sol[[2]];

          Plot[expr, x, -1, 1]



          (source: tri.org.au)




          I want x0, x1 and x2 to have these values from here on




          Although it is certainly possible to globally set x0 = blah, and x1 = bleh, ... you will quickly find yourself in trouble if you do so. It is a much better approach generally to leave x0, x1 and x2 as global unassigned variables, and to then create a special expression like expr above with these numeric values replaced, rather than globally setting the values of x0, x1, and x2.






          share|cite|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: "69"
            ;
            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
            ,
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f525938%2fhow-to-set-variables-in-mathematica%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












            $begingroup$

            Give your solution a name, such as sol:



            sol = NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0, 
            x0 + x1*+x2 == 0.0, x0, x1, x2]



            0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




            You want to grab the second part of this solution namely sol[[2]]:



            sol[[2]]



            x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




            and substitute those values into your expression:



            expr = x0 + x1*x + x2*x^2 /. sol[[2]];

            Plot[expr, x, -1, 1]



            (source: tri.org.au)




            I want x0, x1 and x2 to have these values from here on




            Although it is certainly possible to globally set x0 = blah, and x1 = bleh, ... you will quickly find yourself in trouble if you do so. It is a much better approach generally to leave x0, x1 and x2 as global unassigned variables, and to then create a special expression like expr above with these numeric values replaced, rather than globally setting the values of x0, x1, and x2.






            share|cite|improve this answer











            $endgroup$

















              1












              $begingroup$

              Give your solution a name, such as sol:



              sol = NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0, 
              x0 + x1*+x2 == 0.0, x0, x1, x2]



              0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




              You want to grab the second part of this solution namely sol[[2]]:



              sol[[2]]



              x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




              and substitute those values into your expression:



              expr = x0 + x1*x + x2*x^2 /. sol[[2]];

              Plot[expr, x, -1, 1]



              (source: tri.org.au)




              I want x0, x1 and x2 to have these values from here on




              Although it is certainly possible to globally set x0 = blah, and x1 = bleh, ... you will quickly find yourself in trouble if you do so. It is a much better approach generally to leave x0, x1 and x2 as global unassigned variables, and to then create a special expression like expr above with these numeric values replaced, rather than globally setting the values of x0, x1, and x2.






              share|cite|improve this answer











              $endgroup$















                1












                1








                1





                $begingroup$

                Give your solution a name, such as sol:



                sol = NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0, 
                x0 + x1*+x2 == 0.0, x0, x1, x2]



                0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




                You want to grab the second part of this solution namely sol[[2]]:



                sol[[2]]



                x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




                and substitute those values into your expression:



                expr = x0 + x1*x + x2*x^2 /. sol[[2]];

                Plot[expr, x, -1, 1]



                (source: tri.org.au)




                I want x0, x1 and x2 to have these values from here on




                Although it is certainly possible to globally set x0 = blah, and x1 = bleh, ... you will quickly find yourself in trouble if you do so. It is a much better approach generally to leave x0, x1 and x2 as global unassigned variables, and to then create a special expression like expr above with these numeric values replaced, rather than globally setting the values of x0, x1, and x2.






                share|cite|improve this answer











                $endgroup$



                Give your solution a name, such as sol:



                sol = NMinimize[x0^2 + x1^2 + x2^2, x0 - x1 + 2.0 x2 == 1.0, 
                x0 + x1*+x2 == 0.0, x0, x1, x2]



                0.17748, x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




                You want to grab the second part of this solution namely sol[[2]]:



                sol[[2]]



                x0 -> 0.0739345, x1 -> -0.205098, x2 -> 0.360484




                and substitute those values into your expression:



                expr = x0 + x1*x + x2*x^2 /. sol[[2]];

                Plot[expr, x, -1, 1]



                (source: tri.org.au)




                I want x0, x1 and x2 to have these values from here on




                Although it is certainly possible to globally set x0 = blah, and x1 = bleh, ... you will quickly find yourself in trouble if you do so. It is a much better approach generally to leave x0, x1 and x2 as global unassigned variables, and to then create a special expression like expr above with these numeric values replaced, rather than globally setting the values of x0, x1, and x2.







                share|cite|improve this answer














                share|cite|improve this answer



                share|cite|improve this answer








                edited Mar 12 at 18:22









                Glorfindel

                3,42981830




                3,42981830










                answered Oct 14 '13 at 15:35









                wolfieswolfies

                4,2392923




                4,2392923



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Mathematics 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%2fmath.stackexchange.com%2fquestions%2f525938%2fhow-to-set-variables-in-mathematica%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

                    Moe incest case Sentencing See also References Navigation menu"'Australian Josef Fritzl' fathered four children by daughter""Small town recoils in horror at 'Australian Fritzl' incest case""Victorian rape allegations echo Fritzl case - Just In (Australian Broadcasting Corporation)""Incest father jailed for 22 years""'Australian Fritzl' sentenced to 22 years in prison for abusing daughter for three decades""RSJ v The Queen"

                    Who is our nearest planetary neighbor, on average?Santa Claus flies to the South PoleSeven Spheres of Unequal Mass, a weighing problem with a twistDescribe a large integerFast Mental Calculation of $7.5^7$Math in Space (without the help of celebrities)Find the value of $bigstar$: Puzzle 8 - InequalityWho drinks beer while running anyway?A Crucial DeliveryRanking And AverageHow long will my money last at roulette?

                    Daza language Contents Vocabulary Phonology References External links Navigation menudaza1242Daza"Dazaga"eeee178086576