0
$\begingroup$

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

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

$\endgroup$
  • $\begingroup$ Gosh, this is so easy, just use NDSolveValue instead of NDSolve. Is there any reason why should one use the latter instead of former? $\endgroup$ – Pygmalion Oct 14 '15 at 6:50
  • $\begingroup$ @Pygmalion Yes, NDSolve returns replacement rules that are a fundamental Mathematica construct. You just don't need them in this case. $\endgroup$ – Dr. belisarius Oct 14 '15 at 11:13
1
$\begingroup$
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} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.