Fast Diagonals of Rational Functions in SageMath

John Hunn Smith

ICMS 2026, Waterloo, ON

Let

  • \(\bm z = (z_1,...,z_d)\) be variables

We start with a definition...

  • \( \bm r \in \mathbb N_{>0}^d \) be a vector
F(\bm z) = \sum_{i_1,i_2,...,i_d \geq 0} f_{\bm i} \bm z^{\bm i}

be a power series, with \( \bm z^{\bm i } = z_1^{i_1}z_2^{i_2}\cdots z_d^{i_d}\)

(\Delta_{\bm r} F)(t) = \sum_{n=0}^\infty f_{n\bm r} t^n.

Definition

 

The \( \bm r\)-diagonal of \(F(\bm z)\) is the univariate series

 

When \( \bm r= (1,...,1) \) we denote it simply by \((\Delta F)(t)\).

Example

We start with a definition...

\begin{aligned} F(x,y) & = \frac{1}{1-x-y} \\ & = 1+x+y+2xy+x^2+y^2+3x^2y+3xy^2 + y^3 + 6x^2y^2+\cdots \end{aligned}

Let

Example

We start with a definition...

\begin{aligned} F(x,y) & = \frac{1}{1-x-y} \\ & = 1+x+y+2xy+x^2+y^2+3x^2y+3xy^2 + y^3 + 6x^2y^2+\cdots \end{aligned}
\Delta_{(1,1)}F(t):

Let

Example

 

We start with a definition...

\begin{aligned} F(x,y) & = \frac{1}{1-x-y} \\ & = 1+x+y+2xy+x^2+y^2+3x^2y+3xy^2 + \cdots + 15x^4y^2+\cdots \end{aligned}
\Delta_{(2,1)}F(t):

Let

Diagonals appear in many places...

...etc.

Lattice paths

Irrational tilings

Graphs & networks

Ising model

Definition

Given a rational function \(R(\bm z,t) \) and a product of circles \(\gamma \subset \mathbb C^d\),

\[ I(t) = \int_\gamma R(\bm z,t) d \bm z \]

is a period of \( R \) depending on \( \gamma \).

They are also rational periods.

Fact   

Given \( F(\bm z) \), its \( \bm r\)-diagonal \(\Delta_{\bm r}F\) is a period.

Fact   

Given \( F(\bm z) \), its \( \bm r\)-diagonal \(\Delta_{\bm r}F\) is a period.

Proof   

\left(\Delta_{\bm{r}} F\right)(t)=\sum_{n \geq 0} f_{n \bm{r}} t^n
\square
=\frac{1}{(2 \pi \mathrm{i})^d} \int_{\mathcal{T}} \sum_{n \geq 0} \frac{t^nF(\bm{z})}{\bm z^{n\bm r + \bm 1}} d \bm z
=\frac{1}{(2 \pi \mathrm{i})^d} \int_{\mathcal{T}} \frac{\bm{z}^{\bm{r}-1} F(\bm{z})}{\bm{z}^{\bm{r}}-t} d \bm{z}.
=\sum_{n \geq 0}\left(\frac{1}{(2 \pi \bm{i})^d} \int_{\mathcal{T}} \frac{F(\bm{z})}{\bm z^{n\bm r + \bm 1}} d \bm z\right) t^n

But why write diagonals in this way?

Fact   

\Delta_{\bm{r}} F(t)= \frac{1}{(2 \pi \mathrm{i})^d} \int_{\mathcal{T}} \frac{\bm{z}^{\bm{r}-1} F(\bm{z})}{\bm{z}^{\bm{r}}-t} d \bm{z}

Periods satisfy linear homogeneous ODEs with coefficients in \( \mathbb C[t]\).

Given a period \( I(t) \) there exists an \( \mathcal L \in \mathbb C[t] \langle \partial_t \rangle \) so that \( \mathcal L I = 0\).

Thus, we can learn about \( \Delta_{\bm r}F \) by studying \( \mathcal L \).

General-purpose:

Software for computing periods:

Specific applications:   

  • exact_convex_volumes by L. Ramesh and N. Weiss (2026), for Sage
    • Computes volumes of semi-algebraic convex bodies
  • Based off of Lairez' MAGMA package.
  • Designed for compatibility with:
  • Aimed at (algebraic or analytic) combinatorialists.

Our software...

sage: from sage_periods import compute_diagonal_annihilator as diagonal
sage: var('w x y z u')
sage: diagonal(1/(1-x-y))
> (t - 1/4)*Dt + 1/2
compute_diagonal_annihilator(R, r=None, vari=None, Dt=None, t=None)
compute_period_annihilator(R, t, Dt)

How it works

Write \( R = a/f^q \) with \( a,f \) homogeneous polys, \( f\) squarefree, and \( q \in \mathbb Z \),

\implies ~~\mathcal L \left (\int_\gamma R(\bm z,t)d \bm z \right) = 0.

\( \mathcal R_f = \{\) rational functions of the form \( b/f^\ell ~\}\).

Then

\sum_{k=0}^m a_k(t) [\partial_t^k R] = 0 ~~\implies ~~ \mathcal L =\sum_{k=0}^m a_k(t) \partial_t^k

satisfies \( (*) \).

For large enough \(m\), 

\quad \mathcal L R = \sum_{i=1}^d \partial_i (B_i)

for \( B_i \in \mathcal R_f \)

Idea:   Find \( [\cdot ] : \mathcal R_f \to \mathcal R_f \) which:

  1. Is \( \mathbb C(t)\)-linear
  2. Has \( [R] = 0 \iff R = \sum_i \partial_i (\cdots) \)
  3. Has all \( [\partial_t^k R] \), \( k \geq 0\), contained in finite-dimensional vector space.
(*)

How it works

The Griffiths-Dwork reduction,  denoted \( [\cdot]_{GD} \), uses a Groebner basis

for \( \operatorname{Jac}(f) = (\partial_1 f, ..., \partial_d f)\) to:

R = \frac r {f^q} + \underbrace{\frac{\frac 1 {q-1} \sum_i \partial_i b_i}{f^{q-1}}}_{R_1} + \sum_i \partial_i \left ( \frac{-b_i}{(q-1)f^{q-1}} \right )
  • Define \( [R]_{GD} = [R_1]_{GD}\),  iterate on \( R_1 \)
  • Write

Theorem (Griffiths)

When \( \operatorname{Jac}(f) \) is smooth in \( \mathbb P^d \), this works!  (I.e. \( [\cdot]_{GD} \) satisfies properties 1 - 3.)

  • Decompose \( a = r + \sum_i b_i \partial_i f \)

Extending to the nonsmooth case...

In the non-smooth case we must account for nontrivial syzygies between derivatives.

Theorem (Lairez)

One can construct spaces \( W_q^r\) that eventually stabilize in \( r\).

Gaussian elimination modulo \( W_q^r\) gives a good reduction.

Lairez also gave improvements to this algorithm, resulting in a MAGMA implementation.

Used to compute \(\mathcal L\) for periods of Calabi-Yau varieties:

F(t) = \oint_\gamma \frac{1}{1-tg(x_1,x_2,x_3,x_4)} \frac{dx_1}{x_1} \frac{dx_2}{x_2} \frac{dx_3}{x_3} \frac{dx_4}{x_4},

\( g \) representing a lattice polytope.

Examples

Example 1:   Lattice Paths & the Kernel Method

Step set:   \( \mathcal S = \{ (\pm 1,0), (0,\pm 1) \} \) .

Let

s_n = \#\{\text{lattice walks of length \(n\) starting at \((0,0)\) and staying in \( \mathbb N_{>0}^2\) with steps in \(\mathcal S\)} \}.

The kernel method implies that

\sum_{n \geq 0}s_n t^n = \Delta \bigg ( \underbrace{\frac{(1+x)(1+y)}{1-uxy(x+x^{-1}+y+y^{-1})}}_{F(u,x,y)} \bigg ).

Example 1:   Lattice Paths & the Kernel Method

