micropython/lib/libm_dbl/tanh.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
190 B
C
Raw Normal View History

#include <math.h>
double tanh(double x) {
int sign = 0;
if (x < 0) {
sign = 1;
x = -x;
}
x = expm1(-2 * x);
x = x / (x + 2);
return sign ? x : -x;
}