I have to minimize transpose(x)*A*x ./ transpose(x)*B*x
function where x is a vector, A and B are matrices. Is there a function in matlab that will minimize it?
Thanks
I have to minimize transpose(x)*A*x ./ transpose(x)*B*x
function where x is a vector, A and B are matrices. Is there a function in matlab that will minimize it?
Thanks
If you have a multivariate scalar function (which it appears you have) you can use fminunc
, referred to here.
Also, I take it you are trying to perform (x'Ax)/(x'Bx) <-- the apostrophe is transpose in MATLAB.
Here's an example:
>> A = rand(3)
A =
0.8491 0.7577 0.6555
0.9340 0.7431 0.1712
0.6787 0.3922 0.7060
>> B = rand(3)
B =
0.0318 0.0971 0.3171
0.2769 0.8235 0.9502
0.0462 0.6948 0.0344
>> f = @(x)x'*A*x./(x'*B*x);
>> fminunc(f,[1;2;4]) % some arbitrary starting guess.
Warning: Gradient must be provided for trust-region algorithm; using quasi-newton algorithm instead.
> In fminunc at 403
Local minimum found.
Optimization completed because the size of the gradient is less than the default value of the function tolerance.
<stopping criteria details>
ans =
-7.3912
2.1750
5.5588
>>