Lelifi·tools

Sum of Squares Calculator

The sum of squares adds every squared value in a list: square each number, then total the results. Enter numbers separated by commas, spaces or new lines, and the calculator also returns the squared deviations from the mean with the variance and standard deviation.

Paste a list of numbers and get the sum of their squares, plus the squared deviations, variance and standard deviation for samples and populations.

By the Lelifi editors ·

Key takeaways

Squaring turns 1 to 5 into 1, 4, 9, 16 and 25each bar is one squared value; together they total 55114293164255sum of squares = 1 + 4 + 9 + 16 + 25 = 55
Each bar is a squared term for the list 1, 2, 3, 4, 5, and the five bars add up to a sum of squares of 55.
One list, two sums of squaresthe raw squares measure size; the deviations measure spreadlist: 4, 8, 15, 16, 23, 42squares: 16, 64, 225, 256, 529, 1764sum of squares = 2854sum = 108, mean = 108 / 6 = 18squared deviations = 910sample variance = 910 / 5 = 182sample standard deviation = 13.4907The mean is exact here, so both routes land on 910 and the variance follows.
The list 4, 8, 15, 16, 23, 42 squares to 2854, while the squared deviations from its mean of 18 total 910.
On this page
  1. What the sum of squares measures
  2. How to use this calculator
  3. The sum of squares formula, two forms
  4. Worked examples from homework to hardware
  5. From sum of squares to variance and standard deviation
  6. The computational formula and when it breaks
  7. Sum of squares in ANOVA and regression
  8. Common mistakes with squared sums

What the sum of squares measures

Sum of squares is the accountant's trick for turning a list of numbers into one measure of size. Take each value, multiply it by itself, and add every product. The list 3, 4, 5 becomes 9 + 16 + 25 = 50. Negative values drop out of the picture on the first step, because squaring makes them positive: minus 4, 0, 4 squares to 16 + 0 + 16 = 32.

That no canceling property is the whole point. An ordinary sum of plus 4 and minus 4 is 0, which hides the fact that both values sit far from the middle. Squared, they contribute 16 apiece. Analysts lean on squared terms whenever direction does not matter but distance does: error sizes, spreads, fit quality.

The phrase names two different sums that share a mechanic, and both appear on this page. Squaring the raw values measures overall size. Squaring each value's distance from the mean measures spread. Statistics courses usually mean the second one; engineering and geometry problems usually mean the first.

NameWhat gets squaredWhat it feeds
Sum of squares of valueseach raw numberdistance, energy, least squares fitting
Sum of squared deviationseach value minus the meanvariance and standard deviation
Residual sum of squareseach prediction errorregression fit quality

How to use this calculator

Type or paste numbers into the box, separated by commas, spaces, semicolons or new lines, then press Calculate. Copying a column straight out of a spreadsheet works without cleanup. The results table shows the square of each value, the sum of squares, the count, the plain sum and the mean.

With two or more values the table grows four more rows: the sum of squared deviations, sample variance and standard deviation, then the population versions. One number alone has no spread, so those rows stay blank instead of inventing an answer. A non numeric entry earns a clear message rather than a silent zero.

Try the list 3, 4, 5. The calculator should report squares of 9, 16 and 25, a sum of squares of 50, a mean of 4, and squared deviations of 2, which gives a sample standard deviation of 1 and a population one of about 0.8165. When those lines match, the tool is doing exactly what the examples below describe.

The sum of squares formula, two forms

The long form does exactly what the name says. Label the values x1 through xn. The sum of squares of the values is x1 squared plus x2 squared, and so on to xn squared. The sum of squared deviations subtracts the mean first: each value minus the mean, squared, then totaled. Both produce one non negative number.

The short form collapses the deviation version into raw sums: the sum of squares equals the sum of x squared, minus the square of the sum of x divided by n. For 3, 4, 5 that is 50 minus 144 / 3, which is 50 - 48 = 2, matching the long form's 1 + 0 + 1 = 2. The Penn State STAT 200 notes on measures of spread walk through the same arithmetic on classroom data.