Creating \(F(u,x,y) \):

sage: from sage_periods import compute_diagonal_annihilator
sage: 
sage: deq = compute_diagonal_annihilator(F)
sage: deq
(t^4 - 1/16*t^2)*Dt^3 + (8*t^3 + 1/2*t^2 - 3/8*t)*Dt^2 + (14*t^2 + 7/4*t - 3/8)*Dt + 4*t + 3/4
sage: var('w x y z u')
sage: F = (1+x)*(1+y)/(1-u*x*y*(x + 1/x + y + 1/y))

...and plugging it into our code:

Its parent is an OreAlgebra in \(t \) and \( \partial_t \), and we can pretty-print it:

sage: deq.parent()
Univariate Ore algebra in Dt over Univariate Polynomial Ring in t over Rational Field

sage: show(deq)
\left(t^{4} - \frac{1}{16} t^{2}\right) \mathit{Dt}^{3} + \left(8 t^{3} + \frac{1}{2} t^{2} - \frac{3}{8} t\right) \mathit{Dt}^{2} + \left(14 t^{2} + \frac{7}{4} t - \frac{3}{8}\right) \mathit{Dt} + 4 t + \frac{3}{4}

Example 1:   Lattice Paths & the Kernel Method

Since \( \Delta F \) is D-finite, its coefficients are P-recursive.

sage: from ore_algebra import OreAlgebra
sage: rec = deq.to_S(OreAlgebra(QQ['n'],'Sn'))
sage: rec
(-1/16*n^3 - 9/16*n^2 - 13/8*n - 3/2)*Sn^2 + (1/2*n^2 + 9/4*n + 5/2)*Sn + n^3 + 5*n^2 + 8*n + 4
\left(-\frac{1}{16} n^{3} - \frac{9}{16} n^{2} - \frac{13}{8} n - \frac{3}{2}\right) \mathit{Sn}^{2} + \left(\frac{1}{2} n^{2} + \frac{9}{4} n + \frac{5}{2}\right) \mathit{Sn} + n^{3} + 5 n^{2} + 8 n + 4

We can use the recurrence to generate terms efficiently:

sage: # Takes a second or so to compute the first 10000 terms
sage: rec.to_list([1,2],100001)[-1]

