1
$\begingroup$

I have two best response functions that I have defined like this:

BRc[p_, s_, l_] := (3 p + 2 s + 4 l p s + 4 l s^2)/(4 (1 + 2 l s));
BRp[c_, s_, l_] := (-(c/s) - c/(s (2 + 4 l s)))/(
  1/(2 (1 + 2 l s)^2) - 2/(1 + 2 l s) - 2/(s (1 + 2 l s)));

I want to define certain ranges, values and add a title for the plot, like this:

Manipulate[
 ParametricPlot[{{p, BRc[p, s, l]}, {BRp[c, s, l], c}}, {c, 0, 
   50}, {p, 0, 50}, PlotStyle -> {{Blue, Thick}, {Red, Thick}}, 
  PlotRange -> {{0, 50}, {0, 50}}, AxesLabel -> {c, p}, 
  AspectRatio -> 1, 
  PlotLabel -> Style["Best Response Curves", Blue, 20]], 
 Style["Parameters", Bold, Medium], {s, 0, 10}, {l, 0, 10}]

But I need to define the following restrictions inside Manipulate[ ]:

p > 0 && ((0 < l < 1/
      2 && ((p < c < p/(2 l) && 
         0 < s < (-2 c + p)/(4 c l - 2 p)) || (c >= p/(2 l) && 
         s > 0))) || (1/2 <= l <= 1 && c > p && s > 0))

To make sure that the two functions always intersect.

I don't know where to insert the restrictions. Help needed here. Also I would like to name the axis

When I run the code without these restrictions, I get the following image/error:

enter image description here

$\endgroup$
2
  • $\begingroup$ You can try FrameLabel instead of AxesLabel. $\endgroup$
    – Karsten7
    Commented May 11, 2016 at 23:03
  • $\begingroup$ @Karsten7. FrameLabel worked. Thx! $\endgroup$
    – Saud
    Commented May 12, 2016 at 7:50

1 Answer 1

1
$\begingroup$

I am not confident that the restrictions

p > 0 && c > 
  p && ((0 < l < p/(2 c) && 
     0 < s < (-2 c + p)/(4 c l - 2 p)) || (p/(2 c) <= l <= 1 && 
     s > 0))

will ensure that the two functions will intersect.

However to answer the question about how to implement these restrictions in Manipulate we will redefine the two functions so that each have all four of the variables c, p, s and l.

Further we will apply the restriction to the definition of the functions:

BRc[p_, s_, l_, c_] := (3 p + 2 s + 4 l p s + 4 l s^2)/(4 (1 + 2 l s)) /; 
  p > 0 && c > 
    p && ((0 < l < p/(2 c) && 
       0 < s < (-2 c + p)/(4 c l - 2 p)) || (p/(2 c) <= l <= 1 && 
       s > 0))

BRp[c_, s_, l_, p_] := (-(c/s) - c/(s (2 + 4 l s)))/(1/(2 (1 + 2 l s)^2) - 
     2/(1 + 2 l s) - 2/(s (1 + 2 l s))) /; 
  p > 0 && c > 
    p && ((0 < l < p/(2 c) && 
       0 < s < (-2 c + p)/(4 c l - 2 p)) || (p/(2 c) <= l <= 1 && 
       s > 0))

Now the Manipulate can be used (it is a bit slow). I found that l had to be greater than zero and less than 1 in order for the restriction to be satisfied.

Manipulate[
 ParametricPlot[{{p, BRc[p, s, l, c]}, {BRp[c, s, l, p], c}}, {c, 0, 
   50}, {p, 0, 50},
  PlotStyle -> {{Blue, Thick}, {Red, Thick}},
  PlotRange -> {{0, 50}, {0, 50}},
  AspectRatio -> 1,
  PlotLabel -> Style["Best Response Curves", Blue, 20]
  ],

 {{s, 1}, 0, 10, Appearance -> "Open"},
 {{l, 0.001}, 0.001, 1, Appearance -> "Open"}
 ]

Mathematica graphics

I was not able to get AxesLabel to work. My workaround would be to manually label with with text or see if you can find a solution on this site.

$\endgroup$
1
  • $\begingroup$ Jack, thx for input! l<1 means that they always intersect? I fixed the labeling using FrameLabel - suggestion from @Karsten7 above. $\endgroup$
    – Saud
    Commented May 12, 2016 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.