Bài 12 Min X + y - 2x-6y+14 Subject To X + y - 16 0 Code Matlab
Bài 12 Min X + y - 2x-6y+14 Subject To X + y - 16 0 Code Matlab
min x² + y² -2x-6y+14
subject to x²+ y²-16=0
code matlab
% Initial guess
x0 = [0; 0];
% Newton's method
for iter = 1:max_iter
% Evaluate objective and constraint functions and their derivatives
f_val = fun(x0);
g_val = constraint(x0);
grad_f = grad(x0);
grad_g = constraint_grad(x0);
14 max x+y+z
subject to x²+ y²+z²
code malab
% Define the objective function and its derivatives
fun = @(x) -(x(1) + x(2) + x(3));
grad = @(x) [-1; -1; -1];
% Initial guess
x0 = [1; 0; 0];
% Initial guess
x0 = [1; 1];
% Define the objective function and its derivatives
fun = @(x) x(1)*exp(-norm(x)^2) + norm(x)^2/20;
grad = @(x) [exp(-norm(x)^2) - 2*x(1)*norm(x)^2*exp(-norm(x)^2); 2*x(2)/20];
hessian = @(x) [(-4*x(1)^2*norm(x)^2 + 2 - 4*x(1)^2*norm(x)^4*exp(-
norm(x)^2))*exp(-norm(x)^2), 0; 0, 2/20];
% Newton's method
for iter = 1:max_iter
% Evaluate objective function and its derivatives
f_val = fun(x0);
grad_f = grad(x0);
13 Max √ xy
Subjest 20x+10y= 200