Solving the problem for the free extremum of a function of several variables - numerical determination local minimum.

3 views (last 30 days)
Hello, I am trying to do an automatization project, which numericaly determine and writes out the local minimum of given method, also it creates a table and a plot as written below. I am also uploading the .m-files which are also listen in one methon. Thank you for every help or solution in advance.
Task: Find the minimum of the objective function 𝒇(𝒙, 𝒚) = x^4 + 5x^2 - 9x^2*y + 2y^2 + 2y^4 + 2x
My given starting point for every method is: [0;0.5]
a) by the Newton and Raphson method
b) Levenberg and Marquardt method. Consider 𝛼 = 8, 𝑐 = 4
c) by the method of conjugate gradients: add function to the konj_tab program (also to graph) and find the minimum for entered starting point and for another selected starting point - at least one different (in each coordinate) from the specified one, I want this: [0.5;1]
d) compare in one image the dependence of the value of the objective function on the iterations (x-axis: number iterations, y-axis: value of the objective function)
For all methods, consider an individually specified starting point. Consider 𝑔1^2 + 𝑔2^2 = 𝑑 ≤ 0.001 as the termination condition of the minimization process, 𝑔1, 𝑔2 are gradient components of the gradient ∇𝑓 = [ g1 ; g2 ].
Solution instructions:
In each method:
- state the basic relationship and briefly describe the procedure, at least 2 steps.
- state the results of the individual calculation steps (in the table).
- draw a contour plot of the function in a range appropriate to the calculated points and plot the points calculated in individual iterations into it.
Evaluate and compare the obtained results. Consider success - whether the method found a local extremum (using the Hessian), accuracy, number of iterations, computational complexity.
  3 Comments
Sam Chak
Sam Chak on 18 Oct 2024
The minimum point seems to lie at .
X = linspace(-4, 4, 81);
Y = linspace( 0, 3, 61);
[x, y] = meshgrid(X, Y);
z = x.^4 + 5*x.^2 - 9*(x.^2).*y + 2*y.^2 + 2*y.^4 + 2*x;
figure(1)
surfc(x, y, z),
xlabel('x'), ylabel('y'), zlabel('z')
figure(2)
contour(x, y, z, 50)
xlabel('x'), ylabel('y')
DS
DS on 18 Oct 2024
Thank you, this is only c) by the method of conjugate gradients I guess, for me I got it completely different (see pictures - graph and table), the minimum was (−0.263, 0.149) , I am attaching the files too I can't guess whats wrong.

Sign in to comment.

Answers (1)

Alan Stevens
Alan Stevens on 21 Oct 2024
Here's a "starter for ten" with the Newton-Raphson method:
% Newton-Raphson Approach
% Function
f = @(x,y)x^4+5*x^2-9*x^2*y+2*y^2+2*y^4+2*x;
% Gradients
gx = @(x,y) 4*x^3+10*x-18*x*y+2;
gy = @(x,y) -9*x^2+4*y+8*y^3;
% Hessian
H = @(x,y) [12*x^2+10-18*y, -18*x;
-18*x, 4+24*y^2];
% Initial guess
x0 = -3; y0 = 3;
tol = 1E-3; err = 1;
maxsteps = 20; steps = 0;
x = x0; y = y0;
while err>tol && steps<maxsteps
steps = steps + 1;
X = [x; y] - H(x,y)\[gx(x,y); gy(x,y)];
err = gx(x,y)^2 + gy(x,y)^2;
x = X(1); y = X(2);
end
disp(['coordinates are: (', num2str(x),' ', num2str(y),')'])
coordinates are: (-2.3734 1.7606)
disp(['in ', int2str(steps), ' steps'])
in 5 steps
disp(['function value is: ', num2str(f(x,y))])
function value is: -8.6924
Note that the results are very sensitive to the initial guesses as is suggested by the contour plot posted by Sam Chak above.
  2 Comments
DS
DS on 21 Oct 2024
Moved: Torsten on 21 Oct 2024
Hello thank you, I got this method also completely different I got values: −0.2638 and 0.1499 with 6 iterations I am attaching the code.

Sign in to comment.

Categories

Find more on Geographic Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!