✔ 最佳答案
Function to optimize: f(x,y) = (x-1)^2 + (y-1)^2
Constraint: g(x,y) = 4x^2 + 9y^2 - 36
Therefore the lagrange function is:
Λ(x,y,λ) = (x-1)^2 + (y-1)^2 + λ(4x^2 + 9y^2 - 36)
Its partial derivatives and setting to zero:
dΛ/dx = 2(x-1) + 8λx = 0 ..................................(1)
dΛ/dy = 2(y-1) + 18λy = 0 ................................(2)
dΛ/dλ = 4x^2 + 9y^2 - 36 = 0 ............................(3)
From (1), x=1/(4λ+1) ........................................(4)
From (2), y=1/(9λ+1) ........................................(5)
Put (4) (5) into (3):
4/(4λ+1)^2 + 9/(9λ+1)^2 - 36 = 0
Solving for λ for real roots yields:
λ = -0.336, -0.050
When λ = -0.336, (x,y)=(-2.907, -0.494)
When λ = -0.050, (x,y)=(1.250, 1.818)
Plot for your reference:
http://www.badongo.com/pic/766443
其實上面果個concept全對, 只是differentiate錯左.