clc, close all, clear all
f = @(x, y) x.^4 + y.^4 -4*x.*y;
fsurf(f, [-3 3 -3 3])
H_0 = [0 -4; -4 0]
eig(H_0)
H_A = [12 -4; -4 12]
eig(H_A)

%{
    We pass to Matlab the function and an initial point
    close enough to a minimum. The result will be the
    coordinates of the nearest minimum.
    Unfortunatelt we can't pass to matlab the previous
    anonymous function

    f = @(x, y) x.^4 + y.^4 -4*x.*y;

    but a similar one:
    f = @(x) x(1)^4 + x(2)^4 -4*x(1)*x(2);

    Before x was the first variable and y was the second
    variable.
    Now x is a vector of two variable x(1) and x(2) where
    x(1) is the equivalent of the previous x and x(2) is
    the equivalent of the previous y.
    Also, we don't need the elementwise operation.
%}
f = @(x) x(1)^4 + x(2)^4 -4*x(1)*x(2);
x0 = [1.1, 1.1] % we start close to (1, 1)
fminsearch(f, x0)
x0 = [1, 1] % we start at (1, 1)
fminsearch(f, x0)
x0 = [-1.1, -1.1]
fminsearch(f, x0)
fminsearch(f, [0, 0])