Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Vector Calculator (Sum, Difference, Magnitude, Dot Product and Angle)

Choose 2D or 3D, then enter the components of the two vectors a and b and the coefficients k and l. The formula below is linked to the input fields, so you can also edit the components right inside it.

Enter numbers only. Decimals, negative numbers and fractions such as 3/4 are OK. A blank component is treated as 0, and a blank coefficient k or l as 1.
Result and figure
Enter the components of the vectors in the fields on the left and press "Calculate". The result and a figure will appear here.

What you can do on this page

  • Just enter the components of the 2D or 3D vectors \(\vec{a}\) and \(\vec{b}\) to get the sum \(\vec{a}+\vec{b}\), the difference \(\vec{a}-\vec{b}\) and the linear combination \(k\vec{a}+l\vec{b}\) at once
  • The magnitude \(|\vec{a}|\) is shown both as an exact value with the radical simplified, such as \(\sqrt{20}=2\sqrt{5}\), and as a decimal
  • You also get the dot product \(\vec{a}\cdot\vec{b}\), the angle between the vectors \(\theta\) (in degrees and radians, with exact values for special angles such as \(45^{\circ}\)), the unit vectors and a perpendicular/parallel check
  • The calculator shows the vectors as columns, just as you would write them by hand, and you can edit the components right inside them
  • Components and coefficients can be decimals, negative numbers or fractions such as 3/4
  • A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
A vector with magnitude 0 (the zero vector) has no direction, so there is no angle between it and another vector and no unit vector. This calculator does not calculate when either \(\vec{a}\) or \(\vec{b}\) is the zero vector.

What is this calculation used for?

Combining forces (physics, architecture and engineering)

When several forces act on an object, their combined effect is the sum of vectors. Splitting the tension of a rope pulled at an angle into horizontal and vertical components and adding them up is exactly this calculation.
In designing bridges and buildings, forces such as the structure's own weight, wind and earthquakes are combined as vectors to find the direction and size of the force on each part. Adding only the sizes and ignoring the directions would lead to a dangerous design, so working with vectors is essential.

3D games and computer graphics

In a game, a character's movement is calculated as "position vector + velocity vector", and the direction of the camera and of a flying projectile are all vectors. Unit vectors are used every frame whenever only a direction is needed (direction of travel, direction of view).
The dot product is also the key to lighting. The larger the dot product of the direction a surface faces (its normal vector) and the direction of the light, the more directly the light hits it, and that value sets the brightness on screen. If the dot product is 0 or less, the light does not reach the surface.

The course of a plane or ship (combining velocities)

A plane's actual path is the sum of its velocity vector in the direction the nose points and the wind's velocity vector. To fly due east with a wind from the north, the nose has to point partly into the wind, and how far to turn it is found by subtracting vectors.
At sea, ships add and subtract the vector of the current to decide which way to steer. Being able to handle speed and time component by component is a strength of vectors.

Measuring how similar texts or products are (AI and recommendations)

Search engines and generative AI turn texts into long lists of numbers, that is, vectors. Whether two texts are similar is judged by the angle between their vectors: the closer \(\cos\theta\) is to 1, the more similar they are (cosine similarity).
Online stores' "customers who viewed this also liked" features also turn purchase histories into vectors and look for people and products with small angles between them. Here the direction (the pattern of tastes) matters more than the length (such as how much someone spends in total), which is why measuring by angle works well.

Devices that measure position and tilt (drones, GPS navigation and smartphones)

Drones and smartphones work out how much they are tilted from the angle between the gravity vector measured by the accelerometer and a reference direction vector of the device. The screen switching between portrait and landscape is a result of this calculation.
In GPS navigation and surveying, the difference between the coordinates of two points is treated as a vector: its magnitude is the distance and its direction is the bearing. In 3D, just add the height component and the same formulas work as is.

Formulas and figures

