# \log

Used for logarithms in algebra, calculus, asymptotics, and applied mathematics

https://texform.dev/latex/commands/log

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Functions and operators](https://texform.dev/latex/topics/functions) |
| Packages | base, physics |
| Allowed mode | math |
| Tags |  |
| Commonality | high |
| Kind | prefix |

## Syntax

### base

Argument specification: ``

Used for logarithms in algebra, calculus, asymptotics, and applied mathematics

### physics

Argument specification: `o d()`

Used for logarithm notation, including the physics package's bracketed power/base-like form such as \log[2](x).

## Common tasks

### How to write a logarithm

```latex
\log x
```

[Open in Playground](https://play.texform.dev/?input=%5Clog+x)

### How to write a logarithm with a base

```latex
\log_2 n
```

[Open in Playground](https://play.texform.dev/?input=%5Clog_2+n)

### How to write a log in big-O notation

```latex
O(n\log n)
```

[Open in Playground](https://play.texform.dev/?input=O%28n%5Clog+n%29)

## Examples

```latex
\log
```

[Open in Playground](https://play.texform.dev/?input=%5Clog)

```latex
\log x
```

[Open in Playground](https://play.texform.dev/?input=%5Clog+x)

```latex
\log[2](x)
```

[Open in Playground](https://play.texform.dev/?input=%5Clog%5B2%5D%28x%29)

## Package variants

| Package | Argument specification | Allowed mode | Description |
| --- | --- | --- | --- |
| base |  | math | Used for logarithms in algebra, calculus, asymptotics, and applied mathematics |
| physics | o d() | math | Used for logarithm notation, including the physics package's bracketed power/base-like form such as \log[2](x). |

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| base | full | full | full |
| physics | full | full | full |

## Usage frequency

3.19% of formulas in the measured corpus contain this entry, rank 19 of 263 entries with frequency data.

## In TeXForm

TeXForm parses this entry as prefix syntax; the package determines its argument specification.

### [physics/named-fn-paren-expand](https://texform.dev/rules/physics/named-fn-paren-expand)

Expand physics power and auto-sized parenthesis arguments of standard named functions.

Level: faithful. Fidelity: reading.

```latex
\sin(#1)
```

→

```latex
\sin\left(#1\right)
```

```latex
\sin(x+(y-z)\frac{a}{b})
```

→

```latex
\sin\left(x+(y-z)\frac{a}{b}\right)
```

## See also

- [\\acos](https://texform.dev/latex/commands/acos)
- [\\acosecant](https://texform.dev/latex/commands/acosecant)
- [\\acosine](https://texform.dev/latex/commands/acosine)
- [\\acot](https://texform.dev/latex/commands/acot)
- [\\acotangent](https://texform.dev/latex/commands/acotangent)
- [\\acsc](https://texform.dev/latex/commands/acsc)
- [\\arccos](https://texform.dev/latex/commands/arccos)
- [\\arccosecant](https://texform.dev/latex/commands/arccosecant)
- [\\arccosine](https://texform.dev/latex/commands/arccosine)
- [\\arccot](https://texform.dev/latex/commands/arccot)
- [\\arccotangent](https://texform.dev/latex/commands/arccotangent)
- [\\arccsc](https://texform.dev/latex/commands/arccsc)
- [\\arcsec](https://texform.dev/latex/commands/arcsec)
- [\\arcsecant](https://texform.dev/latex/commands/arcsecant)
- [\\arcsin](https://texform.dev/latex/commands/arcsin)
- [\\arcsine](https://texform.dev/latex/commands/arcsine)
- [\\arctan](https://texform.dev/latex/commands/arctan)
- [\\arctangent](https://texform.dev/latex/commands/arctangent)
- [\\arg](https://texform.dev/latex/commands/arg)
- [\\asec](https://texform.dev/latex/commands/asec)
- [\\asecant](https://texform.dev/latex/commands/asecant)
- [\\asin](https://texform.dev/latex/commands/asin)
- [\\asine](https://texform.dev/latex/commands/asine)
- [\\atan](https://texform.dev/latex/commands/atan)
- [\\atangent](https://texform.dev/latex/commands/atangent)
- [\\cos](https://texform.dev/latex/commands/cos)
- [\\cosecant](https://texform.dev/latex/commands/cosecant)
- [\\cosh](https://texform.dev/latex/commands/cosh)
- [\\cosine](https://texform.dev/latex/commands/cosine)
- [\\cot](https://texform.dev/latex/commands/cot)
- [\\cotangent](https://texform.dev/latex/commands/cotangent)
- [\\coth](https://texform.dev/latex/commands/coth)
- [\\csc](https://texform.dev/latex/commands/csc)
- [\\csch](https://texform.dev/latex/commands/csch)
- [\\deg](https://texform.dev/latex/commands/deg)
- [\\det](https://texform.dev/latex/commands/det)
- [\\determinant](https://texform.dev/latex/commands/determinant)
- [\\dim](https://texform.dev/latex/commands/dim)
- [\\erf](https://texform.dev/latex/commands/erf)
- [\\exp](https://texform.dev/latex/commands/exp)
- [\\exponential](https://texform.dev/latex/commands/exponential)
- [\\hom](https://texform.dev/latex/commands/hom)
- [\\hypcosecant](https://texform.dev/latex/commands/hypcosecant)
- [\\hypcosine](https://texform.dev/latex/commands/hypcosine)
- [\\hypcotangent](https://texform.dev/latex/commands/hypcotangent)
- [\\hypsecant](https://texform.dev/latex/commands/hypsecant)
- [\\hypsine](https://texform.dev/latex/commands/hypsine)
- [\\hyptangent](https://texform.dev/latex/commands/hyptangent)
- [\\ker](https://texform.dev/latex/commands/ker)
- [\\lg](https://texform.dev/latex/commands/lg)
- [\\ln](https://texform.dev/latex/commands/ln)
- [\\logarithm](https://texform.dev/latex/commands/logarithm)
- [\\naturallogarithm](https://texform.dev/latex/commands/naturallogarithm)
- [\\Pr](https://texform.dev/latex/commands/Pr)
- [\\Probability](https://texform.dev/latex/commands/Probability)
- [\\rank](https://texform.dev/latex/commands/rank)
- [\\sec](https://texform.dev/latex/commands/sec)
- [\\secant](https://texform.dev/latex/commands/secant)
- [\\sech](https://texform.dev/latex/commands/sech)
- [\\sin](https://texform.dev/latex/commands/sin)
- [\\sine](https://texform.dev/latex/commands/sine)
- [\\sinh](https://texform.dev/latex/commands/sinh)
- [\\tan](https://texform.dev/latex/commands/tan)
- [\\tangent](https://texform.dev/latex/commands/tangent)
- [\\tanh](https://texform.dev/latex/commands/tanh)
- [\\tr](https://texform.dev/latex/commands/tr)
- [\\Tr](https://texform.dev/latex/commands/Tr)
- [\\trace](https://texform.dev/latex/commands/trace)
- [\\Trace](https://texform.dev/latex/commands/Trace)

## Test cases

### base

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \log | Positive: baseline | Pass | Pass | Pass |

### physics

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \log | Positive: baseline | Pass | Pass | Pass |
| \log[a] | Positive: vary:o[0] | Pass | Pass | Pass |
| \log (a) | Positive: vary:d[1] | Pass | Pass | Pass |
| \log[a](b) | Positive: maximal | Pass | Pass | Pass |
