Assg 4
Assg 4
Assg 4
clc
clear all
syms x y z lam
f=81*x^2+y^2
g=4*x^2+y^2-9
H=f+lam*g
Hx=diff(H,x)
Hy=diff(H,y)
Hlam=diff(H,lam)
[ax,ay,alam]=solve(Hx,Hy,Hlam)
for i=1:length(ax)
d=subs(subs(f,x,ax),y,ay)
end
a1=max(d)
a2=min(d)
f =
81*x^2 + y^2
g =
4*x^2 + y^2 - 9
H =
Hx =
162*x + 8*lam*x
Hy =
2*y + 2*lam*y
Hlam =
4*x^2 + y^2 - 9
ax =
-1
-1
1
-81/4
-81/4
ay =
0
0
-3/2
3/2
alam =
-3
3
0
0
d =
81
81
333/4
333/4
81
81
333/4
333/4
531441/16
531441/16
531477/16
531477/16
531441/16
531441/16
531477/16
531477/16
d =
81
81
333/4
333/4
81
81
333/4
333/4
531441/16
531441/16
531477/16
531477/16
2
531441/16
531441/16
531477/16
531477/16
d =
81
81
333/4
333/4
81
81
333/4
333/4
531441/16
531441/16
531477/16
531477/16
531441/16
531441/16
531477/16
531477/16
d =
81
81
333/4
333/4
81
81
333/4
333/4
531441/16
531441/16
531477/16
531477/16
531441/16
531441/16
531477/16
531477/16
a1 =
531477/16
a2 =
81
3
%2
clc
clear all
syms x y lam
f=8*x^2-2*y
g=x^2+y^2-1
H=f+lam*g
Hx=diff(H,x)
Hy=diff(H,y)
Hlam=diff(H,lam)
[ax,ay,alam]=solve(Hx,Hy,Hlam)
for i=1:length(ax)
d=subs(subs(f,x,ax),y,ay)
end
a1=max(d)
a2=min(d)
f =
8*x^2 - 2*y
g =
4
x^2 + y^2 - 1
H =
Hx =
16*x + 2*lam*x
Hy =
2*lam*y - 2
Hlam =
x^2 + y^2 - 1
ax =
-1
1
-8
-8
ay =
0
0
-(3*7^(1/2))/8
(3*7^(1/2))/8
alam =
-1
1
-1/8
-1/8
d =
8
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
8
5
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
d =
8
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
8
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
d =
8
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
8
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
d =
6
8
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
8
8
(3*7^(1/2))/4 + 8
8 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
512
512
(3*7^(1/2))/4 + 512
512 - (3*7^(1/2))/4
a1 =
(3*7^(1/2))/4 + 512
a2 =
8 - (3*7^(1/2))/4