Let $A$ be an $n\times m$ matrix, with $n<m$. Is there a way to test if the null space of $A$ contains a positive vector? By positive vector, I mean a vector with only non-negative entries and different from zero.
Testing if the Null Space of a Matrix Contains a Positive Vector
linear algebramatrices
Best Answer
It suffices to find a matrix $M$ whose columns form a basis of the nullspace and solve the following linear programming problem:
\begin{align} \min_x\quad & c^TMx \\ \text{such that }\quad & -Mx \leq -\vec 1\\ &x \in \Bbb R, \end{align} where $c$ can be any $m \times 1$ vector. We make use of the following "trick" here: if an element of the nullspace with positive elements exists, then it is of course possible to scale this element so that its entries are greater than or equal to $1$. So, it suffices to consider the constraint where all entries of the vector are strictly greater than $1$.
If you merely want to assess existence, then you can take $c$ to be a zero vector as I have below, but you might prefer to choose a different $c$ as a niceness heuristic. For example, taking $c$ to be a vector of $1$'s results in a solution with minimal $1$-norm.
If the inequalities seems strange, that's because they have been arranged to accommodate the nature of the inputs to scipy's linprog function.
Here's the Python script (modified for relevancy) that I used to deal with a very similar problem.
The
print(res)
command gives you a summary of the result. TheTrue/False
aftersuccess:
tells you whether a satisfactory vector $x$ exists. This condition is stored asres.success
. The vector $x$ is stored asres.x
, and the corresponding element of the nullspace is[email protected]
.Implementation of the simpler method, per the helpful comment:
If the outcome is "success", then the feasible element of the nullspace is given by
res.x
.