Question Sheet 10 - Challenge Problem Example Answers

1a) The equation of motion for a damped oscillator is x''(t)+(b/m)x'(t)+(k/m)x(t)=0. Set k = 5 N/m and m = 2 kg (remember to include the units in your code). Solve the differential equation.

k=5(*N/m*);m=2(*kg*);

DSolve[{x''[t]+(b/m)x'[t]+(k/m)x[t]==0,x'[0]==0,x[0]==1},x[t],t]

b) Make a function, depending on b and t, with the output of the above DE as its RHS.

f[b_,t_]:=(1/(2 (Sqrt[-40+(b^2)])))(-b (E^((1/4) (-b-(Sqrt[-40+(b^2)])) t))+(Sqrt[-40+(b^2)]) (E^((1/4) (-b-(Sqrt[-40+(b^2)])) t))+b (E^((1/4) (-b+(Sqrt[-40+(b^2)])) t))+(Sqrt[-40+(b^2)]) (E^((1/4) (-b+(Sqrt[-40+(b^2)])) t)))

c) Now make a function which plots the above function over the range t from 0 to 10. (Remember to label your axes!)

g[b_]:=Plot[f[b,t],{t,0,10},AxesLabel->{"t","x(t)"},PlotLabel->"Damped Oscillator"]

d) Use manipulate to animate this plot for a range of values for b from 1 to 10.

Manipulate[g[b],{b,1,10}]

e) The range of the x(t) axis changes depending on the value of b in our above manipulate, so it is not very useful for comparing the output for different values of b. Create a new function, which has a Plot[ ] function with a fixed range. Then make a manipulate of this function.

h[b_]:=Plot[f[b,t],{t,0,10},AxesLabel->{"t","x(t)"},PlotLabel->"Damped Oscillator",PlotRange->{-1,1}]

Manipulate[h[b],{b,1,10}]