latex

How to Write and Use a Tensor Product in LaTeX

In mathematics, Tensors describe the physical properties such as vectors and scalars. It is a set of techniques that is commonly used in machine learning to generalize the vectors and scalars. In the operation and training of a deep learning model, the Tensor product describes each subsystem by a vector in a Hilbert space or vector space.

Tensor products represent the systems with multiple subsystems and are used in many applications such as engineering and physics. The symbol of the Tensor product looks like ⊗ which is impossible to create using a standard keyboard. This tutorial explains the ways to add a Tensor product in LaTeX.

How to Write and Use a Tensor Product in LaTeX

You can write a Tensor product symbol easily as it doesn’t require any package in the source code. For example, use the “\otimes” code  in LaTeX to get the Tensor product symbol:

\documentclass{article}

\begin{document}

$$ a \otimes b = ab $$

\end{document}

Output:

Technically, a⊗b is known as an outer product of a and b. You can represent them as shown in the previous image.

Let’s take another example. You have three vectors – a, b, and c – and you need to construct the Tensor using an outer product.

\documentclass{article}

\begin{document}

$$

\mathbf{a} \otimes \mathbf{b} \otimes \mathbf{c}=

\begin{aligned}

\left[\begin{array}{l}

1 \\

2

\end{array}\right] \otimes\left[\begin{array}{l}

3 \\

4

\end{array}\right] \otimes\left[\begin{array}{l}

5 \\

6

\end{array}\right]=\left[\begin{array}{l}

1 \\

2

\end{array}\right] \otimes\left[\begin{array}{l}

15 \\

18 \\

20 \\

24

\end{array}\right] =\left[\begin{array}{l}

15 \\

18 \\

20 \\

24 \\

30 \\

36 \\

40 \\

48

\end{array}\right]

\end{aligned}

$$

\end{document}

Bigger Size of Tensor Symbol in LaTeX

You can use the Tensor product symbol in a large size using the following source code:

\documentclass{article}

\begin{document}

Small Size of Tensor Product vs Big Size of Tensor Product

$$ \otimes vs \bigotimes $$

\end{document}

Output:

Different Variations of Tensor Product

We can use many other variations of Tensor products easily in LateX. Let’s discuss a few of these variations.

Tensor Product with Subscript in LaTeX

To write a subscript with the Tensor product symbol, you can write that letter or word with an underscore sign in the source code.

\documentclass{article}

\begin{document}

$$ \otimes_{subscript} $$

\end{document}

Output:

Tensor Product with Hat Symbol in LaTeX

Similarly, you can add a hat symbol with the Tensor product through the following source code:

\documentclass{article}

\begin{document}

$$ \hat\otimes $$

\end{document}

Output:

You can use the Tensor product symbol, subscript, and hat symbol together through the following source code:

\documentclass{article}

\begin{document}

$$ \hat{\otimes}_{subscript} $$

\end{document}

Output:

Conclusion

This tutorial briefly overviews the Tensor product symbol in LaTeX. You can enlarge or reduce the Tensor product symbol depending on your needs. A Tensor product symbol has an important role in physics and mathematics, so it is good to learn how to create it in LaTeX. We recommend that you use the source codes correctly. Otherwise, you may get some unexpected errors.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.