Vectors: Difference between revisions

From Physics Book
Jump to navigation Jump to search
No edit summary
 
(23 intermediate revisions by one other user not shown)
Line 1: Line 1:
'''Claimed by Terry Zhou Spring 2025'''
'''Aditya Verma – Fall 2025'''
==Vectors and Units==


Vectors and units are fundamental concepts in mathematics and physics, playing a crucial role in describing quantities with both magnitude and direction. Understanding vectors and units is essential for various fields, including physics, engineering, and computer science.
==Vectors and Units Introduction==


[[File:Vectorfirst.png]]
Vectors and units are core tools for describing the physical world in a precise, quantitative way. A vector is a quantity that has both **magnitude** (how big) and **direction** (which way). Many important physical quantities are vectors: displacement, velocity, acceleration, and force all need both size and direction to be completely specified. By representing these quantities as vectors, we can keep track of how they combine, cancel, and interact in one, two, or three dimensions.


==Overview==
Units, meanwhile, tell us **what** we are measuring. A number by itself has no physical meaning until we attach a unit such as meters (m), seconds (s), or newtons (N). Consistent use of units helps us spot mistakes, compare results, and communicate clearly. Together, vectors and units allow scientists, engineers, and programmers to build models that match real-world behavior and to carry out calculations that remain physically meaningful.
Vectors are mathematical objects represented by directed line segments, characterized by both magnitude and direction. They are often denoted by boldface letters or arrows, such as v or ⟶AB. Vectors can represent various physical quantities, including displacement, velocity, force, and acceleration.


Units, on the other hand, are standards used to quantify and measure physical quantities. They provide a reference for expressing magnitudes and enable meaningful comparisons between measurements. Common units include meters (m) for length, kilograms (kg) for mass, seconds (s) for time, and newtons (N) for force.
In physics and engineering, vectors show up whenever we track motion, balance forces, or work with fields such as electric and magnetic fields. In computer science and related fields, vectors appear in computer graphics, simulations, game physics, machine learning, and data representation. Units ensure that all of these computations line up with real measurements rather than just abstract numbers. A strong grasp of both vectors and units is essential for solving problems, interpreting formulas, and understanding how different parts of a system relate to each other.


Vectors are usually written using boldface letters or an arrow, such as '''v''' or <math>\vec{v}</math>. You may also see a vector written as a directed segment like <math>\overrightarrow{AB}</math>. Common vector quantities include displacement, velocity, force, and acceleration. Units provide the scale for these quantities and are based on standard systems like SI. For example, meters (m) measure length, kilograms (kg) measure mass, seconds (s) measure time, and newtons (N) measure force.
[[File:2d3dvec.png|2D vector vs 3D vector]][[File:smallvector.png]]
==Unit Vector==
A **unit vector** is a vector whose magnitude is exactly 1 (one unit) but that still points in a particular direction. Unit vectors are useful for representing direction independently of size. They are often used to define coordinate directions (such as the x, y, and z axes) and to rewrite any vector as “magnitude × direction.”
[[File:unitvecexp.png]]


https://www.onlinemathlearning.com/image-files/unit-vector.png
==Magnitude==
==Magnitude==
The magnitude of a vector represents its length or size and is denoted by |v|. It is a scalar quantity and is always non-negative. The magnitude of a vector is calculated using the Pythagorean theorem in two or three dimensions.


The **magnitude** of a vector is the length or size of the vector. For a vector <math>\vec{v}</math>, the magnitude is written as <math>|\vec{v}|</math>. Magnitude is always a non-negative scalar. In 2D and 3D, it is usually computed with the Pythagorean theorem, using the vector’s components.
[[File:vec3.png]]


https://www.wikihow.com/images/thumb/0/02/Find-Unit-Vector-Step-3-Version-2.jpg/v4-460px-Find-Unit-Vector-Step-3-Version-2.jpg
==Direction==
==Direction==
The direction of a vector indicates its orientation in space and is often described relative to a reference axis or another vector. It can be expressed using angles, unit vectors, or geometric descriptions.
 
The **direction** of a vector describes how it is oriented in space. It can be specified relative to axes (such as the angle from the positive x-axis), using unit vectors, or using geometric descriptions (like “30° above the horizontal” or “to the south”).
 
[[File:directionvec.png]]
[[File:vec10.png]]


==Addition and Subtraction==
==Addition and Subtraction==
Vectors can be added or subtracted to form new vectors using the parallelogram rule or the head-to-tail method. In component form, vector addition involves adding corresponding components separately.


https://www.wikihow.com/images/thumb/b/b0/Add-or-Subtract-Vectors-Step-3-Version-2.jpg/v4-460px-Add-or-Subtract-Vectors-Step-3-Version-2.jpg
Vectors can be added or subtracted to form new vectors. Geometrically, we often use the **head-to-tail method** or the **parallelogram rule**. In component form, vector addition and subtraction are done by adding or subtracting corresponding components.


[[File:vec4.png]]


==Scalar Multiplication==
==Scalar Multiplication==
Scalar multiplication involves multiplying a vector by a scalar quantity, resulting in a new vector with the same direction but a modified magnitude. It is a fundamental operation in vector algebra and has applications in scaling and resizing vectors.


**Scalar multiplication** means multiplying a vector by a scalar (a regular number). This produces a new vector in the same or opposite direction, but with its magnitude scaled by the scalar. This is used to stretch, shrink, or reverse vectors in many physical and mathematical problems.


https://i.ytimg.com/vi/0LYOSzRuNeI/hqdefault.jpg
[[File:vec5.png]]


==Dot Product==
==Dot Product==
The dot product (or scalar product) of two vectors yields a scalar quantity equal to the product of their magnitudes and the cosine of the angle between them. It is used to calculate the angle between vectors, project one vector onto another, and determine the work done by a force.


https://study.com/cimages/multimages/16/dotproducteq2.jpg
The **dot product** (or scalar product) of two vectors produces a scalar. It can be written in terms of components or in terms of magnitudes and the cosine of the angle between the vectors. Dot products are used to find angles between vectors, project one vector onto another, and calculate physical quantities such as work.
 
[[File:vec7.png]]


==Cross Product==
==Cross Product==
The cross product (or vector product) of two vectors yields a new vector that is perpendicular to the plane containing the original vectors. Its magnitude is equal to the product of the magnitudes of the original vectors and the sine of the angle between them. The cross product is used to find torque, angular momentum, and determine the direction of a resultant force in rotational motion.


https://i.ytimg.com/vi/yLug2TnnyI4/maxresdefault.jpg
The **cross product** (or vector product) of two vectors in 3D produces a new vector that is perpendicular to both original vectors. Its magnitude equals the product of the magnitudes of the two vectors times the sine of the angle between them. Cross products appear in torque, angular momentum, and magnetic force, among other topics in rotational and field-based physics.


[[File:vec8.png]]


For two vectors <math>\vec{A}</math> and <math>\vec{B}</math>, the magnitude of the cross product is
<math>|\vec{A}\times\vec{B}| = |\vec{A}|\;|\vec{B}|\sin(\theta)</math>, 
where <math>\theta</math> is the angle between them. The direction follows the **right-hand rule**.


For 2 vectors A and B, the cross product is |A|x|B| sin(theta) where theta is the angle between them. The direction of this vector can be given by the right hand rule.
Some useful properties of the cross product:


Cross Product properties:
* It is **not commutative**: <math>\vec{A}\times\vec{B} \neq \vec{B}\times\vec{A}</math>. In fact, <math>\vec{A}\times\vec{B} = -(\vec{B}\times\vec{A})</math>.
- The cross product does NOT commute. A x B does NOT equal B x A
* It is **distributive** over addition: <math>\vec{A}\times(\vec{B} + \vec{C}) = \vec{A}\times\vec{B} + \vec{A}\times\vec{C}</math>.
- The cross product distributes over addition A x (B + C) = (A x B) + (A x C)
* The cross product of a vector with itself is zero: <math>\vec{A}\times\vec{A} = \vec{0}</math>, since the angle between a vector and itself is 0 and <math>\sin(0) = 0</math>.
- The cross product of a vector with itself is 0. This is because the angle between a vector and itself if 0, and sin (0) = 0


==Units of Measurement==
==SI Units==
==SI Units==
The International System of Units (SI) is the most widely used system of measurement, adopted by most countries worldwide. It defines seven base units from which all other units are derived, including the meter (m) for length, kilogram (kg) for mass, second (s) for time, ampere (A) for electric current, kelvin (K) for temperature, mole (mol) for amount of substance, and candela (cd) for luminous intensity.


==Derived Units==
The **International System of Units (SI)** is the main measurement system used in science and engineering. It specifies seven base units from which all other units are built:
Derived units are formed by combining base units according to mathematical relationships. Examples include the newton (N) for force (kg·m/s^2), the joule (J) for energy (N·m), and the watt (W) for power (J/s). These units are essential for expressing complex physical quantities.


==Conversion==
* meter (m) – length 
Conversion between units involves transforming measurements from one unit to another while preserving their numerical value. It is often necessary when working with data from different sources or when communicating results to audiences using different unit systems.
* kilogram (kg) – mass 
* second (s) – time 
* ampere (A) – electric current 
* kelvin (K) – temperature 
* mole (mol) – amount of substance 
* candela (cd) – luminous intensity 


==Applications==
All physical vector quantities you encounter in this class will use combinations of these units.
Vectors and units have diverse applications across various disciplines:


*Physics: Vectors are used to describe the motion of objects, forces acting on bodies, and electromagnetic fields.
[[File:vec11.png]]


*Engineering: Vectors are employed in structural analysis, fluid mechanics, and electrical circuit design.
==Derived Units==


*Computer Graphics: Vectors are utilized to represent geometric shapes, positions of objects, and transformations in 2D and 3D graphics.
**Derived units** are units formed by combining base units through multiplication and division. For example:


*Navigation: Vectors are used in GPS systems to determine position, velocity, and direction for navigation purposes.
* newton (N) = kg·m/s<sup>2</sup> (force) 
 
* joule (J) = N·m (energy) 
==Conclusion==
* watt (W) = J/s (power) 
Understanding vectors and units is essential for comprehending and analyzing physical phenomena and mathematical relationships in various fields. By mastering these concepts, researchers, engineers, and scientists can effectively model, predict, and manipulate quantities in the real world.


These units describe more complex physical quantities but are always traceable back to the SI base units.


==Conversion==


**Unit conversion** means changing a quantity from one set of units to another while representing the same physical amount. For example, converting from centimeters to meters or from kilometers per hour to meters per second. In multi-step physics problems, careful unit conversion is essential to avoid errors and to match the units expected in formulas.


==Applications==


Vectors and units appear in many areas:


* **Physics:** describing motion, forces, fields (electric, magnetic, gravitational), and momentum. 
* **Engineering:** analyzing structures, designing mechanical systems, working with fluid flow, and modeling electrical circuits. 
* **Computer Graphics:** representing positions, directions, lighting, and transformations in 2D and 3D scenes. 
* **Navigation:** expressing position, velocity, and direction in GPS systems and for aircraft or ships.


Understanding how vectors and units work together lets us build accurate models and interpret real-world data correctly.


_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Line 88: Line 111:
==What is a Vector?==
==What is a Vector?==


In mathematics and physics, a vector is a quantity with a magnitude and a direction in space.
In mathematics and physics, a **vector** is a quantity that has both a magnitude and a direction.


The general syntax of a vector follows a letter with an arrow above it equaling a set of coordinates in a 1st, 2nd, 3rd or more dimension coordinate system.
In coordinates, we often write a vector as a list of components. For example, in a 3D coordinate system, we might write:
Looking at the following vector <math><v_x, v_y, v_z> </math>,
<math>\vec{v} = \langle v_x, v_y, v_z \rangle</math>
<math>v_x </math> says the x-component of the vector, <math>v_y </math> says the y-component of the vector, and <math>v_z </math> says the z-component of the vector.
 
Alternatively, a vector can be written as a boldface letter: <b>a</b>. Which letter is used depends on the problem and desired quantity; for example, <math>\vec{v}</math> represents velocity.
Here:
A specific component of a vector, see the section titled "forms", is denoted by a subscript: c<sub>x</sub>. For example, q<sub>y</sub> represents the y component of a vector <math>\vec{q}</math>.
 
* <math>v_x</math> is the x-component of the vector,
* <math>v_y</math> is the y-component,
* <math>v_z</math> is the z-component.
 
A vector can also be written as a boldface letter, such as '''a''', or with an arrow, like <math>\vec{a}</math>. The specific letter used often reflects the quantity: <math>\vec{v}</math> for velocity, <math>\vec{r}</math> for position, etc. Individual components of a vector are written with subscripts, such as <math>c_x</math> or <math>q_y</math>.


====Example of a Simple Vector====
====Example of a Simple Vector====


<math> \vec{v} = <1, 0, 0> </math>
<math>\vec{v} = \langle 1, 0, 0 \rangle</math>


This vector is denoted by the letter v. It is in a 3-dimensional coordinate system and its direction is in the positive-x direction with a magnitude of 1.
This vector has magnitude 1 and points along the positive x-direction in 3D space.


===Magnitude===
===Magnitude===


The magnitude of a vector is the length of a vector.
The **magnitude** (or length) of a vector tells us how large the vector is.


Surrounding a vector by | | symbols denotes a vector's magnitude: <math>|\vec{v}|</math>. Alternatively, there exists the notation <math>\overline{v}</math> and <math>\lVert \vec{v} \rVert_2</math>, with the latter denoting the Euclidean norm. This is the type of vector norm that you will see most often.
We denote the magnitude of <math>\vec{v}</math> using vertical bars:
<math>|\vec{v}|</math>. You might also see notations such as <math>\overline{v}</math> or <math>\lVert\vec{v}\rVert_2</math> (the Euclidean norm).


