# How do you solve this systems of equations?

How do your solve this system of linear equations? \begin{align*} a^2 + b^2 + c^2 + d^2 &= 176\\ a+b+c+d &= 24\\ b-a&= c-b\\ b-a&= d-c\\ c-b&= d-c\ \end{align*}

Is there an easy way to solve this system of equations using matrices or any other method?

-
This is not a system of linear equations in $a$, $b$, $c$, and $d$: The first equation is not linear! However, you can solve the last three equations as a system of 3 linear equations in four unknowns, which will essentially express three of the variables in terms of a fourth one (say, $a$, $b$, and $c$ in terms of $d$); Gaussian elimination is the simple way of doing that. Then you can substitute those expressions into the first equation to get a second degree equation in $d$, which can be solved using the quadratic formula. Each value of $d$ then gives you a value for $a,b,c$. –  Arturo Magidin Sep 27 '11 at 19:43
Note: I think the question has been modified after some of the comments and answers were posted. –  Srivatsan Sep 27 '11 at 20:04
I noticed also that the question changed and the OP didn't wrote anything about the reason of this change. This is not very ok in my opinion. The changes made in the equations make the problem even easier, and prove that the OP didn't bother looking through the answers to LEARN how to solve this kind of problems, but only to find the answer to a given problem. –  Beni Bogosel Sep 27 '11 at 20:17
The question comes from an earlier question about finding the $4$ terms of a uniform distribution given mean and variance. I was writing up a solution when the question disappeared. The mean was $6$, I don't remember the variance, probably $8$. Made sense as a probability exercise. –  André Nicolas Sep 27 '11 at 21:46

From the last line you get $b+c=a+d=12$. Replace $c=2a-b$ in the second equation and get $3a+d=24$. Therefore $a=d=6$. Replace $a,d$ in the first two equations and get

$b^2+c^2=104$ and $b+c=12$. $(b+c)^2=144=b^2+c^2+2bc=104+2bc$. Therefore $bc=20$.

Now you have $b+c=12, bc=20$ and therefore $b,c$ are roots of $x^2-12x+20=0$ which is $x \in \{2,10\}$. Then $b=10,c=2$ or the other way around.

There was no trick involved. Just use the easiest equations first, which are those without squares, and find out all that you can from this equations. Then pass to the quadratic one.

-

First, the three equations at the end imply that $a, b, c, d$ are in arithmetic progression, so there is some $k$ such that:

\begin{align*} a &= a \\ b &= a + k \\ c &= a + 2k \\ d &= a + 3k \end{align*}

Plugging into the second equation, $$4a + 6k = 24, \qquad k = 4 - \frac{2}{3}a.$$

So now

\begin{align*} a &= a \\ b &= a/3 + 4 \\ c &= -a/3 + 8 \\ d &= -a + 12 \end{align*}

Then plug into the first equation: $$a^2 + (a/3 + 4)^2 + (-a/3 + 8)^2 + (-a + 12)^2 = 176$$

Solving the resulting quadratic (using a CAS is helpful here), we find $a = \frac{30 \pm 6\sqrt{10}}{5}$, or approximately $2.205, 9.795$. Then plug in to find $b, c, d$ for each choice of $a$:

\begin{align*} a &= 2.205 \\ b &= 4.735 \\ c &= 7.265 \\ d &= 9.795 \end{align*} or \begin{align*} a &= 9.795 \\ b &= 7.265 \\ c &= 4.735 \\ d &= 2.205 \end{align*}

-
The 'mistakes' appear because the OP changed the question. –  Beni Bogosel Sep 28 '11 at 10:44
Ah, I see. I removed my last paragraph talking about 'mistakes'. –  Shaun Ault Sep 28 '11 at 12:00

We have

a + b + c + d = 24

a - b - c + d = 0

2a + 2d = 24

2b + 2c = 24

which means that

a + d = b + c = 12

Also,

2a = b + c = 12

so a = 6, so d = 6. The rest is now easy.

If you want to solve questions of this sort in general, rather than this problem in particular, you need to study Grobner bases, but that sounds as though it might be a little beyond your level at the moment.

-

$$$$\left( \begin{array}{ccc} a & b & c & d \\ 1 & 1 & 1 & 1 \\ -2 & 1 & 1 & 0 \\ -1 & 1 & -1 & 1 \end{array} \right)\qquad \left( \begin{array}{ccc} a\\ b\\ c\\ d\end{array} \right) = \left( \begin{array}{ccc} 176\\ 24\\ 0\\ 0\end{array} \right)$$$$

-
This is hard to understand without explanation. On first reading, I thought this was to imply that $a=176$, $b=24$, $c=0$, $d=0$, however I now see that this is a matrix product that is equivalent to the original system -- though without further work, how would the OP be expected benefit from this version of the problem? –  Shaun Ault Sep 27 '11 at 20:23
Assuming you invert the matrix and multiply both sides on the left by that inverse, you would still have $a$, $b$, $c$, and $d$ in the expression on the right side, so that would not yet be a solution. –  Michael Hardy Sep 27 '11 at 20:26
Right, sorry if I was being a little skeptical but I don't want to give it all away! Otherwise you don't learn. Plus it took me so long to figure out how to code that I got lazy :) –  riotburn Sep 28 '11 at 4:14
riotburn, do you have a method of actually solving the equation that uses what you've written there? –  Daniel McLaury Sep 28 '11 at 16:53
if you look below, percusse already solved it out, though I haven't check to see if it is correct. This is in the form Ax = b and you have to solve for x = A^-1 b. Can't recall if R or matlab would handle having variables in A or not. –  riotburn Sep 28 '11 at 19:07

