Skip to content

Commit bc97cbc

Browse files
readd transcendental-range
1 parent baa4eb0 commit bc97cbc

18 files changed

Lines changed: 2163 additions & 6 deletions

File tree

.github/workflows/transcendental-range.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
name: Tests
1+
name: transcendental-range
22

33
on:
44
push:
5-
branches: [main]
5+
paths:
6+
- ".github/workflows/transcendental-range.yml"
67
pull_request:
7-
branches: [main]
8+
paths:
9+
- ".github/workflows/transcendental-range.yml"
10+
workflow_dispatch:
11+
12+
defaults:
13+
run:
14+
working-directory: packages/transcendental-range/releases/0.8.0/transcendental-range
815

916
jobs:
1017
test:
1118
runs-on: ${{ matrix.os }}
1219
strategy:
20+
fail-fast: false
1321
matrix:
1422
os: [ubuntu-latest, macos-latest, windows-latest]
1523
python-version: ["3.10", "3.11", "3.12", "3.13"]
@@ -25,7 +33,7 @@ jobs:
2533
- name: Install dependencies
2634
run: |
2735
python -m pip install --upgrade pip
28-
pip install .[dev]
36+
pip install -e ".[dev]"
2937
3038
- name: Run tests
31-
run: pytest tests/ -v
39+
run: pytest -v

packages/transcendental-range/releases/0.8.0/transcendental-range/BENCHMARK.md renamed to packages/transcendental-range/BENCHMARK.md

File renamed without changes.

packages/transcendental-range/releases/0.8.0/transcendental-range/LICENSE renamed to packages/transcendental-range/LICENSE

File renamed without changes.

packages/transcendental-range/releases/0.8.0/transcendental-range/README.md renamed to packages/transcendental-range/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# transcendental-range
22

