TransWikia.com

How to solve this DE?

Mathematica Asked by Rahul Chakraborty on December 11, 2020

I’m pasting a code of a DE.I’m getting error. Plz suggest correction.

Clear[x];
r=1;
eqn=x'[t]-1-r*x[t]-(x^2)[t];
sol=NDSolve[{eqn,x[0]==0},x,{t,0,100}][[1]];

tTicks=Range[-24,24 30,24];
tGrid=Range[-60,24 30,6];

ParametricPlot[Evaluate[{x[t],x'[t]}/.sol],{t,0,100},Frame->True,FrameTicks->{tTicks,Automatic},FrameTicksStyle->Directive[Red,Thick],GridLines->{tGrid,Automatic},GridLinesStyle->LightGray,FrameLabel->(Style[#,14,Bold]&/@{x,Overscript[x,"."]}),AspectRatio->1]

ParametricPlot[Evaluate[{t,x[t]/.sol}],{t,0,50},Frame->True,FrameTicks->{Range[0,50,12],Automatic},FrameTicksStyle->Directive[Red,Thick],GridLines->{tGrid,Automatic},GridLinesStyle->LightGray,FrameLabel->(Style[#,14,Bold]&/@{t,x}),AspectRatio->1]

I made the correction regarding the syntax error. But still no execution.

The following code,

Clear[x];
r=1;
eqn=x'[t]-1-r*x[t]-x[t]^2==0;sol=NDSolve[{eqn,x[0]==0},x,{t,0,100}][[1]];
tTicks=Range[-24,24 30,24];
tGrid=Range[-60,24 30,6];

ParametricPlot[Evaluate[{x[t],x'[t]}/.sol],{t,0,100},Frame->True,FrameTicks->{tTicks,Automatic},FrameTicksStyle->Directive[Red,Thick],GridLines->{tGrid,Automatic},GridLinesStyle->LightGray,FrameLabel->(Style[#,14,Bold]&/@{x,Overscript[x,"."]}),AspectRatio->1]

ParametricPlot[Evaluate[{t,x[t]/.sol}],{t,0,50},Frame->True,FrameTicks->{Range[0,50,12],Automatic},FrameTicksStyle->Directive[Red,Thick],GridLines->{tGrid,Automatic},GridLinesStyle->LightGray,FrameLabel->(Style[#,14,Bold]&/@{t,x}),AspectRatio->1]

Giving me the errors

NDSolve::dvnoarg: The function x appears with no arguments. >>

ReplaceAll::reps: {-x[t]^2+(x^2)[t]==0,x[0]==0} is neither a list of
replacement rules nor a valid dispatch table, and so cannot be used
for replacing. >>

ReplaceAll::reps: {-x[0.00204082]^2+(x^2)[0.00204082]==0,x[0]==0} is
neither a list of replacement rules nor a valid dispatch table, and so
cannot be used for replacing. >>

ReplaceAll::reps: {-1.
x[0.00204082]^2+(x^2)[0.00204082]==0.,x[0.]==0.} is neither a list of
replacement rules nor a valid dispatch table, and so cannot be used
for replacing. >>

General::stop: Further output of ReplaceAll::reps will be suppressed
during this calculation. >>

Regards

One Answer

This is an initial attempt to improve your answer. First eliminate errors in the first three lines, and focus on a small t up to 1.2. Beyond that there is a singularity/stiff system. This is for the small t range!

     Clear[x];
     r = 1; 
    sol = NDSolve[{Derivative[1][x][t] - 1 - r*x[t] - x[t]^2 == 0, 
       x[0] == 0}, x, {t, 0, 1.2}]
    Plot[Evaluate[x[t] /. sol], {t, 0, 1.2}]
    ParametricPlot[Evaluate[{x[t], Derivative[1][x][t]} /. sol], {t, 0, 1.2}]

enter image description here

First plot shown here.

Further to the singularity issue, one can explore the sensitivity of parameters for this specific differential equation using

Clear[x, r, s]; 
sol = ParametricNDSolve[{Derivative[1][x][t] - s - r*x[t] == x[t]^2, 
   x[0] == 0}, x, {t, 0, 5}, {r, s}]

Plot[Evaluate[Table[x[r, 0.02][t] /. sol, {r, 0.1, 0.6, 0.02}]], {t, 
  0, 5}, PlotRange -> All]

Plot[Evaluate[Table[x[0.2, s][t] /. sol, {s, 0.01, 0.06, 0.01}]], {t, 
  0, 5}, PlotRange -> All]

The plot (s fixed at 0.02) show how quickly the curve shoots up even for smaller r values

enter image description here

Answered by thils on December 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP