0
$\begingroup$

I'm trying to analyze the roots of this function

$$f(y;a_1,a_2,b_1,b_2,c_1,c_2) = \frac{a_1}{1 + b_1 e^{-c_1 y}} - \frac{a_2}{1 + b_2 e^{-c_2 y}}$$

For example, I fix (in manipulate), $a_1, a_2, b_1, b_2, c_1$ and vary $c_2$ (in parametric plot maybe?) and I would like a plot of the location of the zeros.

I tried this:

Manipulate[
 soln = Solve[a1/(1 + b1 Exp[-c1 y]) - a2/(1 + b2 Exp[-c2 y]) == 0, y];
 ParametricPlot[Evaluate[y /. soln], {c2, 0, 1}], {a1, 0.01, 2}, {a2, 
  0.01, 2}, {b1, 0.01, 2}, {b2, 0.01, 2}, {c1, 0.01, 2}]

But I get that warning that some solutions will not be found. Thanks for your help.

$\endgroup$

1 Answer 1

1
$\begingroup$

I think you are looking for something like that (working with MMA version 8.0):

f[y_, a1_, a2_, b1_, b2_, c1_, c2_] = 
                  a1/(1 + b1 Exp[-c1 y]) - a2/(1 + b2 Exp[-c2 y])

I correct my former answer and now work with Reduce. For all parameters Reduce yields an equation together with a condition (...!=0).

Manipulate[
    Reduce[f[y, a1, a2, b1, b2, c1, c2] == 0] // Quiet, {a1, 0.01, 
    2}, {a2, 0.1, 2}, {b1, 0.01, 2}, {b2, 0.01, 2}, {c1, 1, 2}]

(*     E^(1.247 y) == 
       0.000361533 (18326. E^(c2 y) + 11875. E^(1.247 y + c2 y)) && 
       6.06035*10^18 + 3.91644*10^19 E^(c2 y) + 3.53485*10^19 E^(2 c2 y) + 
       2.11188*10^19 E^(1.247 y + c2 y) + 
       2.29054*10^19 E^(1.247 y + 2 c2 y) != 0    *)

Ploting the equation and Not[condition] shows y solutions depending an c2 as the red curve, where it is not crossed by the blue condion curve.

Manipulate[red = Reduce[f[y, a1, a2, b1, b2, c1, c2] == 0] // Quiet; 
  ContourPlot[
   Evaluate[{red[[1]], ! red[[2]]} /. {y -> yy, c2 -> cc2}], {yy, -20, 
   20}, {cc2, .01, 2}, MaxRecursion -> 4, 
   ContourStyle -> {Red, Blue}], {a1, .01, 2}, {a2, 0.01, 2}, {b1, 
   0.01, 2}, {b2, 0.01, 2}, {c1, 0.01, 2}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks for your answer. How do we know if we miss roots here? I only see one root (the plot is 1-1). Would this be fixed by removing one of the "First" commands? $\endgroup$ Commented Sep 28, 2017 at 16:03
  • $\begingroup$ Also I just tried this on Mathematica 11 and I got errors: Part::partd: Part specification 0.476184[[1]] is longer than depth of object. $\endgroup$ Commented Sep 28, 2017 at 18:13
  • $\begingroup$ I corrected my answer. It is better to work with Reduce. See above. $\endgroup$ Commented Sep 28, 2017 at 18:37

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.