> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for LOG function

# LOG

Returns the common (base 10) logarithm of a numerical expression, or the logarithm to an arbitrary base if specified as the first argument.
The value for which `log` is computed needs to be larger than 0, otherwise an error is returned.
If a base is provided, it also needs to be larger than 0 and not equal to 1.
You can use the function [LN](/reference-sql/functions-reference/numeric/ln) to compute the natural logarithm (base e).

**Alias:** `LOG10` (does not support a custom `base` argument)

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
LOG([<base>,] <value>);
```

## Parameters

| Parameter | Description                                                   | Supported input types |
| :-------- | :------------------------------------------------------------ | :-------------------- |
| `<base>`  | Optional. The base for the logarithm. The default base is 10. | `DOUBLE PRECISION`    |
| `<value>` | The value for which to compute the logarithm.                 | `DOUBLE PRECISION`    |

## Return Type

`DOUBLE PRECISION`

## Example

The following example returns the logarithm of 64.0 to base 2:

<div className="query-window">
  ```
  SELECT LOG(2, 64.0);
  ```

  | log <span>double</span> |
  | :---------------------- |
  | 6                       |

  <p><span>Rows: 1</span><span>Execution time: 5.31ms</span></p>
</div>

The following example returns the logarithm of 100.0 to the default base 10:

<div className="query-window">
  ```
  SELECT LOG(100.0), LOG10(100.0);
  ```

  | log <span>double</span> | log10 <span>double</span> |
  | :---------------------- | :------------------------ |
  | 2                       | 2                         |

  <p><span>Rows: 1</span><span>Execution time: 5.68ms</span></p>
</div>

The logarithm can only be computed for values that are larger than 0. All the following functions return an error:

<div className="query-window">
  ```
  SELECT LOG(0.0);
  -- SELECT LOG(-1.0);
  -- SELECT LOG('-Inf');
  ```

  \|  |
  \|  |

  <p><span>Rows: 0</span><span>Execution time: 0.69ms</span></p>
</div>

When a base is provided, it needs to be positive and not equal to zero. All the following functions return an error:

<div className="query-window">
  ```
  SELECT LOG(0.0, 10.0);
  -- SELECT LOG(-1.0, 10.0);
  -- SELECT LOG(1.0, 10.0);
  -- SELECT LOG('-Inf', 10.0);
  ```

  \|  |
  \|  |

  <p><span>Rows: 0</span><span>Execution time: 0.68ms</span></p>
</div>
