Solving simultaneous equations in excel - excel

I have 4 equations, with 4 unknowns, a,b,c,e
w = c + 0.43*a
x + gb = pc + 2*e
y + 2a + hb = qc + 20.43a + e
z + bi = cr
What would be the best way to solve this in Excel?
I searched and found that LINEST might be a good function to use, but couldn't get it to work
Thanks

First rewrite all you formulas in the form
Ai*(a)+Bi*(b)+Ci*(c)+Ei*(e)=Ki
Then for each equation fill out a row in the matrix
A1 B1 C1 E1 a K1
A2 B2 C2 E2 x b = K2
A3 B3 C3 E3 c K3
A4 B4 C4 E4 e K4
Then use MInverse and MMultiply functions to solve for a,b,c and e
A,B,C,E are the constants multiplying each variable. Set them to 0 when they are not in the formula, and make sure you carry the negative sign.
i is just a way to represent the equation number.
K is the constant in the equation with out a variable attached to it.
So provided I did the formula rearrangement properly, one possible result would be:
Cant take it farther than this as numbers would be needed for g, p, h, q, i, and r (not to mention w, x, y, and z). Though you could set those up in cells so you sheet would automatically update when you entered values.

Related

How to use the Polynomial Trendline Formula

So the blue line graph has values from column CM (x values are in column CF, sorry for the confusing presentation). I want to recreate the polynomial trendline that I had excel generate for it, which is what I'm trying to do in column CH, as you can see from the formula bar.
Excel gives me the formula y = -0,0006x^2 + 0,013x + 0,1878 (shown on the chart) which I then have entered into the values in column CH.
The result is unfortunately not even close (displayed as the orange line graph). Is there any person here sharp enough on maths to tell me what I'm doing wrong?
This is the formula to obtain 2nd Order Polynomial Trendline:
y = (c2 * x^2) + (c1 * x) + b
c2: =INDEX(LINEST(y,x^{1,2}),1)
c1: =INDEX(LINEST(y,x^{1,2}),1,2)
b: =INDEX(LINEST(y,x^{1,2}),1,3)
So now, just examined your formula, you have incorrect parameters (b, c1 and c2) used so the result is different.
Here are the formulas I used to obtain these three parameters:
c2: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1)
c1: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1,2)
b: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1,3)
Then I got:
c2 (cell CG1227) = -0.05675
c1 (cell CG1228) = -0.04025
b (cell CG1229) = 0.25509
Now, from cell CH1234, this formula is used:
=($CG$1227*CF1234^2)+($CG$1228*CF1234)+$CG$1229
I have the outcome matched with the Polynomial Trendline. Try and see if this works for you.

Simple mathematical mystery from Excel

I got a problem to understand on first sight simple to reproduce mathematical problem as follows:
The Table
The first 5 rows of columns A-D are simple numbers. The first 5 rows of column E are E=D/C. The first 5 rows of column F are F=(B-A)+(A*E).
Then the sums row sums up A-D. The number G (just under) equals to Sum(D)/Sum(C) and consequently I=(sum(B)-sum(A))+(sum(A)*G). H=sum(the previous F rows).
Now the question is: Why doesn't H equal I ??? That is, why in this case doesn't sum of partial results equal to the calculation made from sums of the columns?
Dont mess with calculation precedence!
Let's simplify this using only two rows:
F1 is =B1-A1+A1*D1/C1 and F2 is =B2-A2+A2*D2/C2
So F4, your H, is =B1-A1+A1*D1/C1+B2-A2+A2*D2/C2
F6, your I, is =B1+B2-A1-A2+((A1+A2)*(D1+D2)/(C1+C2))
You claim, H should be equal I:
B1-A1+A1*D1/C1+B2-A2+A2*D2/C2 = B1+B2-A1-A2+((A1+A2)*(D1+D2)/(C1+C2))
Subtract B1, B2, and add up A1, A2 on both sides:
A1*D1/C1+A2*D2/C2 = ((A1+A2)*(D1+D2)/(C1+C2))
This is simply not true.
In your table E7 = D7 / C7 and this is different from sum(E1:E5) because of the formulas involved. The value 293.5 corresponds to the case when E7 = sum(E1:E5) and the value 296.4 to the case where E7 = D7/C7.
UPDATE
The two formulas for F7 you are trying to compare are mathematically different.
One is
(B1-A1) + A1*E1 + (B2-A2) + A2*E2 + ... + (B5-A5) + A5*E5
= (B7-A7) + (A1*E1 + ... + A5*E5)
= (B7-A7) + (A1*D1/C1 + ... + A5*D5/C5) (1)
and the other
(B7-A7) + A7 *(D1+D2+D3+D4+D5)/(C1+C2+C3+C4+C5) (2)
Only the first term (B7-A7) is the same in both expressions. The rest is different. In (1) you first multiply and divide Ai*Di/Ci and then sum. In (2) you first sum the Ai, Di and Ci and then multiply the sums.

