0
$\begingroup$

I want to manipulate non linear differential equations

$\dot{x}= x + g\, xy\quad \dot{y}= 1-2x^2-g\, y^2$

where g as parameter.but I don't get any curve on display. Plz help me

$\endgroup$
3

1 Answer 1

2
$\begingroup$
ClearAll["Global`*"]
Remove["Global`*"]

{ysol, xsol} = ParametricNDSolve[{x'[t] == x[t] + g*x[t]*y[t], 
y'[t] == 1 - 2*x[t]^2 - g*y[t]^2, x[1] == 1, y[1] == 1}, {y, x}, {t, 0, 10}, {g}];

ParametricPlot[Evaluate@Table[{y[g][t] /. ysol, x[g][t] /. xsol}, {g, 0, 1, 
1/4}], {t, 0, 2}, PlotRange -> {{-3, 3}, {-3, 3}}, 
PlotLegends -> {"g=1/4", "g=2/4", "g=4/4", "g=4/4"}] // Quiet

enter image description here

For certain values ​​of g ParametricNDSolve gives a warning messages,because system is stiff(solution is singular).This can be a help in some cases by changing the method

 g=3.5
 y[g][t] /. ysol

enter image description here

This may be the reason that the ParametricPlot does not shows parametric curve.

Edited:

Code for g-parameter manipulation.

{ysol, xsol} = ParametricNDSolve[{x'[t] == x[t] + g*x[t]*y[t], 
y'[t] == 1 - 2*x[t]^2 - g*y[t]^2, x[1] == 1, y[1] == 1}, {y, 
x}, {t, 0, 10}, {g}];

Manipulate[ParametricPlot[
Evaluate[{y[g][t] /. ysol, x[g][t] /. xsol}], {t, 0, 2}, 
PlotRange -> {{-5, 5}, {-5, 5}}, 
PlotLegends -> {"g"}], {{g, 0, "g parameter"}, -1, 1, 1/4}]

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.