The National Institute of Standards and Technology keeps a reference page on measures of scale that lists variance and the sums behind it among the standard spread statistics, worth a bookmark when you need the formal definitions.

Choose the form that matches your data. The long form survives huge numbers gracefully. The short form is faster by hand but can lose precision when every value is in the millions and the differences are small.

Worked examples from homework to hardware

Example 1, a quiz key. Scores of 4, 8, 15, 16, 23 and 42 total 108, so the mean is 18. Squaring the deviations gives 196 + 100 + 9 + 4 + 25 + 576 = 910. Divide by n minus 1 = 5 for a sample variance of 182, and the standard deviation is the square root of 182, about 13.4907 points.

Example 2, QC measurements. A machine cut bars measuring 2, 4, 4, 4, 5, 5, 7 and 9 millimeters. The sum of squares of the values is 232, the mean is 5, and the squared deviations total 32. Sample variance is 32 / 7 = 4.5714 and the standard deviation is about 2.1381 millimeters, which flags the 9 as the piece pulling the spread up.

Example 3, a physics shortcut. Kinetic energy is half the mass times the speed squared, so a sum of squares is a sum of energies up to a constant. Three carts at 10, 12 and 14 meters per second square to 100 + 144 + 196 = 440; at 2 kilograms each, the total energy is 2 x 440 / 2 = 440 joules. The OpenStax statistics chapter on spread uses supermarket wait times instead of carts, but the arithmetic is the same one this page runs.

From sum of squares to variance and standard deviation

Variance is the sum of squared deviations shared out. Divide by n and you have the population variance. Divide by n minus 1 and you have the sample variance, the version used when your data is a sample and the population is out of reach. The n minus 1 correction, called Bessel's correction, keeps the estimate honest about the missing data. Standard deviation is the square root of either one, which brings the answer back to the units the data came in.

The next table shows the list 2, 4, 4, 4, 5, 5, 7, 9 under both conventions so the difference is concrete.

QuantityFormulaValue for the list
Sum of squared deviationssum of (x minus mean) squared32
Sample variance32 / 74.5714
Sample standard deviationsquare root of 4.57142.1381
Population variance32 / 84
Population standard deviationsquare root of 42

Which divider applies? Use n minus 1 when the list is a sample you hope says something about a bigger group, and n when the list is the entire population you care about. Test scores for one class are usually a sample. The eight bars you measured and will never measure again are the whole population.

The computational formula and when it breaks

The shortcut, sum of x squared minus the square of the sum of x divided by n, earns its keep on paper exams, and the calculator shows the two pieces it needs: the plain sum and the sum of squares of the values. For 3, 4, 5 the pieces are 12 and 50, and 50 - 144 / 3, which is 2, matches the deviation total exactly.

The same shortcut has a famous failure mode. Feed it values like 1,000,000 and 1,000,002 and every intermediate number is enormous: the sum of squares is 2,000,004,000,004 while the answer is 2. Computers store about 16 significant digits, so subtracting two trillions to get a single digit can round the truth away, a problem textbooks call catastrophic cancellation. The long form never multiplies its way into that corner, because each deviation stays small before it is squared.

This page subtracts the mean and squares the result rather than trusting the shortcut, so lists full of similar large numbers stay safe. If you ever check the work by hand, watch for the pattern: the short form is fine for homework sized numbers and risky for data that clusters near a large value.

Sum of squares in ANOVA and regression

The same idea powers the analysis of variance. In a one way ANOVA, the total sum of squares measures how far all observations sit from the grand mean. The between group sum of squares measures how far each group mean sits from the grand mean, and the within group sum of squares measures the scatter inside groups. The pieces add up, and the F test compares the between piece to the within piece after dividing each by its degrees of freedom.

Regression runs the same accounting. A fitted line splits the total sum of squares into a regression part, the improvement the line explains, and a residual part, what is left over. The R squared statistic is the explained share: regression sum of squares divided by total sum of squares. An R squared of 0.8 means four fifths of the total squared distance from the mean is captured by the line.

