I'm stumped. I'm trying to write this using vectors, but the 2nd derivative isn't being expanded like I expected it to be. This is a system of equations for a projectile with quadratic drag and gravity (the linear drag is ignored for now). Negative Z is down, X and Y are the horizontal plane. If I write it as 9 equations, one for each coordinate, it works fine, but I'd rather use vectors since it is shorter and (to at least me) more obvious what is going on. Plus since I am new to Mathematica it would be good to learn more/better ways to use it.
gravity = 10;
withDrag[p0_, v0_, drag_] :=
NDSolve[{
p[0] == p0,
p'[0] == v0,
p''[t] == drag * Norm[p'[t]] * p'[t] + {0,0,-gravity}},
{p}, {t, 0, 5}]
withDrag[{0,0,0}, {0,10^4,10}, 0.001]
I get:
NDSolve::ndfdmc: Computed derivatives do not have dimensionality consistent with the initial conditions. >>
NDSolve[{
p[0] == {0, 0, 0},
p'[0] == {0, 10000, 10},
p''[t] == {
0.001 Norm[p'[t]] p'[t],
0.001 Norm[p'[t]] p'[t],
-10 + 0.001 Norm[p'[t]] p'[t]}},
{p}, {t,0,5}]
I formatted the output to make the error more obvious. Each of elements of the p'' vector has all three elements of p'[t]. Each one should really be p'[t][[dim]] (or something like that).
Any clues as to what I'm doing wrong?