finding local maximum/minimum for a function
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
how to find the local extreme values of the function xy-x^2-y^2-2x-2y+4
Respuestas (1)
sanidhyak
el 30 de En. de 2025
Hi Adonia,
I understand that you want to find the local maximum and local minimum of this function: xy-x^2-y^2-2x-2y+4
You can follow the following steps:
- Define the function and compute first-order partial derivatives using “diff”.
- Solve for critical points using “solve” and “compute” second-order partial derivatives.
- Calculate the Hessian determinant and use it to classify the critical points (min, max, or saddle) based on its value and the second derivative.
Use the "plot" function in MATLAB to visualize the function's surface and identify the critical points on it. This will help you to verify their nature based on the graphical representation.
% Plot the function
fsurf(f, [-5 5 -5 5]) % Plot the surface
hold on
% Plot critical points in red
plot3(double(crit.x), double(crit.y), double(subs(f, [x, y], [crit.x, crit.y])), 'ro', 'MarkerSize', 8, 'LineWidth', 2)
xlabel('x'), ylabel('y'), zlabel('f(x, y)')
title('Function Plot with Critical Points')
grid on
hold off
Kindly refer to the following MATLAB documentation for detailed information on all the related functions
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!