Formula to change another cell

I'm a novice in excel. I'm using Excel 2010. My spreadsheet looks something like this:
0 A B C D
1 X 10€ X: (sum of all incomes, made by A)
2 Y 20€ Y: (sum of all incomes, made by B)
3 Z 5€ Z: (sum of all incomes, made by C)
4 X 4€
5 Z 6€
I have a list of incomes and outcomes, collected/paid for by 3 different persons. I'd like to format the first column: if the content of the cell is 'X', the income in that row is added to X's sum of all incomes, if it's Y, add to Y's sum, same for Z.
Something like this (for A1):
"if content = X, add B1 to D1; if content = Y, add B1 to D2; if content = Z, add B1 to D3"
How do I write the formula?
Use the =SUMIF() formula.
Before you start, remove the colons from C1, C2 and C3.
In D1 write this formula:
=SUMIF($A$1:$A$5,C1,$B$1:$B$5)
... and copy or drag the formula down to D2 and D3.
Remember the $-signs in the formula to lock the ranges when copying or dragging.

Logical calculation in Excel

I need advice/help. I am working on calculation in excel where I have data like mentioned below.
. A B C D E F G H
1| A275 A277 A273 A777 A777 TOTAL A222 GRAND TOTAL
2| 5 7 4 3 4 7 7
Now, I want to count row 2 based on the header.
Here is the condition.
If A1 <> B1 then take A1, if B1 <> C1 then take B1, if C1 <> D1 then C1, so on.
But tricky part is...
If D1<>E1 then D1 else (if E1<>F1 then E1 else (if F1 = "TOTAL" then F1 else(if F1<>G1 then F1)))
In short H2 should have 30 and not 37.
Added comments:------------------------------------
So, Basically if A1<>B1 then take A1 but if A1=B1 then take B1, but then for B1, its a same rule like if B1<>C1 then take B1, but if B1=C1 then take C1 and for C1, same rule. Stopping point will be "TOTAL". Along with these logic I need to check if any cell in row 1 is "TOTAL" then take value for same column. Now this "TOTAL" can be in any cell in row 1.
So from above table my calculation will be 5(A2) + 7(B2) + 4(C2) + 7(F2) + 7(G2) = 30
In this calculation I have not included D2 and E2 as D2=E2 so I took D2, here E2<>F2 so I should have taken E2, but as F2="TOTAL" so I took F2 and not D2 and E2.
I hope this make sense. (Sorry, I know its confusing.)
I have data in more then 100 columns.
Can this be achieved using Macro?
------------------------------------------------------------
Another pain point is data and header are dynamic, so I can't have a fix format. Logic should be in a way that can handle the dynamic data and header.
Any help or suggestion will be greatly appreciated.
I achieved the results you want with this.
Add a helper row. In cell A3 write this formula and drag it to the right:
=IF(OR(A$1=B$1,B$1="TOTAL"),0,1)
Calculate sum in say cell H4 (not H2 because if the formula refers to entire row 2 there will be circular reference):
=SUMIF($3:$3,1,$2:$2)

Excel Formula- Divide a sum into multiple cells?

I need a formula for excel that will allow me to take a sum and divide it up into a number of cells.
for example:
A1= sum
B1 to B4 needs to have a portion of the devided sum
i.e. if sum 1000 then B1=100 B2=200 B3=300 B4=400
Thank's in advance guys
The decomposition rule is that it goes from B1 to B4 in intervals of 100...adding to the pervious
The formula for the lowest term is (2 * s / n - (n - 1) * d) / 2 where
s is the sum
n the number of terms
d the common difference
You have n = 4 and d = 100.
So the lowest term is (s / 2 - 300) / 2.
So if cell A1 contains the sum (1000), you can write =0.5*(A1 / 2 - 300) in cell B1
Then B2 = B1 + 100, B3 = B2 + 100 and B4 = B3 + 100.
The formula comes from the sum of an arithmetic progression.
Try this
Set alias to cell A1 as amount
Use a cell for the number of division which is 4, assume to put in cell A2
Calculate the formula for the total portions to divide, put it in cell A3. In your case A3 =A2*(A2+1)/2
Set alias to cell A3 as total
In each of B columns, set the formula as =(ROW()/total*amount)
Copy the formula from step 5 above until the maximum row in B according to your need

Resources