Most commonly used in this class, in a three dimensional system, the magnitude of some vector <math><v_x, v_y, v_z> </math> is defined to be <math>\lVert \vec{v} \rVert = \sqrt{v_x^2 + v_y^2 + v_z^2}</math>.
In a 3D system, if
<math>\vec{v} = \langle v_x, v_y, v_z \rangle</math>
then its magnitude is


In other systems, the magnitude of some vector is found by taking the square root of all of its components squared: <math>\lVert \vec{v} \rVert = \sqrt{v_x^2 + v_y^2 + v_z^2 ...+v_n^2}</math>.
<math>\lVert \vec{v} \rVert = \sqrt{v_x^2 + v_y^2 + v_z^2}.</math>


The magnitude of a vector can represent a variety of characteristics, depending on the situation. The magnitude of the vector, and the vector itself, has units corresponding to the characteristic it represents.
More generally, in n dimensions,
<math>\lVert \vec{v} \rVert = \sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}.</math>


Note that a vector does not necessarily extend from one point in real, physical space to another; unless the magnitude is in units of length, the magnitude of the vector usually represents a property that exists at a single point in real, physical space, or no position in particular.
The magnitude carries the units of the quantity being represented. For example, the magnitude of a velocity vector is speed and has units of m/s.
 
Note that a vector does not always represent a literal “arrow in space” between two locations. Often, a vector describes a property at a single point (like electric field at a location) or in an abstract space, even though the mathematics is the same.


[[File:IMG_0325613.jpg|400px|Image: 400 pixels]]
[[File:IMG_0325613.jpg|400px|Image: 400 pixels]]
Line 120: Line 154:
====Unit Vector====
====Unit Vector====


By dividing a vector by its magnitude, the vector's magnitude will be equal to 1, creating a unit vector: <math>\hat{v} = \frac{\vec{v}}{\lVert \vec{v} \rVert} = <v_x, v_y, v_z>/\sqrt{v_x^2 + v_y^2 + v_z^2}</math>. The answer would be in the form of a vector.
If we divide a nonzero vector by its magnitude, we obtain a **unit vector** in the same direction:
 
<math>\hat{v} = \frac{\vec{v}}{\lVert \vec{v} \rVert}</math>.
 
For example, if <math>\vec{v} = \langle v_x, v_y, v_z \rangle</math>, then
 
<math>\hat{v} = \frac{1}{\lVert\vec{v}\rVert}\langle v_x, v_y, v_z \rangle.</math>
 
Unit vectors are written with a “hat,” such as <math>\hat{v}</math>. In many coordinate systems, there are standard unit vectors. In 3D Cartesian coordinates, the unit vectors along the axes are


A unit vector is denoted by a letter with a ^ symbol written over it: <math>\hat{v}</math>. Certain letters represent specific unit vectors. Non-Cartesian coordinate systems often have their own different unit vectors. For example, 2D polar coordinates make use of the <math>\hat{r}</math> and <math>\hat{\theta}</math> unit vectors.
<math>\hat{x} = \langle 1, 0, 0 \rangle, \quad \hat{y} = \langle 0, 1, 0 \rangle, \quad \hat{z} = \langle 0, 0, 1 \rangle.</math>


A simple example of unit vectors are the axes of the 3D-map which are notated as <math>\hat{x}, \hat{y}, \hat{z}</math>. This is spoken as x-hat, y-hat, and z-hat.
Other coordinate systems use different unit vectors, like <math>\hat{r}</math> and <math>\hat{\theta}</math> in polar coordinates.
These unit vectors are equal to <math><1, 0, 0> </math>, <math><0, 1, 0> </math>, <math><0, 0, 1> </math> respectively.


===Direction===
===Direction===


The direction of a vector refers to the direction along which the vector acts.
The **direction** of a vector tells us which way it points.


In a 2-dimensional space, the direction refers to the angle from the positive x -axis.
In 2D, we usually measure direction by an angle from the positive x-axis. For a vector <math>\vec{v} = \langle v_x, v_y \rangle</math>, the direction angle <math>\theta</math> can be computed as


The direction of a vector in a 2-dimensional space can be easily calculated by using the following formula:
<math>\theta = \arctan\left(\frac{v_y}{v_x}\right)</math>,


<math>\theta = arctan(v_y/v_x)</math>
keeping track of the correct quadrant.


===Simple Examples of Vector Quantities===
===Simple Examples of Vector Quantities===


====Position====
====Position====
A person's position can be represented in vector form. Position relative to another object is found by subtracting their respective vector forms. Finding the magnitude of the relative position vector will find the shortest path distance between the two objects. A very common use of the position vector is finding a position relative to the origin. To do this, we subtract the zero vector from the given position vector. This allows for easy manipulation of the position vector because it is centered at zero.
 
A point’s position can be written as a vector. If we have two position vectors, subtracting them gives the **relative position** from one point to the other. The magnitude of this relative position vector gives the straight-line distance between the two points. A common special case is the position relative to the origin, where the origin is at <math>\langle 0,0,0\rangle</math>.


====Velocity====
====Velocity====
Velocity can be represented in vector form. The velocity of an object, often given in meters per second (m/s), is a scalar value describing how quickly the object is moving. Speed is the magnitude of the velocity vector. However, the object's movement happens in a particular spatial direction, which the speed alone does not tell us. The direction of the object's movement is also a part of the velocity vector. Together, speed and direction comprise the velocity vector and give a complete description of an object's motion at a point in time.


The velocity vector can be calculated by calculating the derivative of the position vector.
**Velocity** is a vector that describes how fast and in what direction an object moves. Its magnitude is the **speed**, and it is usually measured in m/s. The velocity vector can be found by differentiating the position vector with respect to time.


For example, let <math>\vec{r}</math> be a position vector equaling to <math><t, 1, 0> m</math>. Where t is equal to the time in seconds. To get the velocity vector, we calculate the derivative of <math>\vec{r}</math> to get the velocity vector <math>\vec{v}</math>:
For example, let <math>\vec{r}(t) = \langle t, 1, 0 \rangle\ \text{m}</math>. Then the velocity is


<math>\vec{v} = <1, 0, 0> m/s </math>
<math>\vec{v}(t) = \frac{d\vec{r}}{dt} = \langle 1, 0, 0 \rangle\ \text{m/s}.</math>


The speed would be the magnitude of the velocity vector, which is equal to 1 m/s.
The speed is the magnitude of <math>\vec{v}</math>, which in this case is 1 m/s.


[[File:Velwiki.png]]
[[File:Velwiki.png]]


====Weight (Force of Gravity)====
====Weight (Force of Gravity)====
Weight is also a vector, typically with only a component in the y-direction. Weight is usually represented by the force of gravity, <math>\vec{F_g}</math>,  on an object. We represent <math>\vec{F_g}</math> as follows:


<math> \vec{F_g} = <0, -mg, 0> </math>
Weight is the gravitational force acting on an object; it is a vector that typically points downward. We often write the gravitational force as <math>\vec{F_g}</math>. In a coordinate system where +y is upward, we can write:
 
<math>\vec{F_g} = \langle 0, -mg, 0 \rangle,</math>


Where <math>g</math> is the Earth's gravitational constant 9.8 <math> m/s^2 </math> and <math>m</math> is the mass of the object. Because the gravitational force is always pointed down towards the Earth, it is always displayed as a negative value in the <math>-y</math> direction. This then commonly yields weight in Newtons (N). The magnitude of the force of gravity, <math>|\vec{F_g}| = mg</math> is the weight of the object, also called the weight force.
where <math>m</math> is the mass of the object and <math>g = 9.8~\text{m/s}^2</math> is the magnitude of the gravitational field near Earth’s surface. The magnitude <math>|\vec{F_g}| = mg</math> is the weight of the object.


===Visually Representing Vectors===
===Visually Representing Vectors===


Vectors are visually represented by arrows. The length of the arrow represents the magnitude of the vector, while the direction the arrow points in represents the direction of the vector. If a vector exists at a particular point in space, the "tail" of the arrow, or the start of the arrow, should be placed at that point.
Vectors are often drawn as **arrows**. The length of the arrow represents the magnitude, and the direction of the arrow shows which way the vector points. If a vector is tied to a particular location, the tail of the arrow is drawn at that point.


This example shows a visual representation of the velocity vector of a ball, which is moving to the right at a speed of 5 m/s.
The example below shows a velocity vector for a ball moving to the right at 5 m/s.


[[File:Vectorvisualrepresentation.png]]
[[File:Vectorvisualrepresentation.png]]
Line 172: Line 214:
==Vector Operations==
==Vector Operations==


It is possible to perform a variety of mathematical operations on vectors, both with other vectors and with scalars. These operations appear in a variety of formulas in physics. To make the operations easier to learn, they are defined below assuming all vectors to be 3-dimensional; the more general n-dimensional definitions look more confusing. If necessary, it is easy to guess how to perform each operation with n-dimensional vectors by extrapolating from the 3-dimensional case.
We can perform several operations on vectors, both with other vectors and with scalars. These operations are used constantly in physics and engineering. To keep the notation simple, we will describe them for 3D vectors, but they generalize naturally to higher dimensions.


===Addition===
===Addition===


<math>\vec{a} + \vec{b} = \langle (a_x + b_x), (a_y + b_y), (a_z + b_z) \rangle</math>.
For vectors <math>\vec{a} = \langle a_x, a_y, a_z \rangle</math> and <math>\vec{b} = \langle b_x, b_y, b_z \rangle</math>,
 
<math>\vec{a} + \vec{b} = \langle a_x + b_x,\; a_y + b_y,\; a_z + b_z \rangle.</math>


In other words, to add two vectors, simply add the vector's components to form the new components. In order to add two vectors together, your first have to identify the heads and the tails of the vectors. Using the head to tail method, you place the head of the second vector on the tail of the first vector. Then, you draw a connecting vector also known as the resultant vector, seen here in red, from the tail of the first vector to the tip of the second vector. The resultant vector is the sum of the two vectors.
Geometrically, we place the tail of <math>\vec{b}</math> at the head of <math>\vec{a}</math>. The vector from the tail of <math>\vec{a}</math> to the head of <math>\vec{b}</math> is the **resultant** <math>\vec{a} + \vec{b}</math>.


[[File:Vectoraddition.png|600px]]
[[File:Vectoraddition.png|600px]]
Line 184: Line 228:
===Subtraction===
===Subtraction===


<math>\vec{a} - \vec{b} =  \vec{a}+(-\vec{b}) = \langle (a_x - b_x), (a_y - b_y), (a_z - b_z) \rangle</math>.
Vector subtraction can be viewed as adding the negative of a vector. We have


In other words, to subtract two vectors, simply subtract their like components to form the new components.
<math>\vec{a} - \vec{b} = \vec{a} + (-\vec{b}) = \langle a_x - b_x,\; a_y - b_y,\; a_z - b_z \rangle.</math>
 
Component-wise, we subtract each component of <math>\vec{b}</math> from the corresponding component of <math>\vec{a}</math>.


[[File:IMG_0326.jpg|500px|Image: 500 pixels]]
[[File:IMG_0326.jpg|500px|Image: 500 pixels]]
Line 192: Line 238:
===Multiplication by Scalar===
===Multiplication by Scalar===


<math>k \cdot \vec{a} = \langle k \cdot a_x, k \cdot a_y, k \cdot a_z \rangle</math>.
If <math>k</math> is a scalar and <math>\vec{a} = \langle a_x, a_y, a_z \rangle</math>, then
 
<math>k \vec{a} = \langle k a_x,\; k a_y,\; k a_z \rangle.</math>


In other words, multiplying a vector by a scalar multiplies each of that vector's components by that scalar, yielding a vector. This will only affect a vector's magnitude, not its direction, unless the scalar is negative, in which case the direction of the vector will be reversed.
Multiplying by a positive scalar changes the magnitude but keeps the direction the same. Multiplying by a negative scalar flips the direction as well.


[[File:Vectorscalarmultiplication.png|400px]]                          [[File:IMG_0327.jpg|400px|Image: 400 pixels]]
[[File:Vectorscalarmultiplication.png|400px]]                          [[File:IMG_0327.jpg|400px|Image: 400 pixels]]
Line 200: Line 248:
===Division by Scalar===
===Division by Scalar===


Division by a scalar behaves exactly like scalar multiplication. Each component is divided by the scalar, thus yielding a vector. This can also be accomplished by multiplying each component by the reciprocal of the scalar: <math> 1/(scalar) </math>
Dividing a vector by a nonzero scalar is equivalent to multiplying by its reciprocal:


The scalar in this case being k.
<math>\frac{\vec{a}}{k} = \langle \frac{a_x}{k},\; \frac{a_y}{k},\; \frac{a_z}{k} \rangle.</math>


<math>\frac{\vec{a}}{k} = \langle \frac{a_x}{k}, \frac{a_y}{k}, \frac{a_z}{k} \rangle</math>.
This operation shrinks or enlarges the vector’s magnitude while preserving (or reversing, if k is negative) its direction.


===Dot Product (also called Scalar Product)===
===Dot Product (also called Scalar Product)===


<math>\vec{a}\cdot\vec{b} =(a_x \cdot b_x) + (a_y \cdot b_y) + (a_z \cdot b_z)</math>.
For <math>\vec{a} = \langle a_x, a_y, a_z \rangle</math> and <math>\vec{b} = \langle b_x, b_y, b_z \rangle</math>, the dot product is
 
