Plotting Differential equation x(t) vs t

I have the system equations as

x'[t] == x[t]*(1 - x[t]^2 - y^2) - y*(1.1 - y/(x[t]^2 + y^2)^(1/2))


I am trying to solve and plot the equation by using

sol1 = NDSolve[{x'[t] ==
x[t]*(1 - x[t]^2 - y^2) - y*(1.1 - y/(x[t]^2 + y^2)^(1/2)),
x[t] == 0}, x, {t, 0, 10}]


and

Plot[Evaluate[{x'[t] /. sol1}], {t, 0, 100}]


but I keep getting errors. And I do not understand why. This is what I should be plotting

• What is y? Your initial condition should be something like x[0] == 0, not x[t] == 0. – Carl Woll Oct 31 '17 at 22:49
• I am assuming y is a variable that may or may not vary with t. The plot I included is a plot of x(t) vs t. – user53231 Oct 31 '17 at 22:51
• y needs to be defined in some way, or you'll get the non-numerical value error from NDSolve. Also, you're solving for x[t] up to t == 10, but trying to plot it up to t == 100. – aardvark2012 Oct 31 '17 at 23:00
• If y is not a number, then you will need to use DSolve. NDSolve only works with numerical equations. – Carl Woll Oct 31 '17 at 23:00
• The plot you provide has to correspond to a particular value of y. Moreover, from the plot x[0] is not 0, and should be given. – José Antonio Díaz Navas Oct 31 '17 at 23:02

1 Answer

Firstly, in numeric computations, where possible, avoid using numbers with limited precision like yours 1.1 - replace by exact 1/10. Secondly, as many folks suggested in comments, you should pass to numerical functions such as NDSolve (N - is for numeric) things that are defined. So your comment:

I am assuming y is a variable that may or may not vary with t.

will not make it tractable by NDSolve. If you do not believe me you can check with Boromir ;-) The only way I can possibly reconcile "may or may not vary with t" is if y is a "weak" function of t depending on a small parameter. If that parameter goes to zero then y becomes a constant. Then you might experiment with your setup a bit trying different y-behaviors. Define a general function:

eq[y_] := x'[t] == x[t] (1 - x[t]^2 - y^2) - y (11/10 - y/(x[t]^2 + y^2)^(1/2))


In simplest case

eq[0]


you have nice analytic solution

DSolve[{eq[0], x[0] == a}, x, t]


which BTW is not periodic - a thing to notice. So you can experiment with more general forms of y. Not all forms will be integrable. I do not know your form of y so I pick any - replace at your will.

Manipulate[
Plot[{#,D[#,t]}//Evaluate,
{t,0,fi},PlotRange->All,Filling->Axis,
PlotTheme->"Detailed",PlotLegends->{x[t],x'[t]}]&@
NDSolveValue[
{eq[a+b Sin[2t]],x[0]==x0},
x,{t,0,fi}][t],
{{a,1/10},-2,2,Appearance->"Labeled"},
{{b,1/10},-1,1,Appearance->"Labeled"},
{{x0,1/10},-2,2,Appearance->"Labeled"},
{{fi,20},1,20,Appearance->"Labeled"}]