sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.39k stars 472 forks source link

Add Jones representation of braid groups and Jones polynomials of braid closures #19011

Closed fuglede closed 9 years ago

fuglede commented 9 years ago

First off, this is my first ticket here, so please let me know about process related stuff that I missed.

As per this discussion on sage-devel, these commits contain methods for Braid and BraidGroup_class to allow for the calculation of the Temperley--Lieb--Jones representations of braid groups. While interesting in their own right, this also allows for a straightforward implementation of the (uncoloured) Jones polynomial of trace closures of braids, also included, which for a fixed number of braid strands is polynomial in the number of crossings. The algorithm uses Kauffman's diagrammatic description of the Temperley--Lieb algebra.

It should be noted that there is some overlap here with #17030 but as discussed on sage-devel, this is not necessarily a problem (although of course any code that is duplicated exactly should be coordinated between that ticket and this one).

One sillily todo is to add my own name (Søren Fuglede Jørgensen) to the list of authors. No matter how I've tried to do this, the building failes; probably due to encoding issues, I would imagine (but simply translating the string to unicode does not solve the issue).

The branch also contains a small bit of code clean-up cf. GH PR #47.

CC: @miguelmarco @amitjamadagni

Component: algebraic topology

Author: Søren Fuglede Jørgensen

Branch/Commit: 37ca1e8

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/19011

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

648509bRemove irrelevant comment
a022f34Add examples to Temperley-Lieb action evaluation
tscrim commented 9 years ago
comment:38

This is completely baffling to me:

sage: R.<x> = QQ[]
sage: p = R.random_element(degree=5000)
sage: %timeit p.subs(x=x^2)
1 loops, best of 3: 1.18 s per loop
sage: %timeit p(x=x^2)
1 loops, best of 3: 1.22 s per loop
sage: %timeit p(x^2)
10 loops, best of 3: 38.6 ms per loop
sage: %timeit p.subs(x^2)
10 loops, best of 3: 38.3 ms per loop
sage: %timeit p(x=x^2)
1 loops, best of 3: 1.23 s per loop

So calling subs or direct evaluation without parameters with way faster for regular polynomials (and deserves a separate ticket if there isn't one already). However nothing beats direct coercion:

sage: S.<x> = LaurentPolynomialRing(QQ)
sage: q = x^-2300 * p
sage: T.<y> = LaurentPolynomialRing(QQ)
sage: %timeit T(q)
The slowest run took 5.28 times longer than the fastest. This could mean that an intermediate result is being cached 
10000 loops, best of 3: 158 µs per loop

I will make this change as part of my review (which I am starting now).

tscrim commented 9 years ago

Reviewer: Travis Scrimshaw

tscrim commented 9 years ago

Changed branch from u/fuglede/jones_rep to u/tscrim/jones_rep-19011

tscrim commented 9 years ago
comment:39

Okay, I've made my first pass of reviewer changes. There's probably some more documentation stuff that will need to be addressed, but I wanted you to run some speed tests against your previous timings to see what improvements (or regressions) have been made.


New commits:

6bede85Merge branch 'u/fuglede/jones_rep' of git://trac.sagemath.org/sage into u/tscrim/jones_rep-19011
53eedfeFirst pass of review changes.
3f29732Doing some more reviewer changes; hopefully gaining some speed.
tscrim commented 9 years ago

Changed commit from a022f34 to 3f29732

fuglede commented 9 years ago
comment:40

Thanks for the detailed review!

Since most of the changes were related to internals in TL_representation and jones_polynomial, I ran some tests on those methods. Each test was performed three times on a fresh instance of sage (so caching specifics have not been tested), alternating between the old branch and the one that includes your fixes.

Test 1: Calculation of a huge TL_representation (34 13260x13260 matrices):

My branch:

```
sage: B = BraidGroup(18)
sage: %time B.TL_representation(4)
CPU times: user 1min 23s, sys: 104 ms, total: 1min 23s
CPU times: user 1min 23s, sys: 104 ms, total: 1min 23s
CPU times: user 1min 22s, sys: 92 ms, total: 1min 22s
```

Your branch:

```
sage: B = BraidGroup(18)
sage: %time B.TL_representation(4)
CPU times: user 1min 12s, sys: 84 ms, total: 1min 12s
CPU times: user 1min 12s, sys: 80 ms, total: 1min 12s
CPU times: user 1min 13s, sys: 116 ms, total: 1min 13s
```

Conclusion: Considerable speed gain.

Test 2: Calculation of the Jones polynomials of 2961 knots obtained as closures of braids on at most 7 strands. The test does not use skein_normalisation so that in particular, any speed gain obtained through the removal of subs should be visible here. The (somewhat ad hoc) test is available here.

My branch:

```
sage: load("jonesdata.py")
sage: test_against_dictionary()
2961 matches and 0 mismatches found in 36.658627 seconds
2961 matches and 0 mismatches found in 35.956593 seconds
2961 matches and 0 mismatches found in 36.534720 seconds
```

Your branch:

```
sage: load("jonesdata.py")
sage: test_against_dictionary()
2961 matches and 0 mismatches found in 34.822386 seconds
2961 matches and 0 mismatches found in 34.758321 seconds
2961 matches and 0 mismatches found in 36.320710 seconds
```

Conclusion: Speed gain appears to be less significant here.

tscrim commented 9 years ago
comment:41

Thank you for running those timings. I'm glad to see that we've squeezed some more speed out of this. I'm going to make another pass over the documentation shortly, but there will likely be minimal changes.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

ecb3f0eMerge branch 'develop' into u/tscrim/jones_rep-19011
460b3caSome other tweaks and changes to finish the review.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 9 years ago

Changed commit from 3f29732 to 460b3ca

tscrim commented 9 years ago
comment:43

Okay, I'm done making reviewer changes. If you're happy with my latest changes, then you can set a positive review.

fuglede commented 9 years ago

Changed commit from 460b3ca to 37ca1e8

fuglede commented 9 years ago

Changed branch from u/tscrim/jones_rep-19011 to u/fuglede/jones_rep

fuglede commented 9 years ago
comment:44

Looks good to me. I'm setting to positive review after changing just a single variable name.

vbraun commented 9 years ago

Changed branch from u/fuglede/jones_rep to 37ca1e8