<math>\vec{a}\cdot\vec{b} = a_x b_x + a_y b_y + a_z b_z.</math>


The dot product of two vectors is the sum of the products of their like components, and this operation yields a scalar. This quantity makes it easy to see the relationship between two vectors in a simple scalar quantity.  
The result is a scalar. The dot product measures how much two vectors “line up” with each other. A key property is


One of the most common uses of the dot product is to use it to check whether two vectors are orthogonal (perpendicular) to one another. Two vectors are orthogonal if (and only if) their dot product is equal to 0.
<math>\vec{a}\cdot\vec{b} = |\vec{a}|\;|\vec{b}|\cos(\theta),</math>


It is important to note that the dot product of two vectors has a specific value: <math>\vec{a}\cdot\vec{b} = |\vec{a}| \cdot |\vec{b}| \cdot \cos(\theta)</math>, where <math>\theta</math> is the angle between the vectors.
where <math>\theta</math> is the angle between <math>\vec{a}</math> and <math>\vec{b}</math>. If the dot product is zero, the vectors are perpendicular.


[[File:IMG_0328.jpg|400px|Image: 400 pixels]]
[[File:IMG_0328.jpg|400px|Image: 400 pixels]]
Line 220: Line 270:
===Cross Product (also called Vector Product)===
===Cross Product (also called Vector Product)===


One definition of a cross product, which is also the one found on the formula sheet, is:
One component-based definition of the cross product (the one often found on formula sheets) is:
 
<math>\vec{a} \times \vec{b} = \langle a_yb_z - a_zb_y,\; a_zb_x - a_xb_z,\; a_xb_y - a_yb_x \rangle.</math>
 
You may also see it written as


<math>\vec{a} \times \vec{b} = \langle (a_yb_z - a_zb_y), (a_zb_x - a_xb_z), (a_xb_y - a_yb_x) \rangle = (a_yb_z - a_zb_y)\hat{i} - (a_zb_x - a_xb_z)\hat{j} + (a_xb_y - a_yb_x)\hat{k}</math>.
<math>\vec{a} \times \vec{b} = (a_yb_z - a_zb_y)\hat{i} - (a_zb_x - a_xb_z)\hat{j} + (a_xb_y - a_yb_x)\hat{k}.</math>


While this definition may appear overwhelming, it helps in application to remember that the result of taking the cross product of two vectors is a third vector that is orthogonal (perpendicular) to both of the original vectors. The order of terms in a cross product determines the sign of the resulting vector, so it is important to have vectors in the correct order when you compute a cross product.
Although this looks complicated, the key idea is that the cross product of two 3D vectors is a new vector that is orthogonal to both of them. The order matters: changing the order flips the sign.


Computing a cross product is equivalent to taking the determinant of a matrix of the following form:
A common way to remember the formula is through the determinant of a 3×3 matrix:


<math>\begin{vmatrix}
<math>\begin{vmatrix}
Line 232: Line 286:
a_x & a_y & a_z \\
a_x & a_y & a_z \\
b_x & b_y & b_z
b_x & b_y & b_z
\end{vmatrix}</math>
\end{vmatrix}.</math>
 
You can expand this determinant using cofactor expansion. Remember that the <math>\hat{j}</math> term has a minus sign.


In order to find the determinant of a 3x3 matrix, it can be helpful to use process of cofactor expansion. The below image shows how this works. You cross out the first row, and then the column corresponding to i. Then, find the determinant of the smaller 2x2 matrix created by this simplification. Perform this 2 more times with j and k, and do not forget that the j term is always subtracted!
[[File:Expansionbyminors.png|400px]]
[[File:Expansionbyminors.png|400px]]


