import math


def acos2(x: float, y: float) -> float:
    """Function to return the inverse cos function across the range (-pi, pi], rather than (0, pi]

    Parameters
    ----------
    x : float
        x coordinate of the point in 2D space
    y : float
        y coordinate of the point in 2D space

    Returns
    -------
    theta : float
        Angle corresponding to point in 2D space in radial coordinates, within range (-pi, pi]
    """
    r = math.sqrt(x**2+y**2)
    if y >= 0:
        return math.acos(x/r)
    else:
        return -math.acos(x/r)