# transcendental-range

[![Tests](https://github.com/Daniele-Gregori/PyPI-packages/actions/workflows/transcendental-range.yml/badge.svg)](https://github.com/Daniele-Gregori/PyPI-packages/actions/workflows/transcendental-range.yml)
[![PyPI version](https://badge.fury.io/py/transcendental-range.svg)](https://badge.fury.io/py/transcendental-range)
[![Python](https://img.shields.io/pypi/pyversions/transcendental-range.svg)](https://pypi.org/project/transcendental-range/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Generate ranges of transcendental numbers.

Python port of the Wolfram Language resource function [TranscendentalRange](https://resources.wolframcloud.com/FunctionRepository/resources/TranscendentalRange).


## Usage

```python
from transcendental_range import transcendental_range
```

**`transcendental_range(x)`** gives all transcendental numbers of the form *t* = *b* e^*a* with 1 <= *t* <= *x* and *a*, *b* algebraics in range(1, *x*).

**`transcendental_range(x, y)`** gives all transcendental numbers of the form *t* = *b* e^*a* with *x* <= *t* <= *y* and *a*, *b* algebraics in range(*x*, *y*).

**`transcendental_range(x, y, s)`** uses a step parameter *s* for the generator range.

**`transcendental_range(x, y, s, d)`** requires a minimum step *d* between successive elements.

## Details

- `transcendental_range` can systematically generate various types of transcendental numbers.

- Transcendental numbers are irrational numbers that cannot be expressed as solutions of any polynomial equation with integer coefficients (that is, they are not algebraic numbers).

- By default, the range elements are generated according to the Lindemann-Weierstrass theorem, that is linear combinations of exponentials *t* = *b* e^*a*, for all algebraic arguments and coefficients *a*, *b* that are members of range(*x*, *y*), or possibly range(*x*, *y*, *s*) using a step parameter *s*.

- For all the available transcendental types, the generated exact numbers have been mathematically proven to be transcendental through the theorems of Lindemann-Weierstrass, Gelfond-Schneider and Baker (cf. Baker, 1975 - Transcendental Number Theory).

- The elements are returned as exact sympy expressions, sorted by numerical value.

## Options

`transcendental_range` accepts the following keyword arguments:

| Option | Default | Description |
|--------|---------|-------------|
| `method` | `'exp'` | Function for generating transcendental numbers |
| `generators_domain` | `'rationals'` | Type of algebraic generators for the function arguments |
| `farey_range` | `False` | Set the step denominators as in the Farey sequence |
| `formula_complexity_threshold` | `math.inf` | Limit the complexity of the expressions |
| `working_precision` | `15` | Precision for all internal numerical evaluations |

### method

The `method` option specifies the transcendental function used to generate numbers. Available values:

| Method | Form |
|--------|------|
| `'exp'` | *b* exp(*a*) |
| `'log'` | *b* log(*a*) |
| `'power'` | *a*^*b* |
| `'sin'`, `'cos'`, `'tan'`, `'cot'`, `'sec'`, `'csc'` | *b* f(*a*) |
| `'sinh'`, `'cosh'`, `'tanh'`, `'coth'`, `'sech'`, `'csch'` | *b* f(*a*) |
| `'asin'`, `'acos'`, `'atan'`, `'acot'`, `'asec'`, `'acsc'` | *b* f(*a*) |
| `'asinh'`, `'acosh'`, `'atanh'`, `'acoth'`, `'asech'`, `'acsch'` | *b* f(*a*) |
| list of the above | combined range |
| `'all'` | all of the above types |

For the method `'power'`, only algebraic irrational generators in the exponent *b* can produce transcendental numbers (Gelfond-Schneider theorem).

### generators_domain

The `generators_domain` option specifies whether the arguments *a*, *b* should belong to the rationals (`'rationals'`) or to the algebraics (`'algebraics'`), as generated by `range` and [`algebraic_range`](https://pypi.org/project/algebraic-range/) respectively. These are restricted to be real numbers.

### formula_complexity_threshold

The output can be restricted by setting a threshold for the complexity of the numeric expressions involved. The corresponding numerical values are assigned through a heuristic recipe provided by `formula_complexity` from the [`algebraic-range`](https://pypi.org/project/algebraic-range/) package.

## Examples

```python
from transcendental_range import transcendental_range

transcendental_range(10)
# [E, 2*E, exp(2), 3*E]
```

Generate transcendental numbers using the logarithm:

```python
transcendental_range(-2, 2, method='log')
# [-2*log(2), -log(2), log(2), 2*log(2)]
```

Use the `'power'` method with algebraic generators to produce numbers of the form *a*^*b* with irrational exponents (Gelfond-Schneider theorem):

```python
from sympy import Rational

transcendental_range(-1, Rational(3, 2), Rational(1, 2),
                     method='power', generators_domain='algebraics')
# [(1/2)**sqrt(2), (1/2)**(sqrt(2)/2), (sqrt(2)/2)**(sqrt(2)/2),
#  2**(sqrt(2)/4), (3/2)**(sqrt(2)/2)]
```

Generate transcendental numbers using the inverse tangent (multiples of pi appear naturally):

```python
transcendental_range(-3, 3, method='atan')
# [-2*atan(3), -3*pi/4, -2*atan(2), -pi/2, -atan(3), -atan(2),
#  -pi/4, pi/4, atan(2), atan(3), pi/2, 2*atan(2), 3*pi/4, 2*atan(3)]
```

Use step, minimum separation and formula complexity threshold together:

```python
transcendental_range(0, 20, Rational(1, 4), 2, formula_complexity_threshold=6)
# [exp(1/4)/4, 3*exp(1/2)/2, exp(3/2), 4*exp(1/2), 13*E/4,
#  4*E, 19*E/4, 11*E/2, 25*E/4, 7*E]
```

For more examples and details, see the [Wolfram Language documentation](https://resources.wolframcloud.com/FunctionRepository/resources/TranscendentalRange).

## Dependencies

- [sympy](https://www.sympy.org/) >= 1.12
- [algebraic-range](https://pypi.org/project/algebraic-range/) >= 0.8.0

## Author

Daniele Gregori

## License

MIT
