def newmoon(jd):
    ''' search newmoon near a given date.

    Angle between Sun-Moon has been converted to [-pi, pi] range so the
    function f_msangle is continuous in that range. Use Secand method to find
    root.

    Test shows newmoon can be found in 5 iterations, if the start is close
    enough, it may use only 3 iterations.

    Arg:
        jd: in JDTT
    Return:
        JDTT of newmoon

    '''

    # 0.0000001 radians is about 0.02 arcsecond, mean error of apparentmoon
    # when compared to JPL Horizon is about 0.7 arcsecond
    ERROR = 0.0000001

    # initilize x0 to the day close to newmoon
    x0 = jd - f_msangle(jd, 0) / MOON_SPEED
    x1 = x0 + 0.5
    return rootbysecand(f_msangle, 0, x0, x1, precision=ERROR)
 search newmoon near a given date.

    Angle between Sun-Moon has been converted to [-pi, pi] range so the
    function f_msangle is continuous in that range. Use Secand method to find
    root.

    Test shows newmoon can be found in 5 iterations, if the start is close
    enough, it may use only 3 iterations.

    Arg:
        jd: in JDTT
    Return:
        JDTT of newmoon

    
aa_full.py