<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Projections on avni.sh</title>
    <link>http://www.avni.sh/tags/projections/</link>
    <description>Recent content in Projections on avni.sh</description>
    <image>
      <title>avni.sh</title>
      <url>http://www.avni.sh/cover.webp</url>
      <link>http://www.avni.sh/cover.webp</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Wed, 10 Jul 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="http://www.avni.sh/tags/projections/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Vectors</title>
      <link>http://www.avni.sh/posts/linear-algebra/vectors/</link>
      <pubDate>Wed, 10 Jul 2024 00:00:00 +0000</pubDate>
      <guid>http://www.avni.sh/posts/linear-algebra/vectors/</guid>
      <description>A vector is an array of data expanding in one dimension.</description>
      <content:encoded><![CDATA[<p>A vector could represent the magnitude of a quantity broken down into its various components, for example, the velocity of an object moving on a 2D plane could be represented using the vector $\vec{v} = \begin{bmatrix} 8 &amp; 9 \end{bmatrix}$.</p>
<p align="center"><img src="vector_example.png" alt="Velocity of an object moving in 2D plane"></p>
<p>On a 2D plane $8$ and $9$ could be called the horizontal and vertical components of the vector $\vec{v}$ respectively. But the words <em>horizontal</em> and <em>vertical</em> on a 2D or 3D plane are relative to the viewer (try rotating the figure above anti-clockwise).</p>
<p>By using <strong>unit vectors</strong> $\hat{i}$, $\hat{j}$, and $\hat{k}$ (vectors with <a href="/posts/math/linear-algebra/tensors/#magnitude-of-a-vector" target="_blank">magnitude</a> 1 along the x, y, and z axis respectively) we can define the orientation of each component of the vector. Thus, vector $\vec{v}$ could be redefined as $8\hat{i} + 9\hat{j} + 0\hat{k}$ in a 3D plane or $8\hat{i} + 9\hat{j}$ on a 2D plane.</p>
<p align="center"><img src="unit_vectors.png" alt="Unit vectors along the x, y, and z axis"></p>
<p align="center"><small><i>Unit vectors along the x, y, and z axis</i></small></p>
<h1 id="projections">Projections</h1>
<p>We can break the vector into its components if we know the angle between the vector and any of the axes.</p>
<p>Assuming we have a vector $\vec{v}$ from the origin, we can draw a circle on the plane with radius $|\vec{v}|$ (magnitude of the vector). To break it into two components along the x and y axis we can draw a <em>projection</em> line starting from the tip of the vector to both axes.</p>
<p align="center"><img src="vector_components.png" alt="Breaking a vector into its components"></p>
<p>From the figure above we can assess that</p>
<p>$$ \vec{v}_{x} = |\vec{v}| \times {\vec{v}_x \over |\vec{v}|} = |\vec{v}|\cos(\theta) $$</p>
<p>$$ \vec{v}_{y} = |\vec{v}| \times {\vec{v}_y \over |\vec{v}|} = |\vec{v}|\sin(\theta) $$</p>
<p>Thus, the vector components of $\vec{v}$ along the x and y axis are $|\vec{v}|\cos(\theta)$ and $|\vec{v}|\sin(\theta)$ respectively, where $\theta$ is the angle between the vector and the x-axis.</p>
<p>Similarly, we can find the projection of a vector on another vector. For example, we have two vectors $\vec{v}$ and $\vec{u}$ subtended by the angle $\phi$.</p>
<p align="center"><img src="vector_projection.png" alt="Projection of vector v on u"></p>
<p align="center"><small><i>Projection of $\vec{v}$ on $\vec{u}$</i></small></p>
<p>The component of $\vec{v}$ on vector $\vec{u}$ will be $|\vec{v}| \cos(\phi)$, but this is just a scalar value. To add direction we have to include $\hat{u}$, the unit vector along the direction of $\vec{u}$. Thus, the <strong>projection vector</strong> of $\vec{v}$ on $\vec{u}$ is $|\vec{v}| \cos(\phi) \hat{u}$.</p>
<h1 id="dot-product">Dot Product</h1>
<p>The <strong>dot product</strong> of two vectors is calculated by multiplying the projection of the first vector with the magnitude of the second vector. It quantifies the similarity in the direction of both vectors.</p>
<p>$$ \vec{v} \cdot \vec{u} = |\vec{v}||\vec{u}|\cos(\phi)$$
The dot product operation is <em>commutative</em>, so it doesn&rsquo;t matter if we multiply the projection of $\vec{v}$ with the magnitude of $\vec{u}$ or vice-versa.
$$\vec{v} \cdot \vec{u} = |\vec{v}||\vec{u}|\cos(\phi) = |\vec{u}||\vec{v}|\cos(\phi) = \vec{u} \cdot \vec{v}$$</p>
<p align="center"><img src="dot_products.png" alt="Projection of vector v on u and vector u on v"></p>
<p align="center"><small><i>Projection of $\vec{v}$ on $\vec{u}$ and projection of $\vec{u}$ on $\vec{v}$</i></small></p>
<p>We can also calculate the dot product by multiplying the corresponding elements of both vectors and adding them up.</p>
<p>$$\vec{v} \cdot \vec{u} = \begin{bmatrix} 1 \\ 1 \end{bmatrix} \cdot \begin{bmatrix} 3 \\ -2 \end{bmatrix} = 1 \times 3 + 1 \times (-2) = 1$$</p>
<h1 id="cross-product">Cross Product</h1>
<p>The <strong>cross product</strong> of two vectors returns a vector that is perpendicular to the direction of both vectors.</p>
<p align="center"><img src="cross_product.png" alt="The result of the cross product of two vectors is another vector that is perpendicular to both"></p>
<p>The magnitude of the resulting vector of the cross product is equal to the area of the parallelogram created by the two vectors.</p>
<p align="center"><img src="cross_product_parallelogram.png" alt="Parallelogram created by both vectors"></p>
<p>The length of the sides of the parallelogram will be $|\vec{v}|$ and $|\vec{u}|$.</p>
<p align="center"><img src="vector_parallelogram.png" alt="Parallelogram created by both vectors"></p>
<p>Hence, from the area of the parallelogram we can calculate the magnitude of the cross product of vectors $\vec{u}$ and $\vec{v}$
$$| \vec{u} \times \vec{v}| = |\vec{u}||\vec{v}|\sin(\phi)$$</p>
<p>Unlike the dot product, the cross product is not commutative.
$$\vec{u} \times \vec{v} \neq \vec{v} \times \vec{u}$$</p>
<p>If we have to find the cross product of two vectors using their elements, we have to create a matrix of both vectors and calculate its <a href="/posts/math/linear-algebra/determinants/" target="_blank">determinant</a>.</p>
<p>$$\vec{u} \times \vec{v} = \begin{bmatrix} u_1 \\ u_2 \end{bmatrix} \times \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} = \begin{vmatrix} u_1 &amp; v_1 \\ u_2 &amp; v_2 \end{vmatrix} = u_1 v_2 - v_1 \ u_2$$</p>
<h1 id="hadamard-product">Hadamard Product</h1>
<p>Named after Jacques Hadamard, the <strong>Hadamard product</strong> is the resultant matrix after the multiplication of corresponding elements of two vectors or matrices.
$$\vec{v} \odot \vec{u} = \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} \odot \begin{bmatrix} u_1 \\ u_2 \end{bmatrix} = \begin{bmatrix} v_1 \times u_1 \\ v_2 \times u_2 \end{bmatrix}$$
The result of the Hadamard product will be the same irrespective of the order of multiplication. Thus, it is commutative.
$$\vec{v} \odot \vec{u} = \vec{u} \odot \vec{v}$$
Some use cases of the Hadamard product operation are JPEG image compression and LSTM (Long Short-Term Memory) cells of RNNs (Recurrent Neural Networks). It is also known as Schur Product (named after Issai Schur).</p>
<h1 id="resources">Resources</h1>
<p><a href="https://medium.com/linear-algebra/part-12-vectors-a99364499121" target="_blank">Part 12 : Vectors</a><br>
<a href="https://www.khanacademy.org/math/precalculus/x9e81a4f98389efdf:vectors/x9e81a4f98389efdf:component-form/v/vector-components-from-magnitude-and-direction" target="_blank">Vector components from magnitude &amp; direction</a><br>
<a href="https://medium.com/linear-algebra/part-13-vector-components-b78a61be3817" target="_blank">Part 13 : Vector Components</a><br>
<a href="https://www.youtube.com/watch?v=LyGKycYT2v0" target="_blank">Dot products and duality | Chapter 9, Essence of linear algebra</a><br>
<a href="https://medium.com/linear-algebra/part-14-dot-and-hadamard-product-b7e0723b9133" target="_blank">Part 14 : Dot and Hadamard Product</a><br>
<a href="https://www.youtube.com/watch?v=eu6i7WJeinw" target="_blank">Cross products | Chapter 10, Essence of linear algebra</a><br>
<a href="https://www.khanacademy.org/math/cc-sixth-grade-math/x0267d782:cc-6th-plane-figures/cc-6th-parallelogram-area/a/area-of-parallelogram" target="_blank">Area of parallelograms</a><br>
<a href="https://en.wikipedia.org/wiki/Jacques_Hadamard" target="_blank">Jacques Hadamard</a><br>
<a href="https://en.wikipedia.org/wiki/Issai_Schur" target="_blank">Issai Schur</a></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
