minimize the function, -(x1/2) - (3*x2 / 2) in matlab

You can use the built-in fminsearch function in MATLAB to minimize the function. Here is the MATLAB code:

main.m
% Define the function
fun = @(x) -(x(1)/2) - (3*x(2)/2);

% Define the initial guess
x0 = [0 0];

% Minimize the function using fminsearch
[x, fval] = fminsearch(fun, x0);

% Display the results
fprintf('Minimum point: (%f, %f)\n', x(1), x(2));
fprintf('Minimum value: %f\n', -fval);
284 chars
13 lines

The output will show the minimum point and the minimum value of the function.

related categories

gistlibby LogSnag