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
NDSolve
? If it is, the rest of the info is extraneous. Is it in theParametricPlot
? Then perhaps remove all of the unnecessary formatting options which are most likely irrelevant. Also, please edit your post so that the code are in code blocks: clock the grey question mark on the far right of the toolbar when editing your post for help. Edit: the error that you get tells you exactly what the problem is. Replaceeqn
witheqn==0
insideNDSolve
. Secondly, you have some syntax errors:(x^2)[t]
should bex[t]^2
. $\endgroup$