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

# math constants

> Reference for the 4 constants of the math namespace: math.e, math.phi, math.pi and math.rphi, each with its definition and an example.

> [!NOTE]
>
> Language version: 2 · Reference version: 2.7 · Date: 2026-10-25 · Compiler build: df7b3b14 · Namespace: math · Entries: 4

## `math.e` (constant)

**Definition**

Euler's number: the base of the natural logarithm, 2.718281828459045.

**Type**

`const float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("math.e Example", overlay=false)
// math.log(math.e) is 1
plot(math.log(math.e), title="ln(e)", color=color.blue)
```

## `math.phi` (constant)

**Definition**

The golden ratio: the positive number whose square is one greater than itself, 1.618033988749895.

**Type**

`const float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("math.phi Example", overlay=true)
// A level at the golden ratio of the 50-bar range
hi = talib.highest(high, 50)
lo = talib.lowest(low, 50)
plot(lo + (hi - lo) / math.phi, title="Golden Ratio Level", color=color.orange)
```

## `math.pi` (constant)

**Definition**

Archimedes' constant: the ratio of a circle's circumference to its diameter, 3.141592653589793.

**Type**

`const float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("math.pi Example", overlay=false)
// A sine wave with a 20-bar period
plot(math.sin(2 * math.pi * bar_index / 20), title="Sine Wave", color=color.blue)
```

## `math.rphi` (constant)

**Definition**

The golden ratio conjugate: the reciprocal of the golden ratio, 0.6180339887498948.

**Type**

`const float`

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("math.rphi Example", overlay=true)
// A 0.618 retracement of the 50-bar range
hi = talib.highest(high, 50)
lo = talib.lowest(low, 50)
plot(hi - (hi - lo) * math.rphi, title="0.618 Retracement", color=color.orange)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.