{
  "id": "percentage-difference",
  "version": "5adba1d752b3",
  "status": "published",
  "name": "Percentage Difference Calculator",
  "question": "What is the percent difference?",
  "summary": "Finds the percentage difference between two positive numbers, compared with their average, or a number from the other and the difference.",
  "category": "math",
  "subcategory": "arithmetic",
  "url": "https://www.acalculator.org/math/percentage-difference-calculator",
  "markdown": "https://www.acalculator.org/math/percentage-difference-calculator.md",
  "kind": "formulas",
  "method": "d = |A − B| ÷ ((A + B) ÷ 2) × 100: the gap between A and B as a percent of their average.",
  "assumptions": [
    "Both values are more than 0, so the difference is from 0% up to (but not including) 200%.",
    "The order of A and B does not matter.",
    "Finding a value from the other value and the difference gives two answers, one above and one below the other value: both are shown."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "a": {
        "title": "Value A",
        "description": "The first value, more than 0.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "b": {
        "title": "Value B",
        "description": "The second value, more than 0.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "diff": {
        "title": "Percentage difference",
        "description": "The gap between A and B as a percent of their average: 0 up to (but not including) 200.",
        "type": "number",
        "x-unit": "percent",
        "minimum": 0,
        "exclusiveMaximum": 200
      }
    }
  },
  "solve": {
    "fillAny": 2,
    "variables": [
      "a",
      "b",
      "diff"
    ],
    "inputsOnly": []
  },
  "outputs": {
    "a": {
      "label": "Value A",
      "description": "The first value, more than 0.",
      "format": "number"
    },
    "b": {
      "label": "Value B",
      "description": "The second value, more than 0.",
      "format": "number"
    },
    "diff": {
      "label": "Percentage difference",
      "description": "The gap between A and B as a percent of their average: 0 up to (but not including) 200.",
      "format": "percent"
    },
    "difference": {
      "label": "Difference",
      "description": "The gap between the two values: |A − B|.",
      "format": "number"
    },
    "average": {
      "label": "Average",
      "description": "The mean of the two values: (A + B) ÷ 2.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "a": 20,
      "b": 30
    },
    "outputs": {
      "diff": 40,
      "difference": 10,
      "average": 25
    },
    "text": "The percentage difference between 20 and 30 is 40%."
  },
  "examples": [
    {
      "given": {
        "a": 20,
        "b": 30
      },
      "expect": {
        "diff": 40,
        "difference": 10,
        "average": 25
      },
      "source": "hand calculation in content.mdx: |20 − 30| ÷ 25 × 100 = 40%"
    },
    {
      "given": {
        "a": 100,
        "b": 125
      },
      "expect": {
        "diff": 22.22222222222222,
        "difference": 25,
        "average": 112.5
      },
      "source": "hand calculation in content.mdx: 25 ÷ 112.5 × 100 = 22.22%; Python 3: 25 / 112.5 * 100 = 22.22222222222222"
    },
    {
      "given": {
        "a": 125,
        "b": 100
      },
      "expect": {
        "diff": 22.22222222222222
      },
      "source": "hand calculation in content.mdx: the same two numbers in the other order give the same difference"
    },
    {
      "given": {
        "a": 20,
        "diff": 40
      },
      "expect": {
        "b": 30
      },
      "source": "hand calculation in content.mdx: B = 20 × 2.4 ÷ 1.6 = 30, or 20 × 1.6 ÷ 2.4 = 13.333…"
    },
    {
      "given": {
        "a": 7.5,
        "b": 7.5
      },
      "expect": {
        "diff": 0,
        "difference": 0
      },
      "source": "hand calculation in content.mdx: equal values have no difference"
    }
  ],
  "sources": [
    "Wikipedia, Relative change (the percentage difference measured against the arithmetic mean of the two values): https://en.wikipedia.org/wiki/Relative_change"
  ],
  "related": [
    "percentage-change",
    "percentage",
    "percentage-increase"
  ],
  "changelog": []
}
