title: Fastest Implementation of the Natural Exponential Function Using SSE
body: <p>I'm looking for an approximation of the natural exponential function operating on SSE element. Namely - <code>__m128 exp( __m128 x )</code>.  </p>
  
  <p>I have an implementation which is quick but seems to be very low in accuracy:</p>
  
  <pre><code>static inline __m128 FastExpSse(__m128 x)
  {
      __m128 a = _mm_set1_ps(12102203.2f); // (1 &lt;&lt; 23) / ln(2)
      __m128i b = _mm_set1_epi32(127 * (1 &lt;&lt; 23) - 486411);
      __m128  m87 = _mm_set1_ps(-87);
      // fast exponential function, x should be in [-87, 87]
      __m128 mask = _mm_cmpge_ps(x, m87);
  
      __m128i tmp = _mm_add_epi32(_mm_cvtps_epi32(_mm_mul_ps(a, x)), b);
      return _mm_and_ps(_mm_castsi128_ps(tmp), mask);
  }
  </code></pre>
  
  <p>Could anybody have an implementation with better accuracy yet as fast (Or faster)?</p>
  
  <p>I'd be happy if it is written in C Style.</p>
  
  <p>Thank You.</p>