Let me explain SOME of the the mathematics here.
First, you have 4 equations, in 4 unknowns. Typically, that means there is one unique solution when the system of equations is linear. That is only true if the system is full rank. If the system has less than full rank (here, 4) then there will be infinitely many solutions.
Second, the system is a homogeneous system. The idea is, if we moved ALL of the terms with unknowns in them to the left side, and ALL constant terms to the right side of the equality, then the right hand side would have ALL zeros. That is, there are no constant terms. Do you see that?
Next, you should see that if you substitute all zeros in for the unknowns, the equations are trivially satisfied. You would have 0==0 in each case.
To see what case applies here, we can first express this as a linear algebra problem in a standard form.
eqn(2) = b == a/3 + (2*d)/3;
eqn(3) = c == a/3 + (2*d)/3;
eqn(4) = d == b/4 + c /4;
[A,rhs] = equationsToMatrix(eqn,[a,b,c,d])
A =
rhs =
As I said, this is a homogeneous system of equations. We can reconstruct what is equivalent to the original system like this:
A*[a;b;c;d] == rhs
ans =
And, clearly, if we use [0;0;0;0] as a solution, we do have
A*[0;0;0;0] == 0
ans =
Next, what matters is, what is the rank of A. As I said before, if the matrix A has full rank, then the only solution possible is the all zero solution.
So A has rank only 3. The completely general solution to the homogeneous system is given by the function null.
Anull = null(A)
Anull =
That is, the unknowns a,b,c,d are given by the vector:
abcd = Anull*t
abcd =
And we can see this is a solution to the problem, if we plug it back into the original equations.
subs(eqn,[a;b;c;d],abcd)
ans = All of those equations are valid, for ANY value of t.
You want the particular solution where the sum is 1. So we can arbitrarily choose t = 1/9. That will make the sum equal to 1.
sol = abcd/sum(abcd)
sol =
Could you have done this by simply appending the equation a+b+c+d==1 to the system? Well, yes, in this case, that will work. But that may not be correct for all problems. I can give a several trivial examples where it would fail. But I've already long overspent my time on this problem, and doing so would double the amount of writing I've already invested on what is likely homework.