Skip to main content

Generate ranges of algebraic numbers

Project description

algebraic-range

Tests PyPI version Python License: MIT

Generate ranges of algebraic numbers.

Python port of the Wolfram resource function "AlgebraicRange" resource function.

Requires SymPy ≥ 1.12.

Overview

algebraic_range creates ranges made of algebraic numbers. This extends the basic concept of range() to include, besides rational numbers, also roots — always restricted to the real domain.

The first two arguments represent the bounds of the range (minimum and maximum values), while the optional third and fourth arguments (by default equal to 1 and 0) regulate the upper and lower bounds of the steps (differences between successive elements).

Usage

algebraic_range(x)                # Sqrt[Range[1, x²]]  for x ≥ 1
algebraic_range(x, y)             # Sqrt[Range[x², y²]]  for 0 ≤ x ≤ y
algebraic_range(x, y, s)          # step upper bound s,  0 < s ≤ y
algebraic_range(x, y, s, d)       # step lower bound d,  0 ≤ d ≤ s

Parameters

Parameter Default Description
r1 (required) Start of range (or single argument)
r2 None End of range
s None Step upper bound (negative → descending)
d 0 Step lower bound
root_order 2 int r → orders 2..r; [r] → only order r; [r1,r2,…] → listed orders
step_method "Outer" "Outer" or "Root"
farey_range False Use Farey-sequence–based rational multipliers
formula_complexity_threshold inf Discard elements above this complexity
algebraics_only True Reject transcendental inputs

Options

root_order

# Include square and cubic roots
algebraic_range(2, root_order=3)

# Only cubic roots
algebraic_range(2, root_order=[3])

# Cubic and fifth roots
algebraic_range(1, Rational(3, 2), root_order=[3, 5])

step_method

# "Root" method: Sqrt[Range[x², y², s²]]
algebraic_range(0, 3, Rational(1, 3), step_method="Root")

The default "Outer" method uses the outer product construction. The "Root" method is generally a superset.

farey_range

algebraic_range(0, 3, Rational(1, 3), farey_range=True)

Generalises FareyRange by combining algebraic ranges over all Farey-sequence steps.

formula_complexity_threshold

# Only keep simple expressions
algebraic_range(4, root_order=4, formula_complexity_threshold=8)

algebraics_only

from sympy import sqrt, E

# This raises NotAlgebraicError:
# algebraic_range(0, 5, sqrt(E))

# Allow transcendental step:
algebraic_range(0, 5, sqrt(E), algebraics_only=False)

See also

For more details, properties and examples see the full documentation for the original Wolfram Language resource function AlgebraicRange, contributed by the same author and vetted by the Wolfram Review Team.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

algebraic_range-0.8.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

algebraic_range-0.8.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file algebraic_range-0.8.1.tar.gz.

File metadata

  • Download URL: algebraic_range-0.8.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for algebraic_range-0.8.1.tar.gz
Algorithm Hash digest
SHA256 0782564d8bab77056f762966c458ddc20b4fab47910c5fbc8ee2fb51e38138e1
MD5 f58e3ab60d2dc3442abd0c8983e1f9a1
BLAKE2b-256 2ab4a9c252cbed6b7970b7e52a9da66998b71ad1ed22a20a3e9f8cb6f8c6ebea

See more details on using hashes here.

File details

Details for the file algebraic_range-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for algebraic_range-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aaa7d3c805037efa3d6b6bc90eecd4e60b67c0208aec03d9a10a1ac4df90a36d
MD5 9d18b5cb7da9b75648e51ea4c365d3af
BLAKE2b-256 4b0679794d971d867bae2f3033ee3507a9fac0f228d1e624f5d7486180cb07fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page