title: R & C versions of function give differing results - rounding or operator error?
body: <p>I have a block of R code that I rewrote in C, and the two versions provide different results.  My belief is that this is due to rounding issues at the R level, i.e. multiple math operations are being performed which creates compounded rounding issues as opposed to the whole thing being done in C and rounding only occurring once.  I'm afraid that I'm being overly optimistic here and was hoping for some more sets of eyes to see if I'm missing something and it's actually just poor coding on my end.</p>
  
  <p>First the R code:</p>
  
  <pre><code>h_tx &lt;- function(x, sigma_nu, sigma_eta, alpha=0) {
     b &lt;- (sqrt(exp(sigma_eta^2) - 1)) / sigma_nu
     a &lt;- -alpha * b
     asinh(a+b*x)
  }
  </code></pre>
  
  <p>Now in C:</p>
  
  <pre><code>double hTx(double x, double sigmaNu, double sigmaEta, double alpha) {
    double a;
    double b;
    double ret;
  
    b = (sqrt(exp(pow(sigmaEta,2)-1))) / sigmaNu;
    a = -alpha * b;
    return asinh(a + b * x);
  }
  </code></pre>
  
  <p>As an example, passing in values 5, 5, 5, 0 gives 13.19 in R and 12.69 in C.  Technically the R code is vectorized but this particular block of C code is not so I don't want to provide a vectorized input as an example.</p>
  
  <p>Are these functionally the same, or am I doing something incorrect?</p>