How to find the x, y range of values for a multivariable function using optimization?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to solve this question by giving a range for x and y specified by me as the following:
x = -5:0.1:5; y = -5:0.1:5;
[x, y] = meshgrid(x, y);
z = 1-(exp(-((x.^2)+(y.^2))) + (((x.^2)+(y.^2))/20));
surf(x, y, z);
but I'm having a problem finding the global minimum when I use:
z = @(x) 1-(exp(-((x(1).^2)+(x(2).^2))) + (((x(1).^2)+(x(2).^2))/20));
Gmin = fminsearch(z, [-5 -5]);
The problem is that the function exits with a message:
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -13541624843901191000000000000000000000000000000000000000000000000000000000000000000000000.000000
and the results are:
1.0e+44
-5.1163 -0.9523
When I asked the professor about it, he told me that I have to find the correct range of x,y using optimization but i didn't quite understand what does he mean. So what should I do? Is there a function that I can use to get the correct range?
5 comentarios
Torsten
el 14 de Dic. de 2022
Editada: Torsten
el 14 de Dic. de 2022
I think it does not need a mathematical proof that your function tends to -Inf as abs(x), abs(y) tend to Inf.
So the global infimum of the function is -Inf.
But I'm quite sure that the error in the assignment is the sign I already mentionned. It should read
f(x,y) = 1 + (exp(-(x^2+y^2)) + (x^2+y^2)/20)
instead of
f(x,y) = 1 - (exp(-(x^2+y^2)) + (x^2+y^2)/20)
Or you should be told to maximize
f(x,y) = 1 - (exp(-(x^2+y^2)) + (x^2+y^2)/20)
instead of minimize it.
Respuestas (1)
Sam Chak
el 15 de Dic. de 2022
Editada: Sam Chak
el 15 de Dic. de 2022
It is probably best to show your professor these plots and asks for guidance. A picture is worth a thousand words; two pictures are worth a million words. Sometimes, assignments and exam papers contain typos.
With educated guess and the structure of the function is clearly known, you can justify whether global minima or maxima of the function exist.
x = -5:0.1:5;
y = -5:0.1:5;
[x, y] = meshgrid(x, y);
z = 1 - (exp(-((x.^2) + (y.^2))) + (((x.^2) + (y.^2))/20));
figure(1)
surf(x, y, z, 'FaceColor', 'interp', 'EdgeColor', 'none', 'FaceLighting', 'gouraud');
fun = @(x) - (1 - (exp(-((x(1).^2) + (x(2).^2))) + (((x(1).^2) + (x(2).^2))/20)));
[Gmax, fval] = fminsearch(fun, [2 2])
Now, look at the underside of the surface. The local minimum exists at the origin .
figure(2)
surf(x, y, z, 'FaceColor', 'interp', 'EdgeColor', 'none', 'FaceLighting', 'gouraud');
view(70, -40)
2 comentarios
Sam Chak
el 15 de Dic. de 2022
Editada: Sam Chak
el 15 de Dic. de 2022
Mathematics and graphs speak louder than words. But you must save the professor's face.
Show these two plot and asks about the purpose of finding the range (which is not officially specified in the assignment). Ask if this is an optimization problem or a range-finding problem (for some unspecified purposes).
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!