{
  "id": "divergence",
  "version": "0d525301d7c3",
  "status": "published",
  "name": "Divergence Calculator",
  "question": "What is the divergence of a field?",
  "summary": "Finds the divergence div F = ∇ · F of a vector field F = (P, Q, R), and its curl, checked numerically.",
  "category": "math",
  "subcategory": "calculus",
  "url": "https://www.acalculator.org/math/divergence-calculator",
  "markdown": "https://www.acalculator.org/math/divergence-calculator.md",
  "kind": "function",
  "method": "div F = ∂P/∂x + ∂Q/∂y + ∂R/∂z, each partial derivative from a CAS, checked.",
  "assumptions": [
    "Radians. An answer that fails its check is not shown."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "p": {
        "title": "P (i component)",
        "description": "The P component, a function of x, y and z.",
        "type": "string",
        "maxLength": 150
      },
      "q": {
        "title": "Q (j component)",
        "description": "The Q component, a function of x, y and z.",
        "type": "string",
        "maxLength": 150
      },
      "r": {
        "title": "R (k component)",
        "description": "The R component, a function of x, y and z.",
        "type": "string",
        "maxLength": 150
      }
    }
  },
  "outputs": {
    "div": {
      "label": "div F",
      "description": "The divergence P_x + Q_y + R_z.",
      "format": "math"
    },
    "curl": {
      "label": "curl F",
      "description": "The curl (R_y − Q_z, P_z − R_x, Q_x − P_y).",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "p": "e^x",
      "q": "y z",
      "r": "-y z^2"
    },
    "outputs": {
      "div": "-2y z + z + e^x",
      "curl": "(-z^2 - y, 0, 0)"
    },
    "text": "The divergence of (e^x, y z, -y z^2) is -2y z + z + e^x."
  },
  "examples": [
    {
      "given": {
        "p": "e^x",
        "q": "y z",
        "r": "-y z^2"
      },
      "expect": {
        "div": "-2y z + z + e^x"
      },
      "source": "OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 6.5, Ex. 6.48"
    },
    {
      "given": {
        "p": "y z",
        "q": "x z",
        "r": "x y"
      },
      "expect": {
        "div": "0",
        "curl": "(0, 0, 0)"
      },
      "source": "OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 6.5, Ex. 6.56"
    },
    {
      "given": {
        "p": "x^2 z",
        "q": "e^y + x z",
        "r": "x y z"
      },
      "expect": {
        "div": "x y + 2x z + e^y",
        "curl": "(x z - x, x^2 - y z, z)"
      },
      "source": "OpenStax Calculus Vol. 3 (Strang and Herman, 2016), 6.5, Ex. 6.52; div by hand in content.mdx"
    }
  ],
  "sources": [
    "OpenStax, Calculus Volume 3, section 6.5 Divergence and Curl (retrieved 2026-10-03): https://openstax.org/books/calculus-volume-3/pages/6-5-divergence-and-curl"
  ],
  "related": [
    "curl",
    "partial-derivative",
    "jacobian",
    "dot-product"
  ],
  "changelog": []
}
