1
$\begingroup$

I have two functions with two parameters (p & x). I am looking for the values of "x" that makes the two functions to be equal, varying "p" from 0 to 1. I have two solutions for this implicit solution, but I am only interested on drawing the first solution where there are equal. The problem looks something like this:

VF[x_, p_] = 
  50 (1 - p) x + 25 p x + 
   59 (0.044/(1/p)^3.7 + (0.52 (1 - p))/(1/p)^2.7) x^2.7;

VL[x_, p_] = -100 + 
   180 p x - (14 x^2.7)/(1/p)^3.7 + (-1 + 
      p) (-50 x + (17 x^2.7)/(1/p)^2.7);

Manipulate[
 Plot[Evaluate@{VF[x, p], VL[x, p]}, {x, 0, 5}], {{p, 1, "p"}, 0.00001, 1}]

Two functions, varying "p", with x in the horizontal axis

Using ContourPlot I get the two curves for "p" within [0,1] and I haven't been able to get rid of the second curve (second solution for each "p") in the plot.

CountourPlot with two solutions for x, varying p from 0 to 1

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – bbgodfrey
    Commented Apr 22, 2015 at 12:20
  • $\begingroup$ you should show the ContourPlot command you used. $\endgroup$
    – george2079
    Commented Apr 22, 2015 at 13:39

1 Answer 1

1
$\begingroup$

One approach:

 p[ x_ ] := p /. 
      First@FindRoot[ VF[x, p] - VL[x, p] == 0 , { p, 0.001 }]
 ParametricPlot[{p[x], x}, {x, .5, 5}, AspectRatio -> 1/GoldenRatio]

enter image description here

Note this is somewhat fortuitous that we can pick an initial guess at p that consistently yields the first solution..

Another approach is to operate on the graphics generated by contour plot to pull out the lines:

 lines = Cases[Normal@First@
    Cases[ContourPlot[ 
       VF[x, p] - VL[x, p] == 0  , {p, 0, 1}, {x, 0, 
           5}], _GraphicsComplex, Infinity], _Line , Infinity];

  GraphicsColumn[
      Graphics[ #  , Axes -> True, AspectRatio -> 1/GoldenRatio] & /@ lines]

enter image description here

enter image description here

$\endgroup$

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.