{
  "id": "angle-between-vectors",
  "version": "44c6f24106f2",
  "status": "published",
  "name": "Angle Between Two Vectors Calculator",
  "question": "Find the angle between two vectors",
  "summary": "Finds the angle between two vectors in 2D, 3D or up to 10 dimensions, in degrees and radians, with the dot product, the lengths, cos θ, and whether they are perpendicular or parallel.",
  "category": "math",
  "subcategory": "linear-algebra",
  "url": "https://www.acalculator.org/math/angle-between-vectors-calculator",
  "markdown": "https://www.acalculator.org/math/angle-between-vectors-calculator.md",
  "kind": "function",
  "method": "cos θ = a·b ÷ (‖a‖‖b‖); θ = 2·atan2(‖â − b̂‖, ‖â + b̂‖) with â = a ÷ ‖a‖ and b̂ = b ÷ ‖b‖ (the same angle, precise near 0° and 180°).",
  "assumptions": [
    "The angle is the smaller one between the two directions, from 0° to 180°.",
    "Both vectors have the same number of components (2 to 10) and neither is the zero vector.",
    "Perpendicular (a·b = 0) and parallel ((a·b)² = ‖a‖²‖b‖²) are decided exactly from the numbers as typed."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "a": {
        "title": "Vector a",
        "description": "The first vector’s components, such as 1, 1, 1.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "b": {
        "title": "Vector b",
        "description": "The second vector’s components, as many as a has.",
        "type": "array",
        "items": {
          "type": "number"
        }
      }
    }
  },
  "outputs": {
    "degrees": {
      "label": "Angle θ",
      "description": "The angle between the two vectors in degrees, from 0° to 180°.",
      "format": "number"
    },
    "radians": {
      "label": "Angle in radians",
      "description": "The same angle in radians, from 0 to π.",
      "format": "number"
    },
    "cos": {
      "label": "cos θ",
      "description": "The dot product divided by the product of the lengths, from −1 to 1.",
      "format": "number"
    },
    "dot": {
      "label": "Dot product a·b",
      "description": "The sum of the products of matching components.",
      "format": "number"
    },
    "lengthA": {
      "label": "Length ‖a‖",
      "description": "The magnitude of vector a.",
      "format": "number"
    },
    "lengthB": {
      "label": "Length ‖b‖",
      "description": "The magnitude of vector b.",
      "format": "number"
    },
    "vectors": {
      "label": "Vectors",
      "description": "The two vectors as typed, each component to 6 significant digits.",
      "format": "text"
    },
    "kind": {
      "label": "The vectors are",
      "description": "Perpendicular (a·b = 0), parallel, opposite, or at an acute or obtuse angle.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "a": [
        1,
        1,
        1
      ],
      "b": [
        2,
        -1,
        -3
      ]
    },
    "outputs": {
      "degrees": 107.9752838098089,
      "radians": 1.884524213256492,
      "cos": -0.3086066999241839,
      "dot": -2,
      "lengthA": 1.7320508075688772,
      "lengthB": 3.741657386773941,
      "vectors": "⟨1, 1, 1⟩ and ⟨2, −1, −3⟩",
      "kind": "at an obtuse angle"
    },
    "text": "The angle between ⟨1, 1, 1⟩ and ⟨2, −1, −3⟩ is 107.975284°."
  },
  "examples": [
    {
      "given": {
        "a": [
          1,
          1,
          1
        ],
        "b": [
          2,
          -1,
          -3
        ]
      },
      "expect": {
        "degrees": 107.97528380980889,
        "radians": 1.8845242132564919,
        "cos": -0.3086066999241838,
        "dot": -2,
        "kind": "at an obtuse angle"
      },
      "source": "OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product; Python 3: math.degrees(math.acos(-2 / math.sqrt(42)))",
      "tolerance": 1e-12
    },
    {
      "given": {
        "a": [
          2,
          5,
          6
        ],
        "b": [
          -2,
          -4,
          4
        ]
      },
      "expect": {
        "degrees": 90,
        "radians": 1.5707963267948966,
        "dot": 0,
        "kind": "perpendicular (orthogonal)"
      },
      "source": "OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product"
    },
    {
      "given": {
        "a": [
          3,
          4
        ],
        "b": [
          4,
          3
        ]
      },
      "expect": {
        "degrees": 16.260204708311967,
        "dot": 24,
        "cos": 0.96,
        "lengthA": 5,
        "lengthB": 5
      },
      "source": "hand calculation in content.mdx: cos θ = 24 ÷ 25 = 0.96, θ = arccos 0.96 = 16.2602°; OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product",
      "tolerance": 1e-12
    },
    {
      "given": {
        "a": [
          1,
          2
        ],
        "b": [
          -2,
          -4
        ]
      },
      "expect": {
        "degrees": 180,
        "kind": "parallel, pointing opposite ways"
      },
      "source": "hand calculation in content.mdx: b = −2a, so cos θ = −1; OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: i + j + k and 2i − j − 3k make θ = arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product"
    }
  ],
  "sources": [
    "OpenStax, Calculus Volume 3, §2.3 The Dot Product (cos θ = u·v ÷ (‖u‖‖v‖); Example 2.23: the angle between i + j + k and 2i − j − 3k is arccos(−2 ÷ √42), and ⟨2, 5, 6⟩ and ⟨−2, −4, 4⟩ are orthogonal). https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product (retrieved 2026-10-02)"
  ],
  "related": [
    "dot-product",
    "cross-product",
    "unit-vector"
  ],
  "changelog": []
}