Magnitude of a vector (from its components)
Figure
Standard notation (the usual math form)
\(|\vec{a}|\) \(=\) \(\sqrt{a_1^{2}+a_2^{2}}\)
In words (symbols replaced with words)
② \(|\vec{a}|\): magnitude of vector \(\vec{a}\) (length of the arrow) \(=\) ① square root of the sum of the squared components, \(a_1^{2}+a_2^{2}\)
The formula in words
① When \(\vec{a}=(a_1,\ a_2)\) in component form, take the square root of \(a_1^{2}+a_2^{2}\), the \(x\) component squared plus the \(y\) component squared ,
② and you get the \(|\vec{a}|\): magnitude of vector \(\vec{a}\) (length of the arrow)
Quick example
The magnitude of \(\vec{a}=(4,\ 2)\) (the length of an arrow that goes 4 right and 2 up) is
magnitude of \(\vec{a}=(4,\ 2)\) \(=\) square root of \(4^2+2^2=20\)
\(|\vec{a}| = \sqrt{4^{2}+2^{2}} = \sqrt{20} = 2\sqrt{5} \approx 4.4721\)
Key idea
This formula is the Pythagorean theorem itself. The components \(a_1\) and \(a_2\) split the arrow into "how far right" and "how far up", so the arrow is the hypotenuse of a right triangle whose two legs are \(a_1\) and \(a_2\). That is why its length is \(\sqrt{a_1^{2}+a_2^{2}}\). For a 3D vector \(\vec{a}=(a_1,\ a_2,\ a_3)\), add the square of the height component too: \(|\vec{a}|=\sqrt{a_1^{2}+a_2^{2}+a_3^{2}}\). There is just one more term; the steps are the same. Always write the radical in the answer in simplest form (for example, \(\sqrt{20}=2\sqrt{5}\)). This calculator also shows both the simplified exact value and a decimal.
Sum and difference of vectors (add or subtract component by component)
Figure
Standard notation (the usual math form)
\(\vec{a}+\vec{b}\) \(=\) \((a_1+b_1,\ a_2+b_2)\)
\(\vec{a}-\vec{b}\) \(=\) \((a_1-b_1,\ a_2-b_2)\)
In words (symbols replaced with words)
② sum of \(\vec{a}\) and \(\vec{b}\) \(=\) ① vector made by adding the \(x\) components and the \(y\) components
④ difference of \(\vec{a}\) and \(\vec{b}\) \(=\) ③ vector made by subtracting the \(x\) components and the \(y\) components
The formula in words
① The vector made by adding the \(x\) components and the \(y\) components, \((a_1+b_1,\ a_2+b_2)\) is the
② sum of \(\vec{a}\) and \(\vec{b}\), \(\vec{a}+\vec{b}\) , and the
③ vector made by subtracting the \(x\) components and the \(y\) components, \((a_1-b_1,\ a_2-b_2)\) is the
④ difference of \(\vec{a}\) and \(\vec{b}\), \(\vec{a}-\vec{b}\)
Quick example
When \(\vec{a}=(4,\ 2)\) and \(\vec{b}=(-1,\ 2)\)
\(\vec{a}+\vec{b}\) \(=\) \((4+(-1),\ 2+2)\)
\(\vec{a}+\vec{b} = (4+(-1),\ 2+2) = (3,\ 4)\)
\(\vec{a}-\vec{b} = (4-(-1),\ 2-2) = (5,\ 0)\)
Key idea
In the figure, the sum \(\vec{a}+\vec{b}\) is the arrow you get by placing the start of \(\vec{b}\) at the end of \(\vec{a}\), going from the very first start to the very last end. It is the diagonal of the parallelogram with sides \(\vec{a}\) and \(\vec{b}\), which is why this is called the parallelogram law. The difference \(\vec{a}-\vec{b}\) is \(\vec{a}+(-\vec{b})\): reverse \(\vec{b}\), then add. In the figure, it is the arrow from the end of \(\vec{b}\) to the end of \(\vec{a}\). The direction is easy to get wrong, so remember: "from the end of the vector being subtracted (\(\vec{b}\)) to the end of the one it is subtracted from (\(\vec{a}\))". If you keep in mind that the arrow points toward \(\vec{a}\), you will not draw it backward. In 3D, there is just one more term that adds or subtracts the \(z\) components; the steps are the same.
Scalar multiple of a vector
Figure
Standard notation (the usual math form)
In words (symbols replaced with words)
\(k\vec{a}\) \(=\) \((ka_1,\ ka_2)\)
② \(k\) times \(\vec{a}\) \(=\) ① vector with each component multiplied by \(k\)
The formula in words
① The vector with each component multiplied by \(k\), \((ka_1,\ ka_2)\) is
② \(k\) times the vector \(\vec{a}\), \(k\vec{a}\)
Quick example
Doubling \(\vec{a}=(4,\ 2)\) (an arrow in the same direction, twice as long) gives
\(2\vec{a}\) \(=\) \((2 \times 4,\ 2 \times 2)\)
\(2\vec{a} = (2 \times 4,\ 2 \times 2) = (8,\ 4)\)
\(|2\vec{a}| = \sqrt{8^{2}+4^{2}} = \sqrt{80} = 4\sqrt{5} = 2 \times 2\sqrt{5} = 2|\vec{a}|\)
Key idea
A scalar multiple stretches or shrinks the arrow. If \(k>0\), the direction stays the same and the length becomes \(k\) times as long. If \(k<0\), the direction flips and the length becomes \(|k|\) times as long (\(k=-1\) gives the opposite vector \(-\vec{a}\)). The magnitude is \(|k\vec{a}|=|k|\,|\vec{a}|\). This calculator works in the form \(k\vec{a}+l\vec{b}\). With \(k=1,\ l=1\) you get the sum, and with \(k=1,\ l=-1\) the difference, so just by changing the coefficients you can also calculate expressions such as \(2\vec{a}-3\vec{b}\). With \(k=0\), you get the zero vector \(\vec{0}\), whose components are all 0. The zero vector has length 0 and no direction.
Dot product (a calculation that turns two vectors into a number)
Figure
Standard notation (the usual math form)
\(\vec{a}\cdot\vec{b}\) \(=\) \(|\vec{a}|\) \(\times\) \(|\vec{b}|\) \(\times\) \(\cos\theta\)
\(\vec{a}\cdot\vec{b}\) \(=\) \(a_1b_1+a_2b_2\)
In words (symbols replaced with words)
④ dot product of \(\vec{a}\) and \(\vec{b}\) \(=\) ① magnitude of \(\vec{a}\) \(\times\) ② magnitude of \(\vec{b}\) \(\times\) ③ \(\cos\theta\): cosine of the angle \(\theta\)
⑥ dot product of \(\vec{a}\) and \(\vec{b}\) \(=\) ⑤ product of the \(x\) components plus product of the \(y\) components
The formula in words
① Multiply the magnitude of \(\vec{a}\), \(|\vec{a}|\) , the
② magnitude of \(\vec{b}\), \(|\vec{b}|\) and the
③ \(\cos\theta\): cosine of the angle \(\theta\) to get the
④ dot product \(\vec{a}\cdot\vec{b}\) . In components, the
⑤ product of the \(x\) components plus product of the \(y\) components, \(a_1b_1+a_2b_2\) gives the same value, so it also gives the
⑥ dot product \(\vec{a}\cdot\vec{b}\)
Quick example
The dot product of \(\vec{a}=(4,\ 2)\) and \(\vec{b}=(-1,\ 2)\) is
dot product \(\vec{a}\cdot\vec{b}\) \(=\) \(4 \times (-1) + 2 \times 2\)
\(\vec{a}\cdot\vec{b} = 4 \times (-1) + 2 \times 2 = -4 + 4 = 0\)
Key idea
The answer of a dot product is not a vector but just a number (a scalar). The name sounds like multiplication, but think of it as a special calculation that turns two arrows into one number. Always write it with a centered dot; \(\vec{a}\times\vec{b}\) is a different calculation (the cross product). In the figure, it is "the length of the shadow of \(\vec{b}\) cast straight down onto the direction of \(\vec{a}\) (the projection), \(|\vec{b}|\cos\theta\), times \(|\vec{a}|\)". So the more the two directions line up, the larger the dot product. At a right angle the shadow has length 0, so the dot product is 0. When the directions are nearly opposite, the shadow points the other way, so the dot product is negative. Use the definition (magnitudes and angle) when you know the angle, and the component formula when you know the coordinates. In 3D, a term \(a_3b_3\) is added: \(\vec{a}\cdot\vec{b}=a_1b_1+a_2b_2+a_3b_3\).
Angle between two vectors
Figure
Standard notation (the usual math form)
\(\cos\theta\) \(=\) \(\dfrac{\vec{a}\cdot\vec{b}}{|\vec{a}|\,|\vec{b}|}\)
In words (symbols replaced with words)
② \(\cos\theta\): cosine of the angle \(\theta\) \(=\) ① \(\dfrac{\text{dot product }\vec{a}\cdot\vec{b}}{\text{product of the magnitudes }|\vec{a}|\,|\vec{b}|}\)
The formula in words
① Calculate \(\dfrac{\text{dot product }\vec{a}\cdot\vec{b}}{\text{product of the magnitudes }|\vec{a}|\,|\vec{b}|}\) to get the
② \(\cos\theta\): cosine of the angle \(\theta\) , and from it the angle \(\theta\)
Quick example
The angle between \(\vec{a}=(1,\ 1)\) and \(\vec{b}=(2,\ 0)\) (the dot product is \(1 \times 2 + 1 \times 0 = 2\), and the magnitudes are \(|\vec{a}|=\sqrt{2}\) and \(|\vec{b}|=2\)) is
\(\cos\theta\) \(=\) \(\dfrac{2}{\sqrt{2} \times 2}\)
\(\cos\theta = \dfrac{2}{\sqrt{2} \times 2} = \dfrac{1}{\sqrt{2}} = \dfrac{\sqrt{2}}{2}\)
\(\theta = 45^{\circ} = \dfrac{\pi}{4}\)
Key idea
This is just the definition of the dot product, \(\vec{a}\cdot\vec{b}=|\vec{a}||\vec{b}|\cos\theta\), solved for \(\cos\theta\). Note that what you get first is the value of \(\cos\theta\), not the angle itself. To get the angle from \(\cos\theta\), compare it with the values for special angles: \(\dfrac{\sqrt{2}}{2}\) is \(45^{\circ}\), \(\dfrac{1}{2}\) is \(60^{\circ}\), and \(0\) is \(90^{\circ}\). For other values, use the inverse cosine \(\cos^{-1}\) (arccos); this calculator shows the result as a decimal. By convention, the angle between two vectors is given in the range \(0^{\circ} \le \theta \le 180^{\circ}\). The sign of \(\cos\theta\) alone tells you the type of angle: positive is acute, 0 is a right angle, and negative is obtuse. If a radical is left in the denominator, rationalize it, as in \(\dfrac{1}{\sqrt{2}}=\dfrac{\sqrt{2}}{2}\).
Conditions for perpendicular and parallel vectors
Figure
Standard notation (the usual math form)
\(\vec{a}\perp\vec{b}\) \(\iff\) \(\vec{a}\cdot\vec{b}=0\)
\(\vec{a}\parallel\vec{b}\) \(\iff\) \(\vec{b}=k\vec{a}\)
In words (symbols replaced with words)
① \(\vec{a}\) and \(\vec{b}\) are perpendicular \(\iff\) ② the dot product is 0
③ \(\vec{a}\) and \(\vec{b}\) are parallel \(\iff\) ④ one is a scalar multiple of the other
The formula in words
① When neither \(\vec{a}\) nor \(\vec{b}\) is the zero vector, \(\vec{a}\) and \(\vec{b}\) meet at a right angle exactly when
② the dot product is 0, \(\vec{a}\cdot\vec{b}=0\) , and
③ \(\vec{a}\) and \(\vec{b}\) are parallel exactly when
④ \(\vec{b}=k\vec{a}\) for some real number \(k\)
Quick example
When \(\vec{a}=(4,\ 2)\) and \(\vec{b}=(-1,\ 2)\), the dot product is \(4 \times (-1) + 2 \times 2 = 0\), so
\(\vec{a}\) and \(\vec{b}\) are perpendicular \(\iff\) the dot product is \(0\)
\(\vec{a}\cdot\vec{b} = 4 \times (-1) + 2 \times 2 = 0 \quad \Rightarrow \quad \vec{a}\perp\vec{b}\)
\(\vec{c} = (8,\ 4) = 2\vec{a} \quad \Rightarrow \quad \vec{c}\parallel\vec{a}\)
Key idea
To check for perpendicular vectors, you do not need the angle; just check whether the dot product is 0. Since \(\cos 90^{\circ}=0\), the whole definition \(|\vec{a}||\vec{b}|\cos\theta\) becomes 0. It is a standard tool for showing that an angle is a right angle in geometry proofs. In the plane, the parallel condition \(\vec{b}=k\vec{a}\) written in components is \(a_1b_2-a_2b_1=0\). This is handy because you can check it without finding \(k\) (it says the same thing as the ratios of the components being equal, \(a_1:a_2=b_1:b_2\)). Both conditions assume that neither \(\vec{a}\) nor \(\vec{b}\) is the zero vector. The zero vector has a dot product of 0 with every vector, but since it has no direction, we do not call it perpendicular, and we do not ask whether it is parallel. That is why textbooks state the conditions with "when \(\vec{a} \neq \vec{0},\ \vec{b} \neq \vec{0}\)".
Unit vector (keeping only the direction)
Figure
Standard notation (the usual math form)
\(\dfrac{\vec{a}}{|\vec{a}|}\) \(=\) \(\left(\dfrac{a_1}{|\vec{a}|},\ \dfrac{a_2}{|\vec{a}|}\right)\)
In words (symbols replaced with words)
② vector with the same direction as \(\vec{a}\) and magnitude 1 \(=\) ① \(\dfrac{\text{original components }(a_1,\ a_2)}{\text{magnitude of the vector }|\vec{a}|}\)
The formula in words
① Divide each component by the magnitude, as in \(\dfrac{\text{original components }(a_1,\ a_2)}{\text{magnitude of the vector }|\vec{a}|}\) , to get the
② vector with the same direction as \(\vec{a}\) and magnitude 1 (the unit vector)
Quick example
The unit vector in the direction of \(\vec{a}=(4,\ 2)\) (with magnitude \(|\vec{a}|=2\sqrt{5}\)) is
unit vector in the direction of \(\vec{a}=(4,\ 2)\) \(=\) \(\dfrac{(4,\ 2)}{2\sqrt{5}}\)
\(\dfrac{\vec{a}}{|\vec{a}|} = \left(\dfrac{4}{2\sqrt{5}},\ \dfrac{2}{2\sqrt{5}}\right) = \left(\dfrac{2\sqrt{5}}{5},\ \dfrac{\sqrt{5}}{5}\right)\)
\(\sqrt{\left(\dfrac{2\sqrt{5}}{5}\right)^{2}+\left(\dfrac{\sqrt{5}}{5}\right)^{2}} = \sqrt{\dfrac{20}{25}+\dfrac{5}{25}} = \sqrt{\dfrac{25}{25}} = 1\)
Key idea
A unit vector is a vector that drops the length information and keeps only the direction. Dividing by the magnitude always gives length 1, because \(\left|\dfrac{\vec{a}}{|\vec{a}|}\right| = \dfrac{|\vec{a}|}{|\vec{a}|} = 1\), so you do not need to check the length again after dividing. With the direction alone, you can write "the point 5 units along the direction of \(\vec{a}\)" as "5 × the unit vector". It is a tool for cases where length does not matter and only direction does, such as the direction of travel, the direction of view or the direction a surface faces (the normal). Dividing the components by the magnitude puts a radical in the denominator, so rationalize the answer, as in \(\dfrac{4}{2\sqrt{5}}=\dfrac{2\sqrt{5}}{5}\). There is a vector of magnitude 1 for every direction, so say "in the direction of \(\vec{a}\)" to tell it apart from the unit vector in the opposite direction, \(-\dfrac{\vec{a}}{|\vec{a}|}\). In 3D, there is just one more term that divides the \(z\) component by the same magnitude; the steps are the same.
A vector is a quantity with both direction and magnitude, and writing it in component form, \(\vec{a}=(a_1,\ a_2)\), makes the calculations much easier. Sums, differences and scalar multiples are done component by component, the magnitude is \(|\vec{a}|=\sqrt{a_1^{2}+a_2^{2}}\) (the Pythagorean theorem), and the dot product is the sum of the products of the components, \(a_1b_1+a_2b_2\). Dividing the dot product by the product of the magnitudes gives \(\cos\theta\), which tells you the angle between the two vectors. If the dot product is 0, the vectors are perpendicular; if one is a scalar multiple of the other, they are parallel.

