I have to model a rocket projectile and, although I understand the question, I can't get the code to work in Mathematica.
Here is the question:
A rocket with a unit mass is fired from the ground with a velocity of 100m/s at an angle 60 degrees with the horizontal (hint: use Degree to convert degrees to radians). The rocket experiences a drag so that the equations of motion are: x'' = - a x' and y'' = -g - a y' where a is the drag coefficient. Modify the code from the workshop to solve the new equations; assume g=9.81 and a=0.1. Find the time at which the rocket will hit the ground and then the horizontal distance it will cover until it hits the ground. On a single graph, plot the trajectory of the rocket (hint: use Solve and ignore any warnings) for a selection of values of a; label the axes and plots.
My coding attempt:
(* Exercise 4 *)
ClearAll["Global`*"]
(*g=gravity; a=drag; vx=Initial Horiz.Velocity; vy=Initial Vert.Velocity*)
g = 9.81; a = 0.1; vx = 100/Tan[Pi/3]; vy = 100;
solution = DSolve[{x''[t] == -a*x'[t], y''[t] == -g - a*y'[t], x'[0] == vx, y'[0] == vy, x[0] == 0, y[0] == 0}, {x[t], y[t]}, t];
horiz[t_] = Evaluate[x[t] /. solution[[1]]];
vert[t_] = Evaluate[y[t] /. solution[[1]]];
ParametricPlot[{horiz[t], vert[t]}, {t, 0, 100}, PlotRange -> {0, 100}]
Help would be much appreciated.
NDSolve, which assigns the right hand side to the left. When you correct it to the double == for equality, it is nowTrue. Short of restarting the kernel, you canClearthe left hand side. – Chris K Oct 18 '16 at 14:39