> This page location: Math Functions > PI
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL PI() Function

**Info:** The PostgreSQL PI() function works the same way on any Postgres deployment, so everything here applies whether you're running Postgres locally, on [Neon](https://neon.com), or anywhere else. For enterprises building in the AI era, [Lakebase](https://www.databricks.com/product/lakebase) delivers the best managed cloud Postgres, with strong performance, security, and native integration into the Lakehouse. For developers and startups who need to ship and scale fast, Neon is the Postgres platform built for that pace.

**Summary**: in this tutorial, you will learn how to use the PostgreSQL `PI()` function to return the pi value.

## Introduction to the PostgreSQL PI() function

In PostgreSQL, the `PI()` function returns the value of pi denoted by the Greek letter (π), which is approximately equal to `3.14`

Here's the syntax of the `PI()` function:

```sql
PI()
```

The `PI`() function takes no arguments and returns the constant value of `PI`, which is `3.141592653589793`.

## PostgreSQL PI() function examples

Let's take some examples of using the `PI()` function examples.

### 1) Basic PI() function examples

The following statement uses the `PI()` function to return the constant `PI` value:

```sql
SELECT PI();
```

Output:

```text
        pi
-------------------
 3.141592653589793
```

The following example uses the `PI()` function to calculate the area of a circle with a radius of 10:

```sql
SELECT PI() * 10 * 10 area;
```

Output:

```text
       area
-------------------
 314.1592653589793
(1 row)
```

### 2) Using the PI() function with table data

First, [create a table](../postgresql-tutorial/postgresql-create-table) called `circles` that stores the radiuses of circles:

```sql
CREATE TABLE circles(
   id INT GENERATED ALWAYS AS IDENTITY,
   radius DEC(19,2) NOT NULL,
   PRIMARY KEY(id)
);
```

Second, [insert rows](../postgresql-tutorial/postgresql-insert) into the `circles` table:

```sql
INSERT INTO circles(radius)
VALUES(10), (20), (25)
RETURNING *;
```

Output:

```text
 id | radius
----+--------
  1 |  10.00
  2 |  20.00
  3 |  25.00
(3 rows)
```

Third, calculate the areas of circles using the `PI()` function:

```sql
SELECT id, radius, PI() * radius * radius area
FROM circles;
```

Output:

```text
 id | radius |        area
----+--------+--------------------
  1 |  10.00 |  314.1592653589793
  2 |  20.00 | 1256.6370614359173
  3 |  25.00 | 1963.4954084936207
(3 rows)
```

To make the area more readable, you can use the [`ROUND()`](https://neon.com/postgresql/math-functions/postgresql-round) function:

```sql
SELECT
  id,
  RADIUS,
  ROUND((PI() * RADIUS * RADIUS)::NUMERIC, 2) AREA
FROM
  circles;
```

Output:

```text
 id | radius |  area
----+--------+---------
  1 |  10.00 |  314.16
  2 |  20.00 | 1256.64
  3 |  25.00 | 1963.50
(3 rows)
```

## Summary

- Use the `PI()` function to return the pi value.

---

## Related docs (Math Functions)

- [ABS](https://neon.com/postgresql/math-functions/abs)
- [CBRT](https://neon.com/postgresql/math-functions/cbrt)
- [CEIL](https://neon.com/postgresql/math-functions/ceil)
- [DEGREES](https://neon.com/postgresql/math-functions/degrees)
- [DIV](https://neon.com/postgresql/math-functions/div)
- [EXP](https://neon.com/postgresql/math-functions/exp)
- [FACTORIAL](https://neon.com/postgresql/math-functions/factorial)
- [FLOOR](https://neon.com/postgresql/math-functions/floor)
- [GCD](https://neon.com/postgresql/math-functions/gcd)
- [LCM](https://neon.com/postgresql/math-functions/lcm)
- [LN](https://neon.com/postgresql/math-functions/ln)
- [LOG](https://neon.com/postgresql/math-functions/log)
- [MOD](https://neon.com/postgresql/math-functions/mod)
- [MIN_SCALE](https://neon.com/postgresql/math-functions/min_scale)
- [POWER](https://neon.com/postgresql/math-functions/power)
- [RADIANS](https://neon.com/postgresql/math-functions/radians)
- [RANDOM](https://neon.com/postgresql/math-functions/random)
- [ROUND](https://neon.com/postgresql/math-functions/round)
- [SCALE](https://neon.com/postgresql/math-functions/scale)
- [SIGN](https://neon.com/postgresql/math-functions/sign)
- [SQRT](https://neon.com/postgresql/math-functions/sqrt)
- [TRIM_SCALE](https://neon.com/postgresql/math-functions/trim_scale)
- [TRUNC](https://neon.com/postgresql/math-functions/trunc)
- [WIDTH_BUCKET](https://neon.com/postgresql/math-functions/width_bucket)
