maximizing a function of 2 variables where coefficients are given by parameters
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2020-7-28
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.)
0 个评论
更多回答(1 个)
Matt J
2020-7-27
编辑:Matt J
2020-7-27
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...
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!