Symbols and terms

Symbols

\(\vec{a}\) vector a The symbol for a vector. The arrow over the letter shows that it is a quantity with direction. Some textbooks use bold type instead, as in \(\boldsymbol{a}\); both are the same vector. The directed segment from point A to point B is written \(\overrightarrow{\mathrm{AB}}\) (the vector from A to B).
\(a_1,\ a_2,\ a_3\) a sub one, a sub two, a sub three The components of vector \(\vec{a}\). The small number at the lower right (the subscript) tells which component it is: \(a_1\) is the step in the \(x\) direction, \(a_2\) in the \(y\) direction and \(a_3\) in the \(z\) direction. Some textbooks use \(x\) and \(y\) as subscripts instead, as in \(\vec{a}=(a_x,\ a_y)\).
\(|\vec{a}|\) magnitude of vector a The magnitude of vector \(\vec{a}\) (the length of the arrow). It uses the same vertical bars as the absolute value of a real number, with the same idea: drop the direction and look only at the size. The value is always 0 or more.
\(\vec{a}\cdot\vec{b}\) a dot b The dot product. By convention it is written with a centered dot, and the answer is a number, not a vector. The name "dot product" comes from this symbol. It is also called the scalar product.
\(\theta\) theta The angle between two vectors. Greek letters are customary for angles, and \(\theta\) is the most common. The angle between vectors is the opening between them when they start at the same point, taken in the range \(0^{\circ}\) to \(180^{\circ}\).
\(\cos\theta\) cosine theta The cosine of the angle \(\theta\). In a right triangle, it is the adjacent side divided by the hypotenuse, and it takes values from \(-1\) to \(1\). It is the key link between the dot product and the angle.
\(\cos^{-1}\) inverse cosine (arccosine) The inverse cosine. A function that gives the angle \(\theta\) from the value of \(\cos\theta\), also written \(\arccos\). The \(-1\) at the upper right stands for "the reverse operation", not \(\cos\) to the power of \(-1\). On a calculator, it is the key marked small above cos (often reached with 2nd or SHIFT).
\(k,\ l\) k, l Real numbers (scalars) that say how many times to multiply a vector. The letter \(k\) is often used for constants. In this calculator you enter them as the coefficients of \(k\vec{a}+l\vec{b}\).
\(\vec{0}\) zero vector The vector whose components are all 0 (the zero vector). It is a special vector with magnitude 0 and no direction, so there is no angle or unit vector for it.
\(\perp\) is perpendicular to The symbol for "is perpendicular to". \(\vec{a}\perp\vec{b}\) is read "\(\vec{a}\) is perpendicular to \(\vec{b}\)". The symbol is a drawing of a right angle.
\(\parallel\) is parallel to The symbol for "is parallel to". \(\vec{a}\parallel\vec{b}\) is read "\(\vec{a}\) is parallel to \(\vec{b}\)". The symbol is two parallel lines side by side.
\(\iff\) if and only if A symbol that says the left side and the right side are equivalent. It says "the right side is true when the left side is true, and only then", and it is written as a two-way arrow.
\(\sqrt{\ }\) square root The square root symbol. \(\sqrt{20}\) is "the positive number that gives 20 when squared". Vector magnitudes are written with this symbol, and answers are given in simplest radical form, pulling square factors out of the radical, as in \(\sqrt{20}=2\sqrt{5}\).

