zsha
zsha

Reputation: 197

Solving a Quadratic Optimisation in MATLAB

I have an unconstrained quadratic optimization problem- I have to find u that will minimize norm (u^H * A_k *u - d_k)) where A_k is 4x4 matrix (k=1,2...180) and u is 4x1 vector(H denotes hermitian).

There are several functions in MATLAB to solve optimization problems but I am not able to figure out the method I need to use for my OP. I would highly appreciate if anyone provides me some hint or suggestion to solve this problem in MATLAB.

Upvotes: 1

Views: 148

Answers (2)

Matthew Gunn
Matthew Gunn

Reputation: 4529

Math preliminaries:

If A is symmetric, positive definite, then the the matrix A defines a norm. This norm, called the A norm, is written ||x||_A = x'Ax. Your problem, minimize (over x) |x'*A*x - d| is equivalent to searching for a vector x whose 'A norm' is equal to d. Such a vector is trivial to find by simply scaling up or down any non-zero vector until it has the appropriate magnitude.

  1. Pick arbitrary y (can't be all zero). eg. y = [1; zeros(n-1, 1)]; or y = rand(n, 1);
  2. Solve for some scalar c such that x = c*y and x'Ax=d. Substituting we get c^2 y'Ay=d hence:.

Trivial procedure to find an answer:

y = [1; zeros(n-1)];   %Any arbitrary y will do as long as its not all zero
c = sqrt(d / (y'*A*y)) 
x = c * y`

x now solves your problem. No toolbox required!

Upvotes: 2

Felix Darvas
Felix Darvas

Reputation: 507

options = optimoptions('fminunc','GradObj','on','TolFun',1e-9,'TolX',1e-9);
x = fminunc(@(x)qfun(x,A,d),zeros(4,1),options);

with

function [y,g]=qfun(x,A,d)
y=(x'*A*x-d);
g=2*y*(A+A')*x;
y=y*y;

Seems to work.

Upvotes: 1

Related Questions