import math


def get_magAB_from_flambda(flambda, wlength):
    """                                                                                                             
    Converts a mag_AB value at a wavelength to f_lambda.
                                                                                                                     
    :param flambda: mag_AB value
    :type flambda: float
    :param wlength: wavelength value [nm]
    :type wlength: float
                                                                                                                     
    :return: the mag_AB value
    :rtype: float
    """
    # transform from flambda to fnue                                                                                 
    fnu = (wlength * wlength) / 2.99792458e+16 * flambda

    # compute mag_AB                                                                                                 
    mag_AB = -2.5 * math.log10(fnu) - 48.6

    # return the mag_AB                                                                                              
    return mag_AB