How to write a dot product in LaTeX

# How to write a dot product in LaTeX

This post may contain affiliate links that allow us to earn a commission at no expense to you. Learn more

This article aims to show you a simple way to create a dot symbol in LaTeX.

In physics and mathematics most of the time when you are working with vectors you will need to calculate the dot product of two vectors. That’s why today you will learn how to write the dot product in LaTeX

## Dot Product

Let’s begin with two vectors A and B, the dot product is defined as the multiplication of two given vectors that results in a positive real number also known as scalar. That means that you get a number rather than a vector.

The dot product of A and B is represent with a dot symbol between both vectors, for example

## Dot Operator Symbol in LaTeX

To write the dot operator symbol, you will need the math mode and one simple command, the \cdot command, and as you can see it does not need arguments. Since the command is already in LaTeX, you don’t need any extra package for it.

Let’s say we have to vectors U and V, the dot product will be

\documentclass{article}
\begin{document}
$$\vec{U} \cdot \vec{V}$$
\end{document}


One variation that you could need, is the vectors with bold font and with the arrow mark, once again without packages.

\documentclass{article}
\begin{document}
$$\vec{\mathbf{U}} \cdot \vec{\mathbf{V}}$$
\end{document}


## Dot product Angle/Vector/Matrix form

Now the dot product between two vectors can have 3 main representations, each one can be used depending on the context, and they can be inserted in LaTeX. Below you will have examples for each one of them.

The first form (Angle Form) involves the angle theta between the vectors, therefore you will need the \theta command and the symbol for the norm of the vector, all of them must be inside the math mode. For example, given R and B the dot product in angle form would be,

\begin{document}
$$\vec{R} \cdot \vec{B} = \Vert\vec{R}\Vert \Vert\vec{B}\Vert \cos(\theta)$$
\end{document}


Gives the output

The second form (Vector Form) is more used when you know each component of two vectors with the same size, it is pretty common in physics to multiply two vectors using this form. Requires the math mode.

\documentclass{article}
\begin{document}
$$\vec{a}=(x_{1}\hat{i}+y_{1}\hat{i}+z_{1}\hat{i})$$
$$\vec{b}=(x_{2}\hat{i}+y_{2}\hat{i}+z_{2}\hat{i})$$
\vspace{2pt}
$$\vec{a}\cdot\vec{b}=x_{1}x_{2}+y_{1}y_{2}+z_{1}z_{2}$$
\end{document}


Gives the output

The third and last form (Matrix Form) is more common in linear algebra, when you are working with vectors. You will need to use the pmatrix (math mode required) environment, and \\ and & for the rows and columns, let’s see it in an example

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Given $\vec{R}$ and $\vec{B}$, the dot product is defined as
$$\vec{R}\cdot\vec{B}=\begin{pmatrix} x_{1} & y_{1} & z_{1} \end{pmatrix} \begin{pmatrix} x_{2}\\ y_{2}\\ z_{2} \end{pmatrix}$$
\end{document}


We use & to determine the position of each new column, and \\ for the position of each row or line. The only thing to take notice of is the need of the amsmath package for the pmatrix environment, but usually this package does not have any trouble with compatibility with other packages. The code above gives the output

## Triple Vector product

Given three vectors A, B and C you can perform what it is called, the triple vector product. It involves the dot product operation and the vector product operation.

The triple vector product is defined as

\begin{document}
$\vec{A}\cdot(\vec{B}\times\vec{C}\,)$
\end{document}


The result of the triple product vector is a scalar number, but in this case, it represents the area of a geometrical figure.

Now you know how to insert the dot symbols used for the dot product in your LaTeX documents, and some forms you may encounter in textbooks. Maybe you already notice it but it is just the normal multiplication sign

I hope this tutorial was helpful in guiding you in LaTeX, and as always keep writing in LaTeX 