2
$\begingroup$

I want to manipulate a differential equation, but I am not getting any graph for it. The following is the code that I have used.

P[t_, a_, b_, c_, d_] = p[t] /.First@NDSolve[{p'[t] - (a*p[t]^2) - b*p[t] + c*(p[t]^(1 - d)) == 0, 
p[0] == 1}, p, {t, 0, 0.335}]; Manipulate[Plot[P[t, a, b, c, d], {t, 0, 0.335}, 
PlotLabel -> P[x, a, b]], {{a, 1, "a"}, -10, 10, 
Appearance -> "Labeled"}, {{b, 1, "b"}, -5, 5, 
Appearance -> "Labeled"}, {{c, 1, "c"}, -5, 5, 
Appearance -> "Labeled"}, {{d, 1, "d"}, -5, 5, 
Appearance -> "Labeled"}]

Note, the differential equation reaches singularity quite quickly, one of the reason why I have used t=0.335 in the code.

Need Help, Thanks in advance

$\endgroup$
3
$\begingroup$

ParametricNDSolve can be helpful:

Manipulate[
 Plot[f[p1, p2, p3, p4][t], {t, 0, 0.3}, PlotRange -> {-1, 10}],
 {{p1, 1, "a"}, -10, 10, Appearance -> "Labeled"}, {{p2, 1, "b"}, -5, 
  5, Appearance -> "Labeled"}, {{p3, 1, "c"}, -5, 5, 
  Appearance -> "Labeled"}, {{p4, 1, "d"}, -5, 5, 
  Appearance -> "Labeled"},
 Initialization :> (
   f = p /. 
     ParametricNDSolve[{p'[t] - (a*p[t]^2) - b*p[t] + 
         c*(p[t]^(1 - d)) == 0, p[0] == 1}, 
      p, {t, 0, 0.335}, {a, b, c, d}])]

enter image description here

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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