F = @(u, w, x, y, z) (x - 3).^2 + (y - 1).^4 + (u - z).^2 + (u - (2 * w)).^2 + (u-6).^2 + 12;
f = @(v) F(v(1), v(2), v(3), v(4), v(5));
initial = randn(1,5) * 100;
fx = fminsearch(f, initial);
However, notice that your variables are mostly separate. You can see by inspection that at the minima, x = 3, y = 1, and you can see that none of the terms are negative so the +12 is a constant shift, so you can reduce this to a search over three variables (u - z).^2 + (u - (2 * w)).^2 + (u-6).^2 . Simple inspection then shows that the minima would be at u = 6, z = u, w = u/2 . This gives an overall solution of u = 6, w = 3, x = 3, y = 1, z = 6
Best Answer