Code Snippets Sage

Short texts Sage 🧑‍💻 Code snippets Sage ✍️ Reading lists Sage 👀

solution.sage

# Sage 8.9 gamma = [159302592, 994350708, 676999378, 80365718, 221916454, 254287578, 216463811, 173496657, 821614440, 911119850, 5400857, 701609575, 177531310, 859972182, 602200504, 105439052, 702643155, 84354161, 799582453, 979166124, 502832636, 25498658, 614033180, 134575285, 908047145, 770703208, 607025100] MOD = 1000000007 field = GF(MOD) gamma = map(field, gamma) A = matrix([[gamma[j + i] for j in range(9)] for i in range(9)]) […]

ferman from CryptoCTF 2021

from Crypto.Util.number import * e = 65537 a = 769 b = 90 # (p – a)**2 + (q – b)**2 == k**7 k = 533349483431826854866479442416204129077526048835547852310509534957185 c = 4478819143432789024587861603523572305269547479550443133641110109373270566470025946722977115602647046295004476694988416461505550664119915082335497331912881526446940124404687029541487759747406116312872601161581904176763818623358120927587871262018474674411074996384180525486478668863914557062661081721929081678057785839028975581815732964462013512812566725502749216649190469493027431158255717939171221374546082898410798277258418126725070247145397363980604758633071972900958843430904130 p, q = var(“p q”) assume(p, “integer”) assume(q, “integer”) sol = solve(p ** 2 + q ** 2 == k, p, q) sol = [(Integer(p), Integer(q)) […]

Chern numbers of K3^[n] in Sage

class TnVariety: “”” A variety with a torus action for computing with Bott’s formula “”” def __init__(self, n, points, weight): self.n = n self.points = points self.weight = weight def chern_numbers(self): n = self.n pp = Partitions(n) ans = {p: 0 for p in pp} for pt in self.points: w = self.weight(pt) chern = [1] […]

LLV decomposition of hyperkähler cohomology in Sage

def hodge_num(d, V): “”” Hodge numbers of a g-module V for a hyperkähler manifold of dimension d “”” n = d / 2 m = V.weight_multiplicities() M = matrix([[0 for i in range(d + 1)] for j in range(d + 1)]) for w in m: M[w[0] + w[1] + n, w[0] – w[1] + n] […]

Searching for periodic hypergeometric functions

In principle, we should derive essentially the same solutions for $(k,l,m)$ as for $(l,k,m)$ by symmetry in the upper arguments, and for $(k,l,m)$ as for $(-k,-l,-m)$ by effectively negating the sign of $t$. I haven’t implemented negative $l$ or positive $m$ so can’t check the latter. For the former, I see the symmetry correctly observed […]