SUMX2MY2 Function in Apple Numbers: Difference of Squares
Use SUMX2MY2 to subtract squared values pairwise and sum the signed differences, with verified inputs, formulas, and troubleshooting.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
SUMX2MY2 subtracts corresponding squared values and adds the signed differences. Apple’s six-pair example gives -158: the first collection has a squared total of 241 and the second 399.
A negative result is valid. This calculation compares total squared magnitudes; it does not measure pairwise distance.
Availability and version history
- Introduced: The original introduction release and date are not established by the checked references.
- Availability: Currently documented in Apple’s Functions Help 15.4 documentation edition; no final supported-version endpoint is established.
- Scope: Shared iWork reference. Function-specific historical Mac, iPad, iPhone and iCloud availability is unverified.
- Checked: October 14, 2026, against the official SUMX2MY2 reference. Worked results were independently calculated; no native Numbers test was performed.
Syntax and numeric collections
SUMX2MY2(set-1-values, set-2-values)
The official SUMX2MY2 reference requires two collections containing number values. It does not provide an optional third argument or an omitted-input default. Use equal-length numeric ranges for the examples; the short entry does not specify an error token for every malformed collection.
Reproduce the complete six-pair source example
Create VendorPairs, with ten columns A:J and ten rows, using no header rows. Enter Apple’s exact values in A1:B6. In C1 enter =A1^2-B1^2 and fill through C6:
| Row | A | B | Expected C |
|---|---|---|---|
| 1 | 2 | 7 | -45 |
| 2 | 9 | 5 | 56 |
| 3 | 3 | 6 | -27 |
| 4 | 11 | 8 | 57 |
| 5 | 1 | 12 | -143 |
| 6 | 5 | 9 | -56 |
Put these formulas in E1:E6, keeping them outside the two input columns:
| Cell | Formula | Expected result |
|---|---|---|
| E1 | =SUMX2MY2(A1:A6,B1:B6) |
-158 |
| E2 | =SUM(C1:C6) |
-158 |
| E3 | =SUMSQ(A1:A6)-SUMSQ(B1:B6) |
-158 |
| E4 | =SUMSQ(A1:A6) |
241 |
| E5 | =SUMSQ(B1:B6) |
399 |
| E6 | =SUMPRODUCT(A1:A6,B1:B6) |
222 |
E2 exposes the row contributions. E3 gives an independently derived identity for the same complete numeric inputs. The 241,399 and 222 controls are useful for distinguishing the three similarly named functions; they are not interchangeable outputs.
Two separate small numeric checks
Create SmallPairs and SignedPairs, each with eight columns A:H and six rows, using no header rows. In SmallPairs, enter 1,2,3 in A1:A3 and 4,5,6 in B1:B3. In SignedPairs, enter 1,0,-2 in A1:A3 and 0,-2,3 in B1:B3.
In D1 of each table enter =SUMX2MY2(A1:A3,B1:B3). The expected results are -63 in SmallPairs and -8 in SignedPairs. Put =A1^2-B1^2 in C1 and fill through C3, then =SUM(C1:C3) in D2 to check the total.
Use the original VendorPairs table for the six-pair example rather than overwriting these smaller fixtures.
Direction, cancellation and unchanged totals
In SmallPairs, put =SUMX2MY2(B1:B3,A1:A3) in D3 for 63, the negative of the original -63. The separate squared totals are 14 and 77. Swapping the collections reverses the difference, while swapping them in SUMXMY2 does not change a squared-distance total.
Create Cancellation, with eight columns A:H and five rows, using no header rows. Put 1,4 in A1:A2 and 4,1 in B1:B2. In C1 enter =A1^2-B1^2 and fill through C2 for -15,15.
In E1 enter =SUMX2MY2(A1:A2,B1:B2) for 0. E2 =SUMXMY2(A1:A2,B1:B2) gives 18, and E3 =SUMSQ(A1:A2)-SUMSQ(B1:B2) gives 0. Equal total squared magnitudes do not imply equal observations or zero paired error.
For complete numeric inputs, rearranging only one collection leaves SUMX2MY2 unchanged because each collection’s separate sum of squares is unchanged. Still preserve record alignment for other analyses. A stable SUMX2MY2 result cannot detect a mismatched-row problem.
Advanced: shifting both series changes this quantity
Copy SmallPairs to ShiftedPairs. Replace A1:A3 with 11,12,13 and B1:B3 with 14,15,16, adding ten to every original value. Leave the existing C and D formulas in place.
C becomes -75,-81,-87; D1 and D2 become -243, and the swapped result in D3 becomes 243. Put =SUMXMY2(A1:A3,B1:B3) in F1 for 27: the pairwise differences remain -3 even though the difference of squared magnitudes changed.
On SmallPairs, put =SUMX2MY2(A1:A3,B1:B3)+20*(SUM(A1:A3)-SUM(B1:B3)) in F1. It predicts -243 for the shifted data because adding ten to both inputs adds 20×(x−y) to each difference of squares. The sums are six and fifteen, so the correction is 20×(-9)=-180.
This dependence on the chosen zero point matters when interpreting measurements. A difference of squared magnitudes is not a translation-invariant distance. Use SUMXMY2 for squared pairwise differences and SUMX2PY2 for the combined squared magnitude.
Numeric inputs, references and practical limits
Use genuine numeric cells in these exercises. The short main-function entry does not supply a complete rule for text, Boolean, blank, date, duration or error-valued inputs. Do not transfer a helper function’s type rules, or another spreadsheet’s rules, into this function without evidence. Unequal collections and exact error tokens also remain outside the paired examples.
Keep corresponding observations and their identifiers together. The fixtures use equal-length, complete numeric ranges; inserting zero for an unknown observation changes the mathematical question. Very large inputs are squared, so finite-precision and magnitude limits matter, but the checked entry does not quantify them.
Within the same Numbers table, the shown cell references are sufficient. For another table, use the reference picker or a qualified form such as TableName::A1:A6. English examples use comma separators; Apple’s functions overview specifies semicolons between arguments when the decimal separator is a comma. Matching English function names do not establish identical historical support, coercion or import behavior across products.
SUMSQ supplies the separate squared totals, SUM adds row contributions and SUMPRODUCT checks the paired product total.