We can continue from riotburn's notation as follows: We do a simple Gauss Elimination (or Row Reduced Echelon Form) starting from the second row $$\left( \begin{array}{ccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 2 & 1 & 0 \\ 0 & -\frac{1}{2} & -1 & \frac{3}{2} \end{array} \right)\left( \begin{array}{ccc} a & b & c & d \\ 1 & 1 & 1 & 1 \\ -2 & 1 & 1 & 0 \\ -1 & 1 & -1 & 1 \end{array} \right) \left( \begin{array}{ccc} a\\ b\\ c\\ d\end{array} \right) = \left( \begin{array}{ccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 2 & 1 & 0 \\ 0 & -\frac{1}{2} & -1 & \frac{3}{2} \end{array} \right) \left( \begin{array}{ccc} 176\\ 24\\ 0\\ 0\end{array} \right)$$ Then we have, $$\left( \begin{array}{cccc} a &b & c &d\\ 1 &1 &1 &1\\ 0 &1 &1 &\frac{2}{3}\\ 0 &0 &-3 &1 \end{array}\right)\left( \begin{array}{ccc} a\\ b\\ c\\ d\end{array} \right) = \pmatrix{176\\24\\16\\-12}$$ Now you do the back substitution in terms of $d$ which gives you $$c=4+\frac{d}{3}, b = 12-d, a = 8-\frac{d}{3}$$ If you plug these in, you get $$(8-\frac{d}{3})^2 + (12-d)^2 + (4+\frac{d}{3})^2 + d^2 = 176$$ and the following solutions $d=2.20527$ and $d=9.79473$. This is in accordance with @shaunault 's result.

-

The question has changed over time, so we restate it, changing the notation a little. Then we generalize.

Problem: Let $(a_1,a_2,a_3,a_4)$ be a $4$-term arithmetic sequence such that

(i) $a_1^2+a_2^2+a_3^2+a_4^2=176$ and (ii) $a_1+a_2+a_3+a_4=24$.

Find the $a_i$.

The problem originally arose in a probabilistic context. We use probabilistic language in the solution.

Let $X$ be the random variable which takes on the value $a_i$ with probability $1/4$ ($i=1,2,3,4$).

Then (i) says that $E(X^2)=44$, and (ii) says that $E(X)=6$. So $X$ has variance $E(X^2)-(E(X))^2$, which is $8$.

Let $Y$ be a random variable which is uniformly distributed on the set $\{0,1,2,3\}$. Let $a=a_1$, and $d=a_2-a_1=a_3-a_2=a_4-a_3$. Then $$X=a+ d\,Y.$$ Note that $E(Y)=(0+1+2+3)/4=\frac{6}{4}$ and $E(Y^2)=(0^2+1^2+2^2+3^2)/4=14/4$. It follows that $Y$ has variance $(14/4-(6/4)^2)$, which is $5/4$.

Since $X=a+d\,Y$, $X$ has variance $d^2$ times the variance of $Y$. It follows that $$8=\frac{5}{4}d^2,$$ and therefore $d=\pm 4\sqrt{2}/\sqrt{5}$. We use the positive value of $d$. Work with the negative value is essentially the same.

Since $X=a+d\,Y$, we have $E(X)=a+d\,E(Y)$. Thus $$6=a+\frac{6}{4}d.$$ But we know $d$, and therefore we can compute $a$. Now that $a$ and $d$ are known, all the $a_i$ are known.

Generalization: Suppose that the sequence $(a_1,a_2, a_3,\dots, a_n)$ is an increasing $n$-term arithmetic sequence. Let $X$ be the random variable that takes on the value $a_i$ with probability $1/n$ ($i=1,2,\dots,n$). Suppose also that we know the mean $\mu$ and the variance $\sigma^2$ of $X$. We want to determine the $a_i$.

Let $a=a_1$ be the first term of our sequence, and $d$ the common difference. Let $Y$ be the random variable that takes on the values $0,1,2,\dots,n-1$, each with probability $1/n$.

Then $X=a+d\,Y$. It is a standard fact that $Y$ has variance $\frac{n^2-1}{12}$. (This can also be easily derived from the usual formula for $\sum_0^{n-1}i^2$.) But the variance of $X$ is $d^2$ times the variance of $Y$. It follows that $$\sigma^2=\frac{n^2-1}{12}d^2,$$ and now we know $d$.

Also, $E(Y)=\frac{n-1}{2}$. Since $X=a+d\,Y$, by taking expectations we obtain $$\mu=a+\frac{n-1}{2}d,$$ and now we know $a$, and therefore everything.

-