maximizing a function of 2 variables where coefficients are given by parameters

1 view (last 30 days)
I have a function of two variables x and y where coefficients are given by paramter a and b. I want to take FOC of this function with respect to x and y and want to find the value of x and y that gives the function the maximium value given a and b. Is it possible to do this operation in Matlab?
  6 Comments
alpedhuez
alpedhuez on 27 Jul 2020
F(x,y)=(a1+a2-y)*y^{2n-2}+(a1-(x+y)/2)*(x^{2n-2}-y^{2n-2})+(a1-x)*(1-x^{2n-2})
where a1, a2, and n are given parameters. I want to sovel x and y that maximize F(x,y) given a1, a2, and n.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Jul 2020
Once n is given, it seems possible to find an expression for y in terms of roots of a polynomial of degree (2*n-2)^2 . Because that is even degree, it is guaranteed that there will be an even number of complex roots -- and my experiments show that it is possible for there be two positive roots that are relatively close together. You would have to find all the real roots and test them to see which produced the maximum.
You are not going to be able to find closed form solutions for x and y in terms of symbolic a1, a2, and n.
Finding the polynomial of degree (2*n-2)^2 that expresses the root is not easy, and unless you were using a really low degree MATLAB probably cannot find it for you (there are some other programs that seem to be able to find it on a case-by-case basis.)

More Answers (1)

Matt J
Matt J on 27 Jul 2020
Edited: Matt J on 27 Jul 2020
You can use fminunc, for example, which would do this for you implicitly. Or, you can write down the first order optimality conditions as equations and solve them with fsolve. Or you could try to solve them analytically with solve() in the Symbolic Toolbox.
Since you have only 2 unknowns, you might consider using fminsearch, which doesn't require any extra toolboxes, but that doesn't employ first derivative conditions, in case that actually matters...

Tags

Community Treasure Hunt

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

Start Hunting!