Question

I'm trying to minimize a quadratic energy with linear equality constraints in Maple. Currently I'm issuing things like:

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

but this seems to give me a numerically optimized solution complete with floating point error:

m := [1.19999999999997, [c2 = 3.00000000000000, c3 = -2.00000000000000]]

(The correct answer is m:= [6/5,[c2=3,c3=-2]])

Is there a way to compute the solution symbolically using maple?

I'd rather not have to work out the Lagrangian myself. I'm hoping for a flag like symbolic=true.

Was it helpful?

Solution

Apply Lagrange multipliers step-by-step. It's fairly easy to do.

p:= t-> c3*t^3+c2*t^2:
Obj:= int(D(p)^2,  0..1):
Con:= {p(1)=1, D(p)(1)=0}:
L:= Obj - l1*lhs(Con[1]) - l2*lhs(Con[2]):
solve(Con union {diff(L,c3), diff(L,c2)});
              /                      12       -1\ 
             { c2 = 3, c3 = -2, l1 = --, l2 = -- }
              \                      5        5 / 
eval(Obj, %);
                               6
                               -
                               5
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top