# Initial values of position (x) and speed (v) of a particle visualizing using Mathematica

$$\vec{F}(\vec{r})=-m\omega^2\begin{pmatrix}x\\4y\end{pmatrix}$$

I have the force $$F$$ shown above. How could I specify the initial values of position ($$x$$) and speed ($$v$$) in Mathematica using the Manipulate command to try finding the initial values so the particle could move on a parabolic trajectory ($$\alpha$$) and a eight-shaped trajectory ($$\beta$$) ?

The initial values are not exact, just one solution each is enough.

Unfortunately I have no idea how to realize this problem, would be thankful for help!

## 2 Answers

Here is an interactive Manipulate using ParametricNDSolveValue to solve the differential equation; you can interact with it by dragging the locators to the desired sites and by adjusting the time horizon T by dragg the control bar at the top:

F[{x_, y_}] := {x, 4 y};
traj = ParametricNDSolveValue[
{
Y''[t] == -F[Y[t]],
Y == {x0, y0},
Y' == {v0, w0}
},
Y,
{t, 0, T},
{x0, y0, v0, w0, T}
];

Manipulate[
Show[
Graphics[Arrow[{X[], X[]}]],
ParametricPlot[
traj[X[[1, 1]], X[[1, 2]], X[[2, 1]] - X[[1, 1]], X[[2, 2]] - X[[1, 2]], T][t],
{t, 0, T}
],
PlotRange -> {{-1, 1}, {-1, 1}} 2
],
{{X, {{1, 0}, {1, 1}}}, Locator},
{{T, 5}, 0, 10}
]

• looks amazing! thank you very much! – Tom Jan 6 '19 at 16:50
• You're welcome. Have fun! – Henrik Schumacher Jan 6 '19 at 16:51
• @Tom Btw.: Don't forget to upvote answers that you found helpful... That's what drives the community. – Henrik Schumacher Jan 6 '19 at 16:54
• @Tom Just in case that you wonder: You can accept only one answer per question. ;) And I can live with it if you choose David's one... – Henrik Schumacher Jan 6 '19 at 16:58
• @Tom: you can upvote both answers, but you can only accept one. – J. M.'s ennui Jan 6 '19 at 16:59

Solve

x[t] /. DSolve[ x''[t] == - w^2 x[t], x[t], t]

y[t] /. DSolve[ y''[t] == - w^2 4 y[t], y[t], t]


to find $$x(t) = \cos (\omega t) + \sin (\omega t)$$ and $$y(t) = \cos (2 \omega t) + \sin (2 \omega t)$$, with arbitrary constants that depend upon the initial conditions. Then plot:

w = 1;
ParametricPlot[{Cos[w t] + Sin[w t], Cos[ 2 w t] + Sin[2 w t]}, {t, 0,
5}] • thank you very much David! – Tom Jan 6 '19 at 16:51
• Note that you can also include x == x0, y == y0 etc. in the list of equations sent to DSolve. This will yield a functional form for the solution that explicitly contains the initial conditions. – Michael Seifert Jan 6 '19 at 22:31