def derivative(self, t, n=<NUM_LIT:1>):
p = self.bpoints()<EOL>if n == <NUM_LIT:1>:<EOL><INDENT>return <NUM_LIT:3>*(p[<NUM_LIT:1>] - p[<NUM_LIT:0>])*(<NUM_LIT:1> - t)**<NUM_LIT:2> + <NUM_LIT:6>*(p[<NUM_LIT:2>] - p[<NUM_LIT:1>])*(<NUM_LIT:1> - t)*t + <NUM_LIT:3>*(<EOL>p[<NUM_LIT:3>] - p[<NUM_LIT:2>])*t**<NUM_LIT:2><EOL><DEDENT>elif n == <NUM_LIT:2>:<EOL><INDENT>return <NUM_LIT:6>*(<EOL>(<NUM_LIT:1> - t)*(p[<NUM_LIT:2>] - <NUM_LIT:2>*p[<NUM_LIT:1>] + p[<NUM_LIT:0>]) + t*(p[<NUM_LIT:3>] - <NUM_LIT:2>*p[<NUM_LIT:2>] + p[<NUM_LIT:1>]))<EOL><DEDENT>elif n == <NUM_LIT:3>:<EOL><INDENT>return <NUM_LIT:6>*(p[<NUM_LIT:3>] - <NUM_LIT:3>*(p[<NUM_LIT:2>] - p[<NUM_LIT:1>]) - p[<NUM_LIT:0>])<EOL><DEDENT>elif n > <NUM_LIT:3>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
returns the nth derivative of the segment at t.
        Note: Bezier curves can have points where their derivative vanishes.
        If you are interested in the tangent direction, use the unit_tangent()
        method instead.