How to use the SUMSQ function
What is the SUMSQ function?
The SUMSQ function calculates the sum of the squares of the arguments.
Table of Contents
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 sum?
Calculating a sum involve adding the numbers together creating a total. Summation combines multiple addends into a total amount. For example, the sum of 2, 3, and 5 is 2 + 3 + 5 = 10.
The numbers added can be positive or negative, resulting in a net sum. For example, the sum of -5, -2, and 5 is -2
Sums can be written using the Greek capital sigma ∑ notation to compactly denote repeated addition. ∑ provides a shorthand for writing out sequences of numbers being added together.
What is the sum of squares?
The sum of squares is the result obtained when you take a set of numbers, square each number, and then sum the squares.
If the numbers are x1, x2, ..., xn, the sum of squares is denoted:
∑(xi2) = x12 + x22 + ... + xn2
The sum of square are used in statistics formulas like sample variance, appears in optimization methods like least squares regression and has applications in numerical integration formulas.
Can be computed iteratively or with summation notation.
The sum of square are related to the square of sums, (∑xi)2
2. Syntax
SUMSQ(number1, [number2], ...)
number1 | Required. The argument for which you want the sum of the squares. |
[number2] | Optional. Up to 253 additional number arguments. |
3. Example 1
Square the following values and then add them: 2, 3, and 4?
Formula in cell D3:
The formula in cell D3 returns 29, lets calculate this manually and see if this is correct. The first step is to square all the numbers:
22 = 4
32 = 9
42 = 16
The next step is to calculate the total:
4+9+16 = 29
This sum is the same value as in cell D3.
4. Example 2
Calculate the hypotenuse in a right triangle if leg 1 is 6 units and leg 2 is 8 units?
What we know:
- A right triangle enables us to calculate the hypotenuse using the Pythagorean theorem:
c = √(a2 + b2) - c = hypotenuse
- a = leg 1 = 6 units
- b = leg 2 = 8 units
Formula in cell C5:
The formula returns 10 units in cell C5. Here is how the formula works:
- Square the numbers and then add them. SUMSQ function.
- Calculate the square root to determine the length of the hypotenuse. SQRT function.
Lets calculate the hypotenuse value manually:
c = √(a2 + b2)
- Square value 6. 62 = 6 * 6 = 36
- Square value 8. 82 = 8 * 8 = 64
- Add values. 36 + 64 = 100.
- Square root the total. √100 = 10
10 is also the calculated value in cell C5.
5. Example 3
You have a dataset containing the weight of a specific vegetable in a study. Calculate the population standard deviation of the weight values to understand the spread of weight across the population of vegetables?
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
Formula in cell E15:
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 average of all data points (μ).
AVERAGE(B16:B25) - Subtract each data point with the average (x - μ).
B16:B25-AVERAGE(B16:B25) - Square the difference and then add the numbers (∑(x - μ)²(x - μ)²).
SUMSQ(B16:B25-AVERAGE(B16:B25)) - Divide the total with the number of data points ((∑(x - μ)²) / N).
SUMSQ(B16:B25-AVERAGE(B16:B25))/ROWS(B16:B25) - Square the ratio (√(∑(x - μ)²) / N).
SQRT(SUMSQ(B16:B25-AVERAGE(B16:B25))/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.
6. Example 4
An electrical engineer is measuring the voltage of an AC circuit over time. They take four voltage readings at different points in the cycle: 120V, -170V, 220V, and -90V. What is the root mean square (RMS) voltage of this AC signal?
What we know:
- The root mean square math formula is:
RMS = √[(x12 + x22 + ... + xn2) / n]
Formula in cell D19:
The formula returns 157.96 V which represents the root mean square voltage of 120V, -170V, 220V, and -90V.
Lets calculate this value manually. Lets begin squaring the values:
120² = 14400
-170² = 28900
220² = 48400
-90² = 8100
Add the values:
14400 + 28900 + 48400 + 8100 = 99800
Divide the result with the number of values:
99800 / 4 = 24950
Calculate the square root of the ratio:
√24950 = 157.955689989313
Explaining formula in cell D19
Step 1 - Square the numbers and then add them
SUMSQ(B19:B22) returns 99800
Step 2 - Count the number of values and then calculate the ratio
The ROWS function calculate the number of rows in a cell range.
Function syntax: ROWS(array)
SUMSQ(B19:B22)/ROWS(B19:B22)
becomes
99800 / 4 = 24950
Step 3 - Square root the ratio
SQRT(SUMSQ(B19:B22)/ROWS(B19:B22))
becomes
SQRT(24950) and returns 157.955689989313
7. Function not working
Arguments that are error values cause errors.
7.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
7.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference B3:B5 converted to hard-coded value using the F9 key. The SUMSQ function requires numerical values which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
7.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
Functions in 'Math and trigonometry' category
The SUMSQ 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