0
$\begingroup$

I want to plot the solutions to: $$(l')^2 + (h')^2 = 1$$ $$(c-1)\sin(2l)=2l''$$

where $c$ is a constant, but I haven't been able to (I tried using NDSolve but didn't manage to do it). Can someone help me? Here's what I've tried (setting $c=2$):

s = NDSolve[{Sin[2 l[x]] == 2 l''[x], l[0] == 1, l'[0] == 1}, 
   l, {x, -10, 10}];
a[x_] := Evaluate[l[x] /. s];
i[x_] := Sqrt[1 - (a'[x])^2];
b[x_] := Integrate[i[x], x]

this leads to errors. This attempt:

Clear[eq1, eq2, initConds, sol];
eq1 = Sin[2 l[s]] == 2 l''[s];
eq2 = l'[s]^2 + h'[s]^2 == 1;
initConds = {l[0] == 1, l'[0] == 1, h[0] == 0, h'[0] == 0};

sol = NDSolve[{eq1, eq2, initConds}, {l, h}, {s, -10, 10}]
ParametricPlot[Evaluate[{l[s], h[s]} /. sol], {s, -10, 10}]

also led nowhere.

$\endgroup$
5
  • 1
    $\begingroup$ What are the conditions for the NDSolve? And what is the region that you are solving the differential equation? And can you please post some code that the members here can easily copy and paste? $\endgroup$ Nov 12 '18 at 11:22
  • $\begingroup$ I want to plot $l$ and $h$ everywhere the system has a solution. I've added the code of my attempts. $\endgroup$ Nov 12 '18 at 11:29
  • $\begingroup$ The error is not produced in a[x] and i[x]. I can actually plot these using the commands you have. Are you talking about the error when you try to plot b[x]? $\endgroup$ Nov 12 '18 at 11:41
  • $\begingroup$ @Konstantinos yes. I need both functions, just $l$ unfortunately doesn't work for me :/ I think the mistake is because I'm trying to do an indefinite integral of a function defined numerically, but I don't know how to do that right. $\endgroup$ Nov 12 '18 at 11:44
  • $\begingroup$ You have performed an analytic integration of a numerical result. Try to take the solution obtained by the first D.E for l[s], and solve the second. $\endgroup$ Nov 12 '18 at 11:45
5
$\begingroup$

The solution has two branches, it is necessary to choose one, for example, the first

Clear[eq1, eq2, initConds, sol];
eq1 = Sin[2 l[s]] == 2 l''[s];
eq2 = l'[s]^2 + h'[s]^2 == 1;
initConds = {l[0] == 1, l'[0] == 1, h[0] == 0};

sol = NDSolve[{eq1, eq2, initConds}, {l, h}, {s, -10, 10}]
ParametricPlot[Evaluate[{l[s], h[s]} /. First[sol]], {s, -10, 10}]

fig1

Two branches

{ParametricPlot[Evaluate[{l[s], h[s]} /. First[sol]], {s, -10, 10}],
 ParametricPlot[Evaluate[{l[s], h[s]} /. sol[[2]]], {s, -10, 10}]}

fig2

$\endgroup$
3
$\begingroup$

In addition to @Alex Trounev 'answer the first solution approach of your question can be solved as follows:

L = NDSolveValue[{Sin[2 l[x]] == 2 l''[x], l[0] == 1, l'[0] == 1}, l, {x, -10, 10}]
hh[x_] := NIntegrate[ Sqrt[1 - L'[u]^2], {u, 0, x}]
ParametricPlot[{L[x], hh[x]}, {x, -10, 10}]  (* negative branch*)

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks. Now I know my earlier mistake. $\endgroup$ Nov 12 '18 at 11:55

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.