From: Eduardo M. A. M.Mendes on
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: Bill Rowe on
On 8/8/10 at 7:20 AM, emammendes(a)gmail.com (Eduardo M. A. M.Mendes)
wrote:

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

Solve returns results as a list of replacement rules. So, what
you need to do is:

sol = Solve[{5*x + 4*y == 12}, {y}];
Plot[y /. First[sol], {x, 0, 5}]

Note, the use of First. Since Solve is intended to solve for
more than one variable and provide all possible solutions the
result is a nested list rather than a flat list. In this
particular case where there is only one variable and only one solution

Plot[y/.sol, {x, 0, 5}]

will create the same plot. But in general, you will need to
select one of the solutions using something like First. So, it
is a good idea to not get into the habit of thinking Plot[y/.sol
.... will always work.


From: Alexei Boulbitch on
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: Bob Hanlon on

This works; however, the Solve is evaluated repeatedly

n = 0; Plot[y /.
Solve[{n++; 5*x + 4*y == 12}, y],
{x, 0, 2}]

n

78

Adding Evaluate results in a single evaluation of the Solve

n = 0; Plot[Evaluate[y /.
Solve[{n++; 5*x + 4*y == 12}, y]],
{x, 0, 2}]

n

1

So use

Plot[Evaluate[y /.
Solve[5*x + 4*y == 12, y]],
{x, 0, 2}]


Bob Hanlon

---- "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: Tomas Garza on
Bear in mind that Solve will yield a list of all the solutions in terms of =
rules of the form {y -> x}. So you want to choose first which of the soluti=
ons you want to plot. You might try something like

In[1]:== sol==Solve[{5*x+4*y====12},{y}]
Out[1]== {{y->1/4 (12-5 x)}}

In[2]:== sol[[1]]
Out[2]== {y->1/4 (12-5 x)}

In[3]:== Plot[y/.sol[[1]],{x,0,2}]


> Date: Sun, 8 Aug 2010 07:20:10 -0400
> From: emammendes(a)gmail.com
> Subject: How to use the result of Solve in Plot?
> To: mathgroup(a)smc.vnet.net
>
> 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.
>