Prev: Convex Hull again
Next: Question about adding thumbnails and snapshots to Wolfram Demonstration.
From: David Park on 9 Aug 2010 05:11 It is not a hard and fast rule, but generally I would not put a lot of symbolic or numerical calculation inside the various plot statements. Rather, generate and define the function to be plotted outside the plot statement where you can check it and debug it, and then put that into the plot statement. So here, we define a function y[x]. sol = First(a)Solve[{5*x + 4*y == 12}, {y}]; y[x_] = y /. sol 1/4 (12 - 5 x) and then plot it. Plot[y[x], {x, 0, 2}] David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: Eduardo M. A. M.Mendes [mailto:emammendes(a)gmail.com] Hello I want to use the result of Solve[{5*x+4*y==12},{y}] in Plot[.,{x,0,2}]. Plot[Solve[.],{x,0,2}] does not work. Many thanks Ed PS. I am new to Mathematica.
From: Helen Read on 9 Aug 2010 05:12 On 8/8/2010 7:19 AM, Eduardo M. A. M.Mendes wrote: > Hello > > I want to use the result of Solve[{5*x+4*y==12},{y}] in Plot[.,{x,0,2}]. > Plot[Solve[.],{x,0,2}] does not work. The results of Solve are given as a list of replacement rules. For example, try the following. Solve[14 x^2 - 17 x - 6 == 0, x] The output looks like this: {{x -> -(2/7)}, {x -> 3/2}} This is a list of replacement rules, {x->-2/7} and {x->3/2} Here is how we evaluate x according to a replacement rule. x/.{x->-2/7} x/.{x->3/2} So to get the solutions out of Solve, we do this. x /. Solve[14 x^2 - 17 x - 6 == 0, x] You might want to name them when you do it. solns=x /. Solve[14 x^2 - 17 x - 6 == 0, x] Try putting solns in a new cell and evaluate. See? You can also pick out the solutions individually, like this. a=x /. Solve[14 x^2 - 17 x - 6 == 0, x][[1]] b=x /. Solve[14 x^2 - 17 x - 6 == 0, x][[2]] Plot[14x^2-17x-6,{x,a,b}] Now, go back to your example. For starters, you don't need all those curly braces, since you have only one equation and one variable to solve for. (If you have a list of equations to solve simultaneously, and a list of variables to solve for, enclose the list of equations and the list of variables in curly braces.) So you can enter your equation more simply, like this. Solve[5*x + 4*y == 12, y] Now, the result is given in the form of a list of replacement rules. You want to evaluate y according to the replacement rule given by the first solution (which in the example is the only solution). Since the result is a function, rather than naming it the way we did in the previous example, let's define the solution as a function of x. f[x_] = y /. Solve[5*x + 4*y == 12, y][[1]] Plot[f[x], {x, 0, 2}] -- Helen Read University of Vermont
From: J. Batista on 9 Aug 2010 05:14 Eduardo, you can perform the desired operation by first assigning a variable to your original solution set at the beginning of your Solve command line. Then, in your Plot command line, you may call all or part of the solution set as a function of the independent variable/parameter, in your case x. The two lines of code below accomplish these goals in this order. solution = Solve[5*x+4*y==12, y] Plot[Evaluate[y /. solution], {x,0,2}] Regards, J. Batista On Sun, Aug 8, 2010 at 7:20 AM, Eduardo M. A. M.Mendes <emammendes(a)gmail.com > wrote: > Hello > > I want to use the result of Solve[{5*x+4*y==12},{y}] in Plot[.,{x,0,2}]. > Plot[Solve[.],{x,0,2}] does not work. > > Many thanks > > Ed > > PS. I am new to Mathematica. > >
From: Eduardo M. A. M.Mendes on 11 Aug 2010 04:46 Hello First of all I would like to thank you who help me with my question. Thanks for the patience and for the time. Second, for Alexis (Thanks, I have added another Solve and it worked just fine). Could you explain what is the idea behind [[1,1,2]]? Many thanks Ed -----Original Message----- From: Alexei Boulbitch [mailto:alexei.boulbitch(a)iee.lu] Sent: Monday, August 09, 2010 6:15 AM Subject: Re: How to use the result of Solve in Plot? Hi, Ed, try this: Plot[Solve[{5*x + 4*y == 12}, y][[1, 1, 2]], {x, 0, 2}] Have fun, Alexei Hello I want to use the result of Solve[{5*x+4*y==12},{y}] in Plot[.,{x,0,2}]. Plot[Solve[.],{x,0,2}] does not work. Many thanks Ed PS. I am new to Mathematica. -- Alexei Boulbitch, Dr. habil. Senior Scientist Material Development IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 CONTERN Luxembourg Tel: +352 2454 2566 Fax: +352 2454 3566 Mobile: +49 (0) 151 52 40 66 44 e-mail: alexei.boulbitch(a)iee.lu www.iee.lu -- This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.
From: Sjoerd C. de Vries on 12 Aug 2010 05:28 select the [[ characters then press F1 (help) and you will be enlightened. Cheers -- Sjoerd On Aug 11, 10:46 am, "Eduardo M. A. M.Mendes" <emammen...(a)gmail.com> wrote: > Hello > > First of all I would like to thank you who help me with my question. Thanks > for the patience and for the time. > > Second, for Alexis (Thanks, I have added another Solve and it worked just > fine). Could you explain what is the idea behind [[1,1,2]]? > > Many thanks > > Ed > > -----Original Message----- > From: Alexei Boulbitch [mailto:alexei.boulbi...(a)iee.lu] > Sent: Monday, August 09, 2010 6:15 AM > Subject: Re: How to use the result of Solve in Plot? > > Hi, Ed, try this: > > Plot[Solve[{5*x + 4*y == 12}, y][[1, 1, 2]], {x, 0, 2}] > > Have fun, Alexei > > Hello > > I want to use the result of Solve[{5*x+4*y==12},{y}] in Plot[.,{x,0,2}]. > Plot[Solve[.],{x,0,2}] does not work. > > Many thanks > > Ed > > PS. I am new to Mathematica. > > -- > Alexei Boulbitch, Dr. habil. > Senior Scientist > Material Development > > IEE S.A. > ZAE Weiergewan > 11, rue Edmond Reuter > L-5326 CONTERN > Luxembourg > > Tel: +352 2454 2566 > Fax: +352 2454 3566 > Mobile: +49 (0) 151 52 40 66 44 > > e-mail: alexei.boulbi...(a)iee.lu > > www.iee.lu > > -- > > This e-mail may contain trade secrets or privileged, undisclosed or > otherwise confidential information. If you are not the intended > recipient and have received this e-mail in error, you are hereby > notified that any review, copying or distribution of it is strictly > prohibited. Please inform us immediately and destroy the original > transmittal from your system. Thank you for your co-operation.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Convex Hull again Next: Question about adding thumbnails and snapshots to Wolfram Demonstration. |