# Plotting a nonlinear damped pendulum with adjustable damping variable

I am trying to graph the formula of the angle of a damped pendulum over time which starts at an angle pi/3 with a 0 angular velocity. The angles used are too large to make use of the small-angle approximation and there is no driving force, so the equation is

y''[x] + b*y'[x] + (g/l)*Sin[y[x]] == 0, y[0]==π/3,y'[0]==0


I have already done the work to separate it into two first-order DEs (if this helps)

x'[t] == y[t], y'[t] == 0 - b*y[t] - (g/l) Sin[x[t]],
x[0] == π/3, y[0] == 0}


I would like to plot it such that I can manipulate b (I don't care about manipulating g or l since g is constant and I only care about a few values for l), but no matter what I do I just keep getting errors. I've tried all sorts of things with DSolve and NDSolve but nothing seems to work. I was able to get a plot of a graph once I set b to be a particular value like so:

ode1 = {x'[t] == y[t], y'[t] == 0 - 0.5*y[t] - (9.8/0.23) Sin[x[t]],
x[0] == π/3, y[0] == 0};
sol = NDSolve[ode1, x[t], {t, 0, 20}]
Plot[Evaluate[x[t] /. sol], {t, 0, 20}, PlotRange -> All]


However, when I try to change it so that I can use manipulate on the plot to adjust b, I just get errors. Is there any way I can make this work?

• Welcome to MMA Stackexchange. One way of doing this is to create a Module test[bst_] := Module[{b = bst}, ode1 = {x'[t] == y[t], y'[t] == 0 - b*y[t] - (9.8/0.23) Sin[x[t]], x[0] == \[Pi]/3, y[0] == 0}; sol = NDSolve[ode1, x[t], {t, 0, 20}]; Plot[Evaluate[x[t] /. sol], {t, 0, 20}, PlotRange -> All] ]and then place this in Manipulate[test[b], {b, 0.1, 1.0}] Commented Nov 12, 2018 at 20:30

Perhaps ParametricNDSolve is the function you are looking for:
X = ParametricNDSolveValue[ode1, x , {t, 0, 20}, b] (**)

Manipulate[Plot[  X[b][t]   , {t, 0, 20}, PlotRange -> All], {{b, 0.5}, 0,1, Appearance -> "Labeled"}]