[Date Index]
[Thread Index]
[Author Index]
Re: How to use the result of Solve in Plot?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg111653] Re: How to use the result of Solve in Plot?
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Mon, 9 Aug 2010 05:13:07 -0400 (EDT)
On 8/8/10 at 7:20 AM, emammendes at 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.
Prev by Date:
**Re: Default and head in function argument**
Next by Date:
**Re: Convex hull in 3D**
Previous by thread:
**Re: How to use the result of Solve in Plot?**
Next by thread:
**Re: How to use the result of Solve in Plot?**
| |