def _solve_expx_x_logx(tau, tol, kernel, ln, max_steps=10):
    """Solves the equation

    log(pi/tau) = pi/2 * exp(x) - x - log(x)

    approximately using Newton's method. The approximate solution is guaranteed
    to overestimate.
    """
    # Initial guess
    x = kernel.log(2 / kernel.pi * ln(kernel.pi / tau))
    # x = ln(tau / kernel.pi) - kernel.lambertw(-tau / 2, -1)
    # x = (
    #     mp.mpf(1) / 2
    #     - mp.log(mp.sqrt(mp.pi / tau))
    #     - mp.lambertw(-mp.sqrt(mp.exp(1) * mp.pi * tau) / 4, -1)
    # )

    def f0(x):
        return kernel.pi / 2 * kernel.exp(x) - x - kernel.log(x * kernel.pi / tau)

    def f1(x):
        return kernel.pi / 2 * kernel.exp(x) - 1 - 1 / x

    f0x = f0(x)
    success = False
    # At least one step is performed. This is required for the guarantee of
    # overestimation.
    for _ in range(max_steps):
        x -= f0x / f1(x)
        f0x = f0(x)
        if abs(f0x) < tol:
            success = True
            break

    assert success
    return x