As of now, for use with EC2, Python3.8.10 (and no later) is required. For local usage, later versions are also OK.
pip install git+https://github.com/RamanujanMachine/LIReC.git
from LIReC.db.access import db
pcfs = db.get_actual_pcfs()
Each pcf is of PCF class which is defined in lib\pcf.py
To access the properties of each pcf:
pcf = pcfs[0]
pcf.a # Polynomial of a_n
pcf.b # Polynomial of b_n
pcf.a.all_coeffs() # List of the coefficients of a_n
pcf.b.all_coeffs() # Same for b_n
from LIReC.db.access import db
db.identify(...)
The db.identify
function allows one to check one (or more) numeric values against the known "famous" constants in the database for the existence of polynomial relations. This is done in three steps:
- First, any decimal expressions within
values
(see below) are tested against each other for relation. This can be skipped by inputtingfirst_step=False
(see below). - If nothing was found yet, all expressions in
values
are tested together for a relation. - Finally, if still nothing was found and
wide_search
is truthy (see below), executes an iterative search against all named constants in the database, stopping at the first relation found.
The inputs are:
values
: List that contains any combination of the following:- Numeric values. It is not recommended to use python's native
float
type as it cannot reach high precision. Instead, usestr
(ordecimal.Decimal
ormpmath.mpf
) for better results. Each such value will be given a namec{i}
wherei
is its position invalues
, and these are assumed to all be accurate up to the least accurate value among them (unlessmin_prec
is specified, see below). If this is not the case, input less digits or explicitly specifymin_prec
. - Strings that represent famous constants. For a full list of possible names try
db.names
. Also trydb.names_with_descriptions
for a full list of names along with a short description of each name, ordb.describe
to conveniently fish out the description of any one name in the database (if it exists). Sympy
expressions that involve one or more famous constants. Can be inputted either in string form or assympy.Expr
form.
- Numeric values. It is not recommended to use python's native
degree
: The maximal degree of the relation. Each relation is defined as the coefficients of a multivariate polynomial, where each monomial (in multi-index notation) is of the form a_alpha * x ** alpha. Then, the degree is the L1 norm on alpha. Defaults to 2.order
: The maximal order of the relation, which is the L-infinity norm on each alpha (see degree). Defaults to 1.min_prec
: The minimal digital precision expected of the numbers invalues
. Can be omitted, in which case it will be inferred fromvalues
, see above.min_roi
: Given a vector of random numbers, the total amount of digits in an integer relation on them is usually about the same as the working precision. To differentiate between such "garbage" cases and potentially substantive results, any relation found will be required to havemin_roi
times less digits than the working precision to be returned. Defaults to2
.isolate
: Modifies the way results will be printed:- If set to
False
, results will be printed in the formexpr = 0 (precision)
, whereprecision
specifies how many digits the computer knows for sure satisfy the equality. This is the default option. - If set to
True
, will take the first recognized named constant and isolate it as a function of all other constants in the relations it participates in, resulting in the formconst = expr (precision)
. - If set to a number
i
, will similarly isolatevalues[i]
as a function of everything else.
- If set to
first_step
: Whether or not to perform the first step of identification (see above). Defaults toTrue
.wide_search
: If truthy, enables the wide search (see above). Also, if this is alist
(or any kind of collection) of positive integers, the search is limited to subsets of sizes contained inwide_search
. Do note that the wide search may take a long time, so Ctrl+C it if you have to. Defaults toFalse
.verbose
: If set toTrue
, will print various messages regarding the input/output and progress. Defaults toFalse
.
The result of calling identify
is a list of pslq_util.PolyPSLQRelation
objects. These can be casted into a string that represents the relation and its estimated precision. For instance, try this code snippet:
from LIReC.db.access import db
import mpmath as mp
mp.mp.dps=400
results = db.identify([(100-mp.zeta(3))/(23+5*mp.zeta(3)), 'Zeta3']) # first run should take a few seconds to query the db...
print([str(x) for x in results])
results = db.identify([mp.mpf(1)/3 - mp.zeta(3), 'Zeta3']) # this works
print([str(x) for x in results])
results = db.identify([1/3 - mp.zeta(3), 'Zeta3']) # this doesn't! don't let bad floats pollute your numbers!
print([str(x) for x in results])