Terms

vector A quantity that has both a direction and a size (magnitude). It describes things such as velocity, force and movement, where the size alone is not enough and you also need the direction. It is drawn as an arrow, and moving it without turning it (same direction and length) gives the same vector.
scalar Just a number with no direction (such as a length, weight or temperature). The word is used to tell it apart from a vector. The answer of a dot product is a scalar.
directed line segment A line segment with a direction: the arrow itself, with a set starting point and end point. A vector is what you get by keeping only its direction and length, whatever its position.
component form Writing a vector as a set of numbers that says "how far in the \(x\) direction, how far in the \(y\) direction". Besides writing it in a row, as in \(\vec{a}=(4,\ 2)\), you can also write it as a column vector; the two are equivalent. Many US textbooks use angle brackets, as in \(\langle 4,\ 2\rangle\). In component form, sums and dot products are just number calculations.
magnitude The length of the vector's arrow. It is also called the norm or length, and you find it from the components with \(\sqrt{a_1^{2}+a_2^{2}}\).
unit vector A vector with magnitude 1. Calculating \(\dfrac{\vec{a}}{|\vec{a}|}\) gives a vector in the same direction as \(\vec{a}\) with its length set to 1. It is used when you only want to show a direction.
zero vector The vector \(\vec{0}\) whose components are all 0. Its magnitude is 0 and it has no direction. It appears as the difference of a vector and itself, as in \(\vec{a}-\vec{a}=\vec{0}\).
opposite vector The vector \(-\vec{a}\) with the same magnitude and exactly the opposite direction. It is the scalar multiple with \(k=-1\), and it is used in the difference \(\vec{a}-\vec{b}=\vec{a}+(-\vec{b})\).
scalar multiple A vector multiplied by a number \(k\) (scalar multiplication). The length becomes \(k\) times as long in the same direction, and if \(k\) is negative the direction reverses.
parallelogram law The rule that the sum of two vectors is the diagonal of the parallelogram with those two vectors as sides. It is used directly to combine forces in a diagram.
dot product A calculation that turns two vectors into one number. It is defined as \(|\vec{a}||\vec{b}|\cos\theta\), and in components it is \(a_1b_1+a_2b_2\). It shows as a number how well the two directions line up.
angle between two vectors The angle \(\theta\) formed when two vectors start at the same point. It is taken in the range \(0^{\circ}\) to \(180^{\circ}\).
projection The shadow of one vector cast onto the direction of another by light shining straight down (the orthogonal projection). The length of the projection of \(\vec{b}\) onto the direction of \(\vec{a}\) is \(|\vec{b}|\cos\theta\) (the scalar projection), and the dot product can be read as this shadow length times \(|\vec{a}|\).
perpendicular Two vectors meeting at a right angle (also called orthogonal). For two vectors that are not the zero vector, it is the same as the dot product being 0.
parallel Two vectors pointing in the same direction or exactly opposite directions. It is the same as one being a scalar multiple of the other, and in the plane you can check it from the components alone with \(a_1b_2-a_2b_1=0\).
position vector A vector that starts at the origin and shows the position of a point. The position vector of point A is \(\overrightarrow{\mathrm{OA}}\), and the coordinates of the point are its components. It is the starting point for studying shapes with vectors.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back to review these topics is the fastest way forward.

The coordinate plane and 3D coordinates (Grade 6 to Precalculus)
  • Being able to describe the position of a point with a pair of numbers such as \((4,\ 2)\) (\(x\) is left–right, \(y\) is up–down)
  • Knowing that in 3D, a height coordinate \(z\) is added, so a point is described by three numbers such as \((4,\ 2,\ 4)\)
  • Knowing that negative coordinates are to the left of or below the origin (and, in 3D, toward you or straight down)
Arithmetic with negative numbers (Grade 7)
  • Being able to add and subtract negative numbers correctly, as in \(4+(-1)\) and \(4-(-1)\)
  • Being able to multiply numbers with different signs, as in \(4 \times (-1) = -4\)
Square roots (Grade 8 to Algebra 1)
  • Knowing that \(\sqrt{20}\) is "the positive number that gives 20 when squared"
  • Being able to simplify a radical by pulling out square factors, as in \(\sqrt{20} = \sqrt{4 \times 5} = 2\sqrt{5}\)
  • Being able to remove a radical from a denominator (rationalize it), as in \(\dfrac{1}{\sqrt{2}} = \dfrac{\sqrt{2}}{2}\)
The Pythagorean theorem (Grade 8)
  • Knowing that in a right triangle, the square of the hypotenuse equals the sum of the squares of the other two sides (\(c^{2}=a^{2}+b^{2}\))
  • Being able to find the hypotenuse from the other two sides (the magnitude of a vector is exactly this)
