How to use the SUMX2MY2 function
What is the SUMX2MY2 function?
The SUMX2MY2 function calculates the sum of the difference of squares of corresponding values in two arrays.
1. Introduction
What is the square?
In mathematics, the square of a number is the result of multiplying the number by itself. Squaring a number is denoted by x2. For example, 52 means 5 * 5 = 25.
Squaring a number results in a positive result as negative signs are removed in multiplication. (-5)2 = 25 Squares grow very rapidly. Already x2 reaches large values quickly as x increases, higher powers grow even faster.
The square root is the inverse operation of squaring. √25 = 5, since squaring 5 gives 25. Squaring is used in geometry to calculate area of squares, side length squared = area. Squaring is also used when calculating the area of a circle.
For example, A = π r²
A is the area.
r is the radius.
π is pi.
The graph of y = x2 is a parabola, symmetric about the origin.
Squares appear frequently in equations in physics, math, statistics, and other fields.
What is the difference of squares?
The difference of squares is an algebraic identity that relates the difference between two squared terms to the product of the sum and difference of those terms.
a² - b² = (a + b)(a - b)
Where a and b are numbers.
(a + b)(a - b) equals a² - ab +ba + b² which is a² - b²
For example:
x² - 16 = (x + 4)(x - 4)
The difference of squares formula is useful for factoring expressions and simplifying equations involving squared terms. It reveals the hidden factors in the difference of squares.
What is the sum of the difference of squares?
SUMX2MY2 function calculates the sum of x² minus y². The arrays x an y must be equal in size.
SUMX2MY2(array1, array2) = ∑(x² - y²)
2. Syntax
SUMX2MY2(array_x, array_y)
array_x | Required. The first array or range of values. |
array_y | Required. The second array or range of values. |
3. Example 1
This example demonstrates how to use the SUMX2MY2 function. The above image shows the input values in B3:B5 and C3:C5 respectively.
Formula in cell F3:
The result is displayed in cell F3 and it is 12. Lets calculate this value manually:
The first array array_x i 4, 3, and 4, the second array contains 2, 3, and 4.
The sum of the difference of squares
4² - 2² = 16 - 4 = 12
3² - 3² = 0
4² - 4² = 0
The sum is 12 + 0 + 0 equals 12.
4. Example 2
Calculate the length of leg 2 in a right triangle with hypotenuse equal to 10 units and leg 1 equal to 6 units?
What we know:
- A right triangle allows us to use the Pythagorean theorem:
a = √(c2 - b2) or b = √(c2 - a2) - Leg 1 (b) = 6
- Leg 2 (a) = unknown
Formula in cell C6:
The formula returns 8 in cell C6. Here is what it does in greater detail:
- Square the values in cells C4 and C3, then calculate the difference. SUMX2MY2(C4,C3)
- Calculate the square root of the difference. SQRT(SUMX2MY2(C4,C3))
Lets calculate the result manually.
Square the hypotenuse: 102 = 100
Square leg 1: 62 = 36
Calculate the difference between the hypotenuse and leg 1:
100 - 36 = 64
Calculate the square root of the difference: √64 = 8 units. Leg 2 is 8 units.
5. Example 3
An object accelerates from 2 m/s to 8 m/s over a distance of 10 meters. What is its acceleration?
Equation is: v2 = u2 + 2as
- v = final velocity (2 m/s)
- u = initial velocity (8 m/s)
- s = distance (10 meters)
- a = acceleration (unknown)
The equation becomes: a= (v2 - u2) / (2 * s)
Formula in cell C22:
Cell C22 returns 3 m/s2 which represents the acceleration from the initial speed 2 m/s to its final speed of 8 m/s across 10 meters.
6. Example 4
A large square (x) has a side length of 10 units, and a smaller square (y) has a side length of 8 units. Another large square (x) has a side length of 4 units, and a smaller square (z) has a side length of 3 units. What is the total area of x minus y and w minus z?
What we know:
- Square x side: 10 units
- Square y side: 8 units
- Square w side: 4 units
- Square z side: 3 units
Formula in cell C22:
The formula in cell C22 returns 43 square units which is equal to the total area of x - y and w - z. The image above contains a chart that displays
- x as a dark red square
- y as a smaller orange square inside the dark red square x
- w as a grey square
- z as a smaller blue square inside the grey square w
How is 43 square units calculated?
- Square x side: 10 units equals 100 square units
- Square y side: 8 units equals 64 square units
- Square w side: 4 units equals 16 square units
- Square z side: 3 units equals 9 square units
Total area = x - y + w - z
100 - 64 + 16 - 9 = 43 square units.
7. Example 5
This example demonstrates how you can use the SUMX2MY2 to calculate the variance of a given set of numbers. Note, the VAR.P and VAR.S functions are much easier to use than this formula.
Cells B19 to B28 contains numbers representing the weights of manufactured products. The image above shows a chart containing a blue line that represents the normal distribution based on a mean of 174 and a standard deviation of 15.85. The chart also shows the different standard deviations 1σ, 2σ, 3σ, -1a, -2σ, and -3σ which represents:
- 68% of the data falls between μ ± 1σ
- 95% of the data falls between μ ± 2σ
- 99.7% of the data falls between μ ± 3σ
Formula in cell E19:
Cell E19 returns 251.36 which represents the variance of the values in cell range B19:B28
Here's a breakdown of how it works:
- B19:B28 is the range of cells containing the numbers for which you want to calculate the average absolute deviation.
- AVERAGE(B19:B28) calculates the mean (average) of the numbers in the range.
- LAMBDA(a,SUMX2MY2(a,AVERAGE(B19:B28))) is a lambda function that calculates the sum of the absolute deviations from the mean for each number in the range.
- a represents each number in the range.
- SUMX2MY2(a,AVERAGE(B19:B28)) calculates the absolute deviation of each number from the mean, squares it, and then sums these squared deviations. However, the SUMX2MY2 function actually calculates the sum of the squares of the differences between corresponding values in two arrays, so in this case it's being used to calculate the sum of the squared differences between each value and the mean.
- BYROW(B19:B28,LAMBDA(a,SUMX2MY2(a,AVERAGE(B19:B28)))) applies the lambda function to each number in the range, effectively calculating the sum of the squared absolute deviations for each number.
- SUM(BYROW(B19:B28,LAMBDA(a,SUMX2MY2(a,AVERAGE(B19:B28))))) sums up these squared absolute deviations for all numbers in the range.
- COUNT(B19:B28) counts the number of values in the range.
- Finally, the formula divides the sum of the squared absolute deviations by the count of numbers to get the average of the squared absolute deviations, which is the variance of the set of numbers.
Functions in 'Math and trigonometry' category
The SUMX2MY2 function function is one of 62 functions in the 'Math and trigonometry' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form