Solving complex linear equations with conjugate operations

Consider the following equations:
Assuming and , substitute them to equations
The real parts and imaginary parts correspondingly equate:
Regarding as unknowns, rearrange to obtain the linear system form .
The result is (using ):
My questions:
1. For complex linear equations involving conjugate operations, is it necessary to calculate them separately?
2. This is just an example. I intend to use this approach to address other similar systems of complex linear equations. In my calculations for other instances, I found the determinant of to be 1e-6, approximately zero. How should I handle this to ensure the accuracy of the equation solutions?
My MATLAB code is attached below.
clc;clear;close all;
%% Set a question
z_1_true=4+2i;%The true value of z1
z_2_true=5+3i;
ee1=z_1_true+z_2_true;%Constant term
ee2=conj(z_1_true)+2*z_2_true-z_1_true;
%% taking the real part and the imaginary part respectively, twice the number of equations
syms z_1 [2 1] real%z1
syms z_2 [2 1] real%z2
z1_com=z_1(1)+1i*z_1(2);%z1_com represents the complex form of z1
z2_com=z_2(1)+1i*z_2(2);
eqns2_com=[z1_com+z2_com-ee1;
conj(z1_com)+2*z2_com-z1_com-ee2];%Construct complex equation
eqns2=[real(eqns2_com)==0;imag(eqns2_com)==0];%Taking the real part and the imaginary part
vars=[reshape(z_1,1,2),reshape(z_2,1,2)];%The variables need to be solved
[A2,b2] = equationsToMatrix(eqns2,vars);%Extract the A and b matrices
Sol2=double(A2)\double(b2);%calculation method
z1_sol2=Sol2(1)+1i*Sol2(2);z2_sol2=Sol2(3)+1i*Sol2(4);
E11=z1_sol2+z2_sol2-ee1;
E22=conj(z1_sol2)+2*z2_sol2-z1_sol2-ee2;
disp('Solve separately:');
Solve separately:
disp(['true value of z1:', num2str(z_1_true),',result:',num2str(z1_sol2),',Error of first equation:',num2str(E11)]);
true value of z1:4+2i,result:4+2i,Error of first equation:0
disp(['true value of z2:', num2str(z_2_true),',result:',num2str(z2_sol2),',Error of second equation:',num2str(E22)]);
true value of z2:5+3i,result:5+3i,Error of second equation:0

 Accepted Answer

Hello SB,
Any way you look at it you have four independent unknown quantities, but there is some choice of their form. For the linear system Af = g, for the unknowns you can use f = [z1; z2; z1*; z2*] instead of [x1; x2; y1; y2].
This leads to (by inspection)
A = [1 1 0 0
0 0 1 1
-1 2 1 0
1 0 -1 2]
g = [9+5i; 9-5i; 10+2i; 10-2i]
f = A\g
f =
4.0000 + 2.0000i
5.0000 + 3.0000i
4.0000 - 2.0000i
5.0000 - 3.0000i
as you would expect. IF A has real coefficients (as in this case), then the second row of A is merely the first row, only with A(1,1:2) swapped with A(1,3:4). The same is true of the fourth row, consisting of A(3,1:2) swapped with A(3,3:4). If you want to find A using symbolic variables it ought to be doable (although I am staying on the sidelines).
To check the matrix for how close it is to being singular, it's better to use cond instead of det. In this cases llike this where all the matrix elements are on the order of 1, det is probably all right, but unlike det, cond has does not have the same scaling issues. And if A is close to being singular, that fact really has very little to do with complex --> real part + imaginary part etc.; or whatever method is used.

5 Comments

According to your advice, I rewrote the solving code and applied it to other complex linear equation systems. I found that the original method would result in a large singular matrix A (cond(A)=6.14e+08), while the condition number of matrix A in your method is 3.59e+03, significantly improving the calculation accuracy. Your method has been very helpful, and I am further exploring the universality of this. Thank you.
Hello SB,
Although it is not a bad thing that going to complex coordinates improves the condtion number, that number is still very large. If the matrix is nonsingular and you know that for a fact, then it appears that complex coordinates are helping. But if the matrix were singular, then complex coordinates.are doing something at a superficial level and would only obscure the fact that it is singular.
There are cases where a singular matrix can be made nonsingular by appropriate choice of variables. One example is an electronic circuit with n nodes. The version with n floating nodes has a singular conductance matrix, but if one of the nodes is fixed to be the ground node at voltage zero, then the matrix is nonsingular. The same idea is true for masses connected by springs in free space. To calculate the natural frequencies of the system the associated matrix is singular, but if the center of mass and the total momentum are set to zero and n-1 coordinates and momenta are taken relative to those, the associated matrix is nonsingular.
Thank you, David.
I have made some attempts again and found that if I treat the unknowns as 𝑓=[𝑧1;𝑧2;𝑧1*;𝑧2*], sometimes the obtained solution [𝑄1;𝑄2;𝑄3;𝑄4] does not satisfy 𝑄1=conj(𝑄3) and Q2​=conj(Q4​). This has been bothering me for a long time. Does it still need to add constraint conditions f(1)=conj(f(3)) and f(2)=conj(f(4))?
Hi SB,
I'm not sure how it could turn out that way, since the x,y variables and the z,z* variables are related by basically a similarity transformation on A. If you have
A*x = b
with all those quantities real, then let
z = T * x
[z1 ] [ 1 i 0 0] [x1]
[z1*] = [ 1 -i 0 0] * [y1]
[z2 ] [ 0 0 1 i] [x2]
[z2*] [ 0 0 1 -i] [y2]
and
x = T^(-1) * z
[x1] [ 1 1 0 0] [z1 ]
[y1] = (1/2) [ -i i 0 0] * [z1*] matrix is T^(-1)
[x2] [ 0 0 1 1] [z2 ]
[y2] [ 0 0 -i i] [z2*]
then
A*x = b
z = T*x
x = T^(-1) *z
so
T*A*T^(-1) *z = T*b
and it seems kind of inevitable that z1, z1*, z2, z2* end up as correct complex conjugates.
Hello David,
Thank you for your patience. This method indeed has no issue, it was my misunderstanding. Essentially, there is no difference compared to the solution where x and y are taken as independent variables, and the condition number of the coefficient matrix remains unchanged. However, it offers a different perspective.

Sign in to comment.

More Answers (0)

Categories

Find more on Linear Algebra in Help Center and File Exchange

Products

Release

R2023b

Community Treasure Hunt

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

Start Hunting!