polynomial decomposition added, it does not scale well with size, but it works
bug corrected