#zadanie 9# 

1) assign beta and define function f

beta : -5 ;  f : x1^2+x2^2+beta*x1*x2 + x1 + 2*x2;

2) calculate gradient

g : [diff(f,x1),diff(f,x2)];

3) solve zero-gradient equations (necessary condition)

s : solve([g[1]=0,g[2]=0],[x1,x2]);

4) select coordinates of stationary point and evaluate function f at it

p : map(rhs,s[1]);

fp : ev(f,x1:p[1],x2:p[2]);

5) draw plot of f

wxdraw3d(
    explicit(
        f,
        x1,-5,5,
        x2,-5,5
        ),
    point_type=10,color=red,
    points([p[1]],[p[2]],[fp])
)$

6) calculate hessian

h: hessian(f,[x1,x2]);

7) define characteristic equation of hessian and find eigenvalues

poly : expand(charpoly(h, lambda));

L : solve(poly,lambda);

8) eigenvalues are nonzero and have different signs => we have a SADDLE POINT