Optimasi Berkendala dan Pengali Langrange
Saturday, November 15, 2008 3:42:44 AM
> with(plots):
Warning, the name changecoords has been redefined
> Elips:=[9*cos(theta),7*sin(theta),0]:
> f:=(x,y)->x+2*y+30;
> Dasar:=spacecurve(Elips,theta=0..2*Pi,color=red):
> Tujuan:=plot3d(f,-9..9,-7..7):
> Pilihan:=(axes=frame,orientation=[150,40],labels=[x,y,z]):
> display({Dasar,Tujuan},Pilihan);
> Proyeksi:=spacecurve([Elips[1],Elips[2],f(Elips[1],Elips[2])],theta=0..2*Pi,color=red,thickness=3):
> display({Dasar,Tujuan,Proyeksi},Pilihan);
> F:=f(Elips[1],Elips[2]);
> plot(F,theta=0..2*Pi);
> Dif_F:=diff(F,theta);
> TKritis:=solve(Dif_F=0,theta);
> NMaks:=simplify(subs(theta=TKritis,F));
> NMaksElips=simplify(subs(theta=TKritis,Elips));
> LevelCurve:=plot3d(f,-9..9,-7..7,style=contour,axes=normal,contours=20,orientation=[270,0]):
> display({LevelCurve,Dasar},axes=normal);
> Level:=solve(f(x,y)=a,y);
> [f(-9,-7),f(-9,7),f(-9,-7)];
> animate({[Elips[1],Elips[2],theta=0..2*Pi],[x,Level,x=-9..9]},a=7..53,scaling=constrained,frames=32);
> CartElips:=x^2/81+y^2/49=1;
> CartElips_1:=subs(y=y(x),CartElips);
> TurunanImp:=diff(CartElips_1,x);
> Turunan:=solve(TurunanImp,diff(y(x),x));
> Kemiringan:=subs(y(x)=y,Turunan);
> solve({CartElips,Kemiringan=-1/2},{x,y});
> Solusi:=allvalues(%);
> eks1:=subs(Solusi[1],f(x,y));
> eks2:=subs(Solusi[2],f(x,y));
> f1:=(x,y)->(x-2)^2+(y+1)^2:
> levelcurve:=plot3d(f1,-9..9,-7..7,style=contour,axes=normal,contours=20,orientation=[270,0]):
> display({levelcurve,Dasar},axes=normal);
> {Diff(f1(x,y),x)=0,Diff(f1(x,y),y)=0};
> tls0:=value(%);
> htls0:=solve(tls0,{x,y});
> subs(%,f1(x,y));
> g1:=(x,y)->x^2/81+y^2/49:
> with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
> dg1:=grad(g1(x,y),[x,y]);
> df1:=grad(f1(x,y),[x,y]);
> persamaan:={df1[1]=lambda*dg1[1],df1[2]=lambda*dg1[2],g1(x,y)=1};
> tkrit:=solve(persamaan,{x,y,lambda});
> tk:=evalf(allvalues(tkrit));
> [f1(-8.991993504,.976528417),f1(4.06563197,-6.2450585477)];
>













