Vector Cross Products In R

by | March 17, 2017

The contents of this post can also be found at my main website here.


I have recently discovered how to compute vector cross products in the statistical programming language R. The very helpful link was from http://stackoverflow.com/questions/36798301/r-compute-cross-product-of-vectors-physics. The last comment of the link mentions using the pracma package for computing vector cross product.

To install the pracma package in R, you can type in:

After installing the pracma package in R you need to load the pracma package in order to use the cross product function in the package. You can load pracma into R using

or by using


Example

Suppose we have the vectors $latex \textbf{u} = (2, 0, -8)$ and $latex \textbf{v} = (0, 0, 1)$. The vector which is perpendicular/orthogonal (90 degrees) to both vectors $latex \textbf{u}$ and $latex \textbf{v}$ is the cross product vector. The cross product vector can be determined using the pracma package in R.

We can check (algebraically) that the cross product vector of $latex (0, -2, 0)$is orthogonal to vectors  $latex \textbf{u}$ and $latex \textbf{v}$.

The cross product vector $latex (0, -2, 0)$ is valid as both dot products are both zero.

The featured image is from http://3.bp.blogspot.com/-74JmGr93Fac/Tu28e4Ve3qI/AAAAAAAAASg/Q8WnbJHPICI/s1600/left+hand.jpg.

Leave a Reply