I want to get a function as output form DSolve. For Example :
sol = DSolve[{Q''[t] + 40 Q'[t] + 625 Q[t] == 100*Cos[10*t], Q[0] == 0, Q'[0] == 0}, Q[t], t]
I want to use Q[t] as a function to use in an another equation.
Answer
It's not too hard:
dsaad[t_] = Q[t] /. First @ DSolve[{Q''[t] + 40 Q'[t] + 625 Q[t] == 100*Cos[10*t],
Q[0] == 0, Q'[0] == 0}, Q, t]
Notes:
I instructed
DSolve[]to return the pure functionQ(through the second argument) instead of the function itself to ease the replacement.I used
Set[](=) instead ofSetDelayed[](:=), so that the replacement is done at once before the definition takes place.
Another possibility is to use DifferentialRoot[] instead:
dsaad[x_] := DifferentialRoot[Function[{Q, t},
{Q''[t] + 40 Q'[t] + 625 Q[t] == 100*Cos[10*t], Q[0] == 0, Q'[0] == 0}]][x]
Comments
Post a Comment