|
| 1 | +# transcendental-range |
| 2 | + |
| 3 | +[](https://github.com/Daniele-Gregori/PyPI-packages/actions/workflows/transcendental-range.yml) |
| 4 | +[](https://badge.fury.io/py/transcendental-range) |
| 5 | +[](https://pypi.org/project/transcendental-range/) |
| 6 | +[](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