def bezier_unit_tangent(seg, t):
assert <NUM_LIT:0> <= t <= <NUM_LIT:1><EOL>dseg = seg.derivative(t)<EOL>try:<EOL><INDENT>unit_tangent = dseg/abs(dseg)<EOL><DEDENT>except (ZeroDivisionError, FloatingPointError):<EOL><INDENT>dseg_poly = seg.poly().deriv()<EOL>dseg_abs_squared_poly = (real(dseg_poly) ** <NUM_LIT:2> +<EOL>imag(dseg_poly) ** <NUM_LIT:2>)<EOL>try:<EOL><INDENT>unit_tangent = csqrt(rational_limit(dseg_poly**<NUM_LIT:2>,<EOL>dseg_abs_squared_poly, t))<EOL><DEDENT>except ValueError:<EOL><INDENT>bef = seg.poly().deriv()(t - <NUM_LIT>)<EOL>aft = seg.poly().deriv()(t + <NUM_LIT>)<EOL>mes = ("<STR_LIT>"<EOL>"<STR_LIT>".format(t) +<EOL>"<STR_LIT>".format(bef) +<EOL>"<STR_LIT>".format(aft))<EOL>raise ValueError(mes)<EOL><DEDENT><DEDENT>return unit_tangent<EOL>
Returns the unit tangent of the segment at t.

    Notes
    -----
    If you receive a RuntimeWarning, try the following:
    >>> import numpy
    >>> old_numpy_error_settings = numpy.seterr(invalid='raise')
    This can be undone with:
    >>> numpy.seterr(**old_numpy_error_settings)