# 4 Equations and 4 Unknowns

1. Aug 5, 2013

### A&X

1. The problem statement, all variables and given/known data

Hello,

Although this could be labeled as an EE problem, this is more of an Algebra problem. Anyways, I am having a very hard time solving for the following 4 equations with 4 unknonws.

269.0 = R1*(R2+R3+R4)/(R1+R2+R3+R4)

267.8 = R2*(R1+R3+R4)/(R1+R2+R3+R4)

265.8 = R3*(R1+R2+R4)/(R1+R2+R3+R4)

267.3 = R4*(R1+R2+R3)/(R1+R2+R3+R4)

2. Relevant equations

Can I set R2 & R3 = 0 to make it easier to simplify it?

3. The attempt at a solution

This is what I was able to narrow it down to:

R4=267.3(R1+R2+R3)/(R1+R2+R3-267.3)
R3=268.8(R1+R2+R4)/(R1+R2+R4-268.8)
R2=267.8(R1+R3+R4)/(R1+R3+R4-267.8)
R1=269.0(R2+R3+R4)/(R2+R3+R4-269.0)

I don't know what to do from here on now. When I tried replacing R1 into R2, R2 into R3, etc. it just kept getting messier and it didn't lead to anything promising.

So I figured I set R2 & R3 = 0 to make it easier, but I don't know if I am allowed to do that. Can someone please lead me to the right direction?

Thank you.

2. Aug 5, 2013

### Staff: Mentor

I guess I'd try a numerical solution (ie write a program) trying all combinations of r1, r2, r3 and r4 within a given range. I can't see any way to reduce it algebraically and I don't think assuming r2=r3=0 will help either.

What if you tried multiplying both sides by (r1+r2+r3+r4) and then tried doing linear algebra on it to cancel righthand side terms like r2*r3 vs r3*r2 (subtract eqn3 from eqn2 ...)? I didn't try it but it probably still gets messy.

3. Aug 5, 2013

### wotanub

I don't think there is a way to do it analytically.

Run it through your favorite computer program, there are many solutions.

4. Aug 5, 2013

### A&X

Thank you for all the response.

Using Matlab to solve, I think this is what the code would be:

[R1,R2,R3,R4]=solve('R1=269.0(R2+R3+R4)/(R2+R3+R4-269.0)','R2=267.8(R1+R3+R4)/(R1+R3+R4-267.8)','R3=268.8(R1+R2+R4)/(R1+R2+R4-268.8)','R4=267.3(R1+R2+R3)/(R1+R2+R3-267.3)','R1','R2','R3','R4')

However, I do not have access to matlab at the moment to check. Correct me if I am wrong

5. Aug 5, 2013

### Staff: Mentor

Okay, MATLAB says:

Undefined function 'solve' for input arguments of type 'char'.

6. Aug 5, 2013

### rcgldr

I created a program to search for values with minimum least square difference, to 4 digits I get:

R1 = 359.6940
R2 = 357.2815
R3 = 353.2965
R4 = 356.2810

but this doesn't actually solve the 4 equations.

7. Aug 5, 2013

### Staff: Mentor

It is a numerical solution. There are many cases in practice where sets of equations are intractable algebraically and numerical solutions are required.

8. Aug 5, 2013

### Staff: Mentor

