Re: Assigning (really dumb question)

*To*: mathgroup at smc.vnet.net*Subject*: [mg61009] Re: [mg60988] Assigning (really dumb question)*From*: Igor Antonio <igora at wolf-ram.com>*Date*: Fri, 7 Oct 2005 03:37:56 -0400 (EDT)*Organization*: Wolfram Research, Inc.*References*: <200510060808.EAA08545@smc.vnet.net>*Reply-to*: igora at wolf-ram.com*Sender*: owner-wri-mathgroup at wolfram.com

vjp2.at at at.BioStrategist.dot.dot.com wrote: > What the heck am I doing wrong? I've been away from Mathematica for a while. > > I can't get it to evaluate the expressions at the solved values. > > I feel so stupid. > > r[q_] := 1800 q - .006 q^2 > c[q_] := 12100000 + 800 q + .004 q ^2 > > qa = Solve[ D[ r[q]-c[q] , q] == 0, q] > r[q] /. q -> qa > c[q] /. q -> qa > r[q]-c[q] /. q -> qa > D[r[q],q] /. q -> qa > D[c[q],q] /. q -> qa > > qm = Solve[ c[q]/q - D[c[q] , q] == 0, q] [[2]] > r[qm] /. q -> qm > c[qm] /. q -> qm > r[qm]-c[qm] /. q -> qm > D[r[q],q] /. q -> qm > D[c[q],q] /. q -> qm > > Vasos, First, do a First[] of the output of Solve since there's only one rule. The problem with your code is that the placement of ReplaceAll is incorrect. It's replacing the "q" inside r[q] before it evaluates r[q]. Here's one way to do it: In[63]:= r[q_] := 1800*q - 0.006*q^2 c[q_] := 12100000 + 800*q + 0.004*q^2 In[65]:= qa = First[Solve[D[r[q] - c[q], q] == 0, q]] Out[65]= {q -> 50000.} In[66]:= r[a] Out[66]= 1800*a - 0.006*a^2 In[67]:= r[q /. qa] Out[67]= 7.5*^7 > > - = - > Vasos-Peter John Panagiotopoulos II, Columbia'81+, Bio$trategist > BachMozart ReaganQuayle EvrytanoKastorian > http://ourworld.compuserve.com/homepages/vjp2/vasos.htm > ---{Nothing herein constitutes advice. Everything fully disclaimed.}--- > [Homeland Security means private firearms not lazy obstructive guards] > [Fooey on GIU,{MS,X}Windows 4 Bimbos] [Cigar smoke belongs in veg food group] -- Igor C. Antonio Wolfram Research, Inc. http://www.wolfram.com To email me personally, remove the dash.

**References**:**Assigning (really dumb question)***From:*vjp2.at@at.BioStrategist.dot.dot.com