# A Solution from infinite solutions within a range

Suppose I have a system of equations whose augmented matrix is $$\left[\begin{array}{ccc|c} 1 & 2 & 3 & 7\\ 4 & 5 & 6 & 8 \end{array}\right]$$ After converting this matrix to row reduced echelon form I got $$\left[\begin{array}{ccc|c} 1 & 0 & -1 & -19/3 \\ 0 & 1 & 2 & 20/3 \end{array}\right]$$

Now I want a solution such that $$0 < x_1 < 9, \quad 0 < x_2 < 7, \quad 0 < x_3 < 2$$ One such solutions is $x_1 = -16/3 , x_2 = 14/3$ and $x_3 = 1$.

But how do I find one such solution in general case, suppose I have n unknowns variables ? I am only considering the case when infinite solutions exist for a linear system

• What logic should I use in coding to get one desired solution. Sep 16, 2018 at 12:28

You determined that the null space of your system is $\operatorname{span}\left\{\begin{bmatrix} 1 \\ -2 \\ 1\end{bmatrix}\right\}$ so the general solution is
$$x = \begin{bmatrix} x_1 \\ x_2 \\ x_3\end{bmatrix} = \begin{bmatrix} -\frac{19}3 \\ \frac{20}3 \\ 0\end{bmatrix} + t\begin{bmatrix} 1 \\ -2 \\ 1\end{bmatrix} = \begin{bmatrix} -\frac{19}3 + t \\ \frac{20}3-2t \\ t\end{bmatrix}$$
Therefore you can solve for $t$ independently in $$0 < -\frac{19}3 + t < 9 \implies t \in\left\langle \frac{19}3, \frac{100}3\right\rangle$$ $$0 < \frac{20}3-2t < 7 \implies t \in\left\langle -\frac16, \frac{10}3\right\rangle$$ $$0 < t < 2 \implies t \in \langle 0, 2\rangle$$