Hi I am just beginning to learn Mathematica and this is my first time I have been exposed to any type of coding. I am encountering a problem in a basic physics problem. For example we are always interested in solving the motion of a projectile with differential equation

x''[t]+k x'[t]==0

Usually though the initial conditions of the velocity in the x (and y direction) depend on the angle (theta) and the magnitude of the initial velocity (v0). Therefore the initial conditions usually look like:

x[0]==0,x'[0]==v0 Cos[theta]

My question is there a way to work around DSolve so that it can output a solution of the form x[t,v0,theta]? I have tried calling the initial condition v0x and simply defining that as

v0x:=v0 Cos[theta]

But I haven't any luck...


1 Answer 1


Something like this?

sol = First @ DSolve[{D[x[t, v0, theta], {t, 2}] + k D[x[t, v0, theta], t] == 0, 
  x[0, v0, theta] == 0, 
  Derivative[1, 0, 0][x][0, v0, theta] == v0 Cos[theta]}, x, {t, v0, 
(*  {x -> Function[{t, v0, theta}, (E^(-k t) (-1 + E^(k t)) v0 Cos[theta])/k]}  *)


x[t, 10, Pi/4] /. sol
(*  (5 Sqrt[2] E^(-k t) (-1 + E^(k t)))/k  *)

(Note this is not projectile motion under gravity, but it gives you the idea how to use DSolve, I hope.)

  • $\begingroup$ This was what I was going for. Genius. I am going to play around with Mathematica and see if I can solve in y motion and how to use the solutions to plot. Thank you! $\endgroup$
    – phandaman
    Commented Jan 26, 2015 at 3:39
  • $\begingroup$ @phandaman You're welcome. Good luck! $\endgroup$
    – Michael E2
    Commented Jan 26, 2015 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.