1270680603216963087544831896028665880692600747891118210063259029800227229751238306453687948356572348909901720679870500545739919508109273012976268715305737763391066421409805233056778744489750898413355962578285944247887860033856801175949105998096436768336916769776946326575785143913151635250212957603612123524911424700144892665323997969152024446540730068717464893001653044034373309584910066751015128278161409603344977468678075049469938364069373576919971174153325799701468430736051374225486256985962025342059016046559384838346818695501759408273077753167464016592414320812497468538975973546362809730302164781719715099043790578277109095008387305392453806460560524801551138756797416783098419454862618948612393417431438050498137204695287082802551351195090459832944811641001000268480831312601562050499792974837748025993087148848699858495814298703552278196894815915660701499032877752197408553508313230615127859367574420235483535905751649195661874385332418776408831329729377673415309073073551010728471120127135568311414715603765163784906172637923080049325813479575220568017464495062570094980764725086090014871514301955474766163567630346476295778392435326952718613339051946196111835674564410125949712430425364520005752506897151615597939650058443361502112154367986066184279957920732882564422570569630582899827813853660953212453069921814578703355243605104417864889246490907941117525349983116788815079088387643400115410725564709334845630462279865042356904841920801373725118172885450800129537161856485450298850289852863588214870047773534871690749011133885100020050616177064021284284210593646487004704599017991516678425077561770654082312259953113942468307697987899634974774236345888363147116230604189223448293543470032629465563604545973934639501622913075858055345770834798686865901155139057697882044300519339890127731068522192493419171131008464759221889598913418077215018901612571555712311053401229109641530163270666148823735900453647990402396967135142272636000171190756807471860328266059473007142530957361889175134691293431451899160857818983399436795849659855644472806343607496040419306484996884034101980447075851120900778755428611240381813290688967005929153394111237220688880184448050019675956674863633865708966805601307830300198678330835979578628164592940340480812775995103928417986616297958399332376024565343447656209950288625087047891239785009194349682307168995629937279644177794747906555193881484806979385766778948219511655551803192101958892010233397423798494598402981448043280788775824514668172466571047149547717159882120029603075634078711441720586568833510588229630056410209933832327269304643630700666769487279639084002882956811785122435571073973888207741207158838748689323373053746194978570346187883831693056517847246075635620864980084544423753030427020590569431285983641800131521240950869545964064411288418803214634742685833145972159256736238588232981178315249972291838389753778155967108102122152099022640997116519482228091195137498378499974596549095183895765243645575068312563993292367923969594255248147358375065392151615731831165540068344291151624034067227585356640009118151429385532937780904274661590978794010767646138246529921205052159140327358537448233857580992981371349453538087523687501732132284811116478408375761244867675581766709787680199913098542111980509214907635878110982478901056235193454148601892648341202137990798677091678195812306234042842222993115817790724473344858929605958918639627848778868467471415154576939789402987879124195347063899488995653340307448189332905515142842803604203447983395666887953976727908520674318317338387484326678932387445343231127390195377363716462552206876126955500271730088149351859104931013974543071610253443731192170845261657204457231100485808888496503897437878482467850267042153804299058302701601835443941905372277002888270401915218249156651465111341379089955904814630999651591032165098359005780165435167856728674384324605860128373855802358130659651326974195961493713418140205309060600775766748119413597123929663006522442854880862261391685497763142532725553968354062916885831114616573208884578990380167957794975072371159173953102354690510006025457375158540674160536290638940663267257489201625128310379969544419107358914959163859332343893060405271974055254144493969578672781896646568025984676651958822278356994631345656718243822242116146730554288434612629573637344999759052940737389500537367717932568692680384467914427991766535992084125358181492492374739777202506852975102328208963526131507386047643340645951844173854162435588168449554184770339289720759381431892742678261340319533243581584222606221958307300866356224875796746982692819988008747899154523354028174679398085325263081702377004849327536653585112034661009735047356169671911845819024190842461833292290644985668963221328587080832862938681125939418569609179772479949132719016119897590110814915188476812816616027515185674720806082967488533267979779644106066979903860486765786449498429588141154459054526312897258245332226048611522166083171257594312565698435233192036686634023626119210292224833921352413276359030541067212526733203128206853642364035168051174403551223579855999377350269135530479155434333445570449420290976936448382645003930002447783747020202766339092775660361132428976555798465219850986279547332231396709548490712981985287792569230073926117199463696255030115517849920846593644311249984438118886629700924567738158015427084209933778956303746375645667012214373056522117969149523728433103304847712134117305184148610056962860629895513717018536612855917361000505318399174426630792597421522907110658503900962309363162896689100224237882809213224948615767413403675489990520266984748954424486160079610723772248887955066755825945815618863214217208117291651662570078345886166382031598828448722720076888515589371584134539405222075602269094016772661344614738776000162981522461238452537828587375955314454111398844946363482395041661964178771998623448172510557614969320385611345927463603925692379948749131687574284966189417943269673032975162957734680915379662493730523035667940873306087100053446962239953621197258207525271026677820717017580960969816221714496600450182697891079077131691523052827965694615682736685348567511854514239990542332433467988112539617281878385691120291459715728949620101342447265716318000784031658527198675073814162093804789609879908030564581590977061397228044396153496965722283354864727827932516118053688547930005602878767731149406783982136202027867443080248214175249907550157450062202012573809303347542348220554622634598702522655176432325103540079101888235051044386050251299949367495388528209976926589647429416127883024617253755115474741938674313241891126784375984835269136628527355589595185855176007239815847368615233059522084407619487835497351462008858265880619650364513511648382758996716812425215002275051260206259657820674538125800896846745342139254126110801043669086095509736659343101063652064191231359287407422994565888835832009965977559165409288003746805799814865663443107530866837007344677488704059554631583278466531414609175364625264018817895826371451019458869846706326468272970789431037518159542030021295448269246800792221762755024852573294748563491338336975936860231011424003632703339525198336691689979320064502181206779944499955588800008909544149706942294853028642382612534918486156122780826140368803894100719676307644642186971116320616243014821628549002686131286071387403615678798457550366309917630812603775155723776318355198902528639380071684038094180026056977825036606828864724812586707998996281708160614743021204580610503682233238064419852296801719883292308100943819450946994571751388278457353826332003592760634771429872667659181945595059679308156681386122181895706373704770641030297751632651335729865334288189138642417977391939461546687897027793916926743500081337242670996834471495069245772242203916090673017765598770677607464382686417271720504474276581476033191715917251319753337073150075737292334950181334083621076226757308758093071797861727025759332786328421704112288527065180368884295562359893116907231099334951819738234743250203297312895962809626296035633219803585169920240224348771675575795505445367606453603289191020082641178251851557674044568927104013854006158625395933473085325156080249474014863198082217036896471831608481948099261919552428240094424422844677518218103051228037993553803488585660609325873462917246028054297736476310181552156759979878488338777837268576980237504537516413668329607249086440441140755010309303413173460381406645139142641669618341914164753055987889116274108460227428912639518081404787659006569228877872292577231646560097047982683306986305129790593580429099529335667388158015713725139007111525910397660123663792560473392918583723301713857088602104950556198781581126319191565369070615592385848309629323733552243435125712830053252116264156158886925664988632852382620674042513794088288492431269747506694976632274454718655467366509468033947507618273203196522652757448137944326917417954978607669142867720899146474922980357273742111805506315943875778404669937059051802687109782628878520387186373298618433957890203298445040915352362561008888230885575644661614862716689623887308449041245810384044054181867488511843883873826873316342948368277302106857593047000391734735082011490144734203557323703426320818995335589114352002629588695013033126149814756759660623006404636690553687241852372121460775190537559072015329431428616883174074106881813155723358904292499564545453769964677856731447619904387161706415880282671860313812615736187035644763191945851857785298949514611246238160241275986078803266416867787655792458131153644786763559540278614569771751057453396034988703652635002183735291015214248075199415097714028108700152877760661043647620248924228033962453990428882165960807896766742658697845923292706155245381280209411406505812851672549709584370485884016943037505079613798862677217539438308982248131886473018870841615286266660026350886384653876238696239007845129785038025330869687124073143742063192733818358467927642240943727803891944388003490466506759808411113022959324610576439846746745364486036987801012222510223044875448330277445163569253937191885012228363831564890412149427937190985212089366290270281049858137268603168697343260245803946459101173068230862817416807415627429490376704335348599506026544626115041613120495124437364057174965269529779978042690818680958032279252629383488535824461151129294641156063432732200659263739706134704355631892929415299357471795494873508686194277356552145475171507039577508514417116362736021673321637015278276249947450509901502073047523425429675975108677815815045894959095451870102891493890861412979412799041455307445612437363340583280138637579119886670906122810923754373845348430976499191643580242835024405092927980666615759931127980217154774712636440548418210315233355711756864119399523458402140523865192642619282253245256628543428677813904013307798091956282500652925457350830908170005374175248229313688203744293452474114497073315025742033243378761377952609633383478144902312350285390310448401604540409985632292621810763782484370954702678929805142434099569735633477237464161901331911090683672748788952688076223803899236399370536008521839843033542412748669990931884188785186993462128328732304008052097546784345380115253792560871774070581702977623146981832066345145279963928074027411539189439509352639098156185599678486673208367990900096571313120871857027654958027822166846055751302461518476166788926732156329094623822379429883088854166527094090063385247689056426038042762218466419113529892742471713857570951939436960767915170066970459159609735831728772740430123438259125419278658776200850727196228040832236535524438534742984975806682803698774252675013395175099841169718563143656632436260604633495249148746533298605221825911962283540547940532352667453094778510437340994733025526506440669673515641501999797029242122662998533705697065642353670564192671209288148394185314276270161071337759320742370352195783859969854235003209969251491135592785589639803901439121438189434002684035671672357961033390655454367618404586813797205520668928466604209018269153614589542287453153051511506323121279219383600496552414419909296929358274804973684795826112432095805098678943205264902899434270792372011164933804359229215687195042499007264938236784200210784054381771289110295595125865383978524337749769548848295971825857913510570058226613057538209987351806637736350254999429028421488619076121634979360949827836732720275390141085794067943103908437240578379035171381149628798759001383910838353408547011360092770976164654158234468441929230000306020514684226632544814821400254620695860135588442415721289074480429254844686438914332029087635149163170221722743463907888589349108906936632627862904664819833703391576383167325954956461704318181467413365763517003929385211329480361115900423215780968426073676894913081583531607781357138420274584289400590725824721179780057507919357761867389320253681207873326754065650167197384576124944147818804367812584572849037493491390795120364545978868018060633238839471738578490915678728234763707080702506959086090586072230680846614927093360341170104316573198799658878178660389731460549028308308705963438893217339580744673519261527440134138782420242210017393378900698785572226618161163263761585508521978612530635802809079055514180041436604142660790674206475373531367078514745715455192581692096156304697048496414133915100647356856083069439812638887461946487079212639715100254644211832973849806228670232399657957102336012642897714132900176815573184671864581184100715486733238418924116614504498540380919006591745223990394993724029251715557950126272493978642257325432288537522085371110728959852597665354263554119615001163421340000014413234564020980632849772732579300471904243208046076723084459302455610899347687640289482263721292681830550727498377964448954414507483784791287886632660502198111947999305047197154064673549556813005167439991853343896092348691614711731223398944972957200705867316944956936705623740785400014457068627416541576486827218152896239490266825248654086573774756438260467974578136532538860019172070253091454825863136849026980955531853600257934149471590305498365550786429848736539235032602047037140859491223996028329596677974988144498253248356243238383662772475936912475506653863883118869741754557305546148547805109145149259946357227927770438285113182919222544998579182129751849261989501385650048748384055280887910349241391648071708445726564751600530812654359869756637824021969653691439229615706192235122998279737488782876031504977779036691716951536741230172350299549281941585123167064202948468670750357814689775157684177965207763492987043103250969988156327821897924877379483326026725893521018506834015572931883603618662401674535697019782112486076856788557210052937514584325230448081544736328671049768554386109443983445247008740922892499735287977443293236772950013028672969396847794094065112801407502233319617263895958496678247733749679549275402984821056894475261251477118769399306050434956379019100838623735114298392975911157579025060077763293083980691148421198284519066427594889430937837085123814858557942323279140010591752861458275110953486416247615848024651432463023921105668523314321132872152887407159348279528757158851655275106375261880404484140151073157402847644327002547342214788131991783558473824723350135371161224392397100564076275172416728657097354400533172944456645030654360533035884938455629226676379268767862250770288914527501892491333623480068482393667145833197182028935467416190057167452939360074397328503188628742448573212347201333573738574006665200534378813626232867775121118464196476834423555935372288618625587706530158377140871495075647951210754208625690954024530384455227865594559275804429953691310429124070419959430053026832000177056307208728205313428541227711327073859801178209077702719729997574150395776645134588322076380948137662540771304127068284808518394155691211511261338948610451438171524530379234506384940986144578623964741211661209409539519121075952724543243689942484264947392466008952804393655128287326409292756230385937951531281690043019483962009647843181290003907918922680606224872208064153257823816627902246628699897766755807915086480331179276451149115824978047612366959270217024347986670290479720547396705353287452316477528810581021154817237384570388423163516979089399141725006754408227160275413878704013544897691557678991976432278511559159490854110446979610832243392902460302896284887901607974126070928154028526802684184728388829272999485563568874199610426044399904594417044553617611056133985945008085009879543296684810907240723734292635762488722308531520511939893738614253596924424140257524569416563823781820953589745549544960534330754971232257655624897071770629056218866869831375628985577312561149506525788361015936760480344056580115533150218527473550956927384315060983595881417153277464769840637076774865757838093092595120960425554942990758545846565623256725672513107728344950356051462655342567511030847754687942395644866030703180269599316349636940627338009922635142566135002383428954888829134007564218795871058526961336830023297607395820230520748417933344528385371996808963348166673601325549539634160503575107925638386533711274561132815169905239667911749002152546995992732332415684074452289762731190327052423058827700307942684523348161441909719695097288137056716718133105507063639903154392117074801302286104080953256555533641113055393914473076939592429057750688694741961260875168241940841678842820200877185589047661037113388677914687125350509949180473210976936954175477702478164004705292843679833863688393379798746536948273096621609956640596686055132093595530827728754774983082216387222669470106878748253907588658775674853851608876092173202874235967398806315993533888340358424486068124341170873304781796736436912789688202512745505738154283803035453573860357920433750477451585400461361696991739703184568203710324721370782440440801888500817199167316331379994161750113902528705300440306228080377518935009686940894101546949280595514440617078983788800028023209600043842848008726025751002829702758001094640152941378703735304773291166240657340243226169128022344037926007249300582636129136488342288594734852651080922145962235095905049318176813412114797814448895447605883525318734611653180610125697726567989219370549466577056413731166218133623282946736420212866313723496019333677891111688766726653066182065820156847375466313839972716914395007084890357417778030912066364912433509829563210223272619441171113428456461540329900881872846786271521899098302030747115619813145128781728523802963304643662978109714598860230722697417041441065838639602105675994921772688559881023813735762476247384182236479087014517062712037790551560122399620585271123732499108222502867126991693569504228585226485395436085844879377131169737334377184309723929721016039623020744626388252209305225777094209696438261540548537495750781077842638088301676112817870873683131109097877245434042355077951072502511411775076736197467944601388012344957341211320611959323842514861250127160070587408252149230673070959153637869543483509405665807622473193210802522075769833825380400601456699125739085754296258261301491047041245104894681108310806063797630082545907173403192008994171994160367057094655989368009087879178669253658109229174002489146144837159799091561813322769227324250681459385754791792347689872944855683874942320250719160598784274623512987663353878505028382713767808900430586658404181653305819560952069785371351037763410785612171396975299349319856693655228786181795791244212118618199311647869230730618390734682476898330781970889710560697953256958696337123560768280847050750077931008093719068629033760627506327634891522668812320684140453112345738294529292338275718381088234465866330835371555158227408825179479258396394423919234532316489946513444705431127435642759785284127013491139589222929338535144281011785926328311846179457778230859967165129150325283278025071863962574342401718698284208652880207444370584401620489335737398358132310730999263603249087041657408390314120119511467315011311076624236579057775418013286107669456784792068117950773913056528324717433457915549572432476845298332402256983674069698632341572475453604435736764859910150324245259771479790424381779973086813254657226446394136998242610433075026018728851672598754296272447859119815890849841751388796787726012168447346907237472678365057570346645797322316672533071610582246371712360077181835048980618539376141112563747391828449755132586757414213911197767619625492872168311316886728052485370372985471204045185615657724270783783984454970381083997289270541615724770335300780303808457366412050373072799815995585659006526424842151663291551570479173915150733469324871602289542984294839218208908815329933578260807705303784654360382359699101470695892597279988149618345193790794888095733098497639744348459773633448714238807114818074827438497370622863301960352309343910157654830308490236192408018458012260720674351073599998620915117318184306088389771653063132689194418961039662911548555122884756907470740076740913727931515399341682514087975603182865443929653382584374625801899792400333663764904976325659006005667653600359590275527947715471142410831954838040857963806859646481649579908605161605243135851887224798968293251809175017664723050536240326290066335115350578902168179719245690850611277045873875420175213607641444484039460629801663916019018592519922627904713449980877406894364233335142061171586217333335219133003726459850955214837127064535246096668112708000241694679839091586031062235872318575436923203237330010165583930837230560124035261011108663671655314580077262661231839689724424021466950228752637053986636952794165789769027234192381082675926897359823371807600811991508005526777642911729018549344083567008860999627440751453548332700565057043837083495657957143768590170283603173712132933750980773276132179172199021621036437564377876020898337778957410078058303952714499635586889942824758654870181315497970357058372155996256777973340436312645909577198667057077338308109727434109086205156279855983384047471085792720624859768529344891308922752874511000325072597307234634264043026917597107265384666398597063758841236209267823173199846108504357305935870914027626052945260611281803293897802966224737549242477166761866369336264238420339771213042584929663431422002862049303036454769669277763584961439309315080449475801665919365778979254385464374782509086660892483617080530450983257481573758148355161865377858309044175459266416494220796784232003716087535059434320383295425284988627042414675709742364767710422778893514864357360916202768942306960680436695500435296439722558142829977867082980560139589143300374728652886555913814029409790241137161369430086502133676474109020531902235068395004065219998460612844611676789426909038611053545282489378819112892410927832089050760690856724594136816584840054020262496838309815743661542999507362965357505884481209088302590540121360812066858387173272824460190369938817490515427607210100388921168657356187591784890392570915762279225887726151710162211761980729341877395469215000543103425758497528638023920384651029357242021165734069856195319926636653922687953041065857682386540104308305433237877376598850413824479521457202803102333007267859932960526915031582346636398214977878962371270592917093698677498859264626048627116807014008201602009826408882997316465382466012997032577279532052837963621370189956744192210069090852607180890206490946074788740805513494440633446434897979414588970595278181027552287049739705731532453956259931019304478616836576470468080293453690911541778251729717856151670041411557573532632393948183722711132348182290047366908673908309826638747338999919228015316198003874667124334590418597476097648733678370838822236506652731896277504890921549126728891224126861442286247466086743641176492478864007991703820807019672099957047535276248267059952108975319568414806285677910700553491491826290370269837584400446508702463363803596225959292223970553823227054397408044656481646652279903132430515503900875238638784583658056113077923270228005295414768646002358978088465378135646337715476979379822334380275350236982436697327874733649193106851262089703812588156955017470707773633505773074493962753370167941313828914369822683874870775595763874183599537848969015891854139541391743447374227458242241306728368343058502211190846943156259893345490214933365312072477181668233934012767017245514807687647214111872629371770016426426052236498944819548742014377192245304932815757311843486692821857747316780104683843588276500244558307760818707827990489248035078584755807625992848804520586074560272123199895091441305947680429875853557541969178822975905652517697798891340643825272548878090471212111010189863876249066575619155749367936555701610891042997713814526024811069396684940531938507796803755094183012063448538921402639303048616489684442586972178532519452123897150389496233491848928889858915275137518933469026622176625471572901779794838604036427797792374140636470229190733346998977333702069320623362435711980636449414709152693323783641262581784460080365847433620993812220002070120029232100687272532779608734037527025910119101529276068109449882465056080990321525046869378551519887677380409750917002033979887201609070329848123604373283513272694771868827429044672764185584600421089997017881645074396782065782770197393193905476007726010148116738585861626245579871372920862817834117245494368013726653450078779985358933717820014813119585205329567049649634565754438395675455034535199015085246361340470134179219943930332538733584502673117100101289105006976787766530830750121187269530821473905977796047715567815435352511621283728105322959974959455758087018232074548684552579692929918876321231973322488498082995774349193724287135523526565014861747693164292583842604632430296264236320841897915542968841703060173148813976497481148226260293632286528610326693092797347439474197276490746793907942334431828916451203223095739405032666794514916605109065580649590449732268664250328054337586136412179728325158419944702892987469912510349996025115266787776215363733196896753281618185393597028997490816705599461995192870204925457144459539329562954228289588841425313655866850312775638437207667438895550614778647131899985742080931693026756487685725955154022742241562968975963076002879166557961078037225315663304027178884818898196069636326446843637974944910893683312659398157057093654628369815207357817539700529626018351406168461123463373069455855553048169403040142206273719130019144976969789544341118533890777601704327917345757400680568735720458067331990369294522379271324307837965474463886612975369911763143547009558982070163091313963501656819865388685505409442444231206805242883407587354036108388158498670309181475727637388640173890266650568425815206112326951674361109530756407708309434685347867410181845082775251392523546294956003370166467421245030504534210223408354813246816704450617051707176484480751196012630721356211407066732048372093143457553777442404390931901398313303986954416138979265480435528041868366517728839213043556056397306949594555620138265255100748103615732470746521086413358793394345826509478626516559797008055160923287711490501407227683989988454791166982323290206094854461004762675298232431916016837589314764039198700443579894729348447897271502920273206433323601611165171671791839706149408220863765647787029670961134064406088374103199309486182111877857268817835374803301461655536133136711896129420594429662498339131303419267082880442980184913124184458380837355568024642051211786067771105658458018804697924743907020320414785592468948914467165134410471502041127527951075055977090722308335282369624234898524499789036937362496346860113414818681585163179347628209913062200468501119182508260780062153728924263352801423098192009619635928547675591431321268181599710776640238910712430286505536202407889500465506594988625836289407287781283045538835936787339420386748854265263746977153661669691149434479897256355364001162101815495530421719508705845543272390931797183549366761420514397960506648105189112239323996960817082892302824314658029421421217553733651384200397026365932509406169077872303116135679883280823004891252111417734490192768748410851156147279191745252756860420696103130607613577659698414715454878482504235064213276337966293076943458024724634894897820921601316223195046912096374190225172780650676834118738701847849814370531388591404285037479945453463431288111446565713217232302727124219912885638465670798971252001959372195558998950438235272020651656395017754712612404086864612482396815929223617208388680210915486860354784412595634794211851138185379253587510121307586322525787021593329349963364607122496132439356115537774819454567949283677405313348834332359347675107274044345668115276641492176550692336393335758836602704370697079371651434325551888598435998416228641191543535081344540635088697916443093982665108321559236324561163726140574187717846891381630297168307764082993582498190274399265728527454547238617628002153393751297615976978007175772910226544067106241828697080020794475289852437037913904476699931504530568207946291068121821003783456574279269254584789233496738502067448737147280105759297543210658129584837205470340003352280533809311149056621573800080706228990264399687940724079653052632298044856836904434605746064207081611663154352423284798949926675414210737908175550043886820256875520925429141944425258372295650503630990699873100158809221851546517368320024582435209392047367325936211118293882345787218642299871355378506737229127670258999628641896233809176233747226171527403143957585990067710066024537452663139721318855703251894698828816960386469575705965778214903676133817952640159276187496684733284393746224165079790530057901370145342176683516478159940026527848708705354284905545226397709840568830576525535856486834041163645920043410490927334177517427449828445563771686738429292892984138072168080509895120055708976406802906003489430387952565908866668668593507623458699093688713456639041463119413922278518086229518181444868684727568147066096952119946008041233965017637602086223040811122451249028451715159321064985620506468676012341758357144435802928189153999836077453915042207893885486924736096819925198463956935761276254750210423654618659375908165519168366280892335716176488343224954801412512430037276688663608861273275457164412742137615098857521490969764313858789450292032016598630655389430157733515511986349584429075982565461986128150202501151820341970124266503832003881003701973663506712648594089475529712611595712863497378794621510184588202029038112228852244776977226915461018539432088786478435528548735878636512508044237695534978680771983625361943464450842981521012581194373952418749734771228725126797925811912529551041642892604173842397680806703558804871090134394538680138458033570212794512698325627739561503102460637066559618001269899324248743491159533136320454935994543033029591956699830296532332742042575986049232339703493339588740007977879677415781188001765288282006249370293712271101338602396698296867616130962909735738465264271203381858494984197414008597003690336104751389787341736365177988827380984306420572312451211432109767682501871416503366169936537990157006887807302092958418984018745075926098915975095169316300457386889068211181965149576322172583762042784014241155531569051518278556205683943770323540100593501496461308200337013698907826707043174300052000881704060456733108775066972381015633249854843904671559238543391772463869146338159965691430914028274778066355703413830351789675041003873954900232686528654460153321727757018079633852150948440853029477784533848006198610313182243190796654705464108902131146602587261990222619561835930978549940726100134015594419923646005686834101595489244212909726868847643741152935274609154337588858788752871378077850337730250405465823360037124371509885389426784579780515781500397579174086219322322170030029352833040701012368787833285887614739419773364760928518958068999892605119597351615437607564048252702612241401186887217038807185191736501974411950661576049066007434542318128174655639444209400070388549065431287512428231149535286237017993070323589550826687851618300348665562910058166880901385038976165253017405181709754352835319788192712350541214605954248286180759667476228828597731802998740093435035532044538486207454716104320891096012927241581139865894933646277864057105324000231259742888380120499818092448612128067899975059211543671651973290391701098836178835459382619466802270855245697960992252516992790955362136850023748403602902486282584225918447484849141306979821893407648630957379285486540241553292626344870170754891921100261994655385870837876233528217459580216145335549747468046479089864048599515474475926424996473760634650467250510209810377015674644920187916691871525644769991565497664192262732315990759605241559662926159313680736462221338911907989618846099808844509802744718973119977921563577113654855211059283937850286060620904272681154479683739443182782575735046369884343543255066121997351497198495935239055123880460289749944496032314694718612789668676139777168789517729742744664790650805866288935518317097540518573132863665496778075680209541864759382694940006217757851459517198741050829279224353644328767614457862303528216703998592483334682254004726995056984783492070449898363541310630428234225574945523185891454606849952832003262263441620703751306578943119784457007625881506412036248654528353754090290490333334910868374234399912603207668960491306308846109248642466941667571386951378952357868360392077957577759038071924574417216026527738384696011354813818245374489201364264477418457243575466140367963458016109898951227885334126634316965625157892765908997429650790264629366813793334658012253929247221898496404285368150172751659320876919187416858450890683498894957750951689091752238323336053549858725947094776972616040279259460458014350353027328472858740067086375606100441426307512265381647935940133945421732261288260261014306717092970245837645289249360471367988038327849902765670459209628240432322481929277676720905252373914442272087127170114354329992829378087126304591974122844498039945985727284231232731288669304964818524857487169963776035573194036276864801888130187810570680086155874900676904343696916960759800412252327361449001886331174055033138864514130326661516616934744313311670881527464910190685390940243103547687580890013202396487241699816968533449596237236192187818800226246314524509392660746768363626133022901326780759598674306748523047717962018207054367163696504219431552534533403666546567344219087411349789479428762193426433771110922907403281474076787041789122566700017757901908888126995009860973299507262537629908584222498404183370913710013531755939041492624692302912491523342891567955646254420976708542535073666819559808937351683483484542097646831217313148558725220788692514128125094528399093816304877908723655177022336836120898789022317293782205736199595557351362433235316409540337185646990943576148661771429603542353583765564620764442975565369312093213035175356512336918363256937479544155517076114068451115107745012430517477842034747523277218950198390597413940126672669893403131334914608185973618223850844101422661020691534090550424607059102896405439916707759734790130243218245508771042096241800586152961817621137063853418238415310570345143981842754800262776558823082629487131312603381927339073882578987071282399995769471404517411239991408838160984400724896206400663090782599756338852008621799284983426876363514996854850587007611076022869643189179243645431147478050661129229092442613459036984259722845173878750921103332112787828186105541268258947067869161668603159691101319355505971385631365174482787063173167976251036615648625999706802016016177846561433483277569108281294642177146903178396620486387390212358764256385574017163813511267829166361513862136029934637335625267062709579694822335505082933866443086381839688290486109104995364945346692866585330810999336487087770401220229023529933865745310611365161736911675289528832353921102326063818025848731449421707366313102626421708897607799067295100447793445683655417225597480096667587387866908675024452568786134284757187540988205448951362309850176733578379707170774155387296937561951012393365719387437904095519464050956778854327641016461778096350141248049695789291766160069445894372267197681421153932036231972112726799889890821474032388548835754246216482446884663561677734527165345949256732686182861466452203551042727741710880773801794742984056711387842912003955364732916023640159335838071212585963962928908580829690508279265690815500995304792048788854954329394563242369881858298403971971072737592001674071279492738623294007557669337730971741821628089594992745536812675829751720280845111057905963574101362827793921373968852153948131314261905625231470585719935889534932399875181574099852618635007429363813656686672877511823081970460430329602243610366075169298523103803325318005050774856514892590342848856107608035364239255438232831301143745159861173888215844180583133400292743999410835719973462252301778550749129056463039595459052609481366173759002873292936058161673558029355163975800281738100411470949987976048077688203605622862619155865314150226530442194580808068609344662062106113895623360732936082639812385441926247189481937643047859357252094782466658100048753022482801836096584394140742649759115721371719400763100035646738931898236263945335133806341075996962886962130308128331506181046538457879437512350268630258537118994377656077039122007068534296868201616241586575257906329229541776412727471880679258119638700749791438891908956077644437321015265571047471181865512770742019831316865059225473178491562424924717440337010444539216581113056178571133251806869428434017334611864434056076272282162363768341983376819195938661054389678677192706254549124151272511392365028001065410599227973373453834689965270093485773676001553708864127879192552550906767895358215755227186031117782496156807709828554734442596193986608651014659776803411621276951985241187934831386199871137473569879294142476630586161329476548049218103405252387884232469590113386400401580758011719489569602344235499988687183268826986936406988445197359016876711537578077619051166565294311781098285399540426761147613719496087247801277541105718708888093903365551456196394856540858194892892561305714265855856469394560499824141599328440510757503675686825410053048968569970723952885210356297536316113210176624771496279127119739045369315070425300922735396951007870290590265789979029552828864902311575941835259922880918878134481077477964244613961068523747461598929314791016874390485703562088305475214834601021290806006204273120263212081561777441340804698900469629834565717113210249299539572811784831979304626337597500481874066669667207689897067971547633683496113727125226487278302493704950180667505009044298481291939192889687391705448833718897807481588236052106728741351756399248339522553531269467163703492488340122928856637232019112865491735816337633153438301432127651657400904189438644772358908869308132919167079739032854944600719632163703561953302770383046639597257529553204192310317208027083889983601339554284987698788952709564947374811396432575931812095660777697285167280781558667072089759468084415405804080644170301765235988545678768811143241013653055583441030557968247268402471622246926316779172471262868308597679875806825248988991807634360945534905621088371930543209295109081569008176458730741810686842077916582264046551615697505090875108361100039828965406617338205469279999035128247018049058692061126070196362957271940423009753045497130327580343283479095654760697128695470232585222465355672456395218601170446603980888098506578989846876522064675462771001016090341899146647369752730970725466102185364577430800586758797163262586974634993209422772352164720510643884608693476634265946026795743038007090653610165141479900534094102979339496802263606474121808544468370017934398183717433903775889398892147700579839110530433371838208031614912765994479813236749668008416701816639748524203546472638080102971347368143639999083000007038319811531464684150977909626166623058439045261415046561428271074713489974430965463221135248750603949015956326709136062379687408723357811850241780269822578354683146349095202137786863817832030440830928222455222179120128555737727080899089553818205017726964829355595316048984223155091076283377009057840229966196675509999511774111984721280878882109357989423146009203588958709517770241438656322970447852727828347641798916491681069291342679698675219400263159911372065783808583230404687035994792052189699159677135580657504868335801984329026615449995945535640325570976017915629019831343706576308876565284744489050451370864762786512742396020883476066830898981937457518958705940966842327954078850517081017965850477437611019716087290793364825525933981917161116388167150380624265177572084309699408265952380390935623084063999656670811404096417152649896461323515309238136876212263251719896473377357919898023805602735588551300504016403435980999170132780535062525114979075194150949305763545934966575923826328692578521441072519610457379089502676901127275891768748740683173248202431638721021321852574651775923380686370235641403264947239547285342744959619939225263726871304191848804001684058093714804301026582330930345094195937958580414408228563933535431016136672474424485160434599913053179510622091740335602595357432505645139713833883810975610238460016219291730482561148718487639555009616836864887007801651907282447443834527522783401258218793669750436350043303141285648366877626338002477008669649675629481519800444266559611600252278439984906291208542281143362496321224412658553467687536277505453656883887958326812121696610019554247701434164113763896360788487942558336295284164813108324049402542932387572921072274457193936305544004223177747838233707065729627652379119951010556175885049783112230002243371041177307014287659536878278779346131674571103540605466461711958408646291318423998734080397329869373373212739976834800440566067213406724676641909810600404439476140669003154349248927266024566189405591663428668696436521229654852491706733954090979252450095618975743477582894811869401347241721012583356788939864622522614170561065863767733075578385068019761978536308784638239108226996941662158850573827954389030236091892617857938086510797979219368015191364082558357563063366075282517082081002651575722834205446344004302607791580615405916912915537710852402871324960546524117388385518987723472569873520420712922746114104020022475218617402934810785597340315743053086880545700813810525593244621409160879448711715193927436495570141795013857729464699762004184153502904617983653812925058509591931311366309869299396242422580565068171142575674033037209635609125171291881203664113229703542054303052919758134915179140396614834846675721684944186094509546961805165601626208011072859050153071582200689296649239502318367350472229534332367121848456614489791749248569419552189746418541493062469796741761483042128752101393515252554438776107552533760829003380703138449081206872777314458132807010560068629411855724697279183381778534929090825776609540905885744008350178792553158985125717716683078982083030879758378137306565883773218931602951518043741238825383753656714885667333661058945954229056198963490778432064522750906136092889852528829220835980150439247490174995137995972746983942775241855829184588473038525970106640188870412172247931685888731409490288501735358519840737225819130201798945526411977879124871583804470908452006361153443583180076961271057325116589883762740433991715474923976629022679623516527735133039793998972237372816090891044388577302928433836133130192231761059363867739842693187284712700013381810879339663737063922428891648188343017674825314444928276606074058327702573130926677620475629131635449822570218903388486471474867550219124075119155689145655104850897811397626266976606709067316757067469032366362399526628911319128757866683233277548553640800325067560971614643856064963006171434673904517549034009833687570734541828837347697415367492519636011397936488694382905879207029222404314456534669749127619350467040798588071318423538673343859475438681066807633737538040635677632795338665170052649670648708684155013263093330579281721699103689671625901897128186052568941989434327963474665575216785260804676460429548297389897449035979421970793368713637799156053452270967174559332787376751353330991596395227028142312886582766697145086048974450245463436262957291390852017483498409376368901246645105557001133553280578446546645881919429127963343924906539435046624282786445228816223620283111158890397923885922492589578899297824429875954948150204151604771937301451396538152414161492775577120100890062878658359116414218279680000240858323310383669471128119606862427670909743170728154020645007653612772609622147807439322443229691031648415593882331663901461466246666246231269311253690985185033900091500862050832161238189710271299305462315261382062560207053270372408700840843087271005225124199755897146558410378367698273387509812618633026656112066105235116840034934200079948939713857614342465050842949291769753781261349529908440823956587765900162103633511971013792813523508188393502012973743696841133744876960850711234435140294455129965417025223703429356887033289750931796615479629637091776289894937488638544596762705715556179045098467040612136195932407169910775926846572360038403180911927471059169071287334299866479487605366733744192287747772626881141503952392052011553744097094720278279125564975548155484166730050522192002021443094718601726890268986950431042694503292120780023100367794581075270610256049411912276217554699357353554795647806502118875422316780294971070089220290550047980095391050485097830062288153573906276722995006969516882607375897342645532562290666260633656791205729841739776063528938670568401402889446441252641902064738214290808113333157916947332579507780998371555709245027751244921645852896020805649497601355571337343967188782539721868429831395987389917901315428889988927294522411114978196214454576663041114834985996285988353387497894571233920164534136672026546869289467980134269279725883487181891917284422413657828271301142656189860882429899107239673472683877070129464156076289638839442427354629432003282284983990491311077594669899050641437761851641246294216732721881070142252554493884394612461627167635847295615167760254386755830886746226446567148461535328163063997109474017423755598551244459302899080176985452897575009351799996650226194287973914996050454562012150365596077874928141155721439866892362264539588123257881578772885360978389003382037505787795353654924576550995622626828952942809589283197182408680463607009753928228755227160449289987887084233364491803856277494017383400789065643903875423771754595378998764877167741642242004054238904858710038979379673358965428643813082188094343627884021350777775701286376212452727963093704088708537652257080696308557276187973425030191932429138512224552961838504062969983927480578139560399478768608346735298505509882885129931011764717285749388878479629676304332917996063890842106768610047693298835272830973926269784459619061999080198588424365741177739029841521116284462801681293816231229031868539375962568643622238910309089975873654948192535515949900749243848509027977391832937369000921913923826735098088967897843074001109582262969242094112736138569658161005658340221873668415157859698396182406808258820830210284925260238311810155427372701801803616974237639723953901431873264150610064577246863114720250734942651932795418115529553001834644719032622016129855658093450387290625923006151853036055446585954690485210284401114324890332349730716644056433456952378162885583767720231199013656738447683005429796558954484625114766840072798973681199829141199891392707451196683088201814334080403352143958059201722500183174673841385508747757488401873825854050481542527807770564603461429248886217782689993628394625386620406357642842033466927362822987349042808168709833595018417668806605897041931121831383180323717354131301388239835656725009056984087547213806369747703026187946801673012626683247591196353936035863733152665501971623910712016623807748612689293746519444206868930925446071165862572410599537903361427238290188405028849184385571097013670714182394268005734641088400282496481470440506693665275215837374304071639798274396316600055055218458456100155756238403997792929816956892492600112426234868381430384455305144064857895123490296961250982041085678659629641968832118041088347436255185548965145265585062076212811824240288002783397839600753740600283245418400767248584020235103062240265812169893173913536229092240587158552366593330033034890211751566695839630483763028388344824379350689780014496026426912157340364572411650872567190143889831834375458404801640042557646040101271346810002851509950770195329267696261158029641006695419755273637037324954779102603171129315045901813462424711561814411678852182651447083870234067558308555263006656351678378767804000402478529075532940207393711440844260109939135093945225581375875651860429629859824157567316763958915789813945070461435822373853271519386920037809053116095232279555325732304349449545099103182116547608647380939184332212458471616796283204697389545894356510244467619930637051878965980148886753086084896622097603902326517723739357829899952156092258238261091399032813858439067868933363907171763982440893423002038558890607388586290953880310661062769971208791746233919242479797289462504754375594476208534690661201229238277531728369713162630237816418373434730956854587228304577752049679424760352486729409909349847655528256983934785276319034244454659497557765153389824646614006632647512692558369846933181552640840041648820456149231856037585344852319771662417558275179070035045136688689629323974962171141817649476404143405457359737136695686115615974377390586870424457072971906592698264799585457906061538071306077650021156503322868903633314049083558089642357879090440446987204770852432595920956157865478850016399712007450175679194918909025189104984259156181992007781565310857487574504627794480183215278656125500871513843949632155231038329921786817625667315484359453796341495298790951465158027666764133301619426720727114715020798047046027236191637467313441310986854245224097524039130882206893473282483335101405436909736749911487232470539141616424929818469919896867251925496554672943390787421705582177637320619465414678350940384464241961005906076629214611921394735902468162348889266222852601702953185850316369022249817050002016258744533132898536124830506581310416493763527024748428608709694511539288804220159223311312130311416424959360748628993981001680184891897407191679970763203815173674573159385345331808498113075235422163467525664620372249058053803304603982808648026613413709646417591563237630049964728725357287657638007615132817569847529545521832010145805667431932426423140922834500095733412513801306202984074046274334058133117713202359099267276532171231314974271778190413541483561689283955052631304884460007845776824087382858859955094053276120501013676960545833285450618623544063741953973355007383508837753888185908653242140792529601378620176339741792795106259584941678413008150658801884169151421339006071919309797901220952669102527113056635088583457735668684359254383411646277615316163452918649160042198746238994792690699977788315957331262855348425176254170758397130652099030497476429192735270267670852222751682342114216454799093416442223798290927045843040354366400155300136557462208474721503517177623786919615963022061323434567008737406120953287936639252415970604736183024000304061883302254351375712332036977268187566077517044739049433127212365708272133762469580077212426044619980481065105106467540862393480282621876238198698361361750311784940408335625097208120685268038487196945424717468335192684078659779537035881514684617531275075823540846044671996990405924478161467678122717655557839449614342532432496265515614243576123022202660465516723446317126783284984318862374327803625387676231050776216493582954504034667442445368787594973027495078427951902337582466578821424816542747587266286518865182545677051910282438040269268565168486359376666031749792517700694219780984663882932260039816732950245095195037740490050915629093990145562416948863754631369864790432554427250017116533627842647864033180996373741695213849113237314212168031422066891573769774632449259193328915880950715561808771574547597961741812669761255842595441193658398163790802177576890341237861822915994983870426136530444343656376311732416270324262770796039189791594226964623396150996138359692188006002581259500820730020521478024950270861206130664498557308026462629163167733109613198935515458110918499957294964215485465298510419606792202005321766339199709862315154263380671692769184384994456820577470293340658255470743323231373597310392415827128908699112085435683959406630167124820144344428318455113992075588567688818272254202106675515242289469092352444182559137281314858675460258924253644921875754498109131010300846125473118363726725787275585285077072433224059018436848191559027946619143913303642364477015168068090085758011329383786548094879721528814833788952087067585518979480400805604373852220193919847087028187129817559987256703421882993848258348583556653170255160952874857946584211684268513570756780463960700258550456181985493405348614203441439285478858796307406577553009821110811895128308587046354089667021988682393423955104677071952906475598137972053446256584884990203221362463442280698813414901319759954190615714488111430953390309102707920244187861336775634302067615587098092088150094792533963259807868722476471259196375897477049057232554586242801731118442202859962332977494159379097280657583824503752507261754844465720153001793903518275059129592577972083283412542919559662381758424145091126408084963817391626971722071578610982947157494208071024753383729688239438647197727322988818442060760763420988536830430622144862429215882619384326225084170489050961979196097161522792926003255034712955620937935753331443597784300006578004373238676167115611413827821662877632555955610833592196748150108397660038986775095950495398996279694515870546485447588111941080455726008043020349159329412710669924227518270704218770549140049856120148763148721414826512806134715149221256331623488662906364642539744704293838401538359306406172082086927207037759906569473503645732402098753982027943862634181718888300221765641372764977008589727691447792463031046318177664613258900138380669031650771411235105710625172406991240000898017758410317925929125698913564787977587333705458631020626490714752497058710036389972494076582036010878991867979971563918357908365002432442364277833353127761020036460061502815916756814355479461495530351167515091922707257183012923241897622772882451061261203568330029101142516697421570709765328240011475026118660724967385869637082505301682174745573069159407990640003576762760568457185012883538353261494106177593409076369949267696372201165049463607481188263475828615704940486975472487962757541394168183886999194136556622101060756323493330982110930216052468770966871014157938207301034697084835269887369215574769038971298986440705224727082990820852162765284149629726675278700439804526482133284043211560292747555826533520167951757628690250884652830749992020171872556767661885754681785216021069559818785251189370031314975531191498158351901706159507749566175811833751260660955326327447993866273279491760854073070757465985071969384932360242117342056736543940318426926768182581732058810730592864234329612928266387232127320061398809232259942147799482516117210860292727585991392501896523122626256996190261143621536663648482977732356874378702513231072449318153427346652996999137592432962666362770558559992256383616994872011556850375829574268433530995498124440769370568835466969771239436073426594011994177317805127382693605889369576418643026136819607101271648654346507297264740851687655164620560611406785354954918369790549660208680233628387426682670110004398976370320875559241655126093795714509666876600843214794387846499800411968160445091439062601482133103699622257643635817636101995789652097537974468792730040463110257699943353413665842819708071046794063516612526949178947291354904692267915227814881712995628729607095019052901727661101504989640409934490245957659357032792441979681834663739928635638780641331079171459593742544196567237858953775164437493432708822102082295238769995859984605874971804298480449471934530548105550883538826803681032080557759349282171626091392049686971111662167985657093922021193317895094081765828362935598489430575146560367734310140564998687613295844243597694950798436133723020755101502014188595093540018730886947351620622539661831258084505779595961784357257816193195201630456420970637528251268515037152499119322481183499740757360783378026761395700023964475369478018677199092060212104577689409800517040646497313747758865918264965476861498642499574691610799435169319114530757282108337876118445937905544052460234167061388295832578626343099129853518336011013661420977130243740967712695744687746204853657645450284168197202422901178995479674842963612421064885900014462563329091709129591113095410366215613075014507571946399625688265580221676493448518484390613874093889109731714479798276135972727976957041395401782694870055788358646387881829470705391403658576810577107188531156323678681563643752135532631558151720737510353876018851976516766876307712759782063500923213310212655484655921446152063127209113527935301904690532822868998735072547887280396356034364893085506306867940126763431500353772334747243085544218372278997182433517059399548716866431061559101860804008536781067280801692193938021486427000920664035836568203539556724451742287524329093067355101698385024102338891815049864708367164661049107496881923822575791482941220377432723552668845122708514144798525216202994525640668983796015773261569685953934998105618880032424726542199159958765109826319068657402963926076133234319496853075524776587699869880110002212652789599338373374766632270584318684921534991531809773674575216885613254834087656906589273595130283061519210347548003952605137435496698676644099432387131358633818004952076878696452858659625118039024007248867042050163583016655271203039033874213637211783100667331086089431366252520553901470890668833020848364327373878667859550418977150340718689569560014789067141150004494865831998097900535239212100240903052271412702313382699719280119995097830391140939900450195796590580701057261880699435929378144716618199687208636854207677220676342703816346007654654000712945948354934168402397730857396789622118001462425687872901733982808538187288054662802687584504335878286744880609117358175147779246874289953869187414407879183327872885840905274452560853038444350220242862503886313537856302346589297466461098782106694618520511864410159894688716112471203266511444054783130100545131107373171894975391504124928831280802745349123088192942368378813918663241289039750335978515435550061755383042559126996440219313219240355217167259371856904217672352302381607216723973870323901331127712357568997354343761508656092683122756120404449104036742386170101970931472393181508708975969810214757937847080875381778848857961351280259240133475856981005185154890639518630478464981585620200331527992266556709946832247098756705406593026035044994185018297994737245258692345642561219850819801785980260442751663369371111594034780239945798553706895722222730424861030216845306526556616455002573154699956394298829493095815687322195517603302378491149164633632387697044309139580484583823120513577081160154944645177389477625688297574952651887730458102010636324892047255779343369810881290864632213333000015767238979649849617699265200112277556984218268227815995259905813651162054337059159023895160396265909809735701024190867404835483989730187922027276933295360579674910089631981219388871858839604916005265251145823140022519873420132605736405290319715562394154824823993721335512291619766060395392863614802803998404432501328869278376632548326126739229991515302269681456998264144785316378476306532697383572685288299897615830981805626433036297420538981718587383656396697630259265100066939771626710317229611508406910778409292466171866417642819451178561441450303250389719658487370988707581736767864358790291399208634173105151255890528279769738276709248915933058653824053837336971923806447676516465605653399314194382571812083832803953161376476391125622390130916139845204481848941173882183486579676742661475545851136929825391534716957013069362479576462955948903931865865150644597654919775298903255078812128400067903097921100719349187357879165195097898389648532618745334706585915568218449538984787343338210921164261034754416599745081951255382474107140138116315944175097819788182506786147523399553756514717889663626280235858884707066671784142375578571822369617525159630502647804063149468761969494176713393098192020009081404987060890492131125482063325898655531153933689803311743547173393048240762865972388334504161961113479179868199950784115623029144454458451961095385812402131140082590548889600

