How to make a Dynamic Plot of a Differential Function?

I'm currently trying to make an educational aid that would graph the position of an object as derived from a second order differential equation. What I would like is for the graph to change as I change the various constants of the equation.

What I currently have looks like this:

a = Manipulate[
DSolve[{m*x''[t] + b*x'[t] + k*x[t] == 0, x == 5, x' == 0},
x[t], t], {b, 1, 20, .1}, {m, 1, 20, .1}, {k, 1, 20, .1}]

f[t_] = x[t] /. a[];

Dynamic[Plot[f[t], {t, 0, 20}]]

The manipulate works fine, it provides sliders and will output a correctly solved x(t) for the differential for whatever constants I change the sliders to. However, the plot doesn't update as the sliders update. Any advice on how to get the plot to correctly update would be greatly appreciated

• Does this Q&A answer your question? – bobthechemist Mar 3 '17 at 2:49

Using Manipulate. It is best to keep everything inside Manipulate, and not have separate functions outside. code

Manipulate[
tick;
sol = x[t] /.
First@DSolve[{m*x''[t] + b*x'[t] + k*x[t] == 0, x == x0,
x' == xd0}, x[t], t];
Plot[sol, {t, 0, 20}, PlotRange -> All, ImageSize -> 300,
ImagePadding -> All, Frame -> True,
FrameLabel -> {{"y(t)", None}, {"t (sec)", "Solution to ODE"}},
GridLines -> Automatic, GridLinesStyle -> LightGray,
BaseStyle -> 14],

Grid[{
{"damping b",
Manipulator[Dynamic[b, {b = #; tick = Not[tick]} &], {1, 20, .1},
ImageSize -> Tiny], Dynamic[b]
},

{"mass m",
Manipulator[Dynamic[m, {m = #; tick = Not[tick]} &], {1, 20, .1},
ImageSize -> Tiny], Dynamic[m]
},

{"stifness k",
Manipulator[Dynamic[k, {k = #; tick = Not[tick]} &], {1, 20, .1},
ImageSize -> Tiny], Dynamic[k]
},

{"x(0)",
Manipulator[
Dynamic[x0, {x0 = #; tick = Not[tick]} &], {0, 20, .1},
ImageSize -> Tiny], Dynamic[x0]
},

{"x'(0)",
Manipulator[
Dynamic[xd0, {xd0 = #; tick = Not[tick]} &], {0, 20, .1},
ImageSize -> Tiny], Dynamic[xd0]
}
}, Alignment -> Center, Spacings -> {1, 1}, Frame -> True],

{{tick, False}, None},
{{m, 1}, None},
{{b, 1}, None},
{{k, 1}, None},
{{x0, 5}, None},
{{xd0, 0}, None},
TrackedSymbols :> {tick},
SynchronousUpdating -> False,
ControlPlacement -> Left
]