Group Abstract Group Abstract

Message Boards Message Boards

Solving a specific initial value problem

Posted 2 years ago

Hi, I am completely new to Mathematica and I really need some advice on solving a specific initial value problem numerically.

The differential equation is: θ''[x] - p^2 sin[2θ[x]] == 0 , x = {0,1}

for p = π/(2 Sqrt[2])

The initial values are θ'[0] == 0; θ[0] == {0, 2π}.

So I need to solve the equation for various initial angles θ[0] from 0 to 2π

Ι tried it with a For-Loop, but it is not working.
I would like to get a list of angles θ[1] after solving the equation for different initial angles θ[0]
I need to plot the angle θ[0] over the resulting angle θ[1].

Thanks for your help!

Attachments:
POSTED BY: Felix Toperczer
6 Replies

Thanks for your reply.

I have another problem, which is even more basic. If I want to solve the differential equation from above for some random initial value problem (let's leave the For-Loop behind and concentrate only on one specific solution), Mathematica always replies with the same error response:

Why is that so??

Attachment

POSTED BY: Felix Toperczer

The following works fine for me, although with a different answer:

Clear[x];
p = Pi/(2 Sqrt[2]);
dgl = \[Theta]''[x] - p^2 Sin[2 \[Theta][x]] == 0;
sol = NDSolve[{dgl, \[Theta][0] == Pi/2, \[Theta]'[0] == 
    0}, \[Theta], {x, 0, 1}]
entry = \[Theta][1] /. sol[[1]]

I cannot reproduce the error you get, but it is similar to what we happens when the independent variable of a differential equation is given a value before NDSolve is called:

x = 0;
NDSolve[{f'[x] == 1, f[0] == 0}, f, {x, 0, 1}]

The variables f, x are not automatically protected from outside interference. However, in your case there must be something else going on.

POSTED BY: Gianluca Gorni
POSTED BY: Roland Franzius

In this case it is no pendulum equation, but an equilibrium condition for a rod in a crooked channel with an asymmetric cross-section. There is no oscillation going on.

POSTED BY: Felix Toperczer

Sorry, yes, there is a minus sign. But except for an x -> i t the algebra is all the same. One is in the uncharted area of the elliptic amplitude unforunately.

POSTED BY: Roland Franzius

You cannot use \[Theta]_entry as a variable name, it is a pattern. I would do it this way:

sol[t0_] := NDSolveValue[
   {\[Theta]''[x] - (\[Pi]/(2 Sqrt[2]))^2 Sin[2 \[Theta][x]] == 0,
    \[Theta][0] == t0, \[Theta]'[0] == 0}, \[Theta], {x, 0, 1}];
Table[{t0, sol[t0][1]},
 {t0, 0, 2 Pi, 0.125 Pi}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard