f32c / arduino

FPGArduino source
http://www.nxlab.fer.hr/fpgarduino
68 stars 44 forks source link

Expression for tanh in tanh.c is incorrect #31

Open MBHelectronics opened 6 years ago

MBHelectronics commented 6 years ago
double tanh(double x)
{
  double x0 = exp(x);
  double x1 = 1.0 / x0;

  return ((x0 + x1) / (x0 - x1));
}

Should be: return ((x0 - x1) / (x0 + x1)); see e.g. https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions

emard commented 6 years ago

Thanks for spotting it, I fixed it in source now. I think also binary library has to be rebuilt for this change to take effect.