Vector Cross Products In R

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 \textbf{u} = (2, 0, -8) and \textbf{v} = (0, 0, 1). The vector which is perpendicular/orthogonal (90 degrees) to both vectors \textbf{u} and \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 (0, -2, 0)is orthogonal to vectors  \textbf{u} and \textbf{v}.

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

Leave a Reply