3
$\begingroup$

I would like to plot the curves given by $\alpha(s) = (u(s), v(s))$, where $u$ and $v$ are like below.

Clear[u, v];
{u, v} = {u[t], v[t]} /. 
   NDSolve[{u'[t]^2 + v'[t]^2 == 1, 
      u'[t] v''[t] - u''[t] v'[t] == u[t] v'[t] - v[t] u'[t], 
      u'[0] == Sin[0.18], v'[0] == Cos[0.18]}, {u[t], v[t]}, {t, -7.5,
       7.5}][[1]];

What I want to do is, for each different initial conditions $u'(0) = \cos(\theta)$, $v'(0) = \sin(\theta)$, $u'(t)v''(t) - u''(t)v'(t) = -c(u'(t)v(t) - u(t)v'(t))$ with $\theta$ varying in $[0, 2\pi]$ and $c$ varying in, say, $(0, 10]$, plot a new curve. I'm new to Mathematica so I still have a hard time doing these little things.

$\endgroup$
2
$\begingroup$
ClearAll[u, v, θ, c]
pndsv = ParametricNDSolveValue[{u'[t]^2 + v'[t]^2 == 1, 
    u'[t] v''[t] - u''[t] v'[t] == -c (-u[t] v'[t] + v[t] u'[t]), 
    u'[0] == Cos[θ], v'[0] == Sin[θ]}, {u, v}, {t, -7.5, 7.5}, {c, θ}] 

An alternative visualization of the solution:

Manipulate[ParametricPlot[Evaluate@Through@pndsv[c, θ][t], {t, -7.5, 7.5}, 
    PlotRange -> {{-3, 3}, {-3, 3}}], {c, 0, 10}, {θ, 0, 2 Pi}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks! In the image you posted it appears I could type the parameters of $c$ and $\theta$, but when I run the code I only have slider controls. Why is that? $\endgroup$ – Matheus Andrade Sep 13 '18 at 23:08
  • 1
    $\begingroup$ @MatheusAndrade, i used Autorun from the + menu to get the picture. You can also use the + button next to the slider to get the input field and other animation controls. $\endgroup$ – kglr Sep 13 '18 at 23:22
3
$\begingroup$

Use ParametricNDSolveValue instead:

sol=ParametricNDSolveValue[
    {
    u'[t]^2 + v'[t]^2 == 1,
    u'[t] v''[t] - u''[t] v'[t] == c (u[t] v'[t] - v[t] u'[t]),
    u'[0] == Sin[θ],v'[0] == Cos[θ]
    },
    {u,v},
    {t, -7.5, 7.5},
    {c, θ}
];

Then, you can use Manipulate to explore the plot for different values of the parameters:

Manipulate[
    Plot[{sol[c,θ][[1]][x],sol[c,θ][[2]][x]}, {x,-7.5,7.5}],
    {{c, 1}, 0, 10},
    {{θ, .18}, 0, 2Pi}
]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.