sage: show(rec)

Example 1:   Lattice Paths & the Kernel Method

We can also find an asymptotic expansion directly via an algo of Dong, Melczer, Mezzarobba (2023):

sage: from ore_algebra.analytic.singularity_analysis import bound_coefficients
sage: 
sage: show(bound_coefficients(deq, [1,2], order=1, prec=20))
1.00000*4^n*(([1.2732 +/- 4.39e-5] + [+/- 2.04e-18]*I)*n^(-1) + B([1678.76 +/- 2.19e-3]*n^(-2)*log(n), n >= 5))

I.e., we have found a real constant \( \lambda \in \left[1.2732 - 4.39\cdot 10^{-5}, 1.2732 + 4.39\cdot 10^{-5}\right] \) so that when \( n \geq 5 \),

\left | s_n - \lambda \frac{4^n}{n} \right | \leq (1678.76 + 2.19\cdot 10^{-3}) ~ \frac{4^n \log n}{n^2}.

(Can also just find an asymptotic in one line with Sage ACSV:)

sage: from sage_acsv import diagonal_asymptotics_combinatorial
sage: diagonal_asymptotics_combinatorial(F)
4/pi*4^n*n^(-1) + O(4^n*n^(-2))
\square

Thank you! :)

Example 2:   Connection Coefficient Problem

