Details and Options
AlgebraicRange creates ranges made of
algebraic numbers. This extends the basic concept of
Range to include, besides
Rational numbers, also roots, always restricted to the
Reals 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).
If no step parameter is specified, the elementary algebraic range
ResourceFunction["AlgebraicRange"][x,y] is determined by the square root range
Sqrt[Range[x^2,y^2]], for
x,y>0. The extension to negative bounds
x <0 or
y<0 is performed simply by reflection, since general real roots are mathematically defined only for positive arguments.
The step between successive algebraics is not straightforward to define univocally, as there exists no constant difference among the irrational numbers generated even with the elementary algebraic range. However, it turns out that an intuitively simple class of algebraic ranges, with non-unit step parameter
s, is obtained by taking the Outer product of
ResourceFunction["AlgebraicRange"][Min[x,x/s],y] with
Join[Range[0,Max[1, s], s], Range[Max[1, s], y, s]], for
0<s<=y-x and
0<=x<=y. Then the parameter
s also becomes the upper bound for all the steps. For example,

This definition of algebraic step is more easily conveyed in terms of
Outer, but if implemented literally it would lead to an intrinsically inefficient algorithm, for which
Timing would scale quadratically with respect to the size of the input arguments. Thus, the actual algorithm implemented by
ResourceFunction["AlgebraicRange"] generates output equivalent to
Outer but is internally more refined - crucially leveraging the function
Nearest inside
For loops - and effectively scales with linear time complexity.
The algebraic numbers thus generated can often be in a great number, with a tendency to accumulate towards certain points. To avoid these features, a further fourth argument d can be optionally provided to require a minimum (absolute value) difference between successive algebraics, that is a lower bound for all the steps. This truncation process typically leads to a nearly uniform distribution of numeric values.
Extended functionality and syntax, especially for creating algebraic numbers of a more general form, are provided in the homonymous function of the paclet
DanieleGregori/GeneralizedRange.
A natural application of AlgebraicRange is in the search for closed forms for floating point numbers, possibly in terms of arbitrary combinations of mathematical functions with algebraic arguments, through ResourceFunction["
FindClosedForm"].
ResourceFunction["AlgebraicRange"] accepts the following options:
| "RootOrder" | 2 | the root orders to be included |
| "StepMethod" | "Outer" | change the method to define the step |
| "FareyRange" | False | generate algebraic numbers with steps given by the Farey sequence |
| "FormulaComplexity" | Infinity | set a complexity threshold over which the algebraics are discarded |
| "AlgebraicsOnly" | True | accept only algebraic arguments and output |
| WorkingPrecision | MachinePrecision | set the precision for all internal numerical evaluations |
The option "RootOrder" can take the following values:
| r | include roots up to r order |
| {r} | include only roots of order r |
| {r1,r2,…} | include roots of all specified orders rk |
The option "StepMethod" can be used to define the step in ResourceFunction["AlgebraicRange"][x,y,s] and can take the following values, for 0<=x<=y, 0<s<=y-x:
| "Outer" | take the Outer product of ResourceFunction["AlgebraicRange"][Min[x,x/s],y] with Join[Range[0,Max[1, s], s]],Range[Max[1, s], y, s]] |
| "Root" | use Sqrt[Range[x^2,y^2,s^2]] |
A more detailed explanation of the step definition, also for negative arguments, can be found in the Properties and Relations examples.
Besides using the fourth argument to impose a lower bound on the steps, another way to restrict the output of
ResourceFunction["AlgebraicRange"] is by setting a threshold for the complexity of the numeric expressions involved through the option "FormulaComplexity". The corresponding numerical values are not meaningful in practice and should be determined through a heuristic approach. A user interested in precise computations of the underlying
homonymous function may use the paclet "
DanieleGregori/GeneralizedRange".