Null after solving for unknowns by setting the matrix det as zero

1 view (last 30 days)
Hi community,
I attach my code here. I try to solve kz by setting the matrix T_mat det as zero. val_arr_sol is the solution. But later when I wanted to get the null of matrix T_mat, it fails.
The reason is related to the low accuracy? How could I improve my method so that I can get the null of a matrix with higher accuracy towards zero determinant, such as 1e^-15?
Thanks in advance
clear;
epsxx = -1.7778;
epsyy = -2.1250;
epsyz = 0.0000 + 1.0417i;
kx = 0;
ky = -5;
k0 = 0.6000;
val_arr_sol = [
0.0000 - 5.0636i
0.0000 - 5.0578i
0.0000 + 5.0578i
0.0000 + 5.0636i];
for i = 1:4
kz = val_arr_sol(i);
eps_mat = [epsxx, 0, 0;
0, epsyy, epsyz;
0, -epsyz, epsyy];
eta_mat = inv(eps_mat);
nabla_matrix = 1i*...
[0, -kz, ky;...
kz, 0, -kx;...
-ky, kx, 0];
rhs_matrix = [1, 0; 0, 1; -kx/kz, -ky/kz];
Tot_matrix = (nabla_matrix*eta_mat*nabla_matrix-k0^2*eye(3))*rhs_matrix;
T_mat = Tot_matrix(1:2, :);
det(T_mat)
null(T_mat)
end
%% The result is:
eigen_vec_null_puzz
ans =
7.5827e-07
ans =
2×0 empty double matrix
ans =
-3.6005e-06
ans =
2×0 empty double matrix
ans =
-3.6005e-06
ans =
2×0 empty double matrix
ans =
7.5827e-07
ans =
2×0 empty double matrix

Answers (1)

Lingling Fan
Lingling Fan on 20 May 2019
Edited: Lingling Fan on 20 May 2019
follow up:
I improved the code by putting the analytical solution function of the determinant inside the eigenvector null solver function. The det is closer to zero, about 1e^-15. But the null of the matrix is still empty.
%% test the eigen vector
clear;
epsxx = -1.7778;
epsyy = -2.1250;
epsyz = 0.0000 + 1.0417i;
kx = 0;
ky = -5;
k0 = 0.6000;
% val_arr_sol = [
% 0.0000 - 5.0636i
% 0.0000 - 5.0578i
% 0.0000 + 5.0578i
% 0.0000 + 5.0636i];
%% what if I solve for the problem once again and without any another transfer
val_arr_sol = eig_val_MO_x(epsxx, epsyy, epsyz, kx, ky, k0);
for i = 1:4
kz = val_arr_sol(i);
eps_mat = [epsxx, 0, 0;
0, epsyy, epsyz;
0, -epsyz, epsyy];
eta_mat = inv(eps_mat);
nabla_matrix = 1i*...
[0, -kz, ky;...
kz, 0, -kx;...
-ky, kx, 0];
rhs_matrix = [1, 0; 0, 1; -kx/kz, -ky/kz];
Tot_matrix = (nabla_matrix*eta_mat*nabla_matrix-k0^2*eye(3))*rhs_matrix;
T_mat = Tot_matrix(1:2, :);
det(T_mat)
null(T_mat)
end
%% results
%% test the eigen vector
ans =
-1.9425e-16
ans =
2×0 empty double matrix
ans =
-1.9425e-16
ans =
2×0 empty double matrix

Categories

Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!