Need help to plot a solution of a differential equation

Clear[t]
solx = DSolve[{x”[t] + k x'[t] == 0, x[0] == 0,
x'[0] == v0 Cos[theta]}, x[t], t][[1, 1, 2]] // Simplify
soly = DSolve[{u”[t] + k u'[t] == -g, u'[0] == v0 Sin[theta],
u[0] == 0}, u[t], t][[1, 1, 2]] // Simplify
v0=10;(*m/s*)
k=1.;
theta=Pi/4;

The soluton of this differential equation describes the trajectory of a particle
considering the air resistance. Im wondering if anyone has a good way plot the solution in 2D.

Thanks!

=================

1

 

ParametricPlot[{solx, soly} /. g -> 9.8, {t, 0, 1}, AspectRatio -> 1].
– march
Dec 16 ’15 at 19:46

=================

1 Answer
1

=================

v0 = 10;
k = 1.;
theta = Pi/4;
g = 10;
solx = DSolve[{x”[t] + k x'[t] == 0, x[0] == 0, x'[0] == v0 Cos[theta]}, x[t], t]
soly = DSolve[{u”[t] + k u'[t] == -g, u'[0] == v0 Sin[theta], u[0] == 0}, u[t], t]
ParametricPlot[{x[t], u[t]} /. solx /. soly, {t, 0, 1}]

To plot until it comes down to earth:

tf = t /. First@Solve[(u[t] /. soly) == 0 && t > .1, t]
ParametricPlot[{x[t], u[t]} /. solx /. soly, {t, 0, tf}]

Here you have the same, done with the vectorial form of NDSolve[ ]

th = Pi/4;
k = 1.;
v0 = 10;
s = {0, -g};
ds = NDSolveValue[
{w'[t] == {0, 0}, w[0] == {0, -g},
r”[t] + k r'[t] == w[t], r[0] == {0, 0}, r'[0] == v0 {Cos@th, Sin@th},
WhenEvent[Last[r[t]] == 0, (tf = t; “StopIntegration”)]},
{r, w}, {t, 0, 10}]

ParametricPlot[Through[ds[t]][[1]], {t, 0, tf}]