jeanluct / braidlab

Matlab package for analyzing data using braids
GNU General Public License v3.0
24 stars 10 forks source link

compact fails on very large braids #46

Closed jeanluct closed 9 years ago

jeanluct commented 9 years ago

Works for random braid of length 1000, but not 10000. I don't see why not.

#!matlab

>> rng('default'); b=braid('random',10,1000); b2 = b*inv(b); b3 = compact(b2); isempty(b3.word)

ans =

     1

>> rng('default'); b=braid('random',10,10000); b2 = b*inv(b); b3 = compact(b2); isempty(b3.word)

ans =

     0
jeanluct commented 9 years ago

From Jean-Luc Thiffeault on 2014-02-16 23:44:08+00:00

Here's a shorter braid with the problem:

#!matlab

for k = 1:1000
  rng('default');
  b = braid('random',10,k);
  b2 = b*inv(b);
  b3 = compact(b2);
  if ~isempty(b3.word)
    error('Not empty: k=%d, b=%s, compact(b*inv(b))=%s',k,char(b),char(b3))
  end
end

Output:

#!matlab

>> test_compact
Error using test_compact (line 7)
Not empty: k=10, b=< 2  9 -9  5  8 -2 -4  9  8  9 >, compact(b*inv(b))=< 8  8  9  8 -8 -9 -8 -8 >

So our problem is reduced to this:

#!matlab

>> compact(braid([8  8  9  8 -8 -9 -8 -8]))

ans = 

 < 8  8  9  8 -8 -9 -8 -8 >
jeanluct commented 9 years ago

From Jean-Luc Thiffeault on 2014-02-17 00:23:47+00:00

Ok, I see why it fails: when it gets to the second 8, compact_helper changes 898 to 989. Then cancellations can't happen. Not sure what to do about this.

jeanluct commented 9 years ago

From Jean-Luc Thiffeault on 2014-02-17 00:36:20+00:00

compact_helper: try with and without the 2nd relation. Resolves issue #46.

→ <>