Would specializing the functions to Double then using realToFrac only when necessary improve things? (It might make things worse of course...) buehlmannGradient :: Gas -> Int -> Double