{
  "category": "Math and trigonometry functions",
  "display_name": "SUMSQ",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.SUMSQ",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 1211,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 1211,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 1,211 in the answer bank and 27 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 1,238 recorded answers",
    "workbook_corpus": {
      "cells": 27,
      "matched": 27
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/aggregate.rs#L98-L98",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/aggregate.rs#L190-L205"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/aggregate::aggregate",
        "catalogue/aggregate::product",
        "catalogue/aggregate::times",
        "catalogue/aggregate::holds_held_arrays",
        "catalogue/aggregate::number_of",
        "catalogue/aggregate::each_number",
        "catalogue/aggregate::read_values",
        "catalogue/aggregate::reader",
        "catalogue/aggregate::read_reference"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/aggregate.rs#L98-L98",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 1,238 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.SUMSQ.json",
  "name": "SUMSQ",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n\n- **`SUMPRODUCT(x, x)`** — the same value by a different route, and a useful cross-check.\n- **`SUMX2PY2(x, y)`** — `SUMSQ(x) + SUMSQ(y)` in one call, over paired arrays. `SUMX2MY2` and\n  `SUMXMY2` complete that trio; all three are documented with a different mismatch error code\n  than `SUMPRODUCT`, which is discussed on their pages.\n- **`DEVSQ`, `VAR.S`, `VAR.P`, `STDEV.S`** — the statistical consumers. Note the warning below\n  about computing them from `SUMSQ`.\n- **`SQRT(SUMSQ(...))`** — the Euclidean norm. There is no `HYPOT` or `NORM` function in Excel,\n  so this composition is the idiom, and it inherits the overflow problem described below.\n- **`SUM`** — the parent aggregate; `SUMSQ` differs only in squaring each term before adding.\n- **`POWER` / `^`** — writing `SUM(A1:A10^2)` as an array formula is the hand-rolled equivalent\n  and is not obliged to agree in the last bit, because it materializes an intermediate array.\n- **Confused with**: `SUMSQ` versus `SUM(...)^2`. The sum of squares and the square of the sum\n  are different numbers, and the confusion is common enough to be worth naming.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n`SUMSQ` combines two well-studied numerical problems: squaring and summing. Each has a standard\ntreatment and Excel offers no control over either.\n\n**1. Overflow and underflow in the squares.** The dynamic range of the squares is twice that of\nthe inputs, in the exponent. A vector whose entries are all around `1e200` has a perfectly\nrepresentable sum of squares in the mathematical sense — but every individual square overflows.\nSymmetrically, entries around `1e-200` square to zero. The standard remedy, from Blue's TOMS\nalgorithm and the LAPACK `dnrm2` lineage, is **scaling**: find the largest magnitude `m`,\naccumulate `SUM (x_i/m)^2`, and multiply back by `m^2` at the end. Blue's refinement uses three\naccumulators for small, medium and large entries so that a single pass suffices even when the\ndata spans the whole range. This is textbook, it costs one extra pass or a running maximum, and\nnothing in `SUMSQ`'s interface tells you whether it is done.\n\nFor `SUMSQ` specifically, the left fold interacts badly with the squaring: squares are all\nnon-negative, so there is no cancellation between terms, but the *magnitude spread* is doubled,\nwhich is exactly the condition under which a naive running sum swallows terms. A sum of squares\nis therefore one of the better cases for compensated summation and one of the worst for a plain\nfold.\n\n**3. Do not compute variance from `SUMSQ`.** The textbook shortcut\n`variance = (SUMSQ(x) - n * mean^2) / (n - 1)` subtracts two large nearly equal quantities and\ncan return a negative variance for data with a large mean and small spread. This is the most\nfamous cancellation example in applied statistics and it is worth repeating on this page because\n`SUMSQ` is what makes the shortcut writable. Use `DEVSQ`, or a two-pass or Welford\nformulation, and leave `SUMSQ` for the cases where the sum of squares is itself the answer.\n\n**4. What a careful implementation does**: scale by the largest magnitude, accumulate pairwise\nor with compensation, and apply the scale back once at the end. The result differs from a naive\nleft fold, sometimes substantially — which is precisely the four-flavour split this Handbook\npublishes rather than hides. The Handbook makes no claim about what Excel does internally.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`, always non-negative.\n\n- **No numeric values found**: zero. An aggregate over an empty or all-text range returns zero,\n  not an error, which is the family convention.\n- **Squares overflow before sums do.** This is the characteristic edge and it is worth stating\n  plainly: a value near the square root of the largest double squares to the top of the range,\n  and anything above that overflows *in a single term* even though the mathematical answer would\n  be perfectly representable if the computation were scaled. Conversely, small values square to\n  subnormals and then to zero, so a vector of small entries can produce a sum of squares of zero\n  when the true value is a small positive number.\n- **Logicals and text** follow the dual policy above.\n- **Arrays**: `SUMSQ` is an aggregate, not a lift kernel — an array argument is consumed by\n  scanning, not applied elementwise.\n\n",
    "sources": "\n- Microsoft, \"SUMSQ function\" —\n  <https://support.microsoft.com/en-us/office/sumsq-function-e3313c02-51cc-4963-aae6-31442d9ec307>\n  (signature, up to 255 arguments, the \"typed into the list\" versus array/reference distinction,\n  and the ignored-contents remark whose treatment of error values this page records as a\n  divergence).\n- Higham, *Accuracy and Stability of Numerical Algorithms* — summation error bounds, pairwise and\n  compensated summation, and the two-pass norm.\n- Blue, \"A Portable Fortran Program to Find the Euclidean Norm of a Vector\", *ACM TOMS*, 1978;\n  the LAPACK `dnrm2` lineage — the scaled accumulation that removes the overflow band.\n- Handbook [Coercion and lifting](../model/02-coercion-and-lifting.md), especially the\n  direct-argument versus range-scan section and the statement that errors in scanned ranges\n  surface.\n- Handbook projections `data/functions/FUNC.SUMSQ.json` (arity 1-255,\n  `coercion_lift_profile: AggregateDirectAndRangeDualPolicy`,\n  `error_collapse_profile: ReductionFold`, `numerical_reduction_policy=SequentialLeftFold`) and\n  `data/presence/FUNC.SUMSQ.json`.\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 20430 | Windows, 64-bit, CPU not recorded | 1,211 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.SUMSQ.json).",
    "what-it-does": "\n`SUMSQ(number1, [number2], ...)` returns\n\n    SUM over i of x_i^2\n\nthe sum of the squares of its arguments.\n\n- **Domain**: any finite list of real numbers.\n- **Range**: `[0, +infinity)`. The result is zero only when every contributing value is zero;\n  it is otherwise strictly positive. `SUMSQ` of an empty selection is zero.\n- **Structure**: this is the squared Euclidean norm, `||x||^2`. It is the quantity that sits\n  under least squares, variance, the chi-square statistic, and every energy or power\n  calculation. `SQRT(SUMSQ(...))` is the Euclidean norm itself, and Excel has no separate\n  function for it.\n- **Identities**: `SUMSQ(x) = SUMPRODUCT(x, x)`; `SUMSQ(x) - n*mean^2 = DEVSQ(x)` is the\n  computational (and numerically unwise — see below) form of the sum of squared deviations;\n  `SUMX2PY2(x, y) = SUMSQ(x) + SUMSQ(y)`.\n- **Degenerate cases**: a single argument gives `x^2`; `SUMSQ(3, 4)` gives 25, the documented\n  example, and is the Pythagorean case that explains why the function is useful.\n\nMicrosoft's page gives the signature and describes the arguments as numbers, names, arrays or\nreferences containing numbers, up to 255 arguments.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Default |\n|---|---|---|\n| `number1` | The first value or range. Required. | — |\n| `number2, ...` | Further values or ranges, up to 255 arguments in total. Optional. | — |\n\n- A value passed **directly** — `SUMSQ(\"3\", TRUE)` — undergoes ordinary to-number coercion.\n- A value reached by **scanning a range** — `SUMSQ(A1:A3)` where a cell holds the text `\"3\"` —\n  is governed by the family's scan policy, which is not the same rule.\n\nMicrosoft's article states both sides in its own vocabulary: values \"typed into the list\" are\nincluded, while \"if an argument is an array or reference, only numbers in that array or\nreference are counted\", and the function \"will ignore empty cells, logical values, text, or\nerror values in the array or reference\". The Handbook's shared treatment of this asymmetry is in\n[Coercion and lifting](../model/02-coercion-and-lifting.md#direct-arguments-versus-range-scans);\nthis page does not restate it.\n\n**A divergence worth recording.** Microsoft's remark places *error values* in the ignored set\nfor arrays and references, while the same article separately says errors arise from error values\nin arguments. The Handbook's call model takes the opposite position from the first clause: \"An\nerror in a scanned range does surface from `SUM` — skipping errors is not part of the\nignore-text scan policy.\" So the documented remark and the Handbook's model of the aggregate\nfamily disagree about what an error value inside a scanned range does. Neither has been checked\nagainst Excel for `SUMSQ` in this record, and the disagreement is published rather than\nsilently resolved. It is the first probe listed below.\n\n\n"
  },
  "signature": {
    "display": "SUMSQ(number1, [number2], ...)",
    "parameters": [
      {
        "description": null,
        "name": "number1",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "number2",
        "optional": true,
        "repeats": true
      }
    ],
    "trailing_repeats": true
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 255,
        "min": 1
      },
      "category": "Math and trigonometry functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "AggregateDirectAndRangeDualPolicy",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "ReductionFold",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "NumsToNum",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Squares of the numbers, added up",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the sum of the squares of the arguments",
        "microsoft_url": "https://support.microsoft.com/en-us/office/sumsq-function-e3313c02-51cc-4963-aae6-31442d9ec307"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "SUMSQ"
        },
        {
          "locale": "bg-BG",
          "name": "SUMSQ"
        },
        {
          "locale": "cs-CZ",
          "name": "SUMA.ČTVERCŮ"
        },
        {
          "locale": "da-DK",
          "name": "SUMKV"
        },
        {
          "locale": "de-DE",
          "name": "SUMSQ"
        },
        {
          "locale": "el-GR",
          "name": "SUMSQ"
        },
        {
          "locale": "en-AU",
          "name": "SUMSQ"
        },
        {
          "locale": "en-GB",
          "name": "SUMSQ"
        },
        {
          "locale": "en-US",
          "name": "SUMSQ"
        },
        {
          "locale": "es-ES",
          "name": "SUMA.CUADRADOS"
        },
        {
          "locale": "et-EE",
          "name": "SUMSQ"
        },
        {
          "locale": "fi-FI",
          "name": "NELIÖSUMMA"
        },
        {
          "locale": "fr-FR",
          "name": "SOMME.CARRES*"
        },
        {
          "locale": "he-IL",
          "name": "SUMSQ"
        },
        {
          "locale": "hr-HR",
          "name": "SUMSQ"
        },
        {
          "locale": "hu-HU",
          "name": "NÉGYZETÖSSZEG"
        },
        {
          "locale": "id-ID",
          "name": "SUMSQ"
        },
        {
          "locale": "it-IT",
          "name": "SUMSQ"
        },
        {
          "locale": "ja-JP",
          "name": "SUMSQ"
        },
        {
          "locale": "ko-KR",
          "name": "SUMSQ"
        },
        {
          "locale": "lt-LT",
          "name": "SUMSQ"
        },
        {
          "locale": "lv-LV",
          "name": "SUMSQ"
        },
        {
          "locale": "nb-NO",
          "name": "SUMSQ"
        },
        {
          "locale": "nl-NL",
          "name": "KWADRATENSOM"
        },
        {
          "locale": "pl-PL",
          "name": "SUMA.KWADRATÓW"
        },
        {
          "locale": "pt-BR",
          "name": "SUMSQ"
        },
        {
          "locale": "pt-PT",
          "name": "SOMARQUAD"
        },
        {
          "locale": "ro-RO",
          "name": "SUMSQ"
        },
        {
          "locale": "ru-RU",
          "name": "СУММКВ"
        },
        {
          "locale": "sk-SK",
          "name": "SUMSQ"
        },
        {
          "locale": "sl-SI",
          "name": "SUMSQ"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "SUMSQ"
        },
        {
          "locale": "sv-SE",
          "name": "KVADRATSUMMA"
        },
        {
          "locale": "th-TH",
          "name": "SUMSQ"
        },
        {
          "locale": "tr-TR",
          "name": "TOPKARE işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "SUMSQ"
        },
        {
          "locale": "vi-VN",
          "name": "SUMSQ"
        },
        {
          "locale": "zh-CN",
          "name": "SUMSQ"
        },
        {
          "locale": "zh-HK",
          "name": "SUMSQ"
        },
        {
          "locale": "zh-TW",
          "name": "SUMSQ"
        }
      ],
      "signature": {
        "display": "SUMSQ(number1, [number2], ...)",
        "parameters": [
          {
            "description": null,
            "name": "number1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "number2",
            "optional": true,
            "repeats": true
          }
        ],
        "trailing_repeats": true
      },
      "surface_name": "SUMSQ",
      "version_marker": null,
      "xlcall": {
        "code": "321",
        "symbol": "xlfSumsq"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/sumsq-function-e3313c02-51cc-4963-aae6-31442d9ec307"
  },
  "try_it": {
    "formula": "=SUMSQ(3, 4)"
  },
  "url": "https://handbook.dnacalc.com/functions/SUMSQ.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "1,211 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.SUMSQ.json"
      ]
    }
  ]
}