Reputation: 1939
I am trying to use MATLAB to find critical values of
f(x,y) = (y-2)ln(xy)
diff(f,x) = (y - 2)/x = 0
diff(f,y) = log(x*y) + (y - 2)/y = 0
Solving the above 2 equations and 2 unknowns by hand, I get x = 1/2 and y = 2. But how do I get MATLAB to yield this result?
I know I have to either use fsolve or fzero but I'm not sure how to.
Upvotes: 0
Views: 69
Reputation: 4519
If you REALLY want to solve that with fsolve, you could do:
o = optimoptions('fsolve','MaxFunEvals',1e5,'MaxIter',1e5);
x0 = [.9;2.1]; % Note this IS SENSITIVE to the starting location!
f = @(x) [(x(2) - 2) / x(1); log(x(2)) + log(x(1)) + 1 - 2/x(2)];
x = fsolve(f,x0, o)
Upvotes: 1