# Energy optimization, calculus of variations, Euler Lagrange equations in Maple

## Alec Jacobson

## August 16, 2016

Here's a simple demonstration of how to solve an energy functional optimization symbolically using Maple.

Suppose we'd like to minimize the 1D Dirichlet energy over the unit line segment:

```
min 1/2 * f'(t)^2
f
subject to: f(0) = 0, f(1) = 1
```

we know that the solution is given by solving the differential equation:

```
f''(t) = 0, f(0) = 0, f(1) = 1
```

and we know that solution to be

```
f(t) = t
```

How do we go about verifying this in Maple:

```
with(VariationalCalculus):
E := diff(f(t),t)^2:
L := EulerLagrange(E,t,f(t)):
```

so far this will output:

```
L := {-2*diff(diff(x(t),t),t), -diff(x(t),t)^2 = K[2], 2*diff(x(t),t) = K[1]}
```

Finally solve with the boundary conditions using:

```
dsolve({L[1],f(0)=0,f(1)=1});
```

which will output

```
t(t) = t
```