Matrix product error accumulated during iteration

Asked by zhao hongzheng

zhao hongzheng (view profile)

on 25 Jun 2019
Latest activity Edited by Jan

Jan (view profile)

on 26 Jun 2019
Accepted Answer by Jan

Jan (view profile)

I have a problem when multiplying unitary matrix many times. Initially, a unitary(or symmetric in the following example) matrix is constructed as U. Then I multiply the matrix in an iteractive way and check the unitarity of the results by comparing U*U' with identity. They are close in the first few steps but deviate gradually. Any suggestions to reduce the error and always keep U unitary?
The following is the code.
clear all
M = rand(10);
M=0.5*(M+M');
U = expm(-1i*M);
for t_i = 1:100
U = U*U;
norm = trace(U*U'-eye(10))
end

Bjorn Gustavsson

Bjorn Gustavsson (view profile)

on 25 Jun 2019
Why not let expm handle all of that and skip the iteration?
zhao hongzheng

zhao hongzheng (view profile)

on 25 Jun 2019
I am acutually constructing a fibonacci sequence of a matrix, for instance
U_n = U_{n-2}*U_{n-1}, with the first two unitaries as U_1=expm(-1i*M1),U_2=expm(-1i*M2). Thus in each step, I need build matrix by iteration, which can not be simply use a single expm.

on 25 Jun 2019
Edited by Jan

Jan (view profile)

on 26 Jun 2019

You can find the nearest unitary matrix in each iteration using an SVD:
for t_i = 1:100
[S,~,D] = svd(U * U);
U = S * D';
norm = trace(U * U' - eye(10))
end

zhao hongzheng

zhao hongzheng (view profile)

on 25 Jun 2019
Thank you so much! It's very helpful.
Jan

Jan (view profile)

on 26 Jun 2019
Does it solve your problem? Then please mark the answer as accepted.