Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: Evaluate, /., {{...}}, etc.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70744] Re: Evaluate, /., {{...}}, etc.
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 25 Oct 2006 01:40:11 -0400 (EDT)
  • References: <ehkc9c$hqr$1@smc.vnet.net>

Hi,

Solve[] can have more than a single solution, to return
more than one solution it group the solution set by

{{solution1},{solution2},{solution3},..}

since every solution set is a sequence of rules x->a,y->b
because you can't use Set[] (=) or Equal[] (==)
the last Set[] would overwrite all previous set operations
in multiple solutions and using Equal[] would be create
logical nonsense because the equations are entered as
Equal[] sequence and the result should be different from
the input.

I can't understand you "example" because the case that
a Solve[] return only a single list can't happen.
And if you remove all the useless Evaluate[] calls and replace the
Set[] operation to the parameter with a replacement
you get

p1[x1_, x2_] := 10 - b1 x1 - c x2
p2[x1_, x2_] := 10 - b2 x2 - c x1
profit1[x1_, x2_] = p1[x1, x2]*x1;
profit2[x1_, x2_] = p2[x1, x2]*x2;
solution1 = Solve[D[profit1[x1, x2], x1] == 0, x1][[1]]
solution2 = Solve[D[profit2[x1, x2], x2] == 0, x2][[1]]
r1[x2_] = x1 /. solution1;
r2[x1_] = x2 /. solution2;
param = {b2 -> 1, b1 -> 1, c -> 1};
Block[{$DisplayFunction = Identity},
     isoprofitLines = ContourPlot[
         Evaluate[profit1[x1, x2] //. param], {x1, 0, 7}, {x2, 0, 7},
       ContourShading -> False];
      reactionCurves = ParametricPlot[
         Evaluate[{{r1[t], t}, {t, r2[t]}} /. param], {t, 0, 7}]
     ];
Show[isoprofitLines, reactionCurves]

Regards
   Jens

misha wrote:
> I'm having trouble figuring out how either Evaluate works or /. works 
> (with the logical understanding of "or"), as well as the asymmetric 
> appearance of curly brackets {} in what appears to me to be analogous 
> conditions.
> 
> In the example below, I expect r1[x1_]:=Evaluate[x1/.solution1] to 
> produce a function r1 as a function of x1 from the equation provided by 
> solution1.  Similar for r2.  I notice that solution1 is {{x1 -> 5 - 
> x2/2}}, whereas solution2 is {x1 -> 10 - 2*x2}.  Why "->" instead of "=" 
> or "=="?  Why two curly brackets in the first case {{...}} and only one 
> in the second case {...}?
> 
> More important,
> 
> r1 produces what I expect,
> In[...]:= ?r1
> 	Global`r1
> 	r1[x2_]:={5 - x2/2}
> 
> while r2 does not.
> In[...]:=?r2
> 	Global'r2
> 	r2[x1_]:=x2
> 
> I would expect the following
> 
> r2[x1_]:=10-2*x2
> 
> (i.e., since this problem is symmetric, firm 1's "reaction function" 
> (r1) should be symmetric w.r.t. firm 2's "reaction function" (r2). 
> Again, why curly brackets in one case, but not in the other?
> 
> Here is the full example (from 
> http://library.wolfram.com/infocenter/MathSource/551/):
> 
> p1[x1_,x2_] := 10 - b1 x1 - c x2
> p2[x1_,x2_] := 10 - b2 x2 - c x1
> profit1[x1_,x2_] := Evaluate[p1[x1,x2]*x1]
> profit2[x1_,x2_] := Evaluate[p2[x1,x2]*x2]
> solution1=Solve[D[profit1[x1,x2],x1]==0,x1][[1]]
> solution2=Solve[D[profit2[x1,x2],x2]==0,x2][[1]]
> r1[x2_] := Evaluate[x1/.solution1]
> r2[x1_] := Evaluate[x2/.solution2]
> c=b1
> b1=b2=c=1
> isoprofitLines=ContourPlot[profit1[x1,x2],{x1,0,7},{x2,0,7},ContourShading->False]
> reactionCurves=ParametricPlot[{{r1[t],t},{t,r2[t]}},{t,0,7}]
> Show[isoprofitLines,reactionCurves]
> 


  • Prev by Date: Re: two questions
  • Next by Date: Re: [TS 27522]--Re:Re: PageWidth option is not measured in characters
  • Previous by thread: Re: Evaluate, /., {{...}}, etc.
  • Next by thread: new procedure for converting a new recursive polynomial set into matrices