Simple mathematical mystery from Excel - 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.

Related

Solving simultaneous equations in 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.

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.

How to get weighted sum depending on multipliers in column in Excel?

I have the table in Excel:
In column C (Sum) I want to get sum this way:
If in column A or B value is 1 then take Amount 48 and multiply by Multiplier (1) = 2.
If in column A or B value is 0 then take Amount 48 and multiply by Multiplier (0) = 1,5.
Then K1 and K2 summed.
So for row 2 the result in column C will be: 48*2 + 48*2 = 192.
For row 5 the result in column C will be: 48*1,5 + 48*2 = 168.
Is it possible to automate this process using Excel formula for C column (inspite of number of columns)?
Or you could use Countif (no shorter though)
=COUNTIF(A2:D2,0)*I$2*I$1+COUNTIF(A2:D2,1)*I$3*I$1
Use Ctrl+Alt+Enter when entering (since it's an array formula)
EDIT: I'm not great with formulas, so there is I'm sure a shorter alernative...

Averaging daily varying column in excel vb

Every day I have to analyze two cols of numbers.
Cols differ each day.
Col 1 has no.'s from 1 to 5, eg. Day 1 there are 150 x 1's and 200 x 2's, etc. Day 2, 350 x 1's and 85 x 2's etc.
Col 2 has values between 1 and 99.
I need to count how many 1's there are to obtain a 1's average, 2's ave., etc. So far I have tried to write a vb program (excel 2010) - I have written the following:
Function Phil2()
ct = 0
For X = 2 To 10
If ax = 1 Then Let b15 = b15 + bx
ct = ct + 1
Next
End Function.
But I cannot get it to display. Can anyone help me?
I want the average of the 1's in cell b15.
See the formula bar for what is in cell E1. If you don't have XL2007 or above, the formula becomes:
=IF(ISERROR(SUMIF($A$1:$B$10,D1,$B$1:$B$10)/COUNTIF($A$1:$B$10,D1)),"",SUMIF($A$1:$B$10,D1,$B$1:$B$10)/COUNTIF($A$1:$B$10,D1))
You could also make more "automated" by using Dynamic Named Ranges for your ID (1,2,3..) and data (%) sets, that change each day.
OK, It works fine - I modified your formula to:
=IFERROR(AVERAGEIFS(B$16:B$500,$A$16:$A$500,$A2,B$16:B$500,">0"),"")
and it works perfectly for values 1, and 2. So that's a great start. I placed the formula cells on top: so in a1 I typed cow no., in b1 %Milk, in c1 %weight, etc.. In a2 I typed 1, a3 2, a4 3 etc.. In b2 your formula etc.. My next challenge is to lump together all cow types 3 to 11. So next to cow type 1 we have a % for each category, same for cow type 2, etc.. But the 3rd row must have an average for all categories 3+. Raw data cow types are in a10 down, vals in b10, c10, etc.

How can I find the median of the difference of two rows?

I have two rows in two different sheets in Excel. Each row has 20 elements. I need to find the median of the difference of the corresponding elements in these two rows. I want this output to be in just one cell. I don't want to add another row in my result.
I have:
If Row1 = p1 p2 p3.... p20
If Row2 = q1 q2 q3.... q20
I need:
result cell = Median of ((p1 - q1), (p2-q2)....(p20-q20))
{=MEDIAN(P1:P20-Q1:Q20)}
This is an array formula you have to validate with Ctrl + Shift + Enter
[EDIT] Including brettdj's suggestion from the comments below, you can try this formula too:
{=MEDIAN(Sheet2!A2:T2-Sheet1!A1:T1)}

Resources