Frequency dependent hyperpolarizabilities with application to formaldehyde and methyl fluoride