code: def derivative(self, t, n=1):
          
          p = self.bpoints()
          if n == 1:
              return 3*(p[1] - p[0])*(1 - t)**2 + 6*(p[2] - p[1])*(1 - t)*t + 3*(
                  p[3] - p[2])*t**2
          elif n == 2:
              return 6*(
                  (1 - t)*(p[2] - 2*p[1] + p[0]) + t*(p[3] - 2*p[2] + p[1]))
          elif n == 3:
              return 6*(p[3] - 3*(p[2] - p[1]) - p[0])
          elif n > 3:
              return 0
          else:
              raise ValueError("n should be a positive integer.")
docs: 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.