Here is a website to conduct cross products and see the steps for how to solve them if you need more help: [https://www.symbolab.com/solver/vector-cross-product-calculator  https://www.symbolab.com/solver/vector-cross-product-calculator]
You can also use online tools or videos to check your work:


Here is a generic video displaying the formula being used: [https://www.youtube.com/watch?v=e9T5p_Jwv5c https://www.youtube.com/watch?v=e9T5p_Jwv5c]
* Cross product step-by-step calculator: [https://www.symbolab.com/solver/vector-cross-product-calculator  https://www.symbolab.com/solver/vector-cross-product-calculator] 
* Video explanation: [https://www.youtube.com/watch?v=e9T5p_Jwv5c https://www.youtube.com/watch?v=e9T5p_Jwv5c]


The cross product of two vectors results in another vector in <math> <\hat{i}, \hat{j}, \hat{k}></math> form. It is important to note that the <i>magnitude</i> of the cross product of two vectors has a specific value: <math>|\vec{a}\times\vec{b}| = |\vec{a}| \cdot |\vec{b}| \cdot \sin(\theta)</math>, where <math>\theta</math> is the angle between the vectors.
The magnitude of the cross product satisfies


The direction of the cross product of two vectors is perpendicular to the plane in which those vectors lie and is given by the [[Right Hand Rule]]. 2D vectors do not have cross products. While the other operations listed here are commutative, associative, and distributive over addition the cross product operation is not associative and is anti-commutative (i.e., <math>\vec{a}\times\vec{b} = -\vec{b}\times\vec{a}</math>), meaning that if the order of the factors is reversed, their cross product will be reversed in direction.
<math>|\vec{a}\times\vec{b}| = |\vec{a}|\;|\vec{b}|\sin(\theta)</math>,


<b>For more mathematically-advanced students</b>, I will invoke some higher-level linear algebra. Recall that the null space, defined as <math>\operatorname{Null}(A) = \{ \vec{v} \in \mathbb{R}^n \mid A\vec{v} = \vec{0} \}</math> for an arbitrary matrix <math>A \in \mathbb{R}^{m \times n}</math>, is the orthogonal complement of its row space. That is, for all <math>\vec{v} \in \operatorname{Null}(A)</math> and for all rows <math>\vec{a}_{j}</math> of <math>A</math>, we have that <math>\vec{a}_j \cdot \vec{v} = 0</math>. This is because, since <math>\vec{v} \in \operatorname{Null}(A)</math>, we have that
where <math>\theta</math> is the angle between <math>\vec{a}</math> and <math>\vec{b}</math>. Its direction is perpendicular to the plane of <math>\vec{a}</math> and <math>\vec{b}</math> and is chosen using the [[Right Hand Rule]]. In 2D, the usual cross product is not defined.


<math displaystyle="true">A\vec{v} = \begin{bmatrix}\vec{a}_1 \\ \vec{a}_2 \\ \vdots \\ \vec{a}_m\end{bmatrix}\vec{v} = \begin{bmatrix}0 \\ 0 \\ \cdots \\ 0\end{bmatrix}.</math>  
<b>For more mathematically-advanced students</b>, we can connect this to linear algebra. Let <math>A \in \mathbb{R}^{m \times n}</math> be a matrix, and consider its **null space**:
Now, recall how matrix vector multiplication works! We see that
<math>\begin{bmatrix}\vec{a}_1 \\ \vec{a}_2 \\ \vdots \\ \vec{a}_m\end{bmatrix}\vec{v} = \begin{bmatrix}\vec{a}_1 \cdot \vec{v} \\ \vec{a}_2 \cdot \vec{v} \\ \vdots \\ \vec{a}_m \cdot \vec{v}\end{bmatrix} = \begin{bmatrix}0 \\ 0 \\ \cdots \\ 0\end{bmatrix}</math>. Since all of the dot products are 0, <math>v</math> is orthogonal to all of the rows of <math>A</math>. Therefore, we can conclude that <math>v</math> is orthogonal to the whole row space of the matrix <math>A</math>.


For two vectors <math>\vec{a},\vec{b} \in \mathbb{R}^{3}</math> that are not scalar multiples of one another, if we think of <math>\vec{a}, \vec{b}</math> as corresponding rows in a matrix <math>A</math>, then the null space contains the set of all vectors orthogonal to them both simultaneously. In particular, it contains the unique vector produced by taking the cross product of both vectors. Once we fix what direction is the right direction, and what is the appropriate magnitude, we would then yield a unique vector in the nullspace that is equal to their cross product. <b>This is why the right-hand rule works.</b> (That is, this is why it yields a unique result.) If we visualize the plane spanned by two vectors with our index and middle fingers, then their null space will be perpendicular to the intersection point of the two vectors, or rather the thumb. Likewise, if we use all of our fingers and our thumb to make an L-shape representing the span of the two vectors, upon curling our fingers, we will have the direction of the cross product, which is orthogonal to the two vectors represented by your thumb and fingers. (If we were in <math>\mathbb{R}^4</math>, this would be much trickier, since the dimension of the nullspace would be 2 dimensional, and as a result, even after fixing the appropriate magnitude, we would have an infinite number of <i>directions</i> we could chose from.)
<math>\operatorname{Null}(A) = \{ \vec{v} \in \mathbb{R}^n \mid A\vec{v} = \vec{0} \}.</math>
 
The null space is the set of all vectors that are orthogonal to every row of <math>A</math>. Writing the rows as <math>\vec{a}_1,\ldots,\vec{a}_m</math>, the equation <math>A\vec{v}=\vec{0}</math> expands to
 
<math>\begin{bmatrix}\vec{a}_1 \\ \vec{a}_2 \\ \vdots \\ \vec{a}_m\end{bmatrix}\vec{v} = \begin{bmatrix}\vec{a}_1 \cdot \vec{v} \\ \vec{a}_2 \cdot \vec{v} \\ \vdots \\ \vec{a}_m \cdot \vec{v}\end{bmatrix} = \begin{bmatrix}0 \\ 0 \\ \vdots \\ 0\end{bmatrix}.</math>
 
So every vector in the null space is perpendicular to each row, and therefore to the whole row space.
 
For two vectors <math>\vec{a}, \vec{b} \in \mathbb{R}^3</math> that are not multiples of each other, think of them as the rows of a 2×3 matrix <math>A</math>. The null space of <math>A</math> consists of all vectors orthogonal to both <math>\vec{a}</math> and <math>\vec{b}</math>. The cross product <math>\vec{a}\times\vec{b}</math> is (up to scaling and orientation) the unique nonzero vector in this null space once we fix the magnitude and choose a direction using the right-hand rule. This is another way to see why the cross product is perpendicular to both original vectors. In higher dimensions, the null space can have more than one dimension, so there isn’t a single unique “cross product direction” in the same way.


====Another Cross Product Trick====
====Another Cross Product Trick====
This trick can be used to calculate the cross product quickly. This is done by bypassing the need to create a big matrix and creating a simple visual representation to quickly calculate the determinants.


The best way to explain this trick is to use an example.
Here is a pattern-based way to compute the cross product quickly, using components.


Let there be two vectors <math>\vec{a}</math> and <math>\vec{b}</math>.
Suppose


<math>\vec{a} = <3, -2, 4></math>
<math>\vec{a} = \langle 3, -2, 4 \rangle, \quad \vec{b} = \langle -1, 6, 3 \rangle.</math>
<math>\vec{b} = <-1, 6, 3></math>


Find <math>\vec{a} \times \vec{b}</math>.
We want <math>\vec{c} = \vec{a} \times \vec{b} = \langle c_x, c_y, c_z \rangle.</math>


To use this trick, section out the vectors in this order like so:
Arrange the components vertically and repeat the first component at the bottom:


<math>\begin{vmatrix}
<math>\begin{vmatrix}
Line 272: Line 332:
a_z \\
a_z \\
a_x
a_x
\end{vmatrix}</math> <math>\times</math> <math>\begin{vmatrix}
\end{vmatrix}
=
\begin{vmatrix}
3 \\
-2 \\
4 \\
3
\end{vmatrix}</math>,
<math>\begin{vmatrix}
b_x \\
b_x \\
b_y \\
b_y \\
b_z \\
b_z \\
b_x
b_x
\end{vmatrix}</math> <math>=</math> <math>\begin{vmatrix}
\end{vmatrix}
c_x \\
=
c_y \\
\begin{vmatrix}
c_z
\end{vmatrix}</math>
 
<math>\begin{vmatrix}
3 \\
-2 \\
4 \\
3
\end{vmatrix}</math> <math>\times</math> <math>\begin{vmatrix}
-1 \\
-1 \\
6 \\
6 \\
3 \\
3 \\
-1
-1
\end{vmatrix}</math> <math>=</math> <math>\begin{vmatrix}
\end{vmatrix}</math>.
c_x \\
c_y \\
c_z
\end{vmatrix}</math>
 
Now to solve for the cross product.


For <math>c_x</math>, draw an X that connects <math>a_y</math> to <math>b_z</math> and <math>a_z</math> to <math>b_y</math>.
To find <math>c_x</math>, draw an “X” connecting <math>a_y</math> with <math>b_z</math> and <math>a_z</math> with <math>b_y</math>:


[[File:Cx.png]]
[[File:Cx.png]]


Now to calculate <math>c_x</math>, multiply the values of the first line of the X and multiply the values of the second line of the X.
Then compute


Then subtract both those values to calculate <math>c_x</math>.
<math>c_x = a_y b_z - a_z b_y = (-2)(3) - (4)(6) = -6 - 24 = -30.</math>


A mathematical form of this would look like this:
For <math>c_y</math>, use <math>a_z</math> with the bottom <math>b_x</math> and the bottom <math>a_x</math> with <math>b_z</math>:


<math>c_x = a_y*b_z - a_z*b_y</math>
[[File:Cy.png]]


<math>c_x = -2*3 - 4*6 = -6 - 24</math>
So


<math>c_x = -30</math>
<math>c_y = a_z b_x - a_x b_z = (4)(-1) - (3)(3) = -4 - 9 = -13.</math>


For <math>c_y</math>, do the same thing except draw an X that connects <math>a_z</math> to the bottom <math>b_x</math> and the bottom <math>a_x</math> to <math>b_z</math>.
For <math>c_z</math>, connect <math>a_x</math> with <math>b_y</math> and <math>a_y</math> with <math>b_x</math>:


[[File:Cy.png]]
[[File:Cz.png]]


Then do the same concept as <math>c_x</math>:
Then


<math>c_y = a_z*b_x - a_x*b_z</math>
<math>c_z = a_x b_y - a_y b_x = (3)(6) - (-2)(-1) = 18 - 2 = 16.</math>


<math>c_y = 4*-1 - 3*3 = -4 - 9</math>
Thus


<math>c_y = -13</math>
<math>\vec{a}\times\vec{b} = \langle -30, -13, 16 \rangle.</math>


Then for <math>c_z</math>, do the same thing by drawing an X that connects <math>a_x</math> to <math>b_y</math> and <math>a_y</math> to <math>b_x</math>.
With practice, you may not need to draw the X each time and can compute the components directly from the pattern.


[[File:Cz.png]]
==Equations Involving Vector Operations==


Then do the same concept as <math>c_x</math>:
You may sometimes encounter equations that mix dot products and cross products. Two useful facts:


<math>c_z = a_x*b_y - a_y*b_x</math>
<ol>
<li><math>(\vec{w} \times \vec{v}) \cdot \vec{v} = 0</math>, because <math>\vec{w} \times \vec{v}</math> is perpendicular to both <math>\vec{w}</math> and <math>\vec{v}</math>, so its dot product with either original vector is zero.</li>
<li><math>\vec{a} \cdot (\vec{b} \times \vec{c}) = (\vec{a} \times \vec{b}) \cdot \vec{c}</math>. This identity, called the scalar triple product identity, can be useful if one cross product is easier to compute than the other. Note that the cross product part is still order-sensitive, while the dot product is commutative.</li>
</ol>


<math>c_z = 3*6 - -2*-1 = 18 - 2</math>
==Forms==


<math>c_z = 16</math>
There are several common ways to describe a vector, all containing the same information.


Now the cross product has been finished with the answer that <math>\vec{a} \times \vec{b} = <-30, -13, 16></math>.
===Magnitude and Direction Form===


As this trick is practiced extensively, the following can be done to make calculations must faster:
In this form, we specify:


- Skipping the drawing of the X as practitioners will know what values to multiply and subtract.
* The magnitude (length), and 
* A description of the direction (cardinal direction, angle, or axis).


- Removing the 4th vector x value on the bottom of the visual representation.
For example, “a 5 m vector at 60° above the horizontal” is in magnitude and direction form. This form is intuitive and often used in word problems and real-life descriptions.


==Equations Involving Vector Operations==
===Component Form===


Sometimes, you might encounter formulas or situations where vector-specific operations, such as a dot product or a cross product, are combined in some way. In this case, it can help to remember these two facts:
Here, we break the vector into components along the coordinate axes. In 3D, a vector is written as


<ol><li><math>(w⨯v)•v=0</math>, because the vector produced by the cross product is orthogonal to both <math>w</math> and <math>v</math>, and therefore that vector dotted with either of the original two vectors will always equal zero.
<math>\langle a_x, a_y, a_z \rangle.</math>
<li><math>a•(b⨯c)=(a⨯b)•c</math>. This property can be useful in situations where computing <math>a⨯b</math> is easier than computing <math>b⨯c</math>. Note that the order of the vectors still matters here in the cross products, but that the dot product commutes.
</ol>


==Forms==
For example, <math>\langle 2, 0, -3 \rangle</math> means the vector extends 2 units in +x, 0 units in y, and 3 units in -z. Most algebraic operations (like dot and cross products) are done using component form. Programming languages also typically store vectors in this way.


The information necessary to describe a specific vector can be presented in several forms.
===Unit Vector Form===


===Magnitude and Direction Form===
In unit vector form, we write a vector as a combination of unit vectors:


In this form, the magnitude and the direction of the vector are explicitly stated. The statement describing direction might be a cardinal direction (ex. "North"), a direction on a graph (ex. "the +x direction"), or an angle (ex. "210<math>^\circ</math> from the x axis counterclockwise"), depending on the situation. Magnitude and direction form is often used in word problems because it is easy to understand. This also makes it easier to measure vectors in real world applications. When building structures, it is much easier to say that you want a 5 foot plank of wood 60<math>^\circ</math> off of the ground.  
<math>\hat{i}</math>, <math>\hat{j}</math>, <math>\hat{k}</math> or <math>\hat{x}</math>, <math>\hat{y}</math>, <math>\hat{z}</math>.


===Component Form===
For instance, the vector <math>\langle 2, 0, -3 \rangle</math> can be written as


In this form, the vector is divided into components, each representing a different coordinate direction. In 2D space, these are the x and y directions. In 3D space, these are the x, y, and z directions. Each component tells how much the vector extends in that particular direction. Often, the three components are written enclosed by angle brackets and separated by commas. For example, the vector <math> <2,0,-3> </math> describes a vector that extends 2 units in the <math>\hat{+x}</math> direction, 0 units in the <math>\hat{y}</math> direction, and 3 units in the <math>\hat{-z}</math> direction. Most vector operations described above can only be performed if the vectors are in component form, so this form may be necessary to do math for certain problems. Additionally, it is important to note that programming languages store vectors in component form.
<math>2\hat{i} - 3\hat{k}.</math>


===Unit Vector Form===
Unit vector form and component form contain the same numerical information; they just use different notation.
 
In this form, the vector is expressed as a sum of unit vectors, each corresponding to a different coordinate direction. The symbols <math>\hat{i}</math>, <math>\hat{j}</math>, and <math>\hat{k}</math> OR the symbols <math>\hat{x}</math>, <math>\hat{y}</math>, and <math>\hat{z}</math> are used to represent unit vectors in the x, y, and z directions respectively. Consider the vector <2,0,-3>. It can be expressed in unit vector form as <math>2\hat{i} - 3\hat{k}</math>, meaning 2 times the x direction unit vector minus 3 times the z direction unit vector. While often considered its own form, unit vector form is very similar to component form, as the information describing the vector is stored in the same values. All references to component form in the rest of this page also apply to unit vector form.


[[File:Vectorsdifferentforms.png]]
[[File:Vectorsdifferentforms.png]]


Note that regardless of which form is used, an n-dimensional vector requires n values to mathematically describe. For example, consider a 3-dimensional vector. Describing this vector in component form requires an x value, a y value, and a z value. Describing it in magnitude and direction form requires one value to give the magnitude of the vector and two to give the its direction. The direction of a 3D vector could be described using, say, its polar angle <math>\theta</math> and its azimuthal angle <math>\phi</math>. A 1-dimensional vector, such as the velocity of a particle whose movement is constrained to the x axis, can be described using only 1 value whose sign indicates the vector's direction.
In n dimensions, a vector always needs n numbers to describe it fully. In 3D, magnitude–direction form uses 1 number for magnitude and 2 angles for direction, while component or unit-vector form uses 3 components.


===Converting Between Forms===
===Converting Between Forms===


It is possible to convert vectors from one form to another using simple trigonometry.
We can move between forms using trigonometry and the Pythagorean theorem.


To find the magnitude of a vector in component form, use the Pythagorean theorem: add the squares of the components and take the square root of the result. For a 2D vector, <math>|\vec{a}| = \sqrt{a_x^2 + a_y^2}</math>.
* For a 2D vector <math>\vec{a} = \langle a_x, a_y \rangle</math>, the magnitude is
  <math>|\vec{a}| = \sqrt{a_x^2 + a_y^2}.</math>


To find the direction of a vector in component form, use inverse trigonometric functions. For a 2D vector, <math>\theta = \tan^{-1}(\frac{a_y}{a_x})</math>, where <math>\theta</math> is the angle vector <math>\vec{a}</math> makes with the x axis in the counterclockwise direction.
* The direction angle from the positive x-axis is
  <math>\theta = \tan^{-1}\left(\frac{a_y}{a_x}\right)</math> (with quadrant checks).


To find the components of a vector in magnitude and direction form, use trigonometric functions. For a 2D vector, <math>a_x = |\vec{a}|\cos\theta</math> and <math>a_y = |\vec{a}|\sin\theta</math>, where <math>\theta</math> is the angle vector <math>\vec{a}</math> makes with the x axis in the counterclockwise direction.
* Given magnitude <math>|\vec{a}|</math> and angle <math>\theta</math>, the components are
  <math>a_x = |\vec{a}|\cos\theta</math>,
  <math>a_y = |\vec{a}|\sin\theta</math>.


==Vectors in VPython==
==Vectors in VPython==


The construction for a vector object is the word <code>vec</code> or <code>vector</code> and it takes three arguments, which define its x, y and z components respectively.
In VPython (used in GlowScript), vectors are represented by the type <code>vec</code> or <code>vector</code>. The constructor takes three arguments: the x, y, and z components.


The following is an example of a vector instantiation:
Example:


<code>velocity = vec(3,-1,2)</code>
<code>velocity = vec(3, -1, 2)</code>


In this example, a vector named <code>velocity</code> is created with an x value of 3, y value of -1, and z value of 2.
This creates a vector called <code>velocity</code> with components (3, -1, 2).


In VPython, vector objects are in component form; each one has an x, y, and z component. Recall that in VPython, using the default camera orientation, the +x axis points to the right, the +y axis points upwards, and the +z axis points out of the plane of the screen towards the viewer.  
In VPython’s default view, +x points to the right, +y points upward, and +z points out of the screen toward the viewer.


===Modifying Vectors===
===Modifying Vectors===
To access or modify a specific component of a vector object, its name should be followed by a period and an x, y, or z. For example, to change the x component of the above velocity vector from 3 to 5, the following line might be used:
 
You can access or modify individual components using <code>.x</code>, <code>.y</code>, and <code>.z</code>. For example:


<code>velocity.x = 5</code>
<code>velocity.x = 5</code>
changes the x-component from 3 to 5.


===Helpful Vector Functions===
===Helpful Vector Functions===
====Magnitude====
====Magnitude====
To calculate the magnitude of a vector, the <code>mag</code> function is used. The <code>mag</code> function takes in one argument of a vector.


'''Example Usage'''
VPython provides the <code>mag</code> function to compute the magnitude of a vector:


velocity = vec(3, -1, 2)
<code>
speed = mag(velocity) # use mag to calculate the magnitude of the velocity vector
velocity = vec(3, -1, 2)
speed = mag(velocity) # magnitude of velocity
</code>


===Normalize===
====Normalize====
To normalize a vector or calculate the unit vector, the <code>norm</code> function is used. The <code>norm</code> function takes in one argument of a vector.


'''Example Usage'''
To obtain a unit vector in the same direction (normalize a vector), use <code>norm</code>:


v = vec(5, 0, 0)
<code>
v_hat = norm(v) # normalize v -> v_hat = <1, 0, 0>
v = vec(5, 0, 0)
v_hat = norm(v) # v_hat = <1, 0, 0>
</code>


===Dot and Cross Prodcut===
====Dot and Cross Product====
To get the dot product of two vectors, the <code>dot</code> function is used.
To get the cross product of two vectors, the <code>cross</code> function is used.


Both functions take in two arguments that are both vectors.
The functions <code>dot</code> and <code>cross</code> compute dot and cross products:


'''Example Usage'''
<code>
 
a = vec(1, 2, 3)
a = vec(1, 2, 3)
b = vec(4, 5, 6)
b = vec(4, 5, 6)
dot_prod = dot(a, b)     # a · b
dot_prod = dot(a, b) # get the dot product a * b
cross_prod = cross(a, b) # a × b
cross_prod = cross(a, b) # get the cross product a x b
</code>


===Visualization===
===Visualization===


To visualize vectors in VPython, the <code>arrow</code> object is used.
To visualize vectors, VPython provides the <code>arrow</code> object. You specify:


To initialize an arrow, a position vector and a direction vector must be passed.
* <code>pos</code> – tail position,
There are optional parameters to increase the size and shape of the arrow:
* <code>axis</code> – direction and length of the arrow (a vector).
- shaftwidth
- headwidth
- headlength


Attributes of the arrow can also be changed, such as color. Read more [https://www.glowscript.org/docs/VPythonDocs/arrow.html here].
Optional parameters include <code>shaftwidth</code>, <code>headwidth</code>, and <code>headlength</code>. You can also change attributes like <code>color</code>. See more details [https://www.glowscript.org/docs/VPythonDocs/arrow.html here].


For example, this is how a velocity vector is visualized with an arrow at the origin:
Example of a velocity vector arrow at the origin:


velocity = vec(1,1,0) # velocity vector (required parameter)
<code>
origin = vec(0, 0, 0) # position vector for the origin (required parameter)
velocity = vec(1, 1, 0)
shaftwidth = 0.1 # optional parameter
origin = vec(0, 0, 0)
vel_arrow = arrow(pos=origin, axis=velocity, shaftwidth=shaftwidth, color=color.red) # create visualization of arrow
shaftwidth = 0.1
vel_arrow = arrow(pos=origin, axis=velocity,
                  shaftwidth=shaftwidth, color=color.red)
</code>


[[File:Arrow_viz.png]]
[[File:Arrow_viz.png]]
Line 458: Line 519:
==A Computational Model==
==A Computational Model==


[https://trinket.io/glowscript/3d7c75ed91 Click Here to run the interactive computational model] This computational model breaks each vector operation down. It begins with defining the vector, and then goes into different vector operations. These operations are broken into both their written formula and the Glowscript shortcut function. Play around with the numbers and vector definitions to see what happens! It begins by defining the vectors as arrows, and that's all you need to play around with the different functions! You may also want to comment out some of the sections, so you can see how each function works individually.
[https://trinket.io/glowscript/3d7c75ed91 Click here to run the interactive computational model.]
 
This model walks through basic vector operations step by step. It starts by defining vectors as arrows, then explores:
 
* Addition and subtraction 
* Scalar multiplication 
* Magnitude and unit vectors 
* Dot and cross products 
 
Each operation is shown both in formula form and using VPython shortcut functions. You can edit the vector values and rerun the code to see how the results change. Commenting out parts of the script can help you focus on one type of operation at a time.


==Examples==
==Examples==
Line 464: Line 534:
===Very Simple===
===Very Simple===


Vector <math>\vec{a}</math> is <2.5, 7.4, 8.0>. What is the magnitude and direction of Vector A?
Vector <math>\vec{a} = \langle 2.5, 7.4, 8.0 \rangle</math>. Find its magnitude and a unit vector in its direction.


Solution:
**Solution:**


First, we must find the magnitude.
First, find the magnitude:


<math>|<2.5, 7.4, 8.0>| = \sqrt{2.5^2 + 7.4^2 + 8.0^2}</math>
<math>|\vec{a}| = \sqrt{2.5^2 + 7.4^2 + 8.0^2}</math>


<math> = \sqrt{6.25 + 54.76 + 64} </math>
<math>= \sqrt{6.25 + 54.76 + 64}</math>


<math> = \sqrt{125.01} </math>
<math>= \sqrt{125.01} \approx 11.18.</math>


<math> = 11.18 </math>
Now form the unit vector:


Now, we must find the direction by finding the unit vector.  
<math>\hat{a} = \frac{\vec{a}}{|\vec{a}|} = \left\langle \frac{2.5}{11.18}, \frac{7.4}{11.18}, \frac{8.0}{11.18} \right\rangle \approx \langle 0.224, 0.662, 0.716 \rangle.</math>


<math> unit vector = \vec{a} / mag(a) </math>
So the magnitude is about 11.18, and the direction can be described by the unit vector <math>\langle 0.224, 0.662, 0.716 \rangle</math>.


<math> x = 2.5/11.18 = .224 </math>
===Simple===


<math> y = 7.4 / 11.18 = .662 </math>
Let <math>\vec{a} = \langle 2, 4, 2 \rangle</math> and <math>\vec{b} = \langle -1, 1, 3 \rangle</math>. Find the magnitude of <math>\vec{a} - 2\vec{b}</math>.


<math> z = 8.0 / 11.18 = .716 </math>
**Solution:**


<math> direction = <.224, .662, .716> </math>
Compute the combination:


===Simple===
<math>\vec{a} - 2\vec{b} = \langle 2, 4, 2 \rangle - 2\langle -1, 1, 3 \rangle</math>


Vector <math>\vec{a}</math> is <2,4,2>. Vector <math>\vec{b}</math> is <-1,1,3>. What is the magnitude of the vector <math>\vec{a} - 2\vec{b}</math>?
<math>= \langle 2, 4, 2 \rangle - \langle -2, 2, 6 \rangle</math>


Solution:
<math>= \langle 4, 2, -4 \rangle.</math>


<math>\vec{a} - 2\vec{b} = <2,4,2> - 2 * <-1,1,3> </math>
Now find the magnitude:


<math> = <2,4,2> - <-2,2,6> </math>
<math>|\langle 4, 2, -4 \rangle| = \sqrt{4^2 + 2^2 + (-4)^2} = \sqrt{16 + 4 + 16} = \sqrt{36} = 6.</math>


<math> = <4,2,-4></math>
===Intermediate===


We  are asked to find the magnitude of this vector, so let us use the Pythagorean theorem with its components:
An airplane is flying in still air at 240 m/s, 35° south of west. A wind blows at 80 m/s, 15° east of north. What must the plane’s new velocity relative to the air be in order to keep the same overall trajectory? Give your answer in components (with +x east and +y north).


<math>|<4,2,-4>| = \sqrt{4^2 + 2^2 + (-4)^2}</math>
[[File:Vectorsplaneproblem.png]]


<math> = \sqrt{16 + 4 + 16} </math>
**Solution:**


<math> = \sqrt{36} </math>
Let


<math> = 6 </math>
* <math>\vec{v_{p,0}}</math> = original velocity of the plane (relative to air), 
* <math>\vec{v_w}</math> = wind velocity (relative to ground), 
* <math>\vec{v_{p,1}}</math> = new plane velocity (relative to air).


===Intermediate===
We want the **resultant ground velocity** of the plane to stay equal to <math>\vec{v_{p,0}}</math>. The velocity relative to the ground is


An airplane is travelling in still air at 240m/s in the direction 35<math>^\circ</math> south of west. A wind begins to blow; the wind has a speed of 80m/s in the direction 15<math>^\circ</math> east of north. What should be the new velocity of the plane relative to the air around it to maintain its original trajectory? You may give your answer in component form (+x is east, +y is north).
<math>\vec{v_{p,1}} + \vec{v_w}.</math>


[[File:Vectorsplaneproblem.png]]
So we require


Solution:
<math>\vec{v_{p,1}} + \vec{v_w} = \vec{v_{p,0}}</math> 
<math>\Rightarrow \vec{v_{p,1}} = \vec{v_{p,0}} - \vec{v_w}.</math>


The vector sum of the new velocity of the plane <math>\vec{v_{p,1}}</math> and the velocity of the wind <math>\vec{v_w}</math> should equal the original velocity of the plane <math>\vec{v_{p,0}}</math> (see [[Relative Velocity]]):
Express everything in components:


[[File:Vectorsplanesolution.png]]
Take +x as east and +y as north.


<math> \vec{v_{p,1}} + \vec{v_w} = \vec{v_{p,0}} </math>
35° south of west corresponds to 215° from the +x-axis:


<math> \vec{v_{p,1}} = \vec{v_{p,0}} - \vec{v_w} </math>
<math>\vec{v_{p,0}} = \langle 240\cos(215^\circ),\; 240\sin(215^\circ) \rangle \approx \langle -196.6,\; -137.7 \rangle\ \text{m/s}.</math>


Let us convert the given vectors to component form for easier subtraction. The +x and +y directions will be east and north respectively.
15° east of north corresponds to 75° from the +x-axis:


<math>\vec{v_{p,0}} = <240\cos(215^\circ), 240\sin(215^\circ)></math>m/s (35<math>^\circ</math> south of west is 215<math>^\circ</math> above the x axis)
<math>\vec{v_w} = \langle 80\cos(75^\circ),\; 80\sin(75^\circ) \rangle \approx \langle 20.7,\; 77.3 \rangle\ \text{m/s}.</math>


<math>\vec{v_{p,0}} = <-196.6, -137.7> </math>m/s
Now subtract:


<math>\vec{v_w} = <80\cos(75^\circ), 80\sin(75^\circ)></math>m/s (15<math>^\circ</math> east of north is 75<math>^\circ</math> above the x axis)
<math>\vec{v_{p,1}} = \vec{v_{p,0}} - \vec{v_w} = \langle -196.6, -137.7 \rangle - \langle 20.7, 77.3 \rangle</math>


<math>\vec{v_w} = <20.7, 77.3> </math>m/s
<math>= \langle -217.3,\; -214.9 \rangle\ \text{m/s}.</math>


Now let us subtract:
So the plane must adjust its airspeed to approximately <math>\langle -217.3,\; -214.9 \rangle</math> m/s relative to the air to keep its original track.


<math> \vec{v_{p,1}} = \vec{v_{p,0}} - \vec{v_w} </math>
===Difficult===


<math> \vec{v_{p,1}} = <-196.6, -137.7> - <20.7, 77.3> </math>m/s
Find the angle between the vectors <math>\langle 2, 5, -2 \rangle</math> and <math>\langle 3, -4, -1 \rangle</math>.


<math> \vec{v_{p,1}} = <-217.3, -214.9> </math>m/s
**Solution:**


===Difficult===
Use the dot product formula:


What is the angle between the vectors <2,5,-2> and <3,-4,-1>?
<math>\vec{a}\cdot\vec{b} = |\vec{a}|\;|\vec{b}|\cos\theta.</math>


Solution:
So


The dot product between two vectors is equal to the product of their magnitudes times the cosine of the angle between them. Let us use this property to find the angle between the given vectors.
<math>\theta = \cos^{-1}\left(\frac{\vec{a}\cdot\vec{b}}{|\vec{a}|\;|\vec{b}|}\right).</math>


<math> <2,5,-2> \cdot <3,-4,-1> = |<2,5,-2>| * |<3,-4,-1>| * \cos\theta </math>
Compute the numerator:


Rearranging this yields
<math>\vec{a}\cdot\vec{b} = 2(3) + 5(-4) + (-2)(-1) = 6 - 20 + 2 = -12.</math>


<math> \theta = \cos^{-1}\frac{<2,5,-2> \cdot <3,-4,-1>}{|<2,5,-2>| * |<3,-4,-1>|} </math>
Compute the magnitudes:


Let us evaluate the dot product and simplify:
<math>|\vec{a}| = \sqrt{2^2 + 5^2 + (-2)^2} = \sqrt{4 + 25 + 4} = \sqrt{33},</math>


<math> \theta = \cos^{-1}\frac{2(3) + 5(-4) + (-2)(-1)}{\sqrt{2^2 + 5^2 + (-2)^2} * \sqrt{3^2 + (-4)^2 + (-1)^2}} </math>
<math>|\vec{b}| = \sqrt{3^2 + (-4)^2 + (-1)^2} = \sqrt{9 + 16 + 1} = \sqrt{26}.</math>


<math> \theta = \cos^{-1}\frac{-12}{\sqrt{33 * 26}} </math>
So


<math> \theta = 114^\circ </math>
<math>\theta = \cos^{-1}\left(\frac{-12}{\sqrt{33}\sqrt{26}}\right) = \cos^{-1}\left(\frac{-12}{\sqrt{858}}\right) \approx 114^\circ.</math>


==Connectedness==
==Connectedness==


Vectors play a part in almost every part of our lives. For example, the desk you are probably sitting at was built by using vectors. A force vector is used to represent things like the force of gravity (0, mg, 0), to represent how the pieces within the desk are exerting forces on each other, and a vector to represent the force of the floor on the desk. This just scratches the surface of the vectors that can represent a desk. Any measurement taken, for example the diagonal across the desk, can be represented as a vector.  
Vectors appear in many everyday and engineering contexts.


Another example of vectors in everyday life is how they can represent how we move. Your position can be represented as a vector relative to any other spot in the universe. To find your relative position vector, you take your position vector and subtract the other vector from it. Velocity can also be represented in vector form. When you move, you have a certain velocity in each direction, so it can be represented in vector form. This can also be found by taking the derivative of the position vector with respect to time. The velocity vector can also be integrated to find the position vector. The magnitude of the velocity vector is equivalent to the speed that one is travelling. Acceleration can be represented by taking the derivative of the velocity vector. Each of these vectors can be broken into their components to be able to see how you are traveling in each direction.
Consider a desk. Its weight is a force vector pointing downward, the normal force from the floor is a vector pointing upward, and the forces among the desk’s parts can all be represented as vectors. Measurements such as the diagonal distance across the desktop can also be seen as vectors from one corner to another.


Vectors are a very important part of most Physics 2 material. Nearly every quantity we are looking for is represented as a vector. Electric field, Magnetic field, all of the forces, and many other things. For example, the Magnetic Force on a point particle is represented as follows:
Your motion can be described using vectors as well. Your **position** relative to some reference point can be written as a position vector. The difference between two position vectors is a displacement vector. **Velocity** describes how your position changes over time; it is the time derivative of the position vector, and its magnitude is your speed. **Acceleration** is the time derivative of velocity. All of these quantities can be broken into components, which makes it easier to analyze motion in each direction separately.


<math>{\vec{F} = q\vec{v}\times\vec{B}}</math>
In Physics 2 and beyond, vectors are everywhere. The electric field, magnetic field, many forces, and other quantities are all vector fields. For example, the magnetic force on a charged particle is


This uses both the cross products of 2 vectors and multiplying that cross product, a vector, by a scalar. Vector knowledge is very important in Physics 2, as it is the basis for nearly everything we do.
<math>\vec{F} = q\;\vec{v} \times \vec{B},</math>


Most scientific disciplines don't rely as heavily on vector forms as Physics. Because Physics is so focused on the motion of different things (people, particles, objects), vectors are an integral part of Physics. Even planets move according to patterns described by vectors. Every physical quantity, no matter how big or small, can be represented in vector form.
which combines a cross product of two vectors and a scalar multiplication.
 
Even outside physics, vectors are central. In engineering, they are used for stress analysis, fluid flow, and control systems. In computer science, vectors appear in graphics, simulations, robotics, and machine learning (where data points are often vectors in high-dimensional spaces). Virtually any physical or abstract quantity that has both “how much” and “which way” can be modeled as a vector.


==History==
==History==


It is unknown who first developed the idea of vectors, but the oldest known reference to vectors is in the work <i>Mechanics</i> by Hero of Alexandria in the first century AD, which described their addition. At this point, however, the idea of a vector was little more than a line segment with a specific orientation. They had a length extending from one point in physical space to another but were not used to represent anything else.
Ideas similar to vectors go back many centuries. Early uses treated them as directed line segments rather than abstract quantities. Hero of Alexandria’s work <i>Mechanics</i> in the first century AD contains one of the earliest known discussions of adding such directed segments.
 
In the 18th and 19th centuries, several mathematicians used 2D vectors to represent complex numbers. Caspar Wessel, Jean-Robert Argand, Carl Friedrich Gauss, and William Rowan Hamilton all contributed to this viewpoint. One component represented the real part, and the other represented the imaginary part. Hamilton also introduced the term “vector.


In the early 19th century, several mathematicians and physicists including Caspar Wessel (1745-1818), Jean Robert Argand (1768-1822), Carl Friedrich Gauss (1777-1855), and William Rowan Hamilton (1805-1865) used 2D vectors to represent complex numbers. One component would represent the real value and another would represent the imaginary value. Hamilton would also become the first to use the word "vector." August Ferdinand Möbius (1790-1868) contributed to vector math in his 1827 book <i>The Barycentric Calculus</i>, in which he developed the convention of labeling vectors with letters and defined the multiplication of a vector by a scalar. Hermann Grassmann (1809-1877) wrote in his 1844 book <i>Ausdehnungslehre</I>, German for "The Calculus of Extension", that vectors could exist in the space of any number of dimensions and described much of what would become linear algebra, which makes ample use of vectors.
August Ferdinand Möbius, in his 1827 book <i>The Barycentric Calculus</i>, formalized many vector ideas, including labeling vectors with letters and defining scalar multiplication. Hermann Grassmann, in his 1844 work <i>Ausdehnungslehre</i> (“The Calculus of Extension”), developed a more general theory of vectors in spaces of arbitrary dimension and laid foundations for linear algebra.


The modern language and conventions surrounding vectors come largely from notes created by J. Willard Gibbs (1839-1903), a professor at Yale University, and Oliver Heaviside (1850-1925), a significant English Physicist. They used their development of how vectors are modernly used to demonstrate the laws of electromagnetism discovered by James Clerk Maxwell.
The modern vector notation and conventions used in physics owe a lot to J. Willard Gibbs and Oliver Heaviside in the late 19th century. They refined vector methods and used them to express Maxwell’s equations of electromagnetism in the compact form we study today.


==See Also==
==See Also==


===External Links===
===External Links===
Mathematical Computations on Vectors: [http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf [http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf]


Computational Work with Vectors: [http://vpython.org/contents/docs/vector.html http://vpython.org/contents/docs/vector.html]
Mathematical computations on vectors (MIT OCW notes): 
[http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf]
 
Computational work with vectors in VPython:
[http://vpython.org/contents/docs/vector.html http://vpython.org/contents/docs/vector.html]


Basics of Vectors: [https://www.physics.uoguelph.ca/tutorials/vectors/vectors.html https://www.physics.uoguelph.ca/tutorials/vectors/vectors.html]
Basic vector introduction:
[https://www.physics.uoguelph.ca/tutorials/vectors/vectors.html https://www.physics.uoguelph.ca/tutorials/vectors/vectors.html]


===Further Reading===
===Further Reading===


Vector Analysis by Josiah Willard Gibbs
* *Vector Analysis* – Josiah Willard Gibbs
 
* *Introduction to Matrices and Vectors* – Jacob T. Schwartz
Introduction to Matrices and Vectors by Jacob T. Schwartz


==References==
==References==
[https://mathinsight.org/definition/magnitude_vector https://mathinsight.org/definition/magnitude_vector]
[https://www.mathsisfun.com/algebra/vectors.html https://www.mathsisfun.com/algebra/vectors.html]
[http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf ]
[http://mathinsight.org/vector_introduction http://mathinsight.org/vector_introduction]
[http://www.math.mcgill.ca/labute/courses/133f03/VectorHistory.html http://www.math.mcgill.ca/labute/courses/133f03/VectorHistory.html]
[https://www.glowscript.org/docs/VPythonDocs/vector.html https://www.glowscript.org/docs/VPythonDocs/vector.html]
[https://www.glowscript.org/docs/VPythonDocs/arrow.html https://www.glowscript.org/docs/VPythonDocs/arrow.html]


[https://www.britannica.com/science/vector-mathematics https://www.britannica.com/science/vector-mathematics]
[https://mathinsight.org/definition/magnitude_vector https://mathinsight.org/definition/magnitude_vector] 
[https://www.mathsisfun.com/algebra/vectors.html https://www.mathsisfun.com/algebra/vectors.html] 
[http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf] 
[http://mathinsight.org/vector_introduction http://mathinsight.org/vector_introduction] 
[http://www.math.mcgill.ca/labute/courses/133f03/VectorHistory.html http://www.math.mcgill.ca/labute/courses/133f03/VectorHistory.html] 
[https://www.glowscript.org/docs/VPythonDocs/vector.html https://www.glowscript.org/docs/VPythonDocs/vector.html] 
[https://www.glowscript.org/docs/VPythonDocs/arrow.html https://www.glowscript.org/docs/VPythonDocs/arrow.html] 
[https://www.britannica.com/science/vector-mathematics https://www.britannica.com/science/vector-mathematics
[https://www.grc.nasa.gov/www/k-12/rocket/vectcomp.html https://www.grc.nasa.gov/www/k-12/rocket/vectcomp.html] 
[https://www.onlinemathlearning.com/dot-product.html https://www.onlinemathlearning.com/dot-product.html]


[[Category: Geometry]]
[[Category: Geometry]]

Latest revision as of 22:52, 2 December 2025

Aditya Verma – Fall 2025

Vectors and Units Introduction

Vectors and units are core tools for describing the physical world in a precise, quantitative way. A vector is a quantity that has both **magnitude** (how big) and **direction** (which way). Many important physical quantities are vectors: displacement, velocity, acceleration, and force all need both size and direction to be completely specified. By representing these quantities as vectors, we can keep track of how they combine, cancel, and interact in one, two, or three dimensions.

Units, meanwhile, tell us **what** we are measuring. A number by itself has no physical meaning until we attach a unit such as meters (m), seconds (s), or newtons (N). Consistent use of units helps us spot mistakes, compare results, and communicate clearly. Together, vectors and units allow scientists, engineers, and programmers to build models that match real-world behavior and to carry out calculations that remain physically meaningful.

In physics and engineering, vectors show up whenever we track motion, balance forces, or work with fields such as electric and magnetic fields. In computer science and related fields, vectors appear in computer graphics, simulations, game physics, machine learning, and data representation. Units ensure that all of these computations line up with real measurements rather than just abstract numbers. A strong grasp of both vectors and units is essential for solving problems, interpreting formulas, and understanding how different parts of a system relate to each other.

Vectors are usually written using boldface letters or an arrow, such as v or [math]\displaystyle{ \vec{v} }[/math]. You may also see a vector written as a directed segment like [math]\displaystyle{ \overrightarrow{AB} }[/math]. Common vector quantities include displacement, velocity, force, and acceleration. Units provide the scale for these quantities and are based on standard systems like SI. For example, meters (m) measure length, kilograms (kg) measure mass, seconds (s) measure time, and newtons (N) measure force.

2D vector vs 3D vector

Unit Vector

A **unit vector** is a vector whose magnitude is exactly 1 (one unit) but that still points in a particular direction. Unit vectors are useful for representing direction independently of size. They are often used to define coordinate directions (such as the x, y, and z axes) and to rewrite any vector as “magnitude × direction.”

Magnitude

The **magnitude** of a vector is the length or size of the vector. For a vector [math]\displaystyle{ \vec{v} }[/math], the magnitude is written as [math]\displaystyle{ |\vec{v}| }[/math]. Magnitude is always a non-negative scalar. In 2D and 3D, it is usually computed with the Pythagorean theorem, using the vector’s components.

Direction

The **direction** of a vector describes how it is oriented in space. It can be specified relative to axes (such as the angle from the positive x-axis), using unit vectors, or using geometric descriptions (like “30° above the horizontal” or “to the south”).

Addition and Subtraction

Vectors can be added or subtracted to form new vectors. Geometrically, we often use the **head-to-tail method** or the **parallelogram rule**. In component form, vector addition and subtraction are done by adding or subtracting corresponding components.

Scalar Multiplication

    • Scalar multiplication** means multiplying a vector by a scalar (a regular number). This produces a new vector in the same or opposite direction, but with its magnitude scaled by the scalar. This is used to stretch, shrink, or reverse vectors in many physical and mathematical problems.

Dot Product

The **dot product** (or scalar product) of two vectors produces a scalar. It can be written in terms of components or in terms of magnitudes and the cosine of the angle between the vectors. Dot products are used to find angles between vectors, project one vector onto another, and calculate physical quantities such as work.

Cross Product

The **cross product** (or vector product) of two vectors in 3D produces a new vector that is perpendicular to both original vectors. Its magnitude equals the product of the magnitudes of the two vectors times the sine of the angle between them. Cross products appear in torque, angular momentum, and magnetic force, among other topics in rotational and field-based physics.

For two vectors [math]\displaystyle{ \vec{A} }[/math] and [math]\displaystyle{ \vec{B} }[/math], the magnitude of the cross product is [math]\displaystyle{ |\vec{A}\times\vec{B}| = |\vec{A}|\;|\vec{B}|\sin(\theta) }[/math], where [math]\displaystyle{ \theta }[/math] is the angle between them. The direction follows the **right-hand rule**.

Some useful properties of the cross product:

  • It is **not commutative**: [math]\displaystyle{ \vec{A}\times\vec{B} \neq \vec{B}\times\vec{A} }[/math]. In fact, [math]\displaystyle{ \vec{A}\times\vec{B} = -(\vec{B}\times\vec{A}) }[/math].
  • It is **distributive** over addition: [math]\displaystyle{ \vec{A}\times(\vec{B} + \vec{C}) = \vec{A}\times\vec{B} + \vec{A}\times\vec{C} }[/math].
  • The cross product of a vector with itself is zero: [math]\displaystyle{ \vec{A}\times\vec{A} = \vec{0} }[/math], since the angle between a vector and itself is 0 and [math]\displaystyle{ \sin(0) = 0 }[/math].

SI Units

The **International System of Units (SI)** is the main measurement system used in science and engineering. It specifies seven base units from which all other units are built:

  • meter (m) – length
  • kilogram (kg) – mass
  • second (s) – time
  • ampere (A) – electric current
  • kelvin (K) – temperature
  • mole (mol) – amount of substance
  • candela (cd) – luminous intensity

All physical vector quantities you encounter in this class will use combinations of these units.

Derived Units

    • Derived units** are units formed by combining base units through multiplication and division. For example:
  • newton (N) = kg·m/s2 (force)
  • joule (J) = N·m (energy)
  • watt (W) = J/s (power)

These units describe more complex physical quantities but are always traceable back to the SI base units.

Conversion

    • Unit conversion** means changing a quantity from one set of units to another while representing the same physical amount. For example, converting from centimeters to meters or from kilometers per hour to meters per second. In multi-step physics problems, careful unit conversion is essential to avoid errors and to match the units expected in formulas.

Applications

Vectors and units appear in many areas:

  • **Physics:** describing motion, forces, fields (electric, magnetic, gravitational), and momentum.
  • **Engineering:** analyzing structures, designing mechanical systems, working with fluid flow, and modeling electrical circuits.
  • **Computer Graphics:** representing positions, directions, lighting, and transformations in 2D and 3D scenes.
  • **Navigation:** expressing position, velocity, and direction in GPS systems and for aircraft or ships.

Understanding how vectors and units work together lets us build accurate models and interpret real-world data correctly.

_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

What is a Vector?

In mathematics and physics, a **vector** is a quantity that has both a magnitude and a direction.

In coordinates, we often write a vector as a list of components. For example, in a 3D coordinate system, we might write: [math]\displaystyle{ \vec{v} = \langle v_x, v_y, v_z \rangle }[/math]

Here:

  • [math]\displaystyle{ v_x }[/math] is the x-component of the vector,
  • [math]\displaystyle{ v_y }[/math] is the y-component,
  • [math]\displaystyle{ v_z }[/math] is the z-component.

A vector can also be written as a boldface letter, such as a, or with an arrow, like [math]\displaystyle{ \vec{a} }[/math]. The specific letter used often reflects the quantity: [math]\displaystyle{ \vec{v} }[/math] for velocity, [math]\displaystyle{ \vec{r} }[/math] for position, etc. Individual components of a vector are written with subscripts, such as [math]\displaystyle{ c_x }[/math] or [math]\displaystyle{ q_y }[/math].

Example of a Simple Vector

[math]\displaystyle{ \vec{v} = \langle 1, 0, 0 \rangle }[/math]

This vector has magnitude 1 and points along the positive x-direction in 3D space.

Magnitude

The **magnitude** (or length) of a vector tells us how large the vector is.

We denote the magnitude of [math]\displaystyle{ \vec{v} }[/math] using vertical bars: [math]\displaystyle{ |\vec{v}| }[/math]. You might also see notations such as [math]\displaystyle{ \overline{v} }[/math] or [math]\displaystyle{ \lVert\vec{v}\rVert_2 }[/math] (the Euclidean norm).

In a 3D system, if [math]\displaystyle{ \vec{v} = \langle v_x, v_y, v_z \rangle }[/math], then its magnitude is

[math]\displaystyle{ \lVert \vec{v} \rVert = \sqrt{v_x^2 + v_y^2 + v_z^2}. }[/math]

More generally, in n dimensions, [math]\displaystyle{ \lVert \vec{v} \rVert = \sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}. }[/math]

The magnitude carries the units of the quantity being represented. For example, the magnitude of a velocity vector is speed and has units of m/s.

Note that a vector does not always represent a literal “arrow in space” between two locations. Often, a vector describes a property at a single point (like electric field at a location) or in an abstract space, even though the mathematics is the same.

Image: 400 pixels

Unit Vector

If we divide a nonzero vector by its magnitude, we obtain a **unit vector** in the same direction:

[math]\displaystyle{ \hat{v} = \frac{\vec{v}}{\lVert \vec{v} \rVert} }[/math].

For example, if [math]\displaystyle{ \vec{v} = \langle v_x, v_y, v_z \rangle }[/math], then

[math]\displaystyle{ \hat{v} = \frac{1}{\lVert\vec{v}\rVert}\langle v_x, v_y, v_z \rangle. }[/math]

Unit vectors are written with a “hat,” such as [math]\displaystyle{ \hat{v} }[/math]. In many coordinate systems, there are standard unit vectors. In 3D Cartesian coordinates, the unit vectors along the axes are

[math]\displaystyle{ \hat{x} = \langle 1, 0, 0 \rangle, \quad \hat{y} = \langle 0, 1, 0 \rangle, \quad \hat{z} = \langle 0, 0, 1 \rangle. }[/math]

Other coordinate systems use different unit vectors, like [math]\displaystyle{ \hat{r} }[/math] and [math]\displaystyle{ \hat{\theta} }[/math] in polar coordinates.

Direction

The **direction** of a vector tells us which way it points.

In 2D, we usually measure direction by an angle from the positive x-axis. For a vector [math]\displaystyle{ \vec{v} = \langle v_x, v_y \rangle }[/math], the direction angle [math]\displaystyle{ \theta }[/math] can be computed as

[math]\displaystyle{ \theta = \arctan\left(\frac{v_y}{v_x}\right) }[/math],

keeping track of the correct quadrant.

Simple Examples of Vector Quantities

Position

A point’s position can be written as a vector. If we have two position vectors, subtracting them gives the **relative position** from one point to the other. The magnitude of this relative position vector gives the straight-line distance between the two points. A common special case is the position relative to the origin, where the origin is at [math]\displaystyle{ \langle 0,0,0\rangle }[/math].

Velocity

    • Velocity** is a vector that describes how fast and in what direction an object moves. Its magnitude is the **speed**, and it is usually measured in m/s. The velocity vector can be found by differentiating the position vector with respect to time.

For example, let [math]\displaystyle{ \vec{r}(t) = \langle t, 1, 0 \rangle\ \text{m} }[/math]. Then the velocity is

[math]\displaystyle{ \vec{v}(t) = \frac{d\vec{r}}{dt} = \langle 1, 0, 0 \rangle\ \text{m/s}. }[/math]

The speed is the magnitude of [math]\displaystyle{ \vec{v} }[/math], which in this case is 1 m/s.

Weight (Force of Gravity)

Weight is the gravitational force acting on an object; it is a vector that typically points downward. We often write the gravitational force as [math]\displaystyle{ \vec{F_g} }[/math]. In a coordinate system where +y is upward, we can write:

[math]\displaystyle{ \vec{F_g} = \langle 0, -mg, 0 \rangle, }[/math]

where [math]\displaystyle{ m }[/math] is the mass of the object and [math]\displaystyle{ g = 9.8~\text{m/s}^2 }[/math] is the magnitude of the gravitational field near Earth’s surface. The magnitude [math]\displaystyle{ |\vec{F_g}| = mg }[/math] is the weight of the object.

Visually Representing Vectors

Vectors are often drawn as **arrows**. The length of the arrow represents the magnitude, and the direction of the arrow shows which way the vector points. If a vector is tied to a particular location, the tail of the arrow is drawn at that point.

The example below shows a velocity vector for a ball moving to the right at 5 m/s.

Vector Operations

We can perform several operations on vectors, both with other vectors and with scalars. These operations are used constantly in physics and engineering. To keep the notation simple, we will describe them for 3D vectors, but they generalize naturally to higher dimensions.

Addition

For vectors [math]\displaystyle{ \vec{a} = \langle a_x, a_y, a_z \rangle }[/math] and [math]\displaystyle{ \vec{b} = \langle b_x, b_y, b_z \rangle }[/math],

[math]\displaystyle{ \vec{a} + \vec{b} = \langle a_x + b_x,\; a_y + b_y,\; a_z + b_z \rangle. }[/math]

Geometrically, we place the tail of [math]\displaystyle{ \vec{b} }[/math] at the head of [math]\displaystyle{ \vec{a} }[/math]. The vector from the tail of [math]\displaystyle{ \vec{a} }[/math] to the head of [math]\displaystyle{ \vec{b} }[/math] is the **resultant** [math]\displaystyle{ \vec{a} + \vec{b} }[/math].

Subtraction

Vector subtraction can be viewed as adding the negative of a vector. We have

[math]\displaystyle{ \vec{a} - \vec{b} = \vec{a} + (-\vec{b}) = \langle a_x - b_x,\; a_y - b_y,\; a_z - b_z \rangle. }[/math]

Component-wise, we subtract each component of [math]\displaystyle{ \vec{b} }[/math] from the corresponding component of [math]\displaystyle{ \vec{a} }[/math].

Image: 500 pixels

Multiplication by Scalar

If [math]\displaystyle{ k }[/math] is a scalar and [math]\displaystyle{ \vec{a} = \langle a_x, a_y, a_z \rangle }[/math], then

[math]\displaystyle{ k \vec{a} = \langle k a_x,\; k a_y,\; k a_z \rangle. }[/math]

Multiplying by a positive scalar changes the magnitude but keeps the direction the same. Multiplying by a negative scalar flips the direction as well.

Image: 400 pixels

Division by Scalar

Dividing a vector by a nonzero scalar is equivalent to multiplying by its reciprocal:

[math]\displaystyle{ \frac{\vec{a}}{k} = \langle \frac{a_x}{k},\; \frac{a_y}{k},\; \frac{a_z}{k} \rangle. }[/math]

This operation shrinks or enlarges the vector’s magnitude while preserving (or reversing, if k is negative) its direction.

Dot Product (also called Scalar Product)

For [math]\displaystyle{ \vec{a} = \langle a_x, a_y, a_z \rangle }[/math] and [math]\displaystyle{ \vec{b} = \langle b_x, b_y, b_z \rangle }[/math], the dot product is

[math]\displaystyle{ \vec{a}\cdot\vec{b} = a_x b_x + a_y b_y + a_z b_z. }[/math]

The result is a scalar. The dot product measures how much two vectors “line up” with each other. A key property is

[math]\displaystyle{ \vec{a}\cdot\vec{b} = |\vec{a}|\;|\vec{b}|\cos(\theta), }[/math]

where [math]\displaystyle{ \theta }[/math] is the angle between [math]\displaystyle{ \vec{a} }[/math] and [math]\displaystyle{ \vec{b} }[/math]. If the dot product is zero, the vectors are perpendicular.

Image: 400 pixels

Cross Product (also called Vector Product)

One component-based definition of the cross product (the one often found on formula sheets) is:

[math]\displaystyle{ \vec{a} \times \vec{b} = \langle a_yb_z - a_zb_y,\; a_zb_x - a_xb_z,\; a_xb_y - a_yb_x \rangle. }[/math]

You may also see it written as

[math]\displaystyle{ \vec{a} \times \vec{b} = (a_yb_z - a_zb_y)\hat{i} - (a_zb_x - a_xb_z)\hat{j} + (a_xb_y - a_yb_x)\hat{k}. }[/math]

Although this looks complicated, the key idea is that the cross product of two 3D vectors is a new vector that is orthogonal to both of them. The order matters: changing the order flips the sign.

A common way to remember the formula is through the determinant of a 3×3 matrix:

[math]\displaystyle{ \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ a_x & a_y & a_z \\ b_x & b_y & b_z \end{vmatrix}. }[/math]

You can expand this determinant using cofactor expansion. Remember that the [math]\displaystyle{ \hat{j} }[/math] term has a minus sign.

You can also use online tools or videos to check your work:

The magnitude of the cross product satisfies

[math]\displaystyle{ |\vec{a}\times\vec{b}| = |\vec{a}|\;|\vec{b}|\sin(\theta) }[/math],

where [math]\displaystyle{ \theta }[/math] is the angle between [math]\displaystyle{ \vec{a} }[/math] and [math]\displaystyle{ \vec{b} }[/math]. Its direction is perpendicular to the plane of [math]\displaystyle{ \vec{a} }[/math] and [math]\displaystyle{ \vec{b} }[/math] and is chosen using the Right Hand Rule. In 2D, the usual cross product is not defined.

For more mathematically-advanced students, we can connect this to linear algebra. Let [math]\displaystyle{ A \in \mathbb{R}^{m \times n} }[/math] be a matrix, and consider its **null space**:

[math]\displaystyle{ \operatorname{Null}(A) = \{ \vec{v} \in \mathbb{R}^n \mid A\vec{v} = \vec{0} \}. }[/math]

The null space is the set of all vectors that are orthogonal to every row of [math]\displaystyle{ A }[/math]. Writing the rows as [math]\displaystyle{ \vec{a}_1,\ldots,\vec{a}_m }[/math], the equation [math]\displaystyle{ A\vec{v}=\vec{0} }[/math] expands to

[math]\displaystyle{ \begin{bmatrix}\vec{a}_1 \\ \vec{a}_2 \\ \vdots \\ \vec{a}_m\end{bmatrix}\vec{v} = \begin{bmatrix}\vec{a}_1 \cdot \vec{v} \\ \vec{a}_2 \cdot \vec{v} \\ \vdots \\ \vec{a}_m \cdot \vec{v}\end{bmatrix} = \begin{bmatrix}0 \\ 0 \\ \vdots \\ 0\end{bmatrix}. }[/math]

So every vector in the null space is perpendicular to each row, and therefore to the whole row space.

For two vectors [math]\displaystyle{ \vec{a}, \vec{b} \in \mathbb{R}^3 }[/math] that are not multiples of each other, think of them as the rows of a 2×3 matrix [math]\displaystyle{ A }[/math]. The null space of [math]\displaystyle{ A }[/math] consists of all vectors orthogonal to both [math]\displaystyle{ \vec{a} }[/math] and [math]\displaystyle{ \vec{b} }[/math]. The cross product [math]\displaystyle{ \vec{a}\times\vec{b} }[/math] is (up to scaling and orientation) the unique nonzero vector in this null space once we fix the magnitude and choose a direction using the right-hand rule. This is another way to see why the cross product is perpendicular to both original vectors. In higher dimensions, the null space can have more than one dimension, so there isn’t a single unique “cross product direction” in the same way.

Another Cross Product Trick

Here is a pattern-based way to compute the cross product quickly, using components.

Suppose

[math]\displaystyle{ \vec{a} = \langle 3, -2, 4 \rangle, \quad \vec{b} = \langle -1, 6, 3 \rangle. }[/math]

We want [math]\displaystyle{ \vec{c} = \vec{a} \times \vec{b} = \langle c_x, c_y, c_z \rangle. }[/math]

Arrange the components vertically and repeat the first component at the bottom:

[math]\displaystyle{ \begin{vmatrix} a_x \\ a_y \\ a_z \\ a_x \end{vmatrix} = \begin{vmatrix} 3 \\ -2 \\ 4 \\ 3 \end{vmatrix} }[/math], [math]\displaystyle{ \begin{vmatrix} b_x \\ b_y \\ b_z \\ b_x \end{vmatrix} = \begin{vmatrix} -1 \\ 6 \\ 3 \\ -1 \end{vmatrix} }[/math].

To find [math]\displaystyle{ c_x }[/math], draw an “X” connecting [math]\displaystyle{ a_y }[/math] with [math]\displaystyle{ b_z }[/math] and [math]\displaystyle{ a_z }[/math] with [math]\displaystyle{ b_y }[/math]:

Then compute

[math]\displaystyle{ c_x = a_y b_z - a_z b_y = (-2)(3) - (4)(6) = -6 - 24 = -30. }[/math]

For [math]\displaystyle{ c_y }[/math], use [math]\displaystyle{ a_z }[/math] with the bottom [math]\displaystyle{ b_x }[/math] and the bottom [math]\displaystyle{ a_x }[/math] with [math]\displaystyle{ b_z }[/math]:

So

[math]\displaystyle{ c_y = a_z b_x - a_x b_z = (4)(-1) - (3)(3) = -4 - 9 = -13. }[/math]

For [math]\displaystyle{ c_z }[/math], connect [math]\displaystyle{ a_x }[/math] with [math]\displaystyle{ b_y }[/math] and [math]\displaystyle{ a_y }[/math] with [math]\displaystyle{ b_x }[/math]:

Then

[math]\displaystyle{ c_z = a_x b_y - a_y b_x = (3)(6) - (-2)(-1) = 18 - 2 = 16. }[/math]

Thus

[math]\displaystyle{ \vec{a}\times\vec{b} = \langle -30, -13, 16 \rangle. }[/math]

With practice, you may not need to draw the X each time and can compute the components directly from the pattern.

Equations Involving Vector Operations

You may sometimes encounter equations that mix dot products and cross products. Two useful facts:

  1. [math]\displaystyle{ (\vec{w} \times \vec{v}) \cdot \vec{v} = 0 }[/math], because [math]\displaystyle{ \vec{w} \times \vec{v} }[/math] is perpendicular to both [math]\displaystyle{ \vec{w} }[/math] and [math]\displaystyle{ \vec{v} }[/math], so its dot product with either original vector is zero.
  2. [math]\displaystyle{ \vec{a} \cdot (\vec{b} \times \vec{c}) = (\vec{a} \times \vec{b}) \cdot \vec{c} }[/math]. This identity, called the scalar triple product identity, can be useful if one cross product is easier to compute than the other. Note that the cross product part is still order-sensitive, while the dot product is commutative.

Forms

There are several common ways to describe a vector, all containing the same information.

Magnitude and Direction Form

In this form, we specify:

  • The magnitude (length), and
  • A description of the direction (cardinal direction, angle, or axis).

For example, “a 5 m vector at 60° above the horizontal” is in magnitude and direction form. This form is intuitive and often used in word problems and real-life descriptions.

Component Form

Here, we break the vector into components along the coordinate axes. In 3D, a vector is written as

[math]\displaystyle{ \langle a_x, a_y, a_z \rangle. }[/math]

For example, [math]\displaystyle{ \langle 2, 0, -3 \rangle }[/math] means the vector extends 2 units in +x, 0 units in y, and 3 units in -z. Most algebraic operations (like dot and cross products) are done using component form. Programming languages also typically store vectors in this way.

Unit Vector Form

In unit vector form, we write a vector as a combination of unit vectors:

[math]\displaystyle{ \hat{i} }[/math], [math]\displaystyle{ \hat{j} }[/math], [math]\displaystyle{ \hat{k} }[/math] or [math]\displaystyle{ \hat{x} }[/math], [math]\displaystyle{ \hat{y} }[/math], [math]\displaystyle{ \hat{z} }[/math].

For instance, the vector [math]\displaystyle{ \langle 2, 0, -3 \rangle }[/math] can be written as

[math]\displaystyle{ 2\hat{i} - 3\hat{k}. }[/math]

Unit vector form and component form contain the same numerical information; they just use different notation.

In n dimensions, a vector always needs n numbers to describe it fully. In 3D, magnitude–direction form uses 1 number for magnitude and 2 angles for direction, while component or unit-vector form uses 3 components.

Converting Between Forms

We can move between forms using trigonometry and the Pythagorean theorem.

  • For a 2D vector [math]\displaystyle{ \vec{a} = \langle a_x, a_y \rangle }[/math], the magnitude is
 [math]\displaystyle{ |\vec{a}| = \sqrt{a_x^2 + a_y^2}. }[/math]
  • The direction angle from the positive x-axis is
 [math]\displaystyle{ \theta = \tan^{-1}\left(\frac{a_y}{a_x}\right) }[/math] (with quadrant checks).
  • Given magnitude [math]\displaystyle{ |\vec{a}| }[/math] and angle [math]\displaystyle{ \theta }[/math], the components are
 [math]\displaystyle{ a_x = |\vec{a}|\cos\theta }[/math],
 [math]\displaystyle{ a_y = |\vec{a}|\sin\theta }[/math].

Vectors in VPython

In VPython (used in GlowScript), vectors are represented by the type vec or vector. The constructor takes three arguments: the x, y, and z components.

Example:

velocity = vec(3, -1, 2)

This creates a vector called velocity with components (3, -1, 2).

In VPython’s default view, +x points to the right, +y points upward, and +z points out of the screen toward the viewer.

Modifying Vectors

You can access or modify individual components using .x, .y, and .z. For example:

velocity.x = 5

changes the x-component from 3 to 5.

Helpful Vector Functions

Magnitude

VPython provides the mag function to compute the magnitude of a vector:

velocity = vec(3, -1, 2) speed = mag(velocity) # magnitude of velocity

Normalize

To obtain a unit vector in the same direction (normalize a vector), use norm:

v = vec(5, 0, 0) v_hat = norm(v) # v_hat = <1, 0, 0>

Dot and Cross Product

The functions dot and cross compute dot and cross products:

a = vec(1, 2, 3) b = vec(4, 5, 6) dot_prod = dot(a, b) # a · b cross_prod = cross(a, b) # a × b

Visualization

To visualize vectors, VPython provides the arrow object. You specify:

  • pos – tail position,
  • axis – direction and length of the arrow (a vector).

Optional parameters include shaftwidth, headwidth, and headlength. You can also change attributes like color. See more details here.

Example of a velocity vector arrow at the origin:

velocity = vec(1, 1, 0) origin = vec(0, 0, 0) shaftwidth = 0.1 vel_arrow = arrow(pos=origin, axis=velocity,

                 shaftwidth=shaftwidth, color=color.red)

Output in VPython of Visualized Vector

A Computational Model

Click here to run the interactive computational model.

This model walks through basic vector operations step by step. It starts by defining vectors as arrows, then explores:

  • Addition and subtraction
  • Scalar multiplication
  • Magnitude and unit vectors
  • Dot and cross products

Each operation is shown both in formula form and using VPython shortcut functions. You can edit the vector values and rerun the code to see how the results change. Commenting out parts of the script can help you focus on one type of operation at a time.

Examples

Very Simple

Vector [math]\displaystyle{ \vec{a} = \langle 2.5, 7.4, 8.0 \rangle }[/math]. Find its magnitude and a unit vector in its direction.

    • Solution:**

First, find the magnitude:

[math]\displaystyle{ |\vec{a}| = \sqrt{2.5^2 + 7.4^2 + 8.0^2} }[/math]

[math]\displaystyle{ = \sqrt{6.25 + 54.76 + 64} }[/math]

[math]\displaystyle{ = \sqrt{125.01} \approx 11.18. }[/math]

Now form the unit vector:

[math]\displaystyle{ \hat{a} = \frac{\vec{a}}{|\vec{a}|} = \left\langle \frac{2.5}{11.18}, \frac{7.4}{11.18}, \frac{8.0}{11.18} \right\rangle \approx \langle 0.224, 0.662, 0.716 \rangle. }[/math]

So the magnitude is about 11.18, and the direction can be described by the unit vector [math]\displaystyle{ \langle 0.224, 0.662, 0.716 \rangle }[/math].

Simple

Let [math]\displaystyle{ \vec{a} = \langle 2, 4, 2 \rangle }[/math] and [math]\displaystyle{ \vec{b} = \langle -1, 1, 3 \rangle }[/math]. Find the magnitude of [math]\displaystyle{ \vec{a} - 2\vec{b} }[/math].

    • Solution:**

Compute the combination:

[math]\displaystyle{ \vec{a} - 2\vec{b} = \langle 2, 4, 2 \rangle - 2\langle -1, 1, 3 \rangle }[/math]

[math]\displaystyle{ = \langle 2, 4, 2 \rangle - \langle -2, 2, 6 \rangle }[/math]

[math]\displaystyle{ = \langle 4, 2, -4 \rangle. }[/math]

Now find the magnitude:

[math]\displaystyle{ |\langle 4, 2, -4 \rangle| = \sqrt{4^2 + 2^2 + (-4)^2} = \sqrt{16 + 4 + 16} = \sqrt{36} = 6. }[/math]

Intermediate

An airplane is flying in still air at 240 m/s, 35° south of west. A wind blows at 80 m/s, 15° east of north. What must the plane’s new velocity relative to the air be in order to keep the same overall trajectory? Give your answer in components (with +x east and +y north).

    • Solution:**

Let

  • [math]\displaystyle{ \vec{v_{p,0}} }[/math] = original velocity of the plane (relative to air),
  • [math]\displaystyle{ \vec{v_w} }[/math] = wind velocity (relative to ground),
  • [math]\displaystyle{ \vec{v_{p,1}} }[/math] = new plane velocity (relative to air).

We want the **resultant ground velocity** of the plane to stay equal to [math]\displaystyle{ \vec{v_{p,0}} }[/math]. The velocity relative to the ground is

[math]\displaystyle{ \vec{v_{p,1}} + \vec{v_w}. }[/math]

So we require

[math]\displaystyle{ \vec{v_{p,1}} + \vec{v_w} = \vec{v_{p,0}} }[/math] [math]\displaystyle{ \Rightarrow \vec{v_{p,1}} = \vec{v_{p,0}} - \vec{v_w}. }[/math]

Express everything in components:

Take +x as east and +y as north.

35° south of west corresponds to 215° from the +x-axis:

[math]\displaystyle{ \vec{v_{p,0}} = \langle 240\cos(215^\circ),\; 240\sin(215^\circ) \rangle \approx \langle -196.6,\; -137.7 \rangle\ \text{m/s}. }[/math]

15° east of north corresponds to 75° from the +x-axis:

[math]\displaystyle{ \vec{v_w} = \langle 80\cos(75^\circ),\; 80\sin(75^\circ) \rangle \approx \langle 20.7,\; 77.3 \rangle\ \text{m/s}. }[/math]

Now subtract:

[math]\displaystyle{ \vec{v_{p,1}} = \vec{v_{p,0}} - \vec{v_w} = \langle -196.6, -137.7 \rangle - \langle 20.7, 77.3 \rangle }[/math]

[math]\displaystyle{ = \langle -217.3,\; -214.9 \rangle\ \text{m/s}. }[/math]

So the plane must adjust its airspeed to approximately [math]\displaystyle{ \langle -217.3,\; -214.9 \rangle }[/math] m/s relative to the air to keep its original track.

Difficult

Find the angle between the vectors [math]\displaystyle{ \langle 2, 5, -2 \rangle }[/math] and [math]\displaystyle{ \langle 3, -4, -1 \rangle }[/math].

    • Solution:**

Use the dot product formula:

[math]\displaystyle{ \vec{a}\cdot\vec{b} = |\vec{a}|\;|\vec{b}|\cos\theta. }[/math]

So

[math]\displaystyle{ \theta = \cos^{-1}\left(\frac{\vec{a}\cdot\vec{b}}{|\vec{a}|\;|\vec{b}|}\right). }[/math]

Compute the numerator:

[math]\displaystyle{ \vec{a}\cdot\vec{b} = 2(3) + 5(-4) + (-2)(-1) = 6 - 20 + 2 = -12. }[/math]

Compute the magnitudes:

[math]\displaystyle{ |\vec{a}| = \sqrt{2^2 + 5^2 + (-2)^2} = \sqrt{4 + 25 + 4} = \sqrt{33}, }[/math]

[math]\displaystyle{ |\vec{b}| = \sqrt{3^2 + (-4)^2 + (-1)^2} = \sqrt{9 + 16 + 1} = \sqrt{26}. }[/math]

So

[math]\displaystyle{ \theta = \cos^{-1}\left(\frac{-12}{\sqrt{33}\sqrt{26}}\right) = \cos^{-1}\left(\frac{-12}{\sqrt{858}}\right) \approx 114^\circ. }[/math]

Connectedness

Vectors appear in many everyday and engineering contexts.

Consider a desk. Its weight is a force vector pointing downward, the normal force from the floor is a vector pointing upward, and the forces among the desk’s parts can all be represented as vectors. Measurements such as the diagonal distance across the desktop can also be seen as vectors from one corner to another.

Your motion can be described using vectors as well. Your **position** relative to some reference point can be written as a position vector. The difference between two position vectors is a displacement vector. **Velocity** describes how your position changes over time; it is the time derivative of the position vector, and its magnitude is your speed. **Acceleration** is the time derivative of velocity. All of these quantities can be broken into components, which makes it easier to analyze motion in each direction separately.

In Physics 2 and beyond, vectors are everywhere. The electric field, magnetic field, many forces, and other quantities are all vector fields. For example, the magnetic force on a charged particle is

[math]\displaystyle{ \vec{F} = q\;\vec{v} \times \vec{B}, }[/math]

which combines a cross product of two vectors and a scalar multiplication.

Even outside physics, vectors are central. In engineering, they are used for stress analysis, fluid flow, and control systems. In computer science, vectors appear in graphics, simulations, robotics, and machine learning (where data points are often vectors in high-dimensional spaces). Virtually any physical or abstract quantity that has both “how much” and “which way” can be modeled as a vector.

History

Ideas similar to vectors go back many centuries. Early uses treated them as directed line segments rather than abstract quantities. Hero of Alexandria’s work Mechanics in the first century AD contains one of the earliest known discussions of adding such directed segments.

In the 18th and 19th centuries, several mathematicians used 2D vectors to represent complex numbers. Caspar Wessel, Jean-Robert Argand, Carl Friedrich Gauss, and William Rowan Hamilton all contributed to this viewpoint. One component represented the real part, and the other represented the imaginary part. Hamilton also introduced the term “vector.”

August Ferdinand Möbius, in his 1827 book The Barycentric Calculus, formalized many vector ideas, including labeling vectors with letters and defining scalar multiplication. Hermann Grassmann, in his 1844 work Ausdehnungslehre (“The Calculus of Extension”), developed a more general theory of vectors in spaces of arbitrary dimension and laid foundations for linear algebra.

The modern vector notation and conventions used in physics owe a lot to J. Willard Gibbs and Oliver Heaviside in the late 19th century. They refined vector methods and used them to express Maxwell’s equations of electromagnetism in the compact form we study today.

See Also

External Links

Mathematical computations on vectors (MIT OCW notes): http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf

Computational work with vectors in VPython: http://vpython.org/contents/docs/vector.html

Basic vector introduction: https://www.physics.uoguelph.ca/tutorials/vectors/vectors.html

Further Reading

  • *Vector Analysis* – Josiah Willard Gibbs
  • *Introduction to Matrices and Vectors* – Jacob T. Schwartz

References

https://mathinsight.org/definition/magnitude_vector https://www.mathsisfun.com/algebra/vectors.html http://ocw.mit.edu/courses/mathematics/18-02sc-multivariable-calculus-fall-2010/1.-vectors-and-matrices/part-a-vectors-determinants-and-planes/session-1-vectors/MIT18_02SC_notes_0.pdf http://mathinsight.org/vector_introduction http://www.math.mcgill.ca/labute/courses/133f03/VectorHistory.html https://www.glowscript.org/docs/VPythonDocs/vector.html https://www.glowscript.org/docs/VPythonDocs/arrow.html https://www.britannica.com/science/vector-mathematics https://www.grc.nasa.gov/www/k-12/rocket/vectcomp.html https://www.onlinemathlearning.com/dot-product.html