Help with symbolic math and matrix multiplication

5 views (last 30 days)
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 Comment
Walter Roberson
Walter Roberson on 14 Feb 2025
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.

Sign in to comment.

Answers (1)

Karan Singh
Karan Singh on 18 Feb 2025
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

Community Treasure Hunt

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

Start Hunting!