3+
[![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)
4+
[![PyPI version](https://badge.fury.io/py/transcendental-range.svg)](https://badge.fury.io/py/transcendental-range)
5+
[![Python](https://img.shields.io/pypi/pyversions/transcendental-range.svg)](https://pypi.org/project/transcendental-range/)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7+
38
Generate ranges of transcendental numbers.
49

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

packages/transcendental-range/releases/0.8.0/transcendental-range/benchmark.py renamed to packages/transcendental-range/benchmark.py

File renamed without changes.

packages/transcendental-range/releases/0.8.0/transcendental-range/pyproject.toml renamed to packages/transcendental-range/pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "transcendental-range"
7-
version = "0.8.0"
7+
version = "0.8.1"
88
description = "Generate transcendental numbers within a range using algebraic generators and transcendental functions."
9+
readme = "README.md"
910
requires-python = ">= 3.10"
1011
license = "MIT"
1112
authors = [
@@ -26,5 +27,11 @@ dependencies = [
2627
[project.optional-dependencies]
2728
dev = ["pytest >= 7.0"]
2829

30+
[project.urls]
31+
Homepage = "https://github.com/Daniele-Gregori/PyPI-packages/tree/main/packages/transcendental-range"
32+
Documentation = "https://resources.wolframcloud.com/FunctionRepository/resources/TranscendentalRange/"
33+
Repository = "https://github.com/Daniele-Gregori/PyPI-packages/tree/main/packages/transcendental-range"
34+
Issues = "https://github.com/Daniele-Gregori/PyPI-packages/issues"
35+
2936
[tool.setuptools.packages.find]
3037
where = ["src"]

packages/transcendental-range/releases/0.8.0/transcendental-range/.github/workflows/tests.yml renamed to packages/transcendental-range/releases/0.8.1/transcendental-range/.github/workflows/tests.yml

File renamed without changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Benchmark
2+
3+
Performance of `transcendental_range(lo, hi, method=...)` across all 27 methods and three range sizes.
4+
Measured on Darwin (x86_64), Python 3.14.2.
5+
6+
## Results
7+
8+
| Method | (-10, 10) | (-25, 25) | (-100, 100) |
9+
|--------|-------------|-------------|-------------|
10+
| exp | 208 in 0.07s | 1276 in 0.05s | 20108 in 0.81s |
11+
| log | 82 in 0.01s | 430 in 0.02s | 5064 in 0.19s |
12+
| power | 0 in 0.00s | 0 in 0.00s | 0 in 0.00s |
13+
| sin | 200 in 0.69s | 1250 in 4.48s | timeout |
14+
| cos | 200 in 0.66s | 1250 in 4.31s | timeout |
15+
| tan | 142 in 0.60s | 884 in 3.78s | 14304 in 59.74s |
16+
| cot | 142 in 0.65s | 886 in 4.22s | timeout |
17+
| sec | 120 in 2.30s | 768 in 15.42s | timeout |
18+
| csc | 120 in 2.60s | 766 in 15.98s | timeout |
19+
| sinh | 20 in 0.01s | 58 in 0.01s | 250 in 0.03s |
20+
| cosh | 16 in 0.00s | 48 in 0.01s | 206 in 0.02s |
21+
| tanh | 200 in 0.01s | 892 in 0.05s | 3592 in 0.22s |
22+
| coth | 176 in 0.01s | 840 in 0.04s | 3498 in 0.23s |
23+
| sech | 200 in 0.01s | 1250 in 0.05s | 20000 in 0.80s |
24+
| csch | 200 in 0.01s | 1250 in 0.05s | 20000 in 0.75s |
25+
| asin | 12 in 0.00s | 30 in 0.00s | 126 in 0.01s |
26+
| acos | 12 in 0.00s | 30 in 0.00s | 126 in 0.01s |
27+
| atan | 144 in 0.01s | 854 in 0.03s | 13100 in 0.53s |
28+
| acot | 200 in 0.01s | 1250 in 0.05s | 20000 in 0.82s |
29+
| asec | 206 in 0.02s | 1476 in 0.06s | 25032 in 0.90s |
30+
| acsc | 186 in 0.01s | 1214 in 0.05s | 19862 in 0.79s |
31+
| asinh | 84 in 0.01s | 420 in 0.02s | 4762 in 0.22s |
32+
| acosh | 66 in 0.01s | 360 in 0.01s | 4356 in 0.16s |
33+
| atanh | 0 in 0.00s | 0 in 0.00s | 0 in 0.00s |
34+
| acoth | 180 in 0.01s | 1200 in 0.04s | 19800 in 0.76s |
35+
| asech | 0 in 0.00s | 0 in 0.00s | 0 in 0.00s |
36+
| acsch | 200 in 0.02s | 1250 in 0.05s | 20010 in 0.79s |
37+
38+
## Notes
39+
40+
- **Efficient path** (exp, log, power, all hyp, all inv-trig, all inv-hyp): uses monotonic outer algorithm with float pre-screening and deferred sympy expression creation. All complete in under 1s at (-100, 100).
41+
- **Naive path** (sin, cos, tan, cot, sec, csc): uses brute-force outer product with exact sympy comparisons. These are slow at larger ranges due to the non-monotonic, periodic nature of trig functions.
42+
- **Zero results** for power, atanh, asech: no algebraic irrational generators exist in the given rational ranges (power requires irrational exponents; atanh and asech have restricted domains).
43+
- Timeout threshold: 60s.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Daniele Gregori
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# transcendental-range
2+
3+
[![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)
4+
[![PyPI version](https://badge.fury.io/py/transcendental-range.svg)](https://badge.fury.io/py/transcendental-range)
5+
[![Python](https://img.shields.io/pypi/pyversions/transcendental-range.svg)](https://pypi.org/project/transcendental-range/)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7+
8+
Generate ranges of transcendental numbers.
9+
10+
Python port of the Wolfram Language resource function [TranscendentalRange](https://resources.wolframcloud.com/FunctionRepository/resources/TranscendentalRange).
11+
12+
13+
## Usage
14+
15+
```python
16+
from transcendental_range import transcendental_range
17+
```
18+
19+
**`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*).
20+
21+
**`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*).
22+
23+
**`transcendental_range(x, y, s)`** uses a step parameter *s* for the generator range.
24+
25+
**`transcendental_range(x, y, s, d)`** requires a minimum step *d* between successive elements.
26+
27+
## Details
28+
29+
- `transcendental_range` can systematically generate various types of transcendental numbers.
30+
31+
- 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).
32+
33+
- 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*.
34+
35+
- 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).
36+
37+
- The elements are returned as exact sympy expressions, sorted by numerical value.
38+
39+
## Options
40+
41+
`transcendental_range` accepts the following keyword arguments:
42+
43+
| Option | Default | Description |
44+
|--------|---------|-------------|
45+
| `method` | `'exp'` | Function for generating transcendental numbers |
46+
| `generators_domain` | `'rationals'` | Type of algebraic generators for the function arguments |
47+
| `farey_range` | `False` | Set the step denominators as in the Farey sequence |
48+
| `formula_complexity_threshold` | `math.inf` | Limit the complexity of the expressions |
49+
| `working_precision` | `15` | Precision for all internal numerical evaluations |
50+
51+
### method
52+
53+
The `method` option specifies the transcendental function used to generate numbers. Available values:
54+
55+
| Method | Form |
56+
|--------|------|
57+
| `'exp'` | *b* exp(*a*) |
58+
| `'log'` | *b* log(*a*) |
59+
| `'power'` | *a*^*b* |
60+
| `'sin'`, `'cos'`, `'tan'`, `'cot'`, `'sec'`, `'csc'` | *b* f(*a*) |
61+
| `'sinh'`, `'cosh'`, `'tanh'`, `'coth'`, `'sech'`, `'csch'` | *b* f(*a*) |
62+
| `'asin'`, `'acos'`, `'atan'`, `'acot'`, `'asec'`, `'acsc'` | *b* f(*a*) |
63+
| `'asinh'`, `'acosh'`, `'atanh'`, `'acoth'`, `'asech'`, `'acsch'` | *b* f(*a*) |
64+
| list of the above | combined range |
65+
| `'all'` | all of the above types |
66+
67+
For the method `'power'`, only algebraic irrational generators in the exponent *b* can produce transcendental numbers (Gelfond-Schneider theorem).
68+
69+
### generators_domain
70+
71+
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.
72+
73+
### formula_complexity_threshold
74+
75+
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.
76+
77+
## Examples
78+
79+
```python
80+
from transcendental_range import transcendental_range
81+
82+
transcendental_range(5)
83+
# [exp(1), 2*exp(1)/3, exp(2)/3, 3*exp(1)/4, exp(1)/2, ...]
84+
```
85+
86+
Generate transcendental numbers using the logarithm:
87+
88+
```python
89+
transcendental_range(-2, 2, method='log')
90+
# [-2*log(2), -log(2), log(2), 2*log(2)]
91+
```
92+
93+
Use the `'power'` method with algebraic generators to produce numbers of the form *a*^*b* with irrational exponents (Gelfond-Schneider theorem):
94+
95+
```python
96+
from sympy import Rational
97+
98+
transcendental_range(-1, Rational(3, 2), Rational(1, 2),
99+
method='power', generators_domain='algebraics')
100+
# [(1/2)**sqrt(2), (1/2)**(sqrt(2)/2), (sqrt(2)/2)**(sqrt(2)/2),
101+
# 2**(sqrt(2)/4), (3/2)**(sqrt(2)/2)]
102+
```
103+
104+
Generate transcendental numbers using the inverse tangent (multiples of pi appear naturally):
105+
106+
```python
107+
transcendental_range(-3, 3, method='atan')
108+
# [-2*atan(3), -3*pi/4, -2*atan(2), -pi/2, -atan(3), -atan(2),
109+
# -pi/4, pi/4, atan(2), atan(3), pi/2, 2*atan(2), 3*pi/4, 2*atan(3)]
110+
```
111+
112+
Use step, minimum separation and formula complexity threshold together:
113+
114+
```python
115+
transcendental_range(0, 20, Rational(1, 4), 2, formula_complexity_threshold=6)
116+
# [exp(1/4)/4, 3*exp(1/2)/2, exp(3/2), 4*exp(1/2), 13*E/4,
117+
# 4*E, 19*E/4, 11*E/2, 25*E/4, 7*E]
118+
```
119+
120+
For more examples and details, see the [Wolfram Language documentation](https://resources.wolframcloud.com/FunctionRepository/resources/TranscendentalRange).
121+
122+
## Dependencies
123+
124+
- [sympy](https://www.sympy.org/) >= 1.12
125+
- [algebraic-range](https://pypi.org/project/algebraic-range/) >= 0.8.0
126+
127+
## Author
128+
129+
Daniele Gregori
130+
131+
## License
132+
133+
MIT

0 commit comments

Comments
 (0)