{
  "id": "summation",
  "version": "8c0e870c4f5a",
  "status": "published",
  "name": "Summation Calculator",
  "question": "What is the value of my summation?",
  "summary": "Adds up a term f(n) for every whole number n from a lower to an upper limit (sigma notation), exactly as a fraction when the term allows, with the terms written out.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/summation-calculator",
  "markdown": "https://www.acalculator.org/math/summation-calculator.md",
  "kind": "function",
  "method": "Σ f(n) for n = a to b = f(a) + f(a + 1) + … + f(b): the term is worked out at every whole number from a to b and the values are added.",
  "assumptions": [
    "The index takes every whole number from the lower limit to the upper limit, both included; the upper limit must be at least the lower one.",
    "A term made of numbers, the index, + − × ÷ and whole-number powers is added up exactly in fractions (0^0 counts as 1); other terms are added in floating point with compensated summation.",
    "log and ln are the natural logarithm; angles are in radians."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "f": {
        "title": "Term f(n)",
        "description": "The term to add up, written with the index n (or i, k, j), such as n^2, 2n + 1 or 1/n.",
        "type": "string",
        "maxLength": 200
      },
      "a": {
        "title": "Lower limit",
        "description": "The first value of the index, a whole number from -100 to 100.",
        "type": "integer",
        "minimum": -100,
        "maximum": 100
      },
      "b": {
        "title": "Upper limit",
        "description": "The last value of the index, a whole number from the lower limit up to 1000.",
        "type": "integer",
        "minimum": -100,
        "maximum": 1000
      }
    }
  },
  "outputs": {
    "sum": {
      "label": "Sum",
      "description": "The sum of the term over every index from the lower to the upper limit.",
      "format": "number"
    },
    "exact": {
      "label": "Exact sum",
      "description": "The sum as a whole number or a fraction in lowest terms, when every term is a fraction.",
      "format": "text"
    },
    "count": {
      "label": "Number of terms",
      "description": "How many values the index takes: upper limit − lower limit + 1.",
      "format": "integer"
    },
    "expanded": {
      "label": "Terms",
      "description": "The terms written out: all of them when there are 5 or fewer, else the first three and the last.",
      "format": "text"
    },
    "problem": {
      "label": "Sum of",
      "description": "The summation in words: the term and the range of the index.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "f": "n^2",
      "a": 1,
      "b": 10
    },
    "outputs": {
      "sum": 385,
      "exact": "385",
      "count": 10,
      "expanded": "1 + 4 + 9 + … + 100",
      "problem": "n^2 for n = 1 to 10"
    },
    "text": "The sum of n^2 for n = 1 to 10 is 385."
  },
  "examples": [
    {
      "given": {
        "f": "n^2",
        "a": 1,
        "b": 10
      },
      "expect": {
        "sum": 385,
        "exact": "385",
        "count": 10,
        "expanded": "1 + 4 + 9 + … + 100"
      },
      "source": "sum of squares formula n(n + 1)(2n + 1)/6 = 10 × 11 × 21 / 6 = 385 (hand calculation in content.mdx); Python 3: sum(n**2 for n in range(1, 11)) = 385; sigma notation as in OpenStax College Algebra 2e, section 9.4: https://openstax.org/books/college-algebra-2e/pages/9-4-series-and-their-notations"
    },
    {
      "given": {
        "f": "n",
        "a": 1,
        "b": 100
      },
      "expect": {
        "sum": 5050,
        "count": 100
      },
      "source": "Gauss's sum n(n + 1)/2 = 100 × 101 / 2 = 5050 (hand calculation in content.mdx)"
    },
    {
      "given": {
        "f": "1/k",
        "a": 1,
        "b": 10
      },
      "expect": {
        "sum": 2.9289682539682538,
        "exact": "7381/2520"
      },
      "source": "the 10th harmonic number H₁₀ = 7381/2520 (hand calculation in content.mdx); Python 3: sum(Fraction(1, k) for k in range(1, 11)) = 7381/2520"
    },
    {
      "given": {
        "f": "(1/2)^i",
        "a": 0,
        "b": 4
      },
      "expect": {
        "sum": 1.9375,
        "exact": "31/16",
        "expanded": "1 + 1/2 + 1/4 + 1/8 + 1/16"
      },
      "source": "geometric series (1 − (1/2)^5)/(1 − 1/2) = 31/16 (hand calculation in content.mdx)"
    },
    {
      "given": {
        "f": "2n - 1",
        "a": -2,
        "b": 2
      },
      "expect": {
        "sum": -5,
        "expanded": "(-5) + (-3) + (-1) + 1 + 3"
      },
      "source": "hand calculation in content.mdx: −5 − 3 − 1 + 1 + 3 = −5"
    },
    {
      "given": {
        "f": "sqrt(n)",
        "a": 1,
        "b": 4
      },
      "expect": {
        "sum": 6.146264369941973,
        "expanded": "1 + 1.414213562 + 1.732050808 + 2"
      },
      "source": "Python 3: sum(math.sqrt(n) for n in range(1, 5)) = 6.146264369941973"
    }
  ],
  "sources": [
    "OpenStax, College Algebra 2e, section 9.4 Series and Their Notations (summation notation): https://openstax.org/books/college-algebra-2e/pages/9-4-series-and-their-notations",
    "Wikipedia, Summation (capital-sigma notation and closed forms): https://en.wikipedia.org/wiki/Summation"
  ],
  "related": [
    "sequence",
    "exponent",
    "order-of-operations"
  ],
  "changelog": []
}
