# How to ask Mathematica to find the nontrivial (nonzero) solution of a homogeneous system of equations?

I have this matrix equation $$\left( \begin{array}{ccc} a & b & 0 \\ c & d & e \\ 0 & f & g \\ \end{array} \right)\left( \begin{array}{c} x \\ y \\ z \\ \end{array} \right)=0$$ where all the parameters $$\{a,b,c,d,e,f,g\}$$ are nonzero; I am looking for a nontrivial solution for $$\{x,y,z\}$$ i.e. when the determinant of the coefficient matrix is zero. How can I ask this from Mathematica? Normally, without any assumptions, it just gives the trivial solution zero.

system = { a x + b y == 0  ,  c x + d y + e z == 0 , f y + g z == 0};
Solve[system, {x, y, z}]
(* {{x -> 0, y -> 0, z -> 0}} *)


P.S. NullSpace also gives the empty answer.

• Just knowing det=0 is not enough to get the general solution, because this depends on the rank of the coefficient matrix. Commented Jul 14 at 1:49

The answer will depend how the determinant vanishes:

mat = {{a, b, 0}, {c, d, e}, {0, f, g}};
Det[mat]

(* -a e f - b c g + a d g *)

cases = Solve[% == 0]


Grid[{#, NullSpace[mat /. #]} & /@ cases, Dividers -> All]


Remark: All the solutions above corresponds to generic cases, i.e. the matrix is assumed to be of rank two.

• Thank you very much. So, since all the parameters are non-zero, only the first case in your list can be a nontrivial solution here. Commented Jul 14 at 2:18
• Your welcome. You are right. I overlooked the non-zero condition. Commented Jul 14 at 2:22
• May I ask you to please explain where the matrix rank plays a role in your code? Commented Jul 14 at 12:51
• @charmin, I'm sorry if I misled you. In this code, the rank does not play any role. Also, with your positivity assumption, mat is guaranteed to have rank two. I just pointed out: Solve and NullSpace treat all parameters, which are not explicitly specialized, as generic values. The generic 3x3 matrix with det=0 has rank two, so the solution space is always one dimensional. But, if you need to care about more special cases, say a=b=f=g=0, then rank of mat becomes one, and the solution space is now two dimensional spanned by {-e/c,0,1} and {-d/c,1,0}. Commented Jul 15 at 1:29

Try Reduce

solu = Reduce[{{a, b, 0}, {c, d, e}, {0, f, g}} . {x, y, z} - {0, 0,0} == 0 , {x, y, z}, Backsubstitution -> True];
Simplify[solu, Map[# != 0 &, {a, b, c, d, e, f, g }]]

(*(e f != d g && y == (c g x)/(e f - d g) && z == (c f x)/(-e f + d g)&&a == (b c g)/(-e f + d g))
|| (a e f + b c g != a d g && x == 0 &&y == 0 && z == 0) *)

• Thank you very much! simple and elegant! Commented Jul 14 at 13:10