Trigonometry - cosine (Geometry)
  • Knowing that \(\cos\theta\) takes values from \(-1\) to \(1\) and gets smaller as the angle gets larger
  • Knowing the values for special angles, such as \(\cos 0^{\circ}=1\), \(\cos 60^{\circ}=\dfrac{1}{2}\), \(\cos 90^{\circ}=0\) and \(\cos 180^{\circ}=-1\)
  • Knowing that to find the angle back from a value of \(\cos\theta\), you use the inverse cosine \(\cos^{-1}\) (the reverse of cos on a calculator)
Equations and fractions (Grades 6–8)
  • Being able to solve a linear equation such as \(2x-12=0\)
  • Being able to keep working with fractions such as \(\dfrac{3}{5}\) and simplify them

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to find the magnitude of a vector
x component a1 4
y component a2 2
z component a3 (0 for 2D) 4
Magnitude |a| =SQRT(B1^2+B2^2+B3^2)
Table to find the sum and difference of vectors
a, x component a1 4
a, y component a2 2
a, z component a3 4
b, x component b1 -1
b, y component b2 2
b, z component b3 2
Sum, x component =B1+B4
Sum, y component =B2+B5
Sum, z component =B3+B6
Difference, x component =B1-B4
Difference, y component =B2-B5
Difference, z component =B3-B6
Table to find a scalar multiple of a vector
Scalar k 2
x component a1 4
y component a2 2
z component a3 4
k times, x component =B1*B2
k times, y component =B1*B3
k times, z component =B1*B4
Table to find the dot product
a, x component a1 4
a, y component a2 2
a, z component a3 4
b, x component b1 -1
b, y component b2 2
b, z component b3 2
Dot product a·b =B1*B4+B2*B5+B3*B6
Table to find the angle between two vectors
Dot product a·b 8
Magnitude |a| 6
Magnitude |b| 3
cosθ =B1/(B2*B3)
Angle θ (degrees) =DEGREES(ACOS(B4))
Angle θ (radians) =ACOS(B4)
Table to check the conditions for perpendicular and parallel (2D)
a, x component a1 4
a, y component a2 2
b, x component b1 -1
b, y component b2 2
Dot product a·b =B1*B3+B2*B4
Perpendicular? =IF(B5=0,"Perpendicular","Not perpendicular")
a1b2 − a2b1 =B1*B4-B2*B3
Parallel? =IF(B7=0,"Parallel","Not parallel")
Table to find the unit vector
x component a1 4
y component a2 2
z component a3 (0 for 2D) 4
Magnitude |a| =SQRT(B1^2+B2^2+B3^2)
Unit vector, x component =B1/B4
Unit vector, y component =B2/B4
Unit vector, z component =B3/B4
Check - magnitude of the unit vector =SQRT(B5^2+B6^2+B7^2)
After pasting, the upper rows (components and coefficients) are the inputs, and the lower rows show the calculated results.
"^" is a power, SQRT is the square root, ACOS is the inverse cosine (a function that finds the angle from a cosine value), and DEGREES converts radians to degrees.
Tables 1 to 4 use the 3D vectors a = (4, 2, 4) and b = (−1, 2, 2). The magnitude |a| is 6, the sum is (3, 4, 6), the difference is (5, 0, 2), 2a is (8, 4, 8), and the dot product is 8. For 2D vectors, set the z component cells to 0.
Table 5 finds the angle from that dot product of 8 and the magnitudes 6 and 3. cosθ is 0.4444…, and the angle is about 63.61 degrees (about 1.1102 radians).
Table 6 uses the 2D vectors a = (4, 2) and b = (−1, 2). The dot product is 0, so it shows "Perpendicular", and a1b2 − a2b1 is 10, not 0, so it shows "Not parallel".
Table 7 finds the unit vector for the same a = (4, 2, 4) as table 1. Each component is divided by the magnitude 6, giving (0.6667, 0.3333, 0.6667), and the bottom row confirms that its magnitude is exactly 1.

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to find the magnitude of a vector
x component a1 4
y component a2 2
z component a3 (0 for 2D) 4
Magnitude |a| =SQRT(B1^2+B2^2+B3^2)
Table to find the sum and difference of vectors
a, x component a1 4
a, y component a2 2
a, z component a3 4
b, x component b1 -1
b, y component b2 2
b, z component b3 2
Sum, x component =B1+B4
Sum, y component =B2+B5
Sum, z component =B3+B6
Difference, x component =B1-B4
Difference, y component =B2-B5
Difference, z component =B3-B6
Table to find a scalar multiple of a vector
Scalar k 2
x component a1 4
y component a2 2
z component a3 4
k times, x component =B1*B2
k times, y component =B1*B3
k times, z component =B1*B4
Table to find the dot product
a, x component a1 4
a, y component a2 2
a, z component a3 4
b, x component b1 -1
b, y component b2 2
b, z component b3 2
Dot product a·b =B1*B4+B2*B5+B3*B6
Table to find the angle between two vectors
Dot product a·b 8
Magnitude |a| 6
Magnitude |b| 3
cosθ =B1/(B2*B3)
Angle θ (degrees) =DEGREES(ACOS(B4))
Angle θ (radians) =ACOS(B4)
Table to check the conditions for perpendicular and parallel (2D)
a, x component a1 4
a, y component a2 2
b, x component b1 -1
b, y component b2 2
Dot product a·b =B1*B3+B2*B4
Perpendicular? =IF(B5=0,"Perpendicular","Not perpendicular")
a1b2 − a2b1 =B1*B4-B2*B3
Parallel? =IF(B7=0,"Parallel","Not parallel")
Table to find the unit vector
x component a1 4
y component a2 2
z component a3 (0 for 2D) 4
Magnitude |a| =SQRT(B1^2+B2^2+B3^2)
Unit vector, x component =B1/B4
Unit vector, y component =B2/B4
Unit vector, z component =B3/B4
Check - magnitude of the unit vector =SQRT(B5^2+B6^2+B7^2)
The same formulas as in Excel work as is (SQRT, ACOS, DEGREES and IF have the same names in both). Copy the whole table, paste it into cell A1, and replace the components with your own numbers.
Google Sheets also has a function called SUMPRODUCT. Give it the two ranges of components, as in "=SUMPRODUCT(B1:B3,B4:B6)", and it finds the dot product in a single formula.

