{
  "id": "unit-vector",
  "version": "c9635cbdfc0f",
  "status": "published",
  "name": "Unit Vector Calculator",
  "question": "What is the unit vector?",
  "summary": "Finds the unit vector in the direction of a vector, from its components or from a start and an end point, in 2D, 3D or up to 10 dimensions, with the exact form and the magnitude.",
  "category": "math",
  "subcategory": "linear-algebra",
  "url": "https://www.acalculator.org/math/unit-vector-calculator",
  "markdown": "https://www.acalculator.org/math/unit-vector-calculator.md",
  "kind": "function",
  "method": "û = v ÷ ‖v‖ with ‖v‖ = √(v₁² + … + vₙ²); from P to Q, v = Q − P.",
  "assumptions": [
    "Euclidean length; from two points, v = Q − P (end minus start), coordinate by coordinate.",
    "1 to 10 components. The zero vector has no unit vector.",
    "The exact form is shown when the squared length, after dividing by the largest component, is p/q with p × q at most 10¹²."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "mode": {
        "title": "I know",
        "description": "The vector’s components, or the point where it starts and the point where it ends.",
        "type": "string",
        "enum": [
          "components",
          "points"
        ]
      },
      "v": {
        "title": "Components of v",
        "description": "The vector’s components, such as 3, 4 or 2, −1, 2.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "p": {
        "title": "Start point P",
        "description": "The coordinates of the start (tail) of the vector.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "q": {
        "title": "End point Q",
        "description": "The coordinates of the end (head) of the vector, as many as P.",
        "type": "array",
        "items": {
          "type": "number"
        }
      }
    }
  },
  "outputs": {
    "unit": {
      "label": "Unit vector û = v ÷ ‖v‖",
      "description": "The vector of length 1 in the same direction, each component to 6 significant digits.",
      "format": "text"
    },
    "exact": {
      "label": "Exact unit vector",
      "description": "The unit vector with exact fractions and square roots, such as ⟨√5/5, 2√5/5⟩.",
      "format": "text"
    },
    "magnitude": {
      "label": "Magnitude ‖v‖",
      "description": "The length of v: the square root of the sum of its squared components.",
      "format": "number"
    },
    "vector": {
      "label": "Vector v",
      "description": "The vector’s components; from two points, Q − P.",
      "format": "text"
    },
    "angle": {
      "label": "Direction angle",
      "description": "For a 2D vector: the angle from the positive x axis, counterclockwise, from 0° up to 360°.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "mode": "components",
      "v": [
        3,
        4
      ],
      "p": [
        1,
        2
      ],
      "q": [
        4,
        6
      ]
    },
    "outputs": {
      "unit": "⟨0.6, 0.8⟩",
      "exact": "⟨3/5, 4/5⟩",
      "magnitude": 5,
      "vector": "⟨3, 4⟩",
      "angle": 53.13010235415595
    },
    "text": "The unit vector of ⟨3, 4⟩ is ⟨0.6, 0.8⟩."
  },
  "examples": [
    {
      "given": {
        "mode": "components",
        "v": [
          1,
          2
        ]
      },
      "expect": {
        "unit": "⟨0.447214, 0.894427⟩",
        "exact": "⟨√5/5, 2√5/5⟩",
        "magnitude": 2.23606797749979
      },
      "source": "OpenStax, Calculus Volume 3, §2.1 Vectors in the Plane (unit vector v ÷ ‖v‖; Example 2.7: v = ⟨1, 2⟩ has unit vector ⟨1/√5, 2/√5⟩). https://openstax.org/books/calculus-volume-3/pages/2-1-vectors-in-the-plane; hand calculation in content.mdx: ‖v‖ = √5, 1/√5 = √5/5"
    },
    {
      "given": {
        "mode": "components",
        "v": [
          3,
          4
        ]
      },
      "expect": {
        "unit": "⟨0.6, 0.8⟩",
        "exact": "⟨3/5, 4/5⟩",
        "magnitude": 5,
        "angle": 53.13010235415598
      },
      "source": "hand calculation in content.mdx: ‖v‖ = √(9 + 16) = 5; OpenStax, Calculus Volume 3, §2.1 Vectors in the Plane (unit vector v ÷ ‖v‖; Example 2.7: v = ⟨1, 2⟩ has unit vector ⟨1/√5, 2/√5⟩). https://openstax.org/books/calculus-volume-3/pages/2-1-vectors-in-the-plane"
    },
    {
      "given": {
        "mode": "components",
        "v": [
          2,
          -1,
          2
        ]
      },
      "expect": {
        "unit": "⟨0.666667, −0.333333, 0.666667⟩",
        "exact": "⟨2/3, −1/3, 2/3⟩",
        "magnitude": 3
      },
      "source": "hand calculation in content.mdx: ‖v‖ = √(4 + 1 + 4) = 3; OpenStax, Calculus Volume 3, §2.2 Vectors in Three Dimensions (‖v‖ = √(x² + y² + z²)). https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions"
    },
    {
      "given": {
        "mode": "points",
        "p": [
          1,
          2
        ],
        "q": [
          4,
          6
        ]
      },
      "expect": {
        "vector": "⟨3, 4⟩",
        "unit": "⟨0.6, 0.8⟩",
        "magnitude": 5
      },
      "source": "hand calculation in content.mdx: Q − P = ⟨3, 4⟩; OpenStax, Calculus Volume 3, §2.1 Vectors in the Plane (unit vector v ÷ ‖v‖; Example 2.7: v = ⟨1, 2⟩ has unit vector ⟨1/√5, 2/√5⟩). https://openstax.org/books/calculus-volume-3/pages/2-1-vectors-in-the-plane"
    }
  ],
  "sources": [
    "OpenStax, Calculus Volume 3, §2.1 Vectors in the Plane (‖v‖ = √(x² + y²); a unit vector is v ÷ ‖v‖; Example 2.7: v = ⟨1, 2⟩ has unit vector ⟨1/√5, 2/√5⟩). https://openstax.org/books/calculus-volume-3/pages/2-1-vectors-in-the-plane (retrieved 2026-10-02)",
    "OpenStax, Calculus Volume 3, §2.2 Vectors in Three Dimensions (‖v‖ = √(x² + y² + z²)). https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions (retrieved 2026-10-02)"
  ],
  "related": [
    "angle-between-vectors",
    "cross-product",
    "dot-product",
    "distance-formula"
  ],
  "changelog": []
}
