/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/
/* [ Created with wxMaxima version 0.8.5 ] */

/* [wxMaxima: comment start ]
   Eric Doviak
   22 April 2012

   Math Methods 7025X
   contemplate the slope at the peak of a bowl
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
z(x,y) := x*y - x^2 - y^2; 
plot3d(z,[x,-1,1],[y,-1,1])$
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
   at the maximum, the slope is zero along both the x and y axes (necessary condition)
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
solx:subst(solve(diff(z(x,y),x)=0,x)[1],x)$
soly:subst(solve(diff(z(x,y),y)=0,y)[1],y)$

print("")$
print("the first order conditions")$
print("")$
print("d z(x,y)"/"d x"," = ",diff(z(x,y),x)," = 0")$
print("")$
print("d z(x,y)"/"d y"," = ",diff(z(x,y),y)," = 0")$
print("")$
print("imply that:")$
print("x = ",solx)$
print("y = ",soly)$
print("")$
print("Both of these conditions can only be satisfied if: x=0 and y=0")$
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
   in all directions from the maximum, the curve decreases (sufficient condition)
   [wxMaxima: comment end   ] */

/* [wxMaxima: input   start ] */
/* set up the Hessian matrix */
dxx:''(diff(diff(z(x,y),x),x))$
dyy:''(diff(diff(z(x,y),y),y))$
dxy:''(diff(diff(z(x,y),x),y))$
H:matrix([dxx,dxy],[dxy,dyy])$

print("")$
print("own-partials must be negative:")$
print("")$
print("d^2 z(x,y)"/"(dx)^2"," = ",dxx)$
print("")$
print("d^2 z(x,y)"/"(dy)^2"," = ",dyy)$
print("")$
print("the cross-partial:")$
print("")$
print("d^2 z(x,y)"/"dx dy"," = ",dxy)$
print("")$
print("the Hessian matrix:")$
print("H = ",H)$
print("")$
print("determinant of Hessian must be positive")$
print("det(H) = ",determinant(H))$
/* [wxMaxima: input   end   ] */

/* Maxima can't load/batch files which end with a comment! */
"Created with wxMaxima"$
