# Minimize a quadratic energy with linear equality constraints symbolically in maple

## Alec Jacobson

## August 21, 2013

I'm working with Maple to fit a polynomial to specific values and derivatives so that it minimized a quadratic energy. I tried the Optimization toolbox/package and came up with this:

```
with(Optimization):
p := (t) -> c3*t^3 + c2*t^2;
C1 := eval(p(t),t=1)-1;
C2 := eval(diff(p(t),t),t=1);
m := Minimize(int(diff(p(t),t)^2,t=0..1),{C1=0,C2=0});
```

but this seems to give me a *numerically* optimized solution:

```
m := [1.19999999999997, [c2 = 3., c3 = -2.]]
```

Rather I want a *symbolically* optimized solution. So far, I can do this by explicitly computing the Lagrangian and finding the saddle point:

```
with(VectorCalculus):
Lambda := int(diff(p(t),t)^2,t=0..1) + lambda_1*(C1) + lambda_2*(C2);
s := solve(convert(Gradient(Lambda,[c3,c2,lambda_1,lambda_2]),list),[c3,c2,lambda_1,lambda_2]);
```

This gives me the exact solution:

```
[[c3 = -2, c2 = 3, lambda_1 = -12/5, lambda_2 = 1/5]]
```