4
$\begingroup$

I've tried to make some research, but without any luck.

How do I setup the Euler equation for this in Mathematica?:

$ \text{Min} \int_0^1\left(2x^2+ \left(4t-5 e^{r \, t} \right) x \, \dot{x} + 12e^{r \, t} \,\dot{x}^2 \right) dt,\; \; \text{for} \; x(0)=1, \; \text{and} \; x(1)=e^{\frac{1}{6}}$

Thanks a lot guys, and happy friday.

$\endgroup$
  • 1
    $\begingroup$ Take a look at VariationalMethods in the help $\endgroup$ – Dr. belisarius Apr 12 '13 at 11:36
10
$\begingroup$
Needs["VariationalMethods`"]
eu = EulerEquations[2 x[t]^2 + (4 t - 5 E^(r t)) x'[t] x[t] +  12 E^(r t) x'[t]^2, {x[t]}, t]
s=DSolve[Join[eu, {x[0] == 0}, {x[1] == E^(1/6)}], x[t], t]

Plot[x[t] /. s /. r -> # & /@ Range[-5, 5], {t, 0, 1},  Evaluated -> True]

enter image description here

ContourPlot[x[t] /. s, {t, 0, 1}, {r, -5, 5}, Evaluated -> True, 
 FrameLabel -> {Style[t, 20, Bold], Style[r, Bold, 20]}, PlotLegends -> Automatic]  

enter image description here

Edit

The dynamics for several values of the parameter r and the velocity profiles:

p = Plot[D[x[t] /. s, t]/14 + # /. r -> # /. t -> u & /@ Range[-5, 5], {u, 0, E^(1/6)},              
         Evaluated -> True, Filling -> Table[{i -> i - 6}, {i, 1, 11}], Axes -> False];
rs = Flatten@{#, -#} &@Range@5;
ss = Animate[Show[
         Graphics[{Line[{{0, #}, {E^(1/6), #}}] & /@ rs, PointSize[Large], 
                   Table[Point[{(x[t] /. s[[1]] /. r -> u) /. t -> v, u}], {u, rs}]}, 
                  PlotRange -> {{0, E^(1/6)}, {-6, 6}}, 
                  FrameLabel -> {Style[t, 20, Bold], Style[r, Bold, 20]}, 
                  Frame -> True, AspectRatio -> 1], 
                 p], 
     {v, 0, 1, .01}]

enter image description here

$\endgroup$
  • $\begingroup$ you just missed the s so no mention! $\endgroup$ – PlatoManiac Apr 12 '13 at 12:06
  • $\begingroup$ Just to point out that one of your boundary conditions is different from the OP's. x[0] == 1. $\endgroup$ – RunnyKine Apr 12 '13 at 15:49
  • $\begingroup$ @RunnyKine Thanks for pointing that out, I haven't noticed it. I think it doesn't make much difference to the system's dynamic behavior. $\endgroup$ – Dr. belisarius Apr 12 '13 at 15:53
  • $\begingroup$ @Belisarius, yeah I figured it wouldn't make much of a difference, +1 by the way. $\endgroup$ – RunnyKine Apr 12 '13 at 15:54
  • $\begingroup$ @RunnyKine Anyway, that's why the questions should always include Mma code. Retyping is an infinite source of errors ... $\endgroup$ – Dr. belisarius Apr 12 '13 at 16:00

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.