import mpmath


def logpdf(x, df):
    """
    Logarithm of the PDF of Student's t distribution.
    """
    if df <= 0:
        raise ValueError('df must be greater than 0')

    with mpmath.extradps(5):
        x = mpmath.mpf(x)
        df = mpmath.mpf(df)
        h = (df + 1) / 2
        logp = (mpmath.loggamma(h)
                - mpmath.log(df * mpmath.pi)/2
                - mpmath.loggamma(df/2)
                - h * mpmath.log1p(x**2/df))
    return logp