Polynomial to Matrix form(canonical form)
8 ビュー (過去 30 日間)
古いコメントを表示
How to convert the given quadratic form(Q = x1^2 + 2x1x2+x2^2) into its canonical form in matlab.
5 件のコメント
Walter Roberson
2020 年 8 月 19 日
https://www.mathworks.com/matlabcentral/answers/445266-polynomial-to-matrix-form-canonical-form#answer_470380
回答 (3 件)
lalith keerthan
2020 年 7 月 24 日
syms x1 x2 x3 y1 y2 y3 a b c p
Q=input('Enter the form in x1 x2 x3')
a11=(1/2)*diff(diff(Q,x1),x1)
a22=(1/2)*diff(diff(Q,x2),x2)
a33=(1/2)*diff(diff(Q,x3),x3)
a12=(1/2)*diff(diff(Q,x1),x2)
a21=a12
a13=(1/2)*diff(diff(Q,x1),x3)
a13=a31
a23=(1/2)*diff(diff(Q,x2),x3)
a23=a23
A=[a11,a12,a13;a21,a22,a23;a31,a32,a33]
[N D]=eig(A)
X=[x1,x2,x3]
Y=[y1,y2,y3]
disp(D(1,1)*y1^2+D(2,2)*y2^2+D(3,3)*y3^2)
[m,n]=size(A);
for i=1:n
N(:,i)=[N(1,i)/sqrt(N(1,i)^2+N(2,i)^2+N(3,i)^2) N(2,i)/sqrt(N(1,i)^2+N(2,i)^2+N(3,i)^2) N(3,i)/sqrt(N(1,i)^2+N(2,i)^2+N(3,i)^2)]
end
display('no repeated eigen value and the orthogonal transformation is X=NY')
X==(N*Y)
2 件のコメント
John D'Errico
2020 年 7 月 24 日
編集済み: John D'Errico
2020 年 7 月 24 日
I think it was an attempt at an answer/ At least it started out as one, sort of. But things got lost along the way, following a convoluted, confused path at the end.
John D'Errico
2020 年 7 月 24 日
編集済み: John D'Errico
2020 年 7 月 24 日
I assume the question is to resolve a quadratic polynomial, perhaps:
Q = x1^2 + 2*x1*x2 + x2^2
into a quadratic form. That is, given Q, you want to recover the matrix H, such that
Q = [x1,x2]*H*[x1;x2]
This is quite easy using the symbolic toolbox. The desired matrix H is 1/2 times the Hessian matrix of Q.
For example, given the quadratic Q...
syms x1 x2
Q = x1^2 + 2*x1*x2 + x2^2
Q =
x1^2 + 2*x1*x2 + x2^2
X = [x1,x2];
H = hessian(Q)/2
H =
[ 1, 1]
[ 1, 1]
H is the desired matrix. We can see Q is recovered:
expand(X*H*X.')
ans =
x1^2 + 2*x1*x2 + x2^2
This is just an educated guess on my part as to the answer. Since there has been no response from the OP since it as first posted, we can only guess.
2 件のコメント
Gaurav Malik
2021 年 8 月 23 日
Yeah but what do you do when you also have linear terms in your function? We need also the c'X term.
Walter Roberson
2021 年 8 月 23 日
In such a case are you working with a quadratic form ? Are you, as John indicates, trying to recover the H in Q = [x1,x2]*H*[x1;x2] ?
参考
カテゴリ
Help Center および File Exchange で Polynomials についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!