arduino icon indicating copy to clipboard operation
arduino copied to clipboard

Expression for tanh in tanh.c is incorrect

Open MBHelectronics opened this issue 7 years ago • 1 comments

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

MBHelectronics avatar May 16 '18 03:05 MBHelectronics

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.

emard avatar May 16 '18 05:05 emard