# How to build a linear equation system?

How can one build a $3\times 3$ linear equation system ($3$ equations with $3$ variables) if the variables are known, for example, $a=1, b=2$ and $c=3$?

-
Are you sure you meant this? What are you trying to achieve? –  alext87 Sep 26 '10 at 13:42
Are you trying to create test cases for your linear equation solver? If so, you could just generate the equations randomly and then verify the solution given by your solver by substitution into the original equations. –  Aryabhata Sep 26 '10 at 14:16
I apologize for not expressing myself clearly. English is not my 1st language. I have been given three answers (a=1, b=2 and c=3) and I have to build the 3x3 linear equation from them. I want to find out how I can do that. –  Artis Sep 26 '10 at 17:45
Artis: as I already said, it's an ill-posed problem; there is no unique solution since there are infinitely many matrix-vector pairs that would have your given as a solution vector. –  Ｊ. Ｍ. Sep 26 '10 at 23:08
it seems to me that this intuitive explanation might help you. If you were given only $a=1$ and $b=2$, then you would have infinitely many straight lines on the $x,y$-plane, all having the point $(1,2)$ in common. –  Américo Tavares Sep 28 '10 at 18:14

If I understand correctly, you have the desired solution for a system of three equations in 3 unknowns and want to know how to construct a system with those solutions. This is a fairly common task for people who teach high-school algebra. The way that I typically do it is to make up the coefficients of the variables first, so something like: \begin{align} 3a+4b+5c&= \\ 8a-5b+7c&= \\ -5a+b+c&= \end{align} then substitute in the desired solutions to get the constant terms on the right side of each equation (using your $a=1$, $b=1$, and $c=3$): \begin{align} 3\cdot 1+4\cdot 2+5\cdot 3&=26 \\ 8\cdot 1-5\cdot 2+7\cdot 3&=19 \\ -5\cdot 1+2+3&=0 \end{align} so that one system with your given solutions would be: \begin{align} 3a+4b+5c&=26 \\ 8a-5b+7c&=19 \\ -5a+b+c&=0 \end{align}

edit: I should probably note (similar to the edited note in Agusti Roig's answer) that this method only guarantees that the given values are a solution to the system, not that they are the only solution to the system. As with nearly any problem, it is worthwhile to check that the resulting system has only the solution(s) you want by solving it.

-

If this is homework, it's a pretty strange one. :-? Anyway, do you like the following system?

\begin{align} x &= 1 \\\ y &= 2 \\\ z &= 3 \end{align}

-Too much easy, I see.

So, try this: your system must fulfil the following equation:

$$A \begin{pmatrix} 1 \\\ 2 \\\ 3 \end{pmatrix} = b$$

where $A$ is a $3\times 3$ matrix and $b$ is a column vector with $3$ coordinates (a $3\times 1$ matrix). Write $a_1, a_2, a_3$ for the columns of $A$. Then this equation is the same as the following equality between vectors in $\mathbb{R}^3$:

$$a_1 + 2a_2 + 3a_3 = b \ .$$

Now, pick your three (linearly independent) favourite vectors in $\mathbb{R}^3$, put in the places of $a_1, a_2, a_3$, compute the resulting $b$ and you have another system of linear equations with solution $x=1, y=2$, and $z=3$. For instance, if you take $a_1 = (1\ 0\ 0)^t$, $a_2 = (0\ 1 \ 0)^t$ and $a_3 = (0\ 0\ 1)^t$, you'll obtain my first example.

EDIT. Maybe I should add something to explain the necessity of my misterious condition that $a_1, a_2, a_3$ must be "linearly independent".

The reason is the following: if you pick your three vectors randomly (that is to say, you put no matter what coefficients into the matrix $A$), you could obtain systems like

$$x + y + z = 6$$

(take $a_1 = a_2 = a_3 = (1\ 0\ 0)^t$). Of course this system has the desired solution $x=1, y=2,$ and $z=3$, but also an infinite number of them. In fact, the solution set is

$$(x, y, z) = (1, 2, 3) + \lambda (1, 0, -1) + \mu (0, 1, -1)$$

for all values of $\lambda, \mu$.

Of course, if you fill in the matrix $A$ randomly, the probability of not obtaining three linearly independent vectors $a_1, a_2, a_3$ is zero, but it won't take you too much time and effort to verify that

$$\det (A) \neq 0$$

-

It's ill-posed; you can construct any nonsingular matrix $\mathbf A$ to be multiplied with $(1\;2\;3)^T$ for the corresponding right hand side.

-