How to calculate it in Python

import math
from fractions import Fraction

# Vector components (a fraction such as 3/4 can be written Fraction(3, 4); for 2D, use two items)
a = [Fraction(4), Fraction(2), Fraction(4)]
b = [Fraction(-1), Fraction(2), Fraction(2)]
k, l = Fraction(2), Fraction(3)

# Sum, difference and linear combination (component by component)
vector_sum = [x + y for x, y in zip(a, b)]
vector_diff = [x - y for x, y in zip(a, b)]
combination = [k * x + l * y for x, y in zip(a, b)]

# Dot product, magnitudes and angle
dot = sum(x * y for x, y in zip(a, b))
size_a = math.sqrt(sum(x * x for x in a))
size_b = math.sqrt(sum(x * x for x in b))
cos_theta = dot / (size_a * size_b)
theta_degrees = math.degrees(math.acos(cos_theta))

print(f"Sum: {vector_sum}")
print(f"Difference: {vector_diff}")
print(f"ka + lb: {combination}")
print(f"Dot product: {dot}")
print(f"Magnitude |a|: {size_a}, |b|: {size_b}")
print(f"cos(theta): {float(cos_theta)}, angle: {theta_degrees} degrees")

# Unit vector and perpendicular check
unit_a = [float(x) / size_a for x in a]
print(f"Unit vector in the direction of a: {unit_a}")
print("Perpendicular" if dot == 0 else "Not perpendicular")
It uses the standard library only. Keeping the components as Fraction (fractions) makes the sum, difference and dot product exact, with no rounding error. The magnitudes and the angle involve square roots, so they are calculated as decimals with the math module. This example uses a = (4, 2, 4) and b = (−1, 2, 2), and prints the dot product 8, the magnitudes 6 and 3, and an angle of about 63.61 degrees. Change the components and run it.

How to write it in LaTeX and other math languages (copy and paste)

Magnitude of a vector (from its components)
|a| = √(a₁² + a₂²)
\left|\vec{a}\right| = \sqrt{a_1^{2} + a_2^{2}}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mrow><mo>|</mo><mover><mi>a</mi><mo>&#x2192;</mo></mover><mo>|</mo></mrow>
    <mo>=</mo>
    <msqrt>
      <mrow>
        <msup><msub><mi>a</mi><mn>1</mn></msub><mn>2</mn></msup>
        <mo>+</mo>
        <msup><msub><mi>a</mi><mn>2</mn></msub><mn>2</mn></msup>
      </mrow>
    </msqrt>
  </mrow>
</math>
abs(vec a) = sqrt(a_1^2 + a_2^2)
Norm[{a1, a2}]
LinearAlgebra:-Norm(Vector([a1, a2]), 2);
norm([a1 a2])
|a| = √(a_1^2 + a_2^2)
Sum and difference of vectors (add or subtract component by component)
a + b = (a₁ + b₁, a₂ + b₂)
\vec{a} + \vec{b} = (a_1 + b_1,\ a_2 + b_2)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mover><mi>a</mi><mo>&#x2192;</mo></mover>
    <mo>+</mo>
    <mover><mi>b</mi><mo>&#x2192;</mo></mover>
    <mo>=</mo>
    <mo>(</mo>
    <msub><mi>a</mi><mn>1</mn></msub><mo>+</mo><msub><mi>b</mi><mn>1</mn></msub>
    <mo>,</mo>
    <msub><mi>a</mi><mn>2</mn></msub><mo>+</mo><msub><mi>b</mi><mn>2</mn></msub>
    <mo>)</mo>
  </mrow>
</math>
vec a + vec b = (a_1 + b_1, a_2 + b_2)
{a1, a2} + {b1, b2}
Vector([a1, a2]) + Vector([b1, b2]);
[a1 a2] + [b1 b2]
a + b = (a_1 + b_1, a_2 + b_2)
Scalar multiple of a vector
ka = (ka₁, ka₂)
k\vec{a} = (k a_1,\ k a_2)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>k</mi><mover><mi>a</mi><mo>&#x2192;</mo></mover>
    <mo>=</mo>
    <mo>(</mo>
    <mi>k</mi><msub><mi>a</mi><mn>1</mn></msub>
    <mo>,</mo>
    <mi>k</mi><msub><mi>a</mi><mn>2</mn></msub>
    <mo>)</mo>
  </mrow>
