def bezier2polynomial(p, numpy_ordering=True, return_poly1d=False):
if len(p) == <NUM_LIT:4>:<EOL><INDENT>coeffs = (-p[<NUM_LIT:0>] + <NUM_LIT:3>*(p[<NUM_LIT:1>] - p[<NUM_LIT:2>]) + p[<NUM_LIT:3>],<EOL><NUM_LIT:3>*(p[<NUM_LIT:0>] - <NUM_LIT:2>*p[<NUM_LIT:1>] + p[<NUM_LIT:2>]),<EOL><NUM_LIT:3>*(p[<NUM_LIT:1>]-p[<NUM_LIT:0>]),<EOL>p[<NUM_LIT:0>])<EOL><DEDENT>elif len(p) == <NUM_LIT:3>:<EOL><INDENT>coeffs = (p[<NUM_LIT:0>] - <NUM_LIT:2>*p[<NUM_LIT:1>] + p[<NUM_LIT:2>],<EOL><NUM_LIT:2>*(p[<NUM_LIT:1>] - p[<NUM_LIT:0>]),<EOL>p[<NUM_LIT:0>])<EOL><DEDENT>elif len(p) == <NUM_LIT:2>:<EOL><INDENT>coeffs = (p[<NUM_LIT:1>]-p[<NUM_LIT:0>],<EOL>p[<NUM_LIT:0>])<EOL><DEDENT>elif len(p) == <NUM_LIT:1>:<EOL><INDENT>coeffs = p<EOL><DEDENT>else:<EOL><INDENT>n = len(p) - <NUM_LIT:1><EOL>coeffs = [fac(n)//fac(n-j) * sum(<EOL>(-<NUM_LIT:1>)**(i+j) * p[i] / (fac(i) * fac(j-i)) for i in range(j+<NUM_LIT:1>))<EOL>for j in range(n+<NUM_LIT:1>)]<EOL>coeffs.reverse()<EOL><DEDENT>if not numpy_ordering:<EOL><INDENT>coeffs = coeffs[::-<NUM_LIT:1>]  <EOL><DEDENT>if return_poly1d:<EOL><INDENT>return poly1d(coeffs)<EOL><DEDENT>return coeffs<EOL>
Converts a tuple of Bezier control points to a tuple of coefficients
    of the expanded polynomial.
    return_poly1d : returns a numpy.poly1d object.  This makes computations
    of derivatives/anti-derivatives and many other operations quite quick.
    numpy_ordering : By default (to accommodate numpy) the coefficients will
    be output in reverse standard order.