# How to display results of NDSolve

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 == π/2, y' == ω, 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

• In your ODE you have the variable mg not m*g. Interesting NDSolve gives nor error message. What do I overlook? – user31001 Oct 13 '15 at 19:17
• @Willinski, the fact that b==0? – panda-34 Oct 13 '15 at 19:30
• @panda-34 ok, I get it. – user31001 Oct 13 '15 at 19:31
• @Willinski Yes, it is error. Fortunately I put b=0 in order to simplify. – Pygmalion Oct 14 '15 at 6:10

s = NDSolveValue[{r/g*y''[x] + (k*r/g + b*r^2/mg)*y'[x]^2 + Cos[x] - k*Sin[x] == 0,
y == π/2, y' == ω}, y, {x, 0, 2}];
Plot[{s[x], s'[x]}, {x, 0, 1.8}, PlotRange -> All] ParametricPlot[{s[x], s'[x]}, {x, 0, 1.8}, PlotRange -> All] • 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 6: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
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 == π/2, y' == ω, y, {x, -5, 1}];

ParametricPlot[{y[t] /. s, y'[t] /.s}, {t, 0, 2}, AspectRatio -> 1/GoldenRatio] y Doesn't take on the value -π/2 for positive x:

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

FindRoot[Evaluate[-(π/2) == y[t] /. s], {t, -2}]
(* {t -> -1.85664} *)