MuPAD
Pro Computing Essentials - Examples
Example 12.7 - Finding Extremes of Function of two
Variables
This is another typical example. We have a function of
two variables and we wish to produce its local extremes.
f := (x,y)->(x^2 - y^2)*exp(-x^2 - y^2); //declare function
EQ1 := diff(f(x,y), x); //produce df/dx
EQ2 := diff(f(x,y), y); //produce df/dy
EQ1 := expand(EQ1*exp(x^2 + y^2))=0; //simplify EQ1
EQ2 := expand(EQ2*exp(x^2 + y^2))=0; //simplify EQ2
solve({EQ1,EQ2}, {x,y}); //solve equations
{[x = 0, y = 0], [x = 0, y = -1], [x = 0, y = 1],
[x = -1, y = 0], [x = 1, y = 0]}
f(0,0), f(0,-1), f(0,1), f(-1,0), f(1,0); // produce values
0, -exp(-1), -exp(-1), exp(-1), exp(-1)
float(-exp(-1)), float(exp(-1));
-0.3678794412, 0.3678794412
|