def contraction_sharp(Di1, Di2):
    """Returns loss coefficient for any sharp edged pipe contraction
    as shown in [1]_.

    .. math::
        K = 0.0696(1-\\beta^5)\\lambda^2 + (\\lambda-1)^2

    .. math::
        \\lambda = 1 + 0.622(1-0.215\\beta^2 -  0.785\\beta^5) 

    .. math::
        \\beta = d_2/d_1

    .. figure:: fittings/contraction_sharp.png
       :scale: 40 %
       :alt: Sharp contraction; after [1]_

    Parameters
    ----------
    Di1 : float
        Inside diameter of original pipe, [m]
    Di2 : float
        Inside diameter of following pipe, [m]

    Returns
    -------
    K : float
        Loss coefficient in terms of the following pipe [-]

    Notes
    -----
    A value of 0.506 or simply 0.5 is often used.

    Examples
    --------
    >>> contraction_sharp(Di1=1, Di2=0.4)
    0.5301269161591805

    References
    ----------
    .. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
       and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
    """
    beta = Di2 / Di1
    lbd = 1 + 0.622 * (1 - 0.215 * beta ** 2 - 0.785 * beta ** 5)
    return 0.0696 * (1 - beta ** 5) * lbd ** 2 + (lbd - 1) ** 2
