Help with symbolic math and matrix multiplication

조회 수: 4 (최근 30일)
riccardo stara
riccardo stara 2015년 12월 9일
답변: Karan Singh 2025년 2월 18일
The following code should prove with symbolic math this well-known statement: for every A in this form, given a matrix U as described in the code, U'AU is diagonal. However there is some numerical problem with the conjugate operation. Anybody can help?
syms A11 A12 A13 A14 A15;
A=[A11 A12 A13 A14 A15 A14 A13 A12;
A12 A11 A12 A13 A14 A15 A14 A13;
A13 A12 A11 A12 A13 A14 A15 A14;
A14 A13 A12 A11 A12 A13 A14 A15;
A15 A14 A13 A12 A11 A12 A13 A14;
A14 A15 A14 A13 A12 A11 A12 A13;
A13 A14 A15 A14 A13 A12 A11 A12;
A12 A13 A14 A15 A14 A13 A12 A11;];
g=sym('exp(1i*2*pi/8)');
U1=sym(zeros(8,8));
for i=1:size(U1,1)
for j=1:size(U1,2)
U1(i,j)=g^mod((i-1)*(j-1),8);
end
end
D=U1'*A*U1/8;
  댓글 수: 1
Walter Roberson
Walter Roberson 2025년 2월 14일
syms A11 A12 A13 A14 A15;
A=[A11 A12 A13 A14 A15 A14 A13 A12;
A12 A11 A12 A13 A14 A15 A14 A13;
A13 A12 A11 A12 A13 A14 A15 A14;
A14 A13 A12 A11 A12 A13 A14 A15;
A15 A14 A13 A12 A11 A12 A13 A14;
A14 A15 A14 A13 A12 A11 A12 A13;
A13 A14 A15 A14 A13 A12 A11 A12;
A12 A13 A14 A15 A14 A13 A12 A11;];
g = exp(1i*2*sym(pi)/8)
g = 
U1 = zeros(8,8, 'sym');
for i=1:size(U1,1)
for j=1:size(U1,2)
U1(i,j) = g^mod((i-1)*(j-1),8);
end
end
D = U1'*A*U1/8
D = 
Looks diagonal to me.

댓글을 달려면 로그인하십시오.

답변 (1개)

Karan Singh
Karan Singh 2025년 2월 18일
I dont know when the entries are created from string expressions (e.g. sym('exp(1i2pi/8)')) the symbolic engine may not recognize that the expression represents a complex number on the unit circle. I have tried the other way round. I define the complex constant using MATLAB’s numeric conversion. Simliar to Walter's code. Also the the symbols in your matrix are meant to be real, you can declare them as real.
g = exp(sym(1i)*2*pi/8);
This is my code
syms A11 A12 A13 A14 A15 real;
A = [A11, A12, A13, A14, A15, A14, A13, A12;
A12, A11, A12, A13, A14, A15, A14, A13;
A13, A12, A11, A12, A13, A14, A15, A14;
A14, A13, A12, A11, A12, A13, A14, A15;
A15, A14, A13, A12, A11, A12, A13, A14;
A14, A15, A14, A13, A12, A11, A12, A13;
A13, A14, A15, A14, A13, A12, A11, A12;
A12, A13, A14, A15, A14, A13, A12, A11];
g = exp(sym(1i)*2*pi/8);
U1 = sym(zeros(8,8));
for i = 1:8
for j = 1:8
U1(i,j) = g^mod((i-1)*(j-1), 8);
end
end
D = simplify(U1' * A * U1 / 8)
D = 
Karan

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by