byorgey / species

Other
17 stars 1 forks source link

Differentiating unlabeled/CycleIndex produces too many terms #2

Closed jasoncarr0 closed 8 years ago

jasoncarr0 commented 8 years ago

For example: unlabeled $ pointed $ (cycles * cycles) [0, 0, 2, 1, 3, 4, 14, 1, 4, 1, 31, 8, 42, 2, 13, 2, 4, 1, 32, 12, 86 ... ] unlabeled $ ((cycles * cycles) >< (x * set)) [0, 0, 2, 4, 6, 8, 10, 12, 14, 16 ...] Which is the correct answer

The cycle indices have similar behaviour: The former produces CI 2 % 1 x1^2 + x1 x2 + 3 % 1 x1^3 + 4 % 3 x1 x3 + x1^2 x2 + 11 % 3 x1^4 + x1 x4 + 4 % 3 x1^2 x3 + 1 + ... The expected is CI 2 % 1 x1^2 + x1 + 3 % 1 x1^3 + 4 % 3 x1 + x1^2 x2 + 11 % 3 x1^4 + x1 + 4 % 3 x1^2 x3 + 1 % 2 x1 + ...

It's possible the behaviour comes from the inherited multivariable polynomial differentiation

byorgey commented 8 years ago

Thanks for the report! I don't have a lot of time right now but I hope to be able to look into this at some point.

byorgey commented 8 years ago

I finally had a chance to look at this. The problem was indeed multivariate polynomial differentiation. I am not sure how this bug survived this long, it was just blatantly wrong. Here was the fix:

http://hub.darcs.net/byorgey/np-extras/patch/a8e0d6d20e91a623bb31810b302f90f993ba67fb

Thanks again for the report! If you do a cabal update and reinstall species, it should pull in np-extras-0.3.1 (the version with the bug fix) and resolve this problem. Let me know if it works for you.