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

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

   Math Methods 7025X
   contemplate the slope on a saddle
   [wxMaxima: comment end   ] */

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

/* [wxMaxima: comment start ]
   at the saddle point, 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("at the saddle point")$
/* [wxMaxima: input   end   ] */

/* [wxMaxima: comment start ]
   at the saddle point, there is upward movement in both directions along one dimension
   and there is downward movement in both directions along the other dimension
   (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("at a saddle point, one of the own-partials is positive and the other is 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 is negative at a saddle point")$
print("det(H) = ",determinant(H))$
/* [wxMaxima: input   end   ] */

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