def atan(x, context=None):
    """
    Return the inverse tangent of ``x``.

    The mathematically exact result lies in the range [-π/2, π/2].  However,
    note that as a result of rounding to the current context, it's possible
    for the actual value to lie just outside this range.

    """
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_atan,
        (BigFloat._implicit_convert(x),),
        context,
    )