So I am trying to make a resonance curve like this one below, using NDSolve.
I tried to use code as below. Basically I try to hold solution for a w (driving frequency value) using NumericQ and then find the max amplitude using FindMaxValue when t is big enough. But my code returns a lot of error code I don't understand. By the way, I am using NDSolve directly, so I can test the accurateness of NDSolve Method.
ClearAll;
f[w_?NumericQ] :=
Block[{sol},
sol = NDSolve[{x''[t] + x'[t] + x[t] == Cos[w*t], x[0] == 0, x'[0] == 0},
x[t], {t, 0, 100}];
(FindMaxValue[x[t], {t, 50}])[[1]]]
ListLinePlot[Table[f[w], {w, 0, 100, 1}], DataRange -> {0, 100}]