mirror of
https://github.com/micropython/micropython.git
synced 2025-09-06 09:50:20 +02:00
13 lines
190 B
C
13 lines
190 B
C
#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;
|
|
}
|