# How can I solve my system of linear equations? [closed]

I have a pretty easy problem where I have 6 equations and 6 unknown of the form m*x = 0, where m is a 6x6 matrix and x is a vector of length 6 with the 6 unknown variables. I'm looking for a nontrivial solution to this problem so I use the Nullspace command.

My code is the following

m =
{{E^(-I*x*b/2), E^(I*x*b/2), -E^(-I*y*b/2), -E^(I*y*b/2), 0, 0},
{I*x*E^(-I*x*b/2), -I*x*E^(I*x*b/2), -I*y*E^(-I*y*b/2), I*y*E^(I*y*b/2), 0, 0},
{0, 0, -E^(I*y*b/2), -E^(-I*y*b/2), E^(I*x*b/2), E^(-I*x*b/2)},
{0, 0, -I*y*E^(I*y*b/2), I*y*E^(-I*y*b/2), I*x*E^(I*x*b/2), -I*x*E^(-I*x*b/2)},
{E^(-I*x*(a + b/2)), E^(I*x*(a + b/2)), 0, 0, 0, 0},
{0, 0, 0, 0, E^(I*x*(a + b/2)), E^(-I*x*(a + b/2))}};
ns = NullSpace[m]


This gives me the output { }. What does this result mean? All the coefficients x,y,a,b are real and greater than zero. Is that something that I should specify in the code? I wonder what is wrong with my code?.

## closed as off-topic by Daniel Lichtblau, MarcoB, Edmund, garej, J. M. will be back soon♦Sep 24 '17 at 6:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, MarcoB, Edmund, garej, J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

• It means that your matrix is invertible/has no zero eigenvalues – aardvark2012 Sep 21 '17 at 11:23
• It looks like mathematica cannot solve it when a,b are not given as numbers. If you set e.g. a=b=0 you get a solution. – kiara Sep 21 '17 at 13:53
• It simply depends on the values of a, b, x, y wether m has nontrivial nullspace or not. – Henrik Schumacher Sep 21 '17 at 18:19
• There is no reason to put this question on hold. It is not off topic. There is no simple mistake such as trivial syntac error, nor incorrect capialization, nor spelling mistake, nor other typographic error. Solving this kind of equations is not easily found in the documentation. The not professional user may expect, that NullSpace could give conditions on the parameters. Because this is not the case, the anser shows a good workaround. Therefore this question and answer is well suited to help future users! @Daniel Lichtblau, MarcoB, Edmund, garej, J. M. please remove the off-topic – Akku14 Sep 24 '17 at 7:22

You have a homogenous linear system with maximal matrix rank == 6. If the determinante of this matrix is not zero, you only get the null-vector as solution.

Therfore find conditions, where the det is zero, to get solutions.

fdet = FullSimplify[Det[m], 0 < x && 0 < y && a > 0 && b > 0]

(*     E^(-I (2 a x + b y)) (-(x + E^(2 I a x) (x - y) + y)^2 +
E^(2 I b y) (x - y + E^(2 I a x) (x + y))^2)     *)


For Reduce it is easier to work in the Real domanin. Split the det into real and imaginary part.

Simplify[ComplexExpand[Re@fdet, TargetFunctions -> {Re, Im}],
0 < x && 0 < y && a > 0 && b > 0]

(*     0     *)

ss = FullSimplify[ComplexExpand[Im@fdet, TargetFunctions -> {Re, Im}],
x > 0 && y > 0 && a > 0 && b > 0]

(*4 (2 x y Cos[b y] Sin[2 a x] + (x^2 - y^2 + (x^2 + y^2) Cos[2 a x]) Sin[b y])*)

red0 = Reduce[
ss == 0 && x > 0 && y > 0 && a > 0 && b > 0, {x, y, a, b}, Reals]


This gives you the desired conditions on the variables. (too long to show here.)

Appy Solve in order to better handle it.

sol0 = Solve[red0 && x > 0 && y > 0 && a > 0 && b > 0, {x, y, a, b},
Reals]


Only first solution shown here.

(*    {b -> ConditionalExpression[(2 ArcTan[(x Cot[a x])/y])/y,
x > 0 && y > 0 && 0 < a < \[Pi]/(2 x)]}    *)


Test it, inserting numbers for the variables.

valuesrule = {x -> 1, y -> 2, a -> 1}
brule = sol0[[1]] /. valuesrule

m /. brule /. valuesrule


Find the corresponding nullspace-vector

nsp0 = NullSpace[m /. brule /. valuesrule] // Flatten // FullSimplify

(*    {1, -Cos[2 + ArcCot[2 Tan[1]]] + I Sin[2 + ArcCot[2 Tan[1]]],
1/4 (-3 + E^(2 I)) E^(-(1/2) I (4 + 3 ArcCot[2 Tan[1]])),
1/4 (-1 + 3 E^(2 I)) E^(
1/2 I (-4 + ArcCot[2 Tan[1]])), -E^(-I (2 + ArcCot[2 Tan[1]])), 1}    *)


Apply this nullspace-vector to the matrix to get the expected nullvector.

FullSimplify[(m /. brule /. valuesrule).nsp0]

(*    {0, 0, 0, 0, 0, 0}    *)