{
  "id": "complex-number",
  "version": "ec7a701226a7",
  "status": "published",
  "name": "Complex Number Calculator",
  "question": "What is my complex number answer?",
  "summary": "Adds, subtracts, multiplies and divides two complex numbers a + bi exactly, and gives the result’s modulus, argument, conjugate and polar form.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/complex-number-calculator",
  "markdown": "https://www.acalculator.org/math/complex-number-calculator.md",
  "kind": "function",
  "method": "(a + bi) ± (c + di) = (a ± c) + (b ± d)i; (a + bi)(c + di) = (ac − bd) + (ad + bc)i; (a + bi) ÷ (c + di) = ((ac + bd) + (bc − ad)i) ÷ (c² + d²).",
  "assumptions": [
    "Each part is read as the exact decimal you typed, so +, −, × and ÷ have no rounding error.",
    "The argument is the principal value, from −180° to 180°.",
    "Each part is from −10¹² to 10¹²."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "a": {
        "title": "Real part of z₁ (a)",
        "description": "The real part a of the first number z₁ = a + bi.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "b": {
        "title": "Imaginary part of z₁ (b)",
        "description": "The imaginary part b of the first number z₁ = a + bi.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "op": {
        "title": "Operation",
        "description": "What to do with z₁ and z₂.",
        "type": "string",
        "enum": [
          "add",
          "sub",
          "mul",
          "div"
        ]
      },
      "c": {
        "title": "Real part of z₂ (c)",
        "description": "The real part c of the second number z₂ = c + di.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "d": {
        "title": "Imaginary part of z₂ (d)",
        "description": "The imaginary part d of the second number z₂ = c + di.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      }
    }
  },
  "outputs": {
    "result": {
      "label": "Result",
      "description": "The answer in the form x + yi, to 10 significant figures.",
      "format": "text"
    },
    "exact": {
      "label": "Exact result",
      "description": "The answer with exact decimals, or fractions in lowest terms where a decimal does not end.",
      "format": "text"
    },
    "re": {
      "label": "Real part x",
      "description": "The real part of the result.",
      "format": "number"
    },
    "im": {
      "label": "Imaginary part y",
      "description": "The imaginary part of the result (the number in front of i).",
      "format": "number"
    },
    "modulus": {
      "label": "Modulus |z|",
      "description": "The distance of the result from 0: √(x² + y²).",
      "format": "number"
    },
    "argument": {
      "label": "Argument θ (degrees)",
      "description": "The angle of the result from the positive real axis, from −180° to 180°.",
      "format": "number"
    },
    "radians": {
      "label": "Argument θ (radians)",
      "description": "The same angle in radians, from −π to π.",
      "format": "number"
    },
    "polar": {
      "label": "Polar form",
      "description": "r(cos θ + i sin θ), with r the modulus and θ the argument in degrees, to 6 significant figures.",
      "format": "text"
    },
    "conjugate": {
      "label": "Conjugate",
      "description": "The result with the sign of its imaginary part flipped: x − yi.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "a": 4,
      "b": 3,
      "op": "mul",
      "c": 2,
      "d": -5
    },
    "outputs": {
      "result": "23 − 14i",
      "exact": "23 − 14i",
      "re": 23,
      "im": -14,
      "modulus": 26.92582403567252,
      "argument": -31.328692867804172,
      "radians": -0.5467888408892474,
      "polar": "26.9258(cos −31.3287° + i sin −31.3287°)",
      "conjugate": "23 + 14i"
    },
    "text": "The result is 23 − 14i."
  },
  "examples": [
    {
      "given": {
        "a": 4,
        "b": 3,
        "op": "mul",
        "c": 2,
        "d": -5
      },
      "expect": {
        "result": "23 − 14i",
        "re": 23,
        "im": -14,
        "conjugate": "23 + 14i",
        "modulus": 26.92582403567252
      },
      "source": "OpenStax, Algebra and Trigonometry 2e, §2.4 Complex Numbers (https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-4-complex-numbers, retrieved 2026-10-02): (4 + 3i)(2 − 5i) = 23 − 14i; hand calculation in content.mdx"
    },
    {
      "given": {
        "a": 2,
        "b": 5,
        "op": "div",
        "c": 4,
        "d": -1
      },
      "expect": {
        "exact": "3/17 + 22/17i",
        "result": "0.1764705882 + 1.294117647i",
        "re": 0.176470588235294,
        "im": 1.29411764705882
      },
      "source": "OpenStax, Algebra and Trigonometry 2e, §2.4 Complex Numbers (https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-4-complex-numbers, retrieved 2026-10-02): (2 + 5i) ÷ (4 − i) = 3/17 + 22i/17; hand calculation in content.mdx"
    },
    {
      "given": {
        "a": 3,
        "b": -4,
        "op": "add",
        "c": 2,
        "d": 5
      },
      "expect": {
        "result": "5 + i",
        "re": 5,
        "im": 1
      },
      "source": "OpenStax, Algebra and Trigonometry 2e, §2.4 Complex Numbers (https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-4-complex-numbers, retrieved 2026-10-02): (3 − 4i) + (2 + 5i) = 5 + i"
    },
    {
      "given": {
        "a": 0.1,
        "b": 0.2,
        "op": "sub",
        "c": 0.3,
        "d": 0.2
      },
      "expect": {
        "result": "−0.2",
        "exact": "−0.2",
        "re": -0.2,
        "im": 0,
        "argument": 180
      },
      "source": "hand calculation in content.mdx: (0.1 − 0.3) + (0.2 − 0.2)i = −0.2; OpenStax, Algebra and Trigonometry 2e, §2.4 Complex Numbers (https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-4-complex-numbers, retrieved 2026-10-02)"
    },
    {
      "given": {
        "a": 1,
        "b": 1,
        "op": "mul",
        "c": 1,
        "d": 0
      },
      "expect": {
        "modulus": 1.4142135623730951,
        "argument": 45,
        "polar": "1.41421(cos 45° + i sin 45°)"
      },
      "source": "hand calculation in content.mdx: |1 + i| = √2, θ = 45°; OpenStax, Algebra and Trigonometry 2e, §10.5 Polar Form of Complex Numbers (https://openstax.org/books/algebra-and-trigonometry-2e/pages/10-5-polar-form-of-complex-numbers, retrieved 2026-10-02)"
    }
  ],
  "sources": [
    "OpenStax, Algebra and Trigonometry 2e, §2.4 Complex Numbers (adding, subtracting, multiplying and dividing; (4 + 3i)(2 − 5i) = 23 − 14i; (2 + 5i) ÷ (4 − i) = 3/17 + 22i/17), CC BY 4.0, retrieved 2026-10-02. https://openstax.org/books/algebra-and-trigonometry-2e/pages/2-4-complex-numbers",
    "OpenStax, Algebra and Trigonometry 2e, §10.5 Polar Form of Complex Numbers (|z| = √(x² + y²), z = r(cos θ + i sin θ)), CC BY 4.0, retrieved 2026-10-02. https://openstax.org/books/algebra-and-trigonometry-2e/pages/10-5-polar-form-of-complex-numbers"
  ],
  "related": [
    "polynomial",
    "quadratic-formula",
    "angle",
    "square-root"
  ],
  "changelog": []
}
