Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Solve and Reduce

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52143] Re: [mg52128] Solve and Reduce
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 12 Nov 2004 02:13:57 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

eqn = 2500*c^2-25*c^3+3500*c*q-
        320*c^2*q-1104*c*q^2-1152*q^3\[Equal]0;

Needs["Graphics`"];

ImplicitPlot[eqn, {c,0,100},{q,0,5},
    AspectRatio->.6,ImageSize->{288,178},
    Frame->True, Axes->False,
     FrameLabel->{"c","q\n"}];

With[{b=(5*(-109199+1497*Sqrt[5489]))/2744},
    DisplayTogether[
      Plot[Root[-2500*c^2+25*c^3-3500*c*#1+
              320*c^2*#1+1104*c*#1^2+1152*#1^3&,1],
        {c,b,100}, PlotStyle->Blue],
      Plot[Root[-2500*c^2+25*c^3-3500*c*#1+
              320*c^2*#1+1104*c*#1^2+1152*#1^3&,3],
        {c,0,b}, PlotStyle->Red],
      PlotRange->{0,5},
      Frame->True, Axes->False,
       FrameLabel->{"c","q\n"}]];

If c is defined before the equation is solved, then the roots are sorted and the 
positive result is last

Table[Chop[(q/. 
        Solve[eqn /. c->{.1,1.,5.,10.}[[n]], q])],
  {n,4}]

Clear[qr];
qr[c_/;0<c<100]:=
    q/.Solve[eqn,q][[3]];

Plot[qr[c],{c,0,100},
    PlotRange->{0,5},
    Frame->True, Axes->False,
     FrameLabel->{"c","q\n"}];

If the equation is solved for q before c is defined then your desired result is 
the second one

Chop[(q/. 
        Solve[eqn, q]) /. c->{.1,1.,5.,10.}]

Clear[qr];
qr[c_/;0<c<100]=
    q/.Solve[eqn,q][[2]];

Plot[qr[c],{c,0,100},
    PlotRange->{0,5},
    Frame->True, Axes->False,
     FrameLabel->{"c","q\n"}];


Bob Hanlon

> 
> From: "Carol Ting" <tingyife at msu.edu>
To: mathgroup at smc.vnet.net
> Date: 2004/11/11 Thu AM 04:53:03 EST
> To: mathgroup at smc.vnet.net
> Subject: [mg52143] [mg52128] Solve and Reduce
> 
> 
> Hello list,
> 
> I want to find q as a function of c, q(c), given the following
> equation:
> 
> 2500*c^2 - 25*c^3 + 3500*c*q - 320*c^2*q - 1104*c*q^2 - 1152*q^3 
== 0
> 
> However, each of the following three methods gives different results.
> I check the Mathematica Book but still cannot figure out why there are
> such differences.  Could someone please explain this to me?  Thanks a
> lot!
> 
> (1) Use "Reduce"
> 
> In[5]:=
> q1[c_] = Reduce[{2500*c^2 - 25*c^3 +3500*c*q - 320*c^2*q 
-1104*c*q^2
> -1152*q^3 == 0, c > 0,q > 0}, q]
> 
> Out[5]=
> 0<c<=(5*(-109199 + 1497*Sqrt[5489]))/2744] &&q == Root[-2500*c^2 +
> 25*c^3 - 3500*c*#1 + 320*c^2*#1 + 1104*c*#1^2 + 1152*#1^3 & ,3] ||
> (5*(-109199 + 1497*Sqrt[5489]))/2744 < c < 100 && q ==Root[
-2500*c^2 +
> 25*c^3 -3500*c*#1 + 320*c^2*#1 + 1104*c*#1^2 + 1152*#1^3 & , 1]
> 
> In[6]:=
> Plot[Root[-2500*c^2 + 25*c^3 - 3500*c*#1 + 320*c^2*#1 + 1104*c*#1^2 
+
> 1152*#1^3 & ,1], {c, 0, 100}]
> Plot[Root[-2500*c^2 + 25*c^3 - 3500*c*#1 + 320*c^2*#1 + 1104*c*#1^2 
+
> 1152*#1^3 & ,3], {c, 0, 100}]
> 
> Out[6]=
> Graphics[]
> 
> Out[7]=
> Graphics[]
> 
> 
> (2) Use "Solve" and Immediate assignment
> 
> In[32]:=
> qdroot1[c_] = q /. Solve[2500*c^2 - 25*c^3 + 3500*c*q - 320*c^2*q -
> 1104*c*q^2 - 1152*q^3 == 0,q][[1]]
> qdroot3[c_] = q /. Solve[2500*c^2 - 25*c^3 + 3500*c*q - 320*c^2*q -
> 1104*c*q^2 - 1152*q^3 == 0,q][[3]]
> 
> In[34]:=
> Plot[qiroot1[c], {c, 0, 100}]
> 
> Out[34]=
> Graphics[]
> 
> In[35]:=
> Plot[qiroot3[c], {c, 0, 100}]
> 
> Out[35]=
> Graphics[]
> 
> (3) Use "Solve" and delayed assignment
> 
> In[28]:=
> qdroot1[c_] := q /. Solve[2500*c^2 - 25*c^3 + 3500*c*q - 320*c^2*q -
> 1104*c*q^2 - 1152*q^3 == 0,q][[1]]
> qdroot3[c_] := q /. Solve[2500*c^2 - 25*c^3 + 3500*c*q - 320*c^2*q -
> 1104*c*q^2 - 1152*q^3 == 0,q][[3]]
> 
> In[30]:=
> Plot[qdroot1[c], {c, 0, 100}]
> 
> Out[30]=
> Graphics[]
> 
> In[31]:=
> Plot[qdroot3[c], {c, 0, 100}]
> 
> Out[31]=
> Graphics[]
> 
> 
> Carol
> 
> 


  • Prev by Date: Re: Re: Re: newbie question DSolve (revisited)
  • Next by Date: newbie question DSolve (revisited again)
  • Previous by thread: Re: Solve and Reduce
  • Next by thread: Why these definitions are so slow