</math>
k vec a = (k a_1, k a_2)
k {a1, a2}
k * Vector([a1, a2]);
k * [a1 a2]
ka = (k a_1, k a_2)
Dot product (a calculation that turns two vectors into a number)
a ⋅ b = |a||b|cosθ = a₁b₁ + a₂b₂
\vec{a}\cdot\vec{b} = \left|\vec{a}\right|\left|\vec{b}\right|\cos\theta = a_1 b_1 + a_2 b_2
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mover><mi>a</mi><mo>&#x2192;</mo></mover>
    <mo>&#x22C5;</mo>
    <mover><mi>b</mi><mo>&#x2192;</mo></mover>
    <mo>=</mo>
    <msub><mi>a</mi><mn>1</mn></msub><msub><mi>b</mi><mn>1</mn></msub>
    <mo>+</mo>
    <msub><mi>a</mi><mn>2</mn></msub><msub><mi>b</mi><mn>2</mn></msub>
  </mrow>
</math>
vec a * vec b = abs(vec a) abs(vec b) cos theta = a_1 b_1 + a_2 b_2
Dot[{a1, a2}, {b1, b2}]
DotProduct(Vector([a1, a2]), Vector([b1, b2]));
dot([a1 a2], [b1 b2])
a ⋅ b = |a||b| cos θ = a_1 b_1 + a_2 b_2
Angle between two vectors
cos θ = (a ⋅ b) / (|a||b|)
\cos\theta = \frac{\vec{a}\cdot\vec{b}}{\left|\vec{a}\right|\left|\vec{b}\right|}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>cos</mi><mi>&#x3B8;</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mover><mi>a</mi><mo>&#x2192;</mo></mover>
        <mo>&#x22C5;</mo>
        <mover><mi>b</mi><mo>&#x2192;</mo></mover>
      </mrow>
      <mrow>
        <mo>|</mo><mover><mi>a</mi><mo>&#x2192;</mo></mover><mo>|</mo>
        <mo>|</mo><mover><mi>b</mi><mo>&#x2192;</mo></mover><mo>|</mo>
      </mrow>
    </mfrac>
  </mrow>
</math>
cos theta = (vec a * vec b) / (abs(vec a) abs(vec b))
ArcCos[Dot[a, b]/(Norm[a] Norm[b])]
VectorAngle(Vector([a1, a2]), Vector([b1, b2]));
acos(dot(a, b) / (norm(a) * norm(b)))
cos θ = (a ⋅ b)/(|a||b|)
Conditions for perpendicular and parallel vectors
a⊥b ⟺ a ⋅ b = 0,  a∥b ⟺ b = ka
\vec{a}\perp\vec{b} \iff \vec{a}\cdot\vec{b}=0,\qquad \vec{a}\parallel\vec{b} \iff \vec{b}=k\vec{a}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mover><mi>a</mi><mo>&#x2192;</mo></mover>
    <mo>&#x22A5;</mo>
    <mover><mi>b</mi><mo>&#x2192;</mo></mover>
    <mo>&#x27FA;</mo>
    <mover><mi>a</mi><mo>&#x2192;</mo></mover>
    <mo>&#x22C5;</mo>
    <mover><mi>b</mi><mo>&#x2192;</mo></mover>
    <mo>=</mo>
    <mn>0</mn>
  </mrow>
</math>
vec a _|_ vec b <=> vec a * vec b = 0
Dot[a, b] == 0
evalb(DotProduct(a, b) = 0);
dot(a, b) == 0
a ⊥ b ⟺ a ⋅ b = 0
Unit vector (keeping only the direction)
a / |a| = (a₁/|a|, a₂/|a|)
\frac{\vec{a}}{\left|\vec{a}\right|} = \left(\frac{a_1}{\left|\vec{a}\right|},\ \frac{a_2}{\left|\vec{a}\right|}\right)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mfrac>
      <mover><mi>a</mi><mo>&#x2192;</mo></mover>
      <mrow><mo>|</mo><mover><mi>a</mi><mo>&#x2192;</mo></mover><mo>|</mo></mrow>
    </mfrac>
    <mo>=</mo>
    <mo>(</mo>
    <mfrac>
      <msub><mi>a</mi><mn>1</mn></msub>
      <mrow><mo>|</mo><mover><mi>a</mi><mo>&#x2192;</mo></mover><mo>|</mo></mrow>
    </mfrac>
    <mo>,</mo>
    <mfrac>
      <msub><mi>a</mi><mn>2</mn></msub>
      <mrow><mo>|</mo><mover><mi>a</mi><mo>&#x2192;</mo></mover><mo>|</mo></mrow>
    </mfrac>
    <mo>)</mo>
  </mrow>
</math>
vec a / abs(vec a) = (a_1/abs(vec a), a_2/abs(vec a))
Normalize[{a1, a2}]
LinearAlgebra:-Normalize(Vector([a1, a2]), 2);
[a1 a2] / norm([a1 a2])
a/|a| = (a_1/|a|, a_2/|a|)

How to have ChatGPT  do the calculation

You are an assistant for math calculations (vectors). Do the following calculations by actually running Python code, and base your answer only on the numbers from the output (do not answer from mental math or guesses).

For the 3D vectors a = (4, 2, 4) and b = (−1, 2, 2), find each of the following.
1. The components of the sum a + b, the difference a − b, and 2a + 3b
2. The magnitudes |a| and |b| (both as exact values with simplified radicals and as decimals)
3. The dot product a·b
4. The angle θ between them (in both degrees and radians, with the exact value if it is a special angle)
5. The unit vector in the direction of a
6. Whether a and b are perpendicular or parallel, and why

In Python, use the fractions and math modules (and sympy if needed), and show the formulas you used and the numbers from the output.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.