{
  "id": "volume",
  "version": "6fe7fbbd2c37",
  "status": "published",
  "name": "Volume Calculator",
  "question": "What is the volume of my shape?",
  "summary": "Finds the volume of a cube, box, cylinder, cone, sphere, hemisphere, pyramid, capsule, conical frustum, or ellipsoid from its dimensions.",
  "category": "math",
  "subcategory": "geometry",
  "url": "https://www.acalculator.org/math/volume-calculator",
  "markdown": "https://www.acalculator.org/math/volume-calculator.md",
  "kind": "function",
  "method": "V = the shape’s standard volume formula, for example V = πr²h for a cylinder and V = 4/3 πr³ for a sphere.",
  "assumptions": [
    "Every length is more than 0 and all are in the same unit; the volume is in that unit cubed.",
    "Cones, pyramids, and frustums are right (the top is straight above the centre of the base).",
    "A capsule is a cylinder of height h with a hemisphere of the same radius on each end."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "shape": {
        "title": "Shape",
        "description": "The solid to find the volume of.",
        "type": "string",
        "enum": [
          "cube",
          "box",
          "cylinder",
          "cone",
          "sphere",
          "hemisphere",
          "pyramid",
          "capsule",
          "frustum",
          "ellipsoid"
        ]
      },
      "s": {
        "title": "Side (s)",
        "description": "The length of each edge of the cube.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "l": {
        "title": "Length (l)",
        "description": "The length of the base.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "w": {
        "title": "Width (w)",
        "description": "The width of the base.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "h": {
        "title": "Height (h)",
        "description": "The height, at right angles to the base; for a capsule, the length of its straight middle part.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "r": {
        "title": "Radius (r)",
        "description": "The radius of the circle (for a frustum, of one end).",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "r2": {
        "title": "Second radius (r₂)",
        "description": "The radius of the other end of the frustum.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "a": {
        "title": "Semi-axis a",
        "description": "Half the length of the first axis of the ellipsoid.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "b": {
        "title": "Semi-axis b",
        "description": "Half the length of the second axis of the ellipsoid.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "c": {
        "title": "Semi-axis c",
        "description": "Half the length of the third axis of the ellipsoid.",
        "type": "number",
        "exclusiveMinimum": 0
      }
    }
  },
  "outputs": {
    "volume": {
      "label": "Volume",
      "description": "The space inside the solid, in the cube of the length unit (cm gives cm³).",
      "format": "number"
    },
    "formula": {
      "label": "Formula",
      "description": "The volume formula for this shape.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "shape": "box",
      "s": 5,
      "l": 10,
      "w": 6,
      "h": 4,
      "r": 3,
      "r2": 2,
      "a": 3,
      "b": 2,
      "c": 1
    },
    "outputs": {
      "volume": 240,
      "formula": "V = l × w × h"
    },
    "text": "Rectangular box volume: 240 cubic units."
  },
  "examples": [
    {
      "given": {
        "shape": "box",
        "l": 10,
        "w": 6,
        "h": 4
      },
      "expect": {
        "volume": 240,
        "formula": "V = l × w × h"
      },
      "source": "hand calculation in content.mdx: 10 × 6 × 4 = 240"
    },
    {
      "given": {
        "shape": "cube",
        "s": 5
      },
      "expect": {
        "volume": 125
      },
      "source": "hand calculation in content.mdx: 5³ = 125"
    },
    {
      "given": {
        "shape": "cylinder",
        "r": 3,
        "h": 4
      },
      "expect": {
        "volume": 113.09733552923255
      },
      "source": "hand calculation in content.mdx: π × 9 × 4 = 36π; Python 3: math.pi * 3**2 * 4 = 113.09733552923255"
    },
    {
      "given": {
        "shape": "cone",
        "r": 3,
        "h": 4
      },
      "expect": {
        "volume": 37.69911184307752
      },
      "source": "hand calculation in content.mdx: 36π ÷ 3 = 12π; Python 3: math.pi * 9 * 4 / 3 = 37.69911184307752"
    },
    {
      "given": {
        "shape": "sphere",
        "r": 3
      },
      "expect": {
        "volume": 113.09733552923254
      },
      "source": "hand calculation in content.mdx: 4/3 × π × 27 = 36π; Python 3: 4/3 * math.pi * 3**3 = 113.09733552923254"
    },
    {
      "given": {
        "shape": "hemisphere",
        "r": 3
      },
      "expect": {
        "volume": 56.54866776461627
      },
      "source": "hand calculation in content.mdx: half of 36π = 18π; Python 3: 4/3 * math.pi * 3**3 / 2 = 56.54866776461627"
    },
    {
      "given": {
        "shape": "pyramid",
        "l": 10,
        "w": 6,
        "h": 4
      },
      "expect": {
        "volume": 80
      },
      "source": "hand calculation in content.mdx: 240 ÷ 3 = 80"
    },
    {
      "given": {
        "shape": "capsule",
        "r": 3,
        "h": 4
      },
      "expect": {
        "volume": 226.19467105846508
      },
      "source": "hand calculation in content.mdx: 36π + 36π = 72π; Python 3: math.pi * 9 * 4 + 4/3 * math.pi * 27 = 226.19467105846508"
    },
    {
      "given": {
        "shape": "frustum",
        "r": 3,
        "r2": 2,
        "h": 4
      },
      "expect": {
        "volume": 79.58701389094142
      },
      "source": "hand calculation in content.mdx: π × 4 × (9 + 6 + 4) ÷ 3 = 76π/3; Python 3: math.pi * 4 * 19 / 3 = 79.58701389094142"
    },
    {
      "given": {
        "shape": "ellipsoid",
        "a": 3,
        "b": 2,
        "c": 1
      },
      "expect": {
        "volume": 25.132741228718345
      },
      "source": "hand calculation in content.mdx: 4/3 × π × 6 = 8π; Python 3: 4/3 * math.pi * 3 * 2 * 1 = 25.132741228718345"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, section 9.6 Solve Geometry Applications: Volume and Surface Area: https://openstax.org/books/prealgebra-2e/pages/9-6-solve-geometry-applications-volume-and-surface-area",
    "Zwillinger (ed.), CRC Standard Mathematical Tables and Formulae, 33rd ed., CRC Press, 2018, section 4 (geometry of solids)"
  ],
  "related": [
    "area"
  ],
  "changelog": []
}
