"""Real directions on a quaternionic slice at H_5 and its local multiplicity.""" from itertools import product import numpy as np import sympy as sp from sympy.polys.matrices import DomainMatrix import real_branches as r from mixed_jets import inverse def slopes(offset): coefficients = r.interpolate(offset) z = sp.Symbol("z") sqrt5 = sp.sqrt(5) polys = [] for row in (0, 1): pair = [] for degree in (2, 3): expr = 0 for (i, j), values in coefficients.items(): if i+j != degree: continue value = values[:, row] assert value[1] == value[3] == 0 coeff = sp.Rational(value[0])+sp.Rational(value[2])*(5+sqrt5)/2 expr += coeff*z**j pair.append(sp.Poly(expr, z, extension=sqrt5)) polys.append(pair) (p, q), (h, k) = polys eliminant = p*k-h*q assert eliminant.degree() == 5 and eliminant.gcd(p*q).degree() == 0 half = sp.Rational(1, 2) intervals = [(-13, -12), (-5, -4), (-7*half, -3), (-3, -2), (-3*half, -half)] for a, b in intervals: signs = [sp.sign(eliminant.eval(x)) for x in (a, b)] assert signs[0]*signs[1] == -1 print("Slope interval:", a, b, signs, flush=True) def tangent_vector(free): vector = np.zeros((4, 40), dtype=object) vector[:, 34:] = free vector[:, :34] = -r.mat(r.iv, r.mat(r.J, vector)[:, r.rows]) return r.phases(vector) def field_rank(columns): # Restriction of scalars from Q(s) to Q multiplies the rank by four. matrix = np.stack(columns, axis=-1).reshape(4, 100, len(columns)) blocks = r.times(matrix[:, :, :, None], np.eye(4, dtype=object)[:, None, None, :]) rational = blocks.transpose(1, 0, 2, 3).reshape(400, 4*len(columns)) rank = DomainMatrix.from_Matrix(sp.Matrix(rational.tolist())).rank() assert rank % 4 == 0 return rank//4 def exclude_original_families(offset): arrays = [tangent_vector(x) for x in [r.A, r.B, offset]] for u, v, sign in product(range(5), range(5), [1, -1]): if (u, v, sign) == (0, 0, 1): continue def indices(labels): return [5*i+(sign*j+v-2*h*u) % 5 for i, h in enumerate(labels) for j in range(5)] cols = [] for array in arrays: difference = array[:, indices(r.slopes)][:, :, indices(r.targets)]-array cols.append(difference-difference[:, :1, :]-difference[:, :, :1]+difference[:, :1, :1]) rank = field_rank(cols[:2]) if r.norm(cols[2]): assert field_rank(cols) > rank else: assert rank == 2 print("All five velocities lie outside the original 27 tangent spaces.", flush=True) def fixed_multiplicity(): def reduce(value): return sum(int(z.numerator)*pow(int(z.denominator), -1, 101)*9**k for k, z in enumerate(value)) % 101 u = r.vec(*(r.q(n) for n in (1, 2, 3, 4, 5, 6))) v = r.vec(*(r.q(n) for n in (2, 3, 5, 7, 11, 13))) values = np.array([[reduce(column) for column in r.along(u+h*v)[-1].T] for h in range(7)]) evaluation = np.array([[pow(h, n, 101) for n in range(7)] for h in range(7)]) forms = inverse(evaluation, 101) @ values % 101 sylvester = np.zeros((12, 12), dtype=int) for j in range(6): sylvester[j, j:j+7] = forms[:, 0] sylvester[j+6, j:j+7] = forms[:, 1] assert int(sp.Matrix(sylvester).det()) % 101 == 14 print("The two leading sextics have resultant 14 modulo 101 on the test plane.") if __name__ == "__main__": offset = r.vec(*(r.q(n) for n in (0, 2, 3, 0, -4, 5))) slopes(offset) exclude_original_families(offset) fixed_multiplicity()