Approximate math library for Linux? Or exp function algorithm?

Approximate math library for Linux? Or exp function algorithm?


I'm working on a project for which I need a very fast & vectorizableapproximation of the exp function, accurate to say 0.1% or so. I've tried to use the approximate math library, but that appears to be Windows-specific. (I did hack around a bit and get a version that would compile, but it causes a segfault sometime after the am_exp_ps call returns.)

Would anyone know if a) there's a Linux version around somewhere; b) what needs to be done to convert the Windows code; or c) the source of the algorithm used, so I can code it myself?


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


Have you ever checked out the Intel Math Kernel Library? Intel MKL contains vecter math functions including exp as part of its Vector Math Library (VML). You can read more at the product website ( or look at the documentation online (


Intel MKL forum:


I've been trying to download the VML library demo, but haven't had much luck. (The registration page said it'd send me a key, but hasn't so far.) However, I think the exp function in it would compute the result to full float precision, no? I don't absolutely need that much accuracy for my project, since a) the measurements from which the code is derived are only accurate to a few percent, and b) there's a random distribution being applied to it anyway.

I wouldlike to be able to trade off that excess accuracy for increased speed. Presently I'm using a 7-term McLaurin series approximation (your basic calculus one), but the code in the AM library looks as though it might be a bit faster.

I've looked at that, butI don't think it'ssuitable for what I'm doing. I'm not simply computing a vector of exps, I'm writing vector routines to compute various complicated equations,some factors inwhichare exps. So if I were to use the vector routines, I'd have to make several passes, storing intermediate results. Not only would that slow down the computation, it would require extra memory. We don't have a lot to spare - I've spent a lot of time trying to sweat the code down to fit in themere 256 GBytes available at present.

Not to mention that I'd still like to save time with a fast approximation rather than a slower but unnecessarily precise routine.


If you are having difficulty installing the Intel MKL evaluation version please file an issue at so we can look into it. The "key" you mention might be a license file which should be emailed to you within an hour or two of registering. If you file an issue we can investigate what the problem might be and get you a license file.


Leave a Comment

Please sign in to add a comment. Not a member? Join today