def bezier_tangent(p0: float, p1: float, p2: float, p3: float, t: float):
    """
    Calculate the tangent of the point with parameter t on the cubic bezier curve.

    Note that the parameter t must >=0 and <=1 .

    :param p0: position of the first control point
    :param p1: position of the second control point
    :param p2: position of the third control point
    :param p3: position of the forth control point
    :param t: the parameter t
    :return: tangent of the point
    """
    if t < 0 or t > 1:
        raise ValueError('t must in [0..1]')
    return 3 * (1 - t) ** 2 * (p1 - p0) + 6 * (1 - t) * t * (p2 - p1
        ) + 3 * t ** 2 * (p3 - p2)
