From: giny giny on
Hello All,
Can anyone please help me with the problem below:

I want to minimize this function:
f(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2 + p03*y^3.

This is an equation of a surface plot. It has 2 variables (x,y).
The range of x starts from 1.8e-09 and of y starts from 3.6e-09.
I use the following function:
x0 = [1.8e-09,3.6e-09];
[x fval] = fminsearch(f, x0)

1)But the problem is it gives me a minimum value which is not from the range that is 1.8e-09 and 3.6e-09. (I need the minimum value of both x and y)
2) How do I maximize a function?

I will be grateful,
Thanks.
From: John D'Errico on
"giny giny" <garimathakral10(a)gmail.com> wrote in message <i06rct$8td$1(a)fred.mathworks.com>...
> Hello All,
> Can anyone please help me with the problem below:
>
> I want to minimize this function:
> f(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p30*x^3 + p21*x^2*y + p12*x*y^2 + p03*y^3.
>
> This is an equation of a surface plot. It has 2 variables (x,y).
> The range of x starts from 1.8e-09 and of y starts from 3.6e-09.
> I use the following function:
> x0 = [1.8e-09,3.6e-09];
> [x fval] = fminsearch(f, x0)
>
> 1)But the problem is it gives me a minimum value which is not from the range that is 1.8e-09 and 3.6e-09. (I need the minimum value of both x and y)

Where in fminsearch did it ever say that you could do a
CONSTRAINED optimization? I'm fairly positive that the
documentation never states that this is an option. How
can fminsearch know that you want it to look only in
a certain region anyway?

You can use a tool that is designed to do a bound
constrained optimization, if that is your goal though.
Download fminsearchbnd from the file exchange. It
does allow you to do a bound constrained optimization.

http://www.mathworks.com/matlabcentral/fileexchange/8277


> 2) How do I maximize a function?

You cannot maximize a function using fminsearch. The
fminsearch tool ONLY minimizes.

However, suppose, just suppose that you tried to minimize
the negative of your function. That is, minimize -f(X).
What result would you expect?

John
From: giny giny on
John,
That was a very useful piece of information. I have a question,
I use this function fminsearchbnd, the case with lower bound.
My lower bound for x is 1.8e-09 and for y is 3.6e-09.

The syntax says: xsol = fminsearchbnd(rosen,[3 3],[2 2])
So, I plugin my values as = xsol = fminsearchbnd(rosen,[3 3],[1.8e-09 3.6e-09])
but what is this [3 3] element for?

I would really appreciate your help,
Thanks and regards
From: giny giny on
John,

I am sorry for the confusion, but I understood the syntax of fminsearchbnd.
My only question is how to know the minimum value of x(1) and x(2) ?
If suppose the equation is this: rosen = @(x) p00 + p10*x(1) + p01*x(2) + p20*x(1).^2 + p11*x(1)*x(2) + p02*x(2)^.2;
The solution gives the answer as minimum and maximum value of x.
I want to know the minimum values of both variables that is x(1) and x(2).

Thanks and regards