title: precomputing exponent (exp) table
body: <p>I am trying to understand a code in <a href="https://code.google.com/p/word2vec" rel="nofollow">word2vec</a> project. The file I am referring to is <a href="https://code.google.com/p/word2vec/source/browse/trunk/word2vec.c" rel="nofollow">word2vec.c</a>. The snippet of the code is : </p>
  
  <pre><code>#define EXP_TABLE_SIZE 1000
  #define MAX_EXP 6
  //...snip...
  expTable = (real *)malloc((EXP_TABLE_SIZE + 1) * sizeof(real));
    for (i = 0; i &lt; EXP_TABLE_SIZE; i++) {
      // Precompute the exp() table
      expTable[i] = exp((i / (real)EXP_TABLE_SIZE * 2 - 1) * MAX_EXP); 
      // Precompute f(x) = x / (x + 1)
      expTable[i] = expTable[i] / (expTable[i] + 1);
    }
  //...snip...
  </code></pre>
  
  <p>It is not clear what is the benefit of precomputing these values. Could someone explain?</p>