I have a different way of approaching this problem that may work. Rewrite the first equation as:
$$269.0 = R1*(R2+R3+R4)/(R1+R2+R3+R4)=R1*(R1+R2+R3+R4-R1)/(R1+R2+R3+R4)$$$$269.0=R1-\frac{(R1)^2}{(R1+R2+R3+R4)}$$
Next:
$$\frac{269.0}{(R1+R2+R3+R4)}=\frac{R1}{(R1+R2+R3+R4)}-\frac{(R1)^2}{(R1+R2+R3+R4)^2}$$
Equivalently:
$$\frac{269.0}{y}=x_1-(x_1)^2$$
where y=(R1+R2+R3+R4) and $x_1=\frac{R1}{(R1+R2+R3+R4)}=\frac{R1}{y}$
From the other equations, we have:
$$\frac{267.8}{y}=x_2-(x_2)^2$$$$\frac{265.8}{y}=x_3-(x_3)^2$$$$\frac{267.3}{y}=x_4-(x_4)^2$$
Clearly, $x_1+x_2+x_3+x_4=1$
If we solve the first equation for x1 in terms of y, we obtain:
$$x_1=\frac{1-\sqrt{1-\frac{(4)(269.0)}{y}}}{2}$$
(I'm guessing that the minus sign is the correct one to use.)
We obtain similar equations for x2, x3, and x4. If we add the four solutions for the x's together, we eliminate the x's using $x_1+x_2+x_3+x_4=1$, and obtain a single equation in one unknown for y.

9. Aug 6, 2013

### rcgldr

an equation with 4 roots, which could be another issue.

Here is the source code to the program I used:
Code (Text):

/* 269.0 = R1*(R2+R3+R4)/(R1+R2+R3+R4) */
/* 267.8 = R2*(R1+R3+R4)/(R1+R2+R3+R4) */
/* 265.8 = R3*(R1+R2+R4)/(R1+R2+R3+R4) */
/* 267.3 = R4*(R1+R2+R3)/(R1+R2+R3+R4) */

#include <stdio.h>
#include <math.h>

static double A[4] =            /* equation values, actual */
{269.0, 267.8, 265.8, 267.3};
static double B[4], C[4];       /* equation values, best, current */
static double R[4], S[4];       /* variables, best, current */
static double SMIN[4], SMAX[4]; /* range for current variables */
static double BLSQ, CLSQ;       /* least squares, best, current */
static double DS;               /* delta step */

int main(void)
{
BLSQ = 100000000.;          /* init best least squares to large value */
DS   = 1000.;               /* init delta step */
R[0] = 1000.;               /* init variables */
R[1] = 1000.;
R[2] = 1000.;
R[3] = 1000.;
while(DS > .0000005){
SMIN[0] = R[0]-DS;      /* set ranges */
SMIN[1] = R[1]-DS;
SMIN[2] = R[2]-DS;
SMIN[3] = R[3]-DS;
SMAX[0] = R[0]+DS;
SMAX[1] = R[1]+DS;
SMAX[2] = R[2]+DS;
SMAX[3] = R[3]+DS;
DS /= 10.;
for(S[0] = SMIN[0]; S[0] <= SMAX[0]; S[0] += DS){
for(S[1] = SMIN[1]; S[1] <= SMAX[1]; S[1] += DS){
for(S[2] = SMIN[2]; S[2] <= SMAX[2]; S[2] += DS){
for(S[3] = SMIN[3]; S[3] <= SMAX[3]; S[3] += DS){
C[0] = S[0]*(S[1]+S[2]+S[3])/(S[0]+S[1]+S[2]+S[3]);
C[1] = S[1]*(S[0]+S[2]+S[3])/(S[0]+S[1]+S[2]+S[3]);
C[2] = S[2]*(S[0]+S[1]+S[3])/(S[0]+S[1]+S[2]+S[3]);
C[3] = S[3]*(S[0]+S[1]+S[2])/(S[0]+S[1]+S[2]+S[3]);
CLSQ =  (A[0]-C[0])*(A[0]-C[0]) +
(A[1]-C[1])*(A[1]-C[1]) +
(A[2]-C[2])*(A[2]-C[2]) +
(A[3]-C[3])*(A[3]-C[3]);
if(CLSQ < BLSQ){    /* if new best */
BLSQ = CLSQ;    /*   update params */
B[0] = C[0];
B[1] = C[1];
B[2] = C[2];
B[3] = C[3];
R[0] = S[0];
R[1] = S[1];
R[2] = S[2];
R[3] = S[3];
}
}
}
}
}
printf("A = %12.7lf %12.7lf %12.7lf %12.7lf\n",A[0],A[1],A[2],A[3]);
printf("B = %12.7lf %12.7lf %12.7lf %12.7lf\n",B[0],B[1],B[2],B[3]);
printf("R = %12.7lf %12.7lf %12.7lf %12.7lf\n",R[0],R[1],R[2],R[3]);
printf("\n");
}
return(0);
}

Last edited: Aug 6, 2013
10. Aug 6, 2013

### The Electrician

Mathematica is able to find exact solutions, but they are VERY complicated. Here is an example of just one solution for R1:

Numerically, here is a solution good to quite a few decimal places, with the four expressions evaluated with the solution, showing its accuracy:

#### Attached Files:

File size:
16.8 KB
Views:
144
• ###### Sol2.png
File size:
12.2 KB
Views:
146
11. Aug 6, 2013

### Staff: Mentor

This physical problem is going to have only one physically realistic answer. I can obtain a very accurate numerical solution to that answer by hand with very little effort. From my previous post, the algebraic equation I get for y is as follows:
$$\sqrt{\frac{1}{4}-\frac{(269.0)}{y}}+\sqrt{\frac{1}{4}-\frac{(267.8)}{y}}+\sqrt{\frac{1}{4}-\frac{(265.8)}{y}}+\sqrt{\frac{1}{4}-\frac{(267.3)}{y}}=1$$
To solve this numerically, all I need is a good initial guess for y:
$$y^{(0)}=\frac{4s}{3}$$
where s = (269.0+267.8+265.8+267.3)
and then I write:
$$y=\frac{4s}{3}+δ$$
where δ is the parameter I will be solving for.
I also write:
$$269.0=\frac{s}{4}+(269.0-\frac{s}{4})$$
where $(269.0-\frac{s}{4})$ is small compared to s/4
I write similar equations for the other three values. I then substitute into the equation for y, and linearize with respect to δ. I then solve the simple linear equation for δ. I guarantee this will give an accurate answer for y.

12. Aug 6, 2013

### epenguin

Because the LHS all nearly equal, if you are doing it by successive approximations R1=R2=R3=R4 will give you an R s that are all close to a solution.

They will probably be the engineering one, not obvious whether it is the only one

13. Aug 6, 2013

### A&X

Thank you all for all the inputs. This problem is for a strain gage with values in a closed bridge with 4 measurements (for those who were curious what this problem was about).

Here's how I was able to solve it using Matlab:

>>equ1='269.0-R1*(R2+R3+R4)/(R1+R2+R3+R4)';
>>equ2='267.8-R2*(R1+R3+R4)/(R1+R2+R3+R4)';
>>equ3='265.8- R3*(R1+R2+R4)/(R1+R2+R3+R4)';
>>equ4='267.3 - R4*(R1+R2+R3)/(R1+R2+R3+R4)';
>>sol=solve(equ1,equ2,equ3,equ4);
>>R1=sol.R1
>>R2=sol.R2
>>R3=sol.R3
>>R4=sol.R4

R1 =

359.69396536017785860423709040818
1.3507021132304585888310244089084
-0.15281241991439544414763284998392
1.8490642922477590181409957542694

R2 =

357.28145453217212584831447055658
-1.3544948044533407508506455121324
0.15238453051809368598400290995311
1.8449211357365443870556345198613

R3 =

353.29653057117303395043663397118
-1.3494402487364598096284603749859
-0.1519010380142547092615828782759
-1.8507933465933516936061609699429

R4 =

356.28105339639228188360351205007
1.3464165716255193771005390620164
0.15224216764211807620525039756688
-1.8559902351679833508578661774425

And since R's cannot be negative, the only possible solution would be:
R1= 359.69396536017785860423709040818
R2=357.28145453217212584831447055658
R3=353.29653057117303395043663397118
R4=356.28105339639228188360351205007

14. Aug 7, 2013

### Staff: Mentor

For whatever it's worth, I completed the linearized analysis of this problem that I outlined in my two previous posts in this thread. The final analytic results came out very simple, and the calculations can be readily done on a hand calculator:
$$R_j=2L_j-\frac{(L_1+L_2+L_3+L_4)}{6}$$
where, in this example,

L1=269.0
L2=267.8
L3=265.8
L4=267.3

The results agree with the Matlab values to one unit in the fifth significant figure.

Chet

15. Aug 7, 2013

### A&X

I checked your formula with different values for L's and compared with the matlab code and it is actually pretty accurate.

In fact, with this formula I can make a spreadsheet on excel which is much more user friendly. Thank you Chestermiller!

16. Aug 7, 2013

### A&X

By the way Chestermiller, I tried following your work and I was able to follow along for the most part. However, one step you did that i cannot figure it out how you did it is the third step.

How do you go from: 269.0=R1∗(R1+R2+R3+R4−R1)/(R1+R2+R3+R4)
To: 269.0= R1− (R1)^2/(R1+R2+R3+R4)

17. Aug 7, 2013

### Staff: Mentor

You are going to kick yourself when you see this.
$$269.0=R1\frac{(R1+R2+R3+R4−R1)}{(R1+R2+R3+R4)}=R1\left(\frac{(R1+R2+R3+R4)}{(R1+R2+R3+R4)}-\frac{R1}{(R1+R2+R3+R4)}\right)$$
Chet

18. Aug 7, 2013

### A&X

Wow...how emberassing of me :shy:

19. Aug 7, 2013

### rcgldr

I tried this and there are some differences, but it could be the the formula is correct, and that the L values have a relationship that doesn't quite match the stated values due to just 4 digits of precision. The first set of values are what I get from my program and match the matlab results to 10 digits. The second set of values are what I get from the linear formula:

Code (Text):

R =  359.6939654  357.2814545  353.2965306  356.2810534
L =  269.0000000  267.8000000  265.8000000  267.3000000

R =  359.6833333  357.2833333  353.2833333  356.2833333
L =  268.9934789  267.7997038  265.7921330  267.2999141

If you substitute the L's for the R's in the original equation, say just the first one, does it work out?

L1 = R1*(R2+R3+R4) / (R1+R2+R3+R4) = (2*L1 - (L1+L2+L3+L4)/6)(...) / (...) ?

Last edited: Aug 7, 2013
20. Aug 7, 2013

### Staff: Mentor

The equation I gave is an approximate solution to the equations, obtained by linearizing them. I'm sure you will agree that getting a solution that is accurate to 4 significant figures isn't too bad, especially since the input data is only accurate to 4 significant figures and since the approximate solution is so simple to implement (not requiring a computer).

Chet