[sage-support] Re: noncommutative polynomials and free differential calculus
Nicholas, Its possible that Axiom's XPOLY non-commutative polynomial domain might be of some help. E.g. sage: x=axiom('x::XDistributedPolynomial(Symbol,Integer)') sage: y=axiom('y::XDistributedPolynomial(Symbol,Integer)') sage: z=axiom('z::XDistributedPolynomial(Symbol,Integer)') sage: p=2*x*y*z sage: q=z*x*y+3*z sage: pq=p*q sage: pq 2 2 6x y z + 2x y z x y sage: pq.leadingCoefficient() 2 sage: pq.leadingMonomial() 2 x y z x y sage: pq.reductum() 2 6x y z But note that XPOLY does not allow negative exponents and you would have to build the derivative operations. Implementing non-commutative Laurent polynomials in Axiom/FriCAS would not be difficult (There is already a commutative Laurent polynomial domain which can serve as a model.) Adding free derivatives would be a little more involved. If you are at all interested, please let me know. In any case, XPOLY might serve as a starting point for something similar in Sage. Regards, Bill Page. On Thu, Aug 13, 2009 at 11:39 AM, Nicholas Jacksonnicholas.jack...@warwick.ac.uk wrote: I'm trying to use SnapPy [1] to calculate Alexander polynomials of knot complements. SnapPy (which interfaces nicely with Sage) will happily give me a presentation of the fundamental group of the knot complement, and I want to take this and calculate the free derivatives of the group's relators by the recursive formula d(uv) = du + u * dv d(u^-1) = -u^-1 * du d(1) = 0 For a word w in the generators, we define the free derivative dw/dx to be the coefficient of dx in the expression for dw - this will in general be a polynomial in the (noncommuting) generators for the fundamental group. I'm having a little difficult figuring out the best way to deal with this in Sage - I need multivariate Laurent polynomials with noncommuting variables - and wondered if anyone has any recommendations. I've been trying to use a FreeAlgebra or FreeAlgebraQuotient but I'm not quite sure how to go about this. Any suggestions would be very welcome. Nicholas [1] http://www.math.uic.edu/~t3m/SnapPy/doc/ --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: noncommutative polynomials and free differential calculus
On Thu, Aug 13, 2009 at 8:39 AM, Nicholas Jacksonnicholas.jack...@warwick.ac.uk wrote: I'm trying to use SnapPy [1] to calculate Alexander polynomials of knot complements. SnapPy (which interfaces nicely with Sage) will happily give me a presentation of the fundamental group of the knot complement, and I want to take this and calculate the free derivatives of the group's relators by the recursive formula d(uv) = du + u * dv d(u^-1) = -u^-1 * du d(1) = 0 For a word w in the generators, we define the free derivative dw/dx to be the coefficient of dx in the expression for dw - this will in general be a polynomial in the (noncommuting) generators for the fundamental group. I'm having a little difficult figuring out the best way to deal with this in Sage - I need multivariate Laurent polynomials with noncommuting variables - and wondered if anyone has any recommendations. I've been trying to use a FreeAlgebra or FreeAlgebraQuotient but I'm not quite sure how to go about this. Any suggestions would be very welcome. Nicholas [1] http://www.math.uic.edu/~t3m/SnapPy/doc/ I'm cc'ing Nathan Dunfield since he wrote SnapPy, and I'm cc'ing the sage-combinat-devel list, since they are perhaps likely to care about functionality related to noncommutative rings. Unless they have some remarks, odds are that the structure you need isn't in Sage at all, and you'll get to implement it nearly from scratch. William --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: noncommutative polynomials and free differential calculus
On Aug 13, 10:39 am, Nicholas Jackson nicholas.jack...@warwick.ac.uk wrote: I'm trying to use SnapPy [1] to calculate Alexander polynomials of knot complements. Nicholas, You can find code I wrote to compute the Alexander polynomial using a mix of Sage and Magma here: http://dunfield.info/fibered-faces/ If you don't have Magma, it shouldn't be too hard to port what's in alexander.magma into Sage, and indeed this would be a worthwhile project. As you can see from the code there, it is possible to avoid actually using noncommutative rings, so there's no need to create them. (Even if you really want to compute twisted Alexander polynomials this can still be avoided.) Just yesterday I wrote Sage code for one thing you'll need --- computing the free abelianization of the fundamental group of the knot complement. It's below. Best, Nathan --- import os, sys, re, string import snappy import sage from sage.all import Integers, vector, matrix # # # Abelianization of the fundamental group # # ZZ = Integers() def abelianize_word(word, gens): return vector(ZZ, [ word.count(g) - word.count(g.swapcase()) for g in gens]) class MapToFreeAbelianization(sage.structure.sage_object.SageObject): def __init__(self, fund_group): self.domain_gens = fund_group.generators() R = matrix(ZZ, [abelianize_word(R, self.domain_gens) for R in fund_group.relators()]).transpose() D, U, V = R.smith_form() self.U = U self.elementry_divisors = [D[i,i] for i in range(D.ncols())] + [0,]*(D.nrows() - D. ncols()) def range(self): return ZZ**self.elementry_divisors.count(0) def __call__(self, word): D = self.elementry_divisors v = self.U*abelianize_word(word, self.domain_gens) return vector(ZZ, [v[i] for i in range(len(D)) if D[i] == 0]) # Sample function using this def homological_longitude(manifold, cusp=0): G = manifold.fundamental_group() f = MapToFreeAbelianization(G) m, l = G.peripheral_curves()[cusp] kernel_basis = matrix(ZZ, [f(m), f(l)]).left_kernel().basis() assert len(kernel_basis) 2 if len(kernel_basis) == 0: return None return kernel_basis[0] --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: noncommutative polynomials and free differential calculus
On Aug 14, 7:54 am, Nathan Dunfield nat...@dunfield.info wrote: You can find code I wrote to compute the Alexander polynomial using a mix of Sage and Magma here: http://dunfield.info/fibered-faces/ If you don't have Magma, it shouldn't be too hard to port what's in alexander.magma into Sage, and indeed this would be a worthwhile project. I just realized that the code I referred to above used the old Python- SnapPea inverface, not SnapPy. Below is a code snippet for using alexander.magma with Sage and SnapPy. An usage example: sage: attach alexander.py sage: M = snappy.Manifold(8^2_4) sage: alexander_polynomial(M) a^5 + 2*a^4 - 2*a^3*b + a^2*b^2 + a^3 - 2*a^2*b + 2*a*b^2 + b^2 Best, Nathan Contents of alexander.py- import os, sys, re, string, snappy # # # Computing Alexander polynomials via Magma # # magma.load(alexander.magma) magma.eval( DeconstructPolynomial := function(p) return [Exponents(m) : m in Monomials(p)], Coefficients(p); end function; ) def sage_poly_from_magma(poly): exponents, coeffs = poly.DeconstructPolynomial(nvals=2) exponents, coeffs = exponents.sage(), coeffs.sage() n = len(exponents[0]) R = PolynomialRing(Rationals(), list(string.lowercase[:n])) gens = R.gens() def make_term(exp, c): ans = c for i in range(len(exp)): ans = ans * gens[i]**exp[i] return ans return sum( [ make_term(exponents[i], coeffs[i]) for i in range(len (exponents))]) def alexander_polynomial(manifold): G = manifold.fundamental_group() if len(G.generators()) == 1 and len(G.relators()) == 0: return PolynomialRing(ZZ, a)(1) G = magma(manifold.fundamental_group()) return sage_poly_from_magma(G.AlexanderPolynomial()) --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: noncommutative polynomials and free differential calculus
I went ahead and did a quick port of my Magma code over to Sage --- I'm trying to wean myself of Magma as much as possible. You can find it as the file alexander.py at http://dunfield.info/snappea/ Example usage: sage: import snappy sage: from alexander import alexander_polynomial sage: M = snappy.Manifold('m004') sage: alexander_polynomial(M) -a^2 + 3*a - 1 sage: M = snappy.Manifold('v3551') sage: alexander_polynomial(M) a^4*b^4 + a^4*b^3 + a^3*b^4 + a^4*b^2 + 2*a^3*b^3 + a^2*b^4 + 2*a^3*b^2 + 2*a^2*b^3 + a^3*b + 2*a^2*b^2 + a*b^3 + 2*a^2*b + 2*a*b^2 + a^2 + 2*a*b + b^2 + a + b + 1 Best, Nathan --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---