# Create Euler equation

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.

-
Take a look at VariationalMethods in the help – Dr. belisarius Apr 12 '13 at 11:36

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]


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


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}]


-
you just missed the s so no mention! – PlatoManiac Apr 12 '13 at 12:06
Just to point out that one of your boundary conditions is different from the OP's. x[0] == 1`. – RunnyKine Apr 12 '13 at 15:49
@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. – Dr. belisarius Apr 12 '13 at 15:53
@Belisarius, yeah I figured it wouldn't make much of a difference, +1 by the way. – RunnyKine Apr 12 '13 at 15:54
@RunnyKine Anyway, that's why the questions should always include Mma code. Retyping is an infinite source of errors ... – Dr. belisarius Apr 12 '13 at 16:00