def __pow__(self, exponent):
        """\
Uses the Russian Peasant Multiplication algorithm.

>>> str(SimplePolynomial() ** 2)
'X**2'
>>> str(SimplePolynomial() ** 0.5)
Traceback (most recent call last):
...
NotImplementedError: exponent is not an integer
>>> str(SimplePolynomial() ** -1)
Traceback (most recent call last):
...
NotImplementedError: exponent is less than zero
"""
        if not isinstance(exponent, int):
            raise NotImplementedError('exponent is not an integer')
        if exponent < 0:
            raise NotImplementedError('exponent is less than zero')
        tmp = self.copy()
        result = SimplePolynomial([1])
        while exponent > 0:
            if exponent & 1:
                result *= tmp
            tmp *= tmp
            exponent >>= 1
        return result
Uses the Russian Peasant Multiplication algorithm.

>>> str(SimplePolynomial() ** 2)
'X**2'
>>> str(SimplePolynomial() ** 0.5)
Traceback (most recent call last):
...
NotImplementedError: exponent is not an integer
>>> str(SimplePolynomial() ** -1)
Traceback (most recent call last):
...
NotImplementedError: exponent is less than zero

recipes/Python/576953_Simple_polynomial_class/recipe-576953.py