Numerical simulation of mechanics problem Say I have a planet and shoot something with a given velocity, which is a significant portion of the escape velocity, in a given angle into the sky. It has some initial velocity and there is the force of gravity acting on it.
I simulated something like this before by creating my own Java vector class, and applying the force onto the velocity in small time intervals and then the velocity onto the position. It worked, but it took quite some time for a simple problem.
Is there any easier way to simulate more or less arbitrary trajectories in force fields?
I have Java, Python and Mathematica around, if any of those help.
 A: In Mathematica you can directly solve the differential equations:
DSolve[{y''[t]==Fy/mass,x''[t]==Fx/mass,y'[0]==vy0,x'[0]==vx0,y[0]==y0,x[0]==x0},{x,y},t]
This is the general format, and you can introduce whatever force you want, even forces which vary with time, or are functions of velocity (i.e. drag). For example, the free-trajectory problem you describe you use Fy=-mg and Fx=0 with vy0=v0 Sin[q] and vx0=v0 Cos[q], where q is the launch angle.
There are some cases where DSolve will not work (i.e. no closed-form solution), then you can use NDSolve to solve the differential equations numerically.
A: If you don't have access to Mathematica, you can use C++ or Java and directly integrate the solution based on Euler's method. Say you have $\frac{dy}{dx}=cos(x) x$ a quick and dirty C++ Euler loop would look like this:
for(int i=0;i<steps;++i){
 y[i]=y[i-1] + step_size * (cos(x[i-1]) * x[i-1]);
}

Just remember to declare your array as a static double. Otherwise you may get stack overflow errors.
A: A small comment:  You'll find that numerical solutions to Newton's equations can have annoying instabilities.  Some of these are real properties of the physics, and some of them are numerical errors.  For example, using the most naive discretized time derivatives, you tend not to preserve energy over time.  This can be ameliorated somewhat by working in phase space, solving Hamilton's equations.
I found the following lecture notes helpful when I was reading about this stuff:  http://math.utaustinportugal.org/summer08/COLAB-Engquist-08.pdf
