Dot Product LaTeX- Code and Examples
Dot Product in LaTeX: The Quick Reference
Writing dot product notation in LaTeX trips up almost everyone at first. The syntax isn't obvious, and the standard approach gives you a tiny dot that nobody can read. Here's exactly what you need.
The Basic Dot Product Symbol
The most common way to write dot product in LaTeX uses \cdot. This gives you a centered multiplication dot.
Code:
\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i
Output:
a · b = Σ aᵢbᵢ
Simple enough. But there's more to it than just the symbol.
Dot Product vs. Other Multiplication Symbols
LaTeX gives you several multiplication options. Using the wrong one is a common mistake.
\cdot— centered dot, best for dot product\times— an × symbol, used for cross product\ast— an asterisk, avoid for vectors\odot— circled dot, rarely used
For dot product specifically, \cdot is the standard. Nobody uses the others for this.
Writing Vector Dot Products
When you're working with vectors, you need to make sure the notation is clear. Here are the common approaches:
Using Bold Vectors
\mathbf{u} \cdot \mathbf{v} = |\mathbf{u}| |\mathbf{v}| \cos\theta
This is the standard physics notation. The boldface makes it obvious you're dealing with vectors.
Using Arrow Notation
\vec{a} \cdot \vec{b} = 5
Some prefer arrows over bold. Either works. Pick one and stay consistent throughout your document.
Using Bracket Notation
\langle \mathbf{u}, \mathbf{v} \rangle = \sum_{i=1}^{3} u_i v_i
This inner product notation is common in mathematics. Use \langle and \rangle for the brackets.
Dot Product in Different Math Environments
Inline Math
The dot product is defined as $ \mathbf{a} \cdot \mathbf{b} = \sum a_i b_i $.
Display Math
\[
\mathbf{a} \cdot \mathbf{b} = a_1 b_1 + a_2 b_2 + a_3 b_3
\]
Display math gives you the large, readable version. Use it for important equations.
Practical Examples
2D Vectors
\[
\begin{pmatrix} 1 \\ 2 \end{pmatrix} \cdot
\begin{pmatrix} 3 \\ 4 \end{pmatrix} = 1 \cdot 3 + 2 \cdot 4 = 11
\]
This requires the amsmath package. Add \usepackage{amsmath} to your preamble.
3D Vectors
\[
\begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix} \cdot
\begin{pmatrix} 4 \\ 5 \\ 6 \end{pmatrix} = 4 + 10 + 18 = 32
\]
With Components
\[
\mathbf{a} \cdot \mathbf{b} = a_x b_x + a_y b_y + a_z b_z
\]
Explicit component notation helps readers understand exactly what's happening.
Common Errors and Fixes
- Dot too small? Use
\mediumdotor\largecdotfrom therelsizepackage - Bold not working? Use
\mathbf{}or\boldsymbol{}from amsbsy - Spacing wrong? Add thin spaces with
\,around the dot:a\, \cdot\, b - Package conflicts? Load amsmath last in your preamble
Quick Comparison: Dot Product Notation Methods
| Method | Code | Best For |
|---|---|---|
| Bold vectors | \mathbf{a} \cdot \mathbf{b} |
Physics, engineering |
| Arrow notation | \vec{a} \cdot \vec{b} |
Introductory courses |
| Inner product | \langle a, b \rangle |
Advanced math, functional analysis |
| Matrix notation | \mathbf{a}^T \mathbf{b} |
Machine learning, linear algebra |
Getting Started: Your Minimal Template
Copy this preamble for dot product equations:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
% Inline example
The dot product is $\mathbf{a} \cdot \mathbf{b}$.
% Display example
\[
\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i
\]
\end{document}
That's everything you need. No extra packages required beyond amsmath.
When You Need More Control
For complex documents, you might want physics package. It provides shortcuts:
\dotproduct{a}{b}— automatic dot product\innerproduct{a}{b}— inner product notation
The esvect package gives better-looking arrows for vectors if that's your thing.
The Bottom Line
Use \cdot for dot products. Use \mathbf{} or \vec{} for vectors. Keep it simple. The notation exists to communicate, not to impress anyone.