Least squares fitting took its name from this quantity. The best line, in that framework, is the one that makes the residual sum of squares as small as possible, which is why every statistics package reports it and why the value can never be negative.

Common mistakes with squared sums

Four slips cover most wrong answers with this quantity.

SlipWhat goes wrongHow to repair it
Squaring the total instead of the terms(3 + 4 + 5) squared = 144, not 50square each value first, then add
Choosing the wrong divisor32 / 8 = 4 when the sample answer is 32 / 7 = 4.5714use n minus 1 for samples
Adding deviations without squaringminus 2, 0 and 2 total 0distance comes from the squared terms
Mixing units across the listadding inches to centimeters before squaringconvert first, then compute

A fifth habit causes quiet damage: rounding the mean before subtracting it. The mean of 4, 8, 15, 16, 23, 42 is 18 exactly, but a mean like 5.3333 should keep its extra digits through the subtraction step. Round once, at the end, and the variance lands where a calculator says it should.

Frequently asked questions

What is the sum of squares of 3, 4 and 5?

50. Squaring each value gives 9, 16 and 25, and 9 + 16 + 25 = 50. The squared deviations from the mean of 4 are much smaller: 1 + 0 + 1 = 2.

What is the sum of squares of 1 through 5?

55. The squares are 1, 4, 9, 16 and 25, and they total 55. There is a closed form for the first n integers, n(n + 1)(2n + 1) / 6, which gives 5 x 6 x 11 / 6 = 55.

How do I find the sum of squared deviations?

Subtract the mean from each value, square the differences, and add them. The values 3, 4, 5 have a mean of 4, so the deviations are minus 1, 0 and 1, and the sum of their squares is 2.

Why does sample variance divide by n minus 1?

A sample underestimates spread because it is centered on its own mean rather than the true one. Dividing the squared deviations by n minus 1, called Bessel's correction, inflates the estimate just enough to remove that bias.

What is the standard deviation of 2, 4, 4, 4, 5, 5, 7, 9?

About 2.1381 as a sample and exactly 2 as a population. The squared deviations total 32, so sample variance is 32 / 7 = 4.5714 and its square root is 2.1381, while 32 / 8 = 4 gives 2.

Can a sum of squares be negative?

No. Every square is zero or positive, so a total of zero happens only when every value is zero, or when every value equals the mean in the deviation version.

What is the computational formula for sum of squares?

The sum of x squared minus the square of the sum of x divided by n. For 3, 4, 5 that is 50 minus 144 / 3, and 144 / 3 is 48, so the answer is 2. Handy by hand, but it can lose precision with huge, similar values.

What does sum of squares mean in regression?

It is the squared error left after fitting. A line splits the total sum of squares into an explained regression part and a leftover residual part, and R squared is the explained share, such as 0.8 out of 1.

How is sum of squares used in ANOVA?

ANOVA splits it in two. The between group part measures how far group means sit from the grand mean, and the within group part measures scatter inside groups. The F statistic compares the two after dividing by degrees of freedom.

What is the sum of squares of minus 4, 0 and 4?

32. Squaring removes the sign, so the terms are 16, 0 and 16. The plain sum of the same list is 0, which is exactly the information squaring recovers.

Do I add units when reporting a sum of squares?

Yes, and the units change. Spread measured in feet reports a variance in square feet, while the standard deviation returns to plain feet after the square root. A sum of squares itself carries squared units.

How many numbers do I need for the deviation statistics?

At least 2. One value sits exactly on its own mean, so its squared deviation is 0 and dividing by n minus 1 would mean dividing by zero, which has no answer.

Is sum of squares the same as variance?

No, though the two are close. Sum of squares is the total of squared distances, while variance is that total divided by n or n minus 1, turning it into an average spread you can compare across lists of different sizes.

Spotted a wrong number or a broken result?

More Math tools

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.