# `numlib`::`pi`

Number of primes up to a given bound

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```numlib::pi(`x`)
```

## Description

`numlib::pi(x)` returns the number of primes not exceeding x.

If the argument `x` is a real number (an integer, rational, or floating-point number), then the number of primes below `x` is returned. If `x` is a complex number, `numlib::pi` stops with an error. For every other kind of arithmetical expression `x`, an unevaluated call is returned.

`numlib::pi` becomes slightly faster if the internal prime number table is large. `ifactor``(PrimeLimit)` displays the limit of the internal prime number table; it can be set by the user via the command line flag `-L`.

Internally, a fast kernel function with constant memory consumption is used for the computation.

## Examples

### Example 1

There are two primes less or equal 3:

`numlib::pi(3)`
` `

### Example 2

Also larger inputs can be handled fast:

`numlib::pi(150000000)`
` `

### Example 3

Floating point arguments are allowed, too.

`numlib::pi(28.72)`
` `

## Parameters

 `x`

## Return Values

Non-negative integer or an unevaluated call to `numlib::pi`

## Algorithms

A Lehmer-type algorithm is used, with no precomputed sieve array and no remember tables. In contrast to the algorithm in “Computing π: The Meissel-Lehmer method”, this means constant memory consumption, at the price of slowness.

## References

 Lagarias, J.C., V.S. Miller, and A.M. Odlyzko. “Computing π: The Meissel-Lehmer method”, Math. Comp., Vol. 44, No. 170 (1985), pp. 537-560