How to use the SUMXMY2 function
What is the SUMXMY2 function?
The SUMXMY2 function calculates the sum of squares of differences 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 x^{2}. For example, 5^{2} 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 x^{2} 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 = x^{2} is a parabola, symmetric about the origin.
Squares appear frequently in equations in physics, math, statistics, and other fields.
What is the sum of squares of differences of corresponding values in two arrays?
SUMXMY2 stands for the sum of (x  y)^{2}
or
SUMX2MY2 = ∑ (x_{1}  y_{1})^{2} + (x_{2}  y_{2})^{2} + ... + (x_{n}  y_{n})^{2}
What is the difference between SUMXMY2 function and SUMX2MY2 function?
The main difference between the SUMXMY2 and SUMX2MY2 functions in Excel is that the SUMXMY2 calculate the sum of squares of differences of corresponding values in two arrays while the SUMX2MY2 sums the of squares of differences of two arrays.
For example:
Array1 = {1, 3, 5}
Array2 = {2, 4, 6}
SUMXMY2(Array1, Array2) = (1  2)^{2} + (3  4)^{2} + (5  6)^{2} = 3
SUMX2MY2(Array1, Array2) = (1^{2}  2^{2}) + (3^{2}  4^{2}) + (5^{2}  6^{2}) = 3 + (7) + (11) = 21
So SUMXMY2 is a direct difference, while SUMX2MY2 differences the squares.
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 SUMXMY2 function. The above image shows the input values in B3:B5 and C3:C5 respectively.
The image above shows two arrays, the first cell range (B3:B5) contains 4, 3, and 4 and the second cell range (C3:C5) contains 2, 3, and 4.
Formula in cell F3:
The result is displayed in cell F3 and it shows 12. Lets calculate this value manually:
(B3  C3)² + (B4  C4)² + (B5  C5)²
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)² = 2² = 4
(3  3)² = 0² = 0
(4  4)² = 0² = 0
The sum is 4 + 0 + 0 equals 4.
4. Example 2
What is the distance between coordinate 1 (1, 2) and coordinate 2 (11, 8)?
What we know:
 A coordinate has an x value and a y value (x, y)
 Coordinate 1 (1,2): x = 1 and y = 2
 Coordinate 2 (11,8): x = 11 and y = 8
Formula in cell C22:
=SQRT(SUMXMY2(C18:D18,C19:D19))
The formula in cell C22 returns approx. 11.66 units which represents the distance between coordinate 1 (1,2) and coordinate 2 (11,8).
The Pythagorean theorem lets you calculate the distance between two points on the Cartesian plane.
c^{2} = a^{2} + b^{2}
 c is the distance
 a is equal to x2  x1 which is 11  1 = 10
 be is equal to y2  y1 which is 8  2 = 6
c = √(a^{2} + b^{2})
c = √(10^{2} + 6^{2})
c = √(100 + 36)
c = √136
c is approx. 11.66 units
5. Example 3
In a scientific study, you've collected data on the lengths of individuals from a particular animal species. To quantify how much these lengths vary within the population, calculate the population standard deviation of the recorded length measurements?
Here are the data points: 40, 76, 60, 31, 27, 42, 60, 59, 42, and 43
What we know:
The formula for calculating the standard deviation of a population is:
σ = √(∑(x  μ)²) / N
 x are data points
 μ is the average of the data points
 N is the total number of data points
The formula in cell range C16:C25 calculates the average, we need the value in as many cells as there are data points.
Formula in cell F15:
This formula returns 14.44 which represents the standard deviation for a population. This is what the formula calculates in greater detail:
standard deviation for the population σ = √(∑(x  μ)²) / N
 Calculate the difference,then square the difference, and finally add the squared values. ∑(x  μ)²
SUMXMY2(B16:B25,C16:C25)  Divide the total with the number of data points (∑(x  μ)²) / N
SUMXMY2(B16:B25,C16:C25)/ROWS(B16:B25)  Square the ratio (√(∑(x  μ)²) / N).
SQRT(SUMXMY2(B16:B25,C16:C25)/ROWS(B16:B25))
Lets calculate the standard deviation manually:
The average is calculated like this:
μ = ∑xᵢ / n

 ∑ (sigma) represents the sum
 i is the index that goes from 1 to n
 n is the total number of values
The total of 40, 76, 60, 31, 27, 42, 60, 59, 42, and 43 is 480.
480/10 = 48
Subtract each data point with the average:
40  48 = 8
76  48 = 28
60  48 = 12
31  48 = 17
27  48 = 21
42  48 = 6
60  48 = 12
59  48 = 11
42  48 = 6
43  48 = 5
Square the difference and then add the numbers
8² = 64
28² = 784
12² = 144
17² = 289
21² = 441
6² = 36
12² = 144
11² = 121
6² = 36
5² = 25
64 + 784 + 144 + 289 + 441 + 36 + 144 + 121 + 36 + 25 = 2084
Divide the total with the number of data points
2084 / 10 = 208.4
Square the ratio
√208.4 = 14.4360659460949
Excel has dedicated formulas for calculating the standard deviation: STDEV.S and STDEV.P functions. These functions are easier to work with than the formula I created above.
Functions in 'Math and trigonometry' category
The SUMXMY2 function function is one of 61 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