helpers
¶
Miscellaneous mathematical helper functions.
- exception sage_acsv.helpers.ACSVException(message, retry=False)[source]¶
- property retry¶
Initialize self. See help(type(self)) for accurate signature.
- class sage_acsv.helpers.Term(coefficient: Expression | AlgebraicNumber, pi_factor: Expression, base: Expression | AlgebraicNumber, power: Expression | AlgebraicNumber)[source]¶
A dataclass for storing the decomposed terms of an asymptotic expression.
INPUT:
coefficient
– The coefficient of the termpi_factor
– The factor of pi in the termbase
– The base of the termpower
– The power of the term
OUTPUT:
A dataclass with the given attributes.
EXAMPLES:
sage: from sage_acsv.helpers import Term sage: Term(1, 1/sqrt(pi), 4, -1/2) Term(coefficient=1, pi_factor=1/sqrt(pi), base=4, power=-1/2)
- base: Expression | AlgebraicNumber¶
- coefficient: Expression | AlgebraicNumber¶
- pi_factor: Expression¶
- power: Expression | AlgebraicNumber¶
- sage_acsv.helpers.compute_hessian(H, variables, r, critical_point=None)[source]¶
Computes the Hessian of an implicitly defined function.
The computed matrix is the Hessian of the map
\[(t_1,...t_{d-1}) \mapsto \log(g(z_1t_1,...,z_{d-1}t_{d-1}))/g(z_1,...,z_{d-1}) + I\cdot (r_1t_1+...+r_{d-1}t_{d-1})/r_d \]at a critical point where the partial derivative of \(H\) with respect to \(z_d\) is non-zero, and \(g\) determined implicitly by
\[H(z_1,...,z_{d-1}, g(z_1,...,z_{d-1})) = 0.\]INPUT:
H
– A polynomial; the denominator of the rational generating function \(F = G/H\).vs
– A list of variablesz_1, ..., z_d
r
– The direction. A vector of length \(d\) with positive algebraic numbers (usually integers) as coordinates.critical_point
– (Optional) A critical point of the map at which to evaluate the Hessian. If not specified, the symbolic Hessian is returned.
OUTPUT:
A matrix representing the specified Hessian.
- sage_acsv.helpers.compute_implicit_hessian(Hs, vs, r, subs)[source]¶
Compute the Hessian of an implicitly defined function.
Given a transverse intersection point \(w\) in \(H_1(w),\dots,H_s(w)=0\), we can parametrize \(V(H_1,\dots,H_s)\) near \(w\) by writing \(z_{d-s+j} = g_j(z_1,\dots,z_{d-s})\).
Let \(h(\theta_1,\dots,\theta_{d-s}) = \sum_{j=1}^s r_{d-s+j}\log g_j({w_1 \exp(i\theta_1) \dots w_{d-s} \exp(i\theta_{d-s})})\). This function returns the Hessian of \(h\).
INPUT:
Hs
– A list of polynomials \(H\)vs
– A list of variables in the equationr
– A direction vectorsubs
– a dictionary{v_i: w_i}
defining the point w
OUTPUT:
The Hessian of the implicitly defined function \(h\) defined above.
EXAMPLES:
sage: from sage_acsv.helpers import compute_implicit_hessian sage: R.<x,y,z,w> = PolynomialRing(QQ,4) sage: Hs = [ ....: z^2+z*w+x*y-4, ....: w^3+z*x-y ....: ] sage: compute_implicit_hessian(Hs, [x,y,z,w], [1,1,1,1], {x:1,y:1,z:1,w:1}) [21/32 0] [ 0 7/8]
- sage_acsv.helpers.compute_newton_series(phi, variables, series_precision)[source]¶
Computes the series expansion of an implicitly defined function.
The function \(g(x)\) for which a series expansion is computed is a simple root of the expression
\[\Phi(x, g(x)) = 0\]INPUT:
phi
– A polynomial; the equation defining the function that is expanded.variables
– A list of variables in the equation. The last variable in this list is the variable corresponding to \(g(x)\).series_precision
– A positive integer, the precision of the series expansion.
OUTPUT:
A series expansion of the function \(g(x)\).
EXAMPLES:
sage: from sage_acsv.helpers import compute_newton_series sage: R.<x, T> = QQ[] sage: compute_newton_series(x*T^2 - T + 1, [x, T], 7) 132*x^6 + 42*x^5 + 14*x^4 + 5*x^3 + 2*x^2 + x + 1
- sage_acsv.helpers.generate_linear_form(system, vsT, u_, linear_form=None)[source]¶
Generate a linear form for the input system.
This is an integer linear combination of the variables that, with high probability, takes unique values on the solutions of the system.
INPUT:
system
– A polynomial system of equationsvsT
– A list of variables in the systemu_
– A variable not in the systemlinear_form
– (Optional) A precomputed linear form in the variables of the system. If passed, the returned form is based on the given linear form and not randomly generated.
OUTPUT:
A linear form in
u_
and the variables ofvsT
.
- sage_acsv.helpers.get_expansion_terms(expr)[source]¶
Determines coefficients for each n^k that appears in the asymptotic expressions returned by
diagonal_asymptotics_combinatorial()
.INPUT:
expr
– An asymptotic expression, symbolic expression, ACSV tuple, or list of ACSV tuples
OUTPUT:
A list of
Term
objects (with attributescoefficient
,pi_factor
,base
andpower
), each representing a summand in the fully expanded expression.EXAMPLES:
sage: from sage_acsv import diagonal_asymptotics_combinatorial, get_expansion_terms sage: var('x y z') (x, y, z) sage: res = diagonal_asymptotics_combinatorial(1/(1 - x - y), r=[1,1], expansion_precision=2) sage: coefs = sorted(get_expansion_terms(res), reverse=True) sage: coefs [Term(coefficient=1, pi_factor=1/sqrt(pi), base=4, power=-1/2), Term(coefficient=-1/8, pi_factor=1/sqrt(pi), base=4, power=-3/2)] sage: res = diagonal_asymptotics_combinatorial(1/(1 - x - y), r=[1,1], expansion_precision=2, output_format="tuple") sage: sorted(get_expansion_terms(res)) == sorted(coefs) True sage: res = diagonal_asymptotics_combinatorial(1/(1 - x - y), r=[1,1], expansion_precision=2, output_format="symbolic") sage: sorted(get_expansion_terms(res)) == sorted(coefs) True
sage: res = diagonal_asymptotics_combinatorial(1/(1 - x^7)) sage: get_expansion_terms(res) [Term(coefficient=1/7, pi_factor=1, base=0.6234898018587335? + 0.7818314824680299?*I, power=0), Term(coefficient=1/7, pi_factor=1, base=0.6234898018587335? - 0.7818314824680299?*I, power=0), Term(coefficient=1/7, pi_factor=1, base=-0.2225209339563144? + 0.9749279121818236?*I, power=0), Term(coefficient=1/7, pi_factor=1, base=-0.2225209339563144? - 0.9749279121818236?*I, power=0), Term(coefficient=1/7, pi_factor=1, base=-0.9009688679024191? + 0.4338837391175582?*I, power=0), Term(coefficient=1/7, pi_factor=1, base=-0.9009688679024191? - 0.4338837391175582?*I, power=0), Term(coefficient=1/7, pi_factor=1, base=1, power=0)]
sage: res = diagonal_asymptotics_combinatorial(1/(1 - x - y^2)) sage: coefs = get_expansion_terms(res); coefs [Term(coefficient=0.6123724356957945?, pi_factor=1/sqrt(pi), base=-2.598076211353316?, power=-1/2), Term(coefficient=0.6123724356957945?, pi_factor=1/sqrt(pi), base=2.598076211353316?, power=-1/2)] sage: coefs[0].coefficient.parent() Algebraic Field sage: coefs[0].coefficient.radical_expression() 1/2*sqrt(3/2)
sage: F2 = (1+x)*(1+y)/(1-z*x*y*(x+y+1/x+1/y)) sage: res = diagonal_asymptotics_combinatorial(F2, expansion_precision=3) sage: coefs = get_expansion_terms(res); coefs [Term(coefficient=4, pi_factor=1/pi, base=4, power=-1), Term(coefficient=1, pi_factor=1/pi, base=-4, power=-3), Term(coefficient=-6, pi_factor=1/pi, base=4, power=-2), Term(coefficient=19/2, pi_factor=1/pi, base=4, power=-3)]
sage: res = diagonal_asymptotics_combinatorial(3/(1 - x)) sage: get_expansion_terms(res) [Term(coefficient=3, pi_factor=1, base=1, power=0)]
sage: res = diagonal_asymptotics_combinatorial((x - y)/(1 - x - y)) sage: get_expansion_terms(res) []
- sage_acsv.helpers.is_contributing(vs, pt, r, factors, c)[source]¶
Determines if a minimal critical point
pt
such that the singular variety has transverse square-free factorization is contributing; that is, whether \(r\) is in the interior of the scaled log-normal cone offactors
atpt
INPUT:
vs
– A list of variablespt
– A pointr
– A direction vectorfactors
– A list of factors of \(H\) for which \(pt\) vanishesc
– The co-dimension of the intersection of factors
OUTPUT:
True
orFalse
verifying ifvs
is contributingEXAMPLES:
sage: from sage_acsv.helpers import is_contributing sage: R.<x,y> = PolynomialRing(QQ, 2) sage: is_contributing([x,y], [1,1], [17/24, 7/24], [1-(2*x+y)/3,1-(3*x+y)/4], 2) True sage: is_contributing([x,y], [1,1], [1, 1], [1-(2*x+y)/3,1-(3*x+y)/4], 2) False