MATLAB: How to calculate the minimum of a function of two variables

MATLABminimum

Hello, I am new to Matlab and encountering some difficulties Computing the minimum of a function of two variables: f(x,y)= e^(x-y) + x^2 + y^2.
Also is it possible to plot the resulting surface around the minimum?

Best Answer

One approach:
syms x y
f(x,y) = exp(x-y) + x^2 + y^2;
Dfx = diff(f, x)
D2fx = diff(Dfx,x)
Dfy = diff(f, y)
D2fy = diff(Dfy, y)
Inflpt = solve(Dfx, Dfy, [x,y])
xs = Inflpt.x
ys = Inflpt.y
Check = [D2fx(xs,ys); D2fy(xs,ys)]
figure
fsurf(f, double([xs-2 xs+2 ys-2 ys+2]))
Since ‘Check’ is positive for both functions, ‘Inflpt’ is a minimum.
EDIT —
Added plot figure —