From direction and magnitude to data points and gradients—vectors are the foundation of linear algebra. They shape how we navigate, calculate, and represent multidimensional spaces. đź§
Vector Notation
A vector is simply a list of numbers that are ordered in \(\mathbb{R}^n\) .
\(n\) is a positive integer indicating the number of entries.
In general, a vector \(\mathbf{v} \in \mathbb{R}^n\) can be written as:
\[
\mathbf{v} =
\begin{bmatrix}
v_1 \\
v_2 \\
\vdots \\
v_n
\end{bmatrix}
\]
For example, in \(\mathbb{R}^2\) :
\[
\mathbf{u} =
\begin{bmatrix}
0 \\
1
\end{bmatrix}
\hspace{0.4cm}
\mathbf{v} =
\begin{bmatrix}
1 \\
1
\end{bmatrix}
\]
Suppose we have the following matrix:
\[
A =
\begin{bmatrix}
2 & -1 & 1 \\
1 & 0 & 0 \\
0 & 0 & 4
\end{bmatrix}
\]
One standard derivation of vectors from matrices are column vectors .
For our example, the first column vector is:
\[
\left[
\begin{array}{c c c}
\color{red}{\boxed{2}} & -1 & 1 \\
\color{red}{\boxed{1}} & 0 & 0 \\
\color{red}{\boxed{0}} & 0 & 4
\end{array}
\right]
\]
\[
\mathbf{a}_1=
\begin{bmatrix}
2 \\
1 \\
0
\end{bmatrix}
\]
Another standard derivation of vectors from matrices are row vectors .
For our example, the first row vector is:
\[
\left[
\begin{array}{c c c}
\color{red}{\boxed{2}} & \color{red}{\boxed{-1}} & \color{red}{\boxed{1}} \\
1 & 0 & 0 \\
0 & 0 & 4
\end{array}
\right]
\]
\[
\mathbf{a}^T_1=
\begin{bmatrix}
2 & -1 & 1
\end{bmatrix}
\]
viewof u1 = Inputs. range ([- 10 , 10 ], {
step : 0.5 ,
value : 3 ,
label : tex `u_1` ,
width : 200
})
viewof u2 = Inputs. range ([- 10 , 10 ], {
step : 0.5 ,
value : 2 ,
label : tex `u_2` ,
width : 200
})
// Vector v components
viewof v1 = Inputs. range ([- 10 , 10 ], {
step : 0.5 ,
value : - 2 ,
label : tex `v_1` ,
width : 200
})
viewof v2 = Inputs. range ([- 10 , 10 ], {
step : 0.5 ,
value : 4 ,
label : tex `v_2` ,
width : 200
})
// Display vectors
html `<div style="text-align: center; font-size: 1.3em; margin: 2em 0;">
<p style="margin-top: 1em;">
${ tex ` \m athbf{u} = \b egin{bmatrix} ${ u1} \\ ${ u2} \e nd{bmatrix} \q uad \m athbf{v} = \b egin{bmatrix} ${ v1} \\ ${ v2} \e nd{bmatrix}` }
</p>
</div>`
Plot. plot ({
style : "overflow: visible; display: block; margin: 0 auto;" ,
width : 600 ,
height : 500 ,
grid : true ,
x : {label : "x_1" , domain : [- 12 , 12 ]},
y : {label : "x_2" , domain : [- 12 , 12 ]},
marks : [
// Grid axes
Plot. ruleY ([0 ], {stroke : "#ccc" }),
Plot. ruleX ([0 ], {stroke : "#ccc" }),
// Vector u (blue arrow)
Plot. arrow ([{x1 : 0 , y1 : 0 , x2 : u1, y2 : u2}], {
x1 : "x1" , y1 : "y1" , x2 : "x2" , y2 : "y2" ,
stroke : "steelblue" ,
strokeWidth : 3 ,
fill : "steelblue"
}),
// Vector v (red arrow)
Plot. arrow ([{x1 : 0 , y1 : 0 , x2 : v1, y2 : v2}], {
x1 : "x1" , y1 : "y1" , x2 : "x2" , y2 : "y2" ,
stroke : "crimson" ,
strokeWidth : 3 ,
fill : "crimson"
}),
// Vector endpoints
Plot. dot ([
{x : u1, y : u2, color : "u" },
{x : v1, y : v2, color : "v" }
], {
x : "x" , y : "y" ,
r : 4 ,
fill : d => d. color === "u" ? "steelblue" : "crimson" ,
stroke : "white" ,
strokeWidth : 1
}),
// Labels
Plot. text ([
{x : u1/ 2 , y : u2/ 2 + 0.5 , text : "u" },
{x : v1/ 2 , y : v2/ 2 - 0.5 , text : "v" }
], {
x : "x" , y : "y" , text : "text" ,
fontSize : 14 ,
fontWeight : "bold"
})
]
})