Consider the function

F(w,x,y,z) = \frac{1}{1-w-x-y-z+27wxyz}.

[GRZ'83]

  • The singularity  \( \bm \sigma = (1/3,1/3,1/3,1/3) \) contributes to asymptotics for \(\Delta F\).
  • But it is a cone point singularity, hence can't be analyzed with  Sage ACSV.
# Need these, or the resulting computation will be slow.
from sage_acsv import ACSVSettings
ACSVSettings.set_default_groebner_backend('macaulay2')
ACSVSettings.set_default_kronecker_backend('msolve')

from sage_acsv import critical_points, get_expansion_terms, compute_asymptotics_at_points
crit = critical_points(F)
# crit[0]=[1/3,1/3,1/3,1/3]
get_expansion_terms(compute_asymptotics_at_points(F,[crit[0]],expansion_precision=3))[0]
---------------------------------------------------------------------------
ACSVException                             Traceback (most recent call last)
(...)
ACSVException: Not a transverse intersection. Cannot deal with this case.

Example 2:   Connection Coefficient Problem

  • An algo of Baryshnikov, Melczer, and Pemantle [BMP'22] shows that \(F\) has no critical points at infinity (CPAI).
  • Using a result of [BMP'25], the asymptotic derived from \( \mathcal L \) for \( \Delta F \) is an integer multiple of the asymptotic derived from Sage ACSV,  ignoring the non-smooth point.
# Get asymptotic expansion from D-finite operator.
asm = bound_coefficients(diag,[1,-3],order=1)
# Get our leading coefficient
C1 = list(asm.series_factor().summands)[0].coefficient
# Get asymptotic expansion directly from each smooth contributing point using Sage ACSV.
asm2 = get_expansion_terms(compute_asymptotics_at_points(F,[crit[2]],expansion_precision=3))[0]
# Get our leading coefficient
C2 = asm2.coefficient * asm2.pi_factor
# Print the ratio of the coeffs from each method.
print("C1/C2:")
print(CIF(C1/C2))
C1/C2:
3.00000000000000? + 0.?e-14*I

Thus, our true asymptotic is 3 times the result returned by  bound_coefficients.

\square

ICMS Talk - Fast Diagonals of Rational Functions

By John Hunn Smith

ICMS Talk - Fast Diagonals of Rational Functions

Talk given at the 2026 edition of the International Congress of Mathematical Software on July 21, 2026.

  • 42