'Computes a functional decomposition of ``f``.
Examples
>>> from sympy import Poly
>>> from sympy.abc import x
>>> Poly(x**4 + 2*x**3 - x - 1, x, domain=\'ZZ\').decompose()
[Poly(x**2 - x - 1, x, domain=\'ZZ\'), Poly(x**2 + x, x, domain=\'ZZ\')]'

def decompose(f):

    if hasattr(f.rep, 'decompose'):
        result = f.rep.decompose()
    else:
        raise OperationNotSupported(f, 'decompose')
    return list(map(f.per, result))
