Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

%% step one: var("y z L")

F(x, y, z, L) = (x-3)^2 + (y-1)^2 + (z+1)^2 + L*(x^2 + y^2 + z^2 - 4)

derivative(F)

%% step two:

eqn1= 2Lx + 2*x - 6 == 0

eqn2= 2Ly + 2*y - 2 == 0

eqn3= 2Lz + 2*z + 2 == 0

eqn4= x^2 + y^2 + z^2 - 4 == 0

solve( [eqn1, eqn2, eqn3, eqn4], [x, y, z, L] )

%% correct answer obtained: [[x == -6/11sqrt(11), y == -2/11sqrt(11), z == 2/11sqrt(11), L == -1/2sqrt(11) - 1],

[x == 6/11sqrt(11), y == 2/11sqrt(11), z == -2/11sqrt(11), L == 1/2sqrt(11) - 1]]

%% moral of the story: if symbolic methods work fine, why bother with numerical methods?! ;-)