```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to get max value of a function subject some constraints in
Date: Thu, 23 Apr 2009 18:56:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 43
Message-ID: <gsqdk1\$f0e\$1@fred.mathworks.com>
References: <10587277.969.1240498965778.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1240512961 15374 172.30.248.35 (23 Apr 2009 18:56:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 23 Apr 2009 18:56:01 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:535047

hhwolf76 <james.zhou76@gmail.com> wrote in message <10587277.969.1240498965778.JavaMail.jakarta@nitrogen.mathforum.org>...
> This is a math problem in my project.
> If theta_N=[a b c d]', which is variable. theta_0=[a0 b0 c0 d0]',which is constant and known. PN is a 4X4 positive definite symetric matrix, which is constant and known.
> If Y=T^2*(a-a0)+T*(b-b0)+(c-c0)+t*(d-d0).
> Here, T and t are constant and known value. Y is scalar.
> I need get the max value of |Y|, and corresponding theta_N
>
> The constaint is
> (theta_N-theta_0)'*(PN^-1)*(theta_N-theta_0)<=alpha
> alpha is a constant and known value.
>
> I asked this question in sci.math, someone told me I should use Lagrange multiplier method. But I don't known how to use this method in Matlab because I am not familar with Matlab.
>
> BTW, the actual problem is even more complicated. In my project, T represents temperature and changes along with the time. t represents time, and the unit is second. At last I need get the max value of the sum of |Y1|+|Y2|+|Y3|+...+|Yn|, when the time is 24 hours, which makes n=24*3600. And I need get corresponding theta_N.

Define the column vectors x = theta_N-theta_0, and R = [T^2;T;1;t].  Then your problem is equivalent to finding x such that Y^2 = (x'*R)^2 = x'*(R*R')*x is maximized subject to x'*(PN^-1)*x <= alpha.  This is an eigenvector problem.

[U,S,V] = svd(PN*R*R');
x = sqrt(alpha/(V(:,1)'*PN^-1*V(:,1)))*V(:,1);

The reasoning is this.  By the way x is defined it has the property that

x'*(PN^-1)*x = alpha

Also

PN*R*R'*V(:,1) = D(1,1)*V(:,1)

where D(1,1) is the largest eigenvalue and V(:,1) the corresponding eigenvector.  Multiplying on the left by V(:,1)'*PN^-1 gives

V(:,1)'*R*R'*V(:,1) = D(1,1)*V(:,1)'*PN^-1*V(:,1)

Thus

Y^2 = x'*R*R'*x = D(1,1)*x'*PN^-1*x = D(1,1)*alpha

Therefore Y^2 takes its maximum value with this maximum eigenvalue, D(1,1).

You can then find [a;b;c;d] as an offset of [a0,b0,c0,d0] by x.

Your informant in sci.math was correct.  This is indeed a problem in Lagrange multipliers and we have selected the largest multiplier by choosing the largest eigenvalue.

Roger Stafford
```