title: Is it possible to optimize this function?
body: <p>after profiling a lot I found out that this method takes up most of the % of calculation time. I don't really see a way to optimize, since it is a horrible function. (it is...)
  Maybe someone can show me some nice idea or so?</p>
  
  <pre><code>public static double perceivedLoudness(double L_G, double L_ETQ, double a0) {
    double t1 = 1d + 1 / 4d * Math.pow(10d, 0.1d * (L_G - a0 - L_ETQ));
    double t2 = Math.pow(t1, 0.25);
    return 0.064d * Math.pow(10, 0.025 * L_ETQ) * (t2 - 1);
   }
  </code></pre>
  
  <p>Here is the improved version: </p>
  
  <pre><code>public static double perceivedLoudness(double L_G, double L_ETQ, double a0) {
    double x = L_G - a0 - L_ETQ;
    double t1 = 0.25 * Math.exp(0.230259 * x) + 1;
    double t2 = Math.sqrt(Math.sqrt(t1));
    return ltqFactors[(int)L_ETQ]  * (t2 - 1);
   }
  </code></pre>
  
  <p>The lookup for ltqFactors goes this way. ltqValues hold 20 points from the given ltq function, that approx should be sufficiant.</p>
  
  <pre><code>for( int i = 0; i &lt; etqValues.length; ++i) {
    ltqFactors[(int)etqValues[i]] = 0.064d * Math.exp(etqValues[i] * 0.05756462732485114210d);
    }
  </code></pre>
  
  <p>Edit: After more test runs with more files, I come up to a ~100% speed up:</p>
  
  <ul>
  <li>Old: 6,2% with 7000000 calls  </li>
  <li>New: 3,2% 8000000 calls.</li>
  </ul>
  
  <p>Thank you so far!</p>
  
  <p>Edit2: I don't know which answer to accept. :(
  With some other improvements (mostly lookup tables) the processing time for 9000 sound files went down from 4:30min to 3:28min. </p>
  
  <p>I will keep this question open to see if there are other ideas, but then accept one answer. </p>
  
  <p>Edit: I'm kind of frustrated now. I use a JFace treeviewer to let the user browse the results, and it need more time to update than the calculations itself. :/</p>