I'm trying to solve an ODE with two independent variables (a cannon firing from a cliff incorporating wind resistance dependent on velocity). I've tried the following for the x-component:
NDSolve[{x''[t, θ] == -0.2*x'[t, θ]/2.30, x'[0, θ] == 10.8*Cos[θ], x[0, θ] == 0},
x[t, θ], t]
Assuming my algebra is correct, how do I properly phrase this input to give me x[t, θ]
?
Answer
If :
sol = DSolve[{D[x[t, th], {t, 2}] == -0.2*D[x[t, th], t]/2.30,
Derivative[1, 0][x][0, th] == 10.8*Cos[th], x[0, th] == 0}, x[t, th], t];
then you can use the solution as :
Plot3D[x[t, th] /. sol, {t, 0, 10}, {th, -Pi, Pi}]
Some checks :
x[t, th] /. First[sol] /. t -> 0
(* 0. *)
Simplify[D[sol[[1, 1, 2]], t] /. t -> 0]
(* 10.8 Cos[th] *)
A more general and robust way to keep the solution for future use is to define :
Remove[sol]
sol[t_, th_] = DSolve[{D[x[t, th], {t, 2}] == -0.2*D[x[t, th], t]/2.30,
Derivative[1, 0][x][0, th] == 10.8*Cos[th], x[0, th] == 0}, x[t, th], t][[1, 1, 2]];
which you can now use as any other function. For instance :
Manipulate[Plot[sol[t, th], {t, 0, 10}], {th, 0, Pi/2}]
Comments
Post a Comment