How to produce the mathematical hat symbol or and a wide hat symbol ? \hat and \widehat

\hat and \widehat commands

The \hat and \widehat commands are used in LaTeX to produce the “hat” accent over a symbol, indicating a variable quantity or an estimate of a parameter.

The \hat command produces a small hat, while the \widehat command produces a wider hat that spans the entire width of the symbol.

Examples of using the \hat and \widehat commands

In mathematics and physics, the hat symbol is often used to represent unit vectors, which have a magnitude of 1 and are used to describe the direction of a physical quantity. For example, the unit vector in the x direction is denoted as $\hat{i}$, while the unit vector in the y direction is denoted as $\hat{j}$:

$$\hat{i} = (1, 0, 0) \quad \widehat{\mathbf{r}} = (x, y, z)/\sqrt{x^2 + y^2 + z^2}$$
\[\hat{i} = (1, 0, 0) \quad \widehat{\mathbf{r}} = (x, y, z)/\sqrt{x^2 + y^2 + z^2}\]

In statistics, the hat symbol is often used to denote an estimator of a parameter. For example, the sample mean is denoted as $\hat{\mu}$, which is an estimate of the population mean:

$$\hat{\mu} = \frac{1}{n}\sum_{i=1}^n x_i$$
\[\hat{\mu} = \frac{1}{n}\sum_{i=1}^n x_i\]

In geometry, the hat symbol is used to denote the altitude of a triangle, which is a line segment drawn from a vertex of the triangle perpendicular to the opposite side:

$$h_a = \widehat{BC}$$
\[h_a = \widehat{BC}\]