0

I am solving differential equation of second order

g = 9.81
k = 0.009
r = 10
b = 0
ω = Sqrt[g/r]

s = NDSolve[{r/g*y''[x] + (k*r/g + b*r^2/mg)*y'[x]^2 + Cos[x] - k*Sin[x] == 0, 
            y[0] == π/2, y'[0] == ω, y, {x, 0, 2}]

and I know hot to display the result.

Plot[Evaluate[y[x] /. s], {x, 0, 1.8}, PlotRange -> All]
Plot[Evaluate[y'[x] /. s], {x, 0, 1.8}, PlotRange -> All]

But I do not know how to display y' as function of y, i.e. y'[y].

I would also like to know how to find the value of x for y=-\[Pi]/2.

Is this possible?

Thanks for help

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
Pygmalion
  • 147
  • 8

2 Answers2

1
g = 9.81;
k = 0.009;
r = 10;
b = 0;
ω = Sqrt[g/r];

s = First@NDSolve[{r/g*y''[x] + (k*r/g + b*r^2/mg)*y'[x]^2 + Cos[x] - k*Sin[x] == 0, y[0] == π/2, y'[0] == ω, y, {x, -5, 1}];

ParametricPlot[{y[t] /. s, y'[t] /.s}, {t, 0, 2}, AspectRatio -> 1/GoldenRatio]

enter image description here

y Doesn't take on the value -π/2 for positive x:

Plot[{-(π/2), y[t] /. s}, {t, -5, 5}]

enter image description here

So:

FindRoot[Evaluate[-(π/2) == y[t] /. s], {t, -2}]
(* {t -> -1.85664} *)
march
  • 23,399
  • 2
  • 44
  • 100
1
s = NDSolveValue[{r/g*y''[x] + (k*r/g + b*r^2/mg)*y'[x]^2 + Cos[x] - k*Sin[x] == 0, 
                  y[0] == π/2, y'[0] == ω}, y, {x, 0, 2}];
Plot[{s[x], s'[x]}, {x, 0, 1.8}, PlotRange -> All]

Mathematica graphics

ParametricPlot[{s[x], s'[x]}, {x, 0, 1.8}, PlotRange -> All]

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • Gosh, this is so easy, just use NDSolveValue instead of NDSolve. Is there any reason why should one use the latter instead of former? – Pygmalion Oct 14 '15 at 06:50
  • @Pygmalion Yes, NDSolve returns replacement rules that are a fundamental Mathematica construct. You just don't need them in this case. – Dr. belisarius Oct 14 '15 at 11:13