{
  "id": "average-value-of-a-function",
  "version": "65a1f10325a7",
  "status": "published",
  "name": "Average Value of a Function Calculator",
  "question": "What is the average value of f(x)?",
  "summary": "Finds the average value of a function, f_ave = (1/(b − a)) ∫ f(x) dx from a to b, exactly when it can.",
  "category": "math",
  "subcategory": "calculus",
  "url": "https://www.acalculator.org/math/average-value-of-a-function-calculator",
  "markdown": "https://www.acalculator.org/math/average-value-of-a-function-calculator.md",
  "kind": "function",
  "method": "f_ave = (1/(b − a)) ∫ₐᵇ f(x) dx, the integral from a computer algebra system, checked numerically.",
  "assumptions": [
    "f is integrable on [a, b]; angles in radians.",
    "An answer that fails its check is not shown."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "f": {
        "title": "Function f(x)",
        "description": "The function of x.",
        "type": "string",
        "maxLength": 200
      },
      "a": {
        "title": "From x = a",
        "description": "The left end: a number or a constant such as pi.",
        "type": "string",
        "maxLength": 40
      },
      "b": {
        "title": "To x = b",
        "description": "The right end, more than a.",
        "type": "string",
        "maxLength": 40
      }
    }
  },
  "outputs": {
    "average": {
      "label": "Average value",
      "description": "The integral of f from a to b, divided by b − a.",
      "format": "number"
    },
    "exact": {
      "label": "Exact average",
      "description": "The average value, exactly.",
      "format": "math"
    },
    "integral": {
      "label": "∫ f(x) dx from a to b",
      "description": "The definite integral.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "f": "x + 1",
      "a": "0",
      "b": "5"
    },
    "outputs": {
      "average": 3.5,
      "exact": "7/2",
      "integral": 17.5
    },
    "text": "The average value of x + 1 from 0 to 5 is 3.5."
  },
  "examples": [
    {
      "given": {
        "f": "x + 1",
        "a": "0",
        "b": "5"
      },
      "expect": {
        "average": 3.5,
        "exact": "7/2",
        "integral": 17.5
      },
      "source": "OpenStax, Calculus Volume 1, section 5.2 The Definite Integral, Example 5.14 (https://openstax.org/books/calculus-volume-1/pages/5-2-the-definite-integral): ∫₀⁵ (x + 1) dx = 35/2, average 7/2"
    },
    {
      "given": {
        "f": "sin(x)",
        "a": "0",
        "b": "pi"
      },
      "expect": {
        "average": 0.6366197723675814,
        "exact": "2/π",
        "integral": 2
      },
      "source": "hand calculation in content.mdx: ∫₀^π sin x dx = 2, average 2/π; Python 3"
    },
    {
      "given": {
        "f": "6 - 2x",
        "a": "0",
        "b": "3"
      },
      "expect": {
        "average": 3,
        "exact": "3",
        "integral": 9
      },
      "source": "OpenStax, Calculus Volume 1, section 5.2, Checkpoint 5.13; by hand in content.mdx"
    }
  ],
  "sources": [
    "OpenStax, Calculus Volume 1, section 5.2 The Definite Integral (retrieved 2026-10-03): https://openstax.org/books/calculus-volume-1/pages/5-2-the-definite-integral"
  ],
  "related": [
    "integral",
    "mean-value-theorem",
    "area-between-curves",
    "midpoint-rule"
  ],
  "changelog": []
}
