@staticmethod
def clenshaw(x, coeffs):
    """Evaluates the polynomial using Clenshaw's algorithm."""
    if len(coeffs) == 1:
        c0 = coeffs[0]
        c1 = 0
    elif len(coeffs) == 2:
        c0 = coeffs[0]
        c1 = coeffs[1]
    else:
        x2 = 2 * x
        c0 = coeffs[-2]
        c1 = coeffs[-1]
        for i in range(3, len(coeffs) + 1):
            tmp = c0
            c0 = coeffs[-i] - c1
            c1 = tmp + c1 * x2
    return c0 + c1 * x
