arduino
arduino copied to clipboard
Expression for tanh in tanh.c is incorrect
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
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.