\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.008959247045566699763075035889414721168578:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\left(\cos x \cdot \frac{{\left(\cos x\right)}^{2} - 1 \cdot 1}{\cos x - 1} + 1 \cdot 1\right) \cdot \sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 0.0:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\frac{1 - \cos x}{\sin x}\right)}\\
\end{array}double f(double x) {
double r51057 = 1.0;
double r51058 = x;
double r51059 = cos(r51058);
double r51060 = r51057 - r51059;
double r51061 = sin(r51058);
double r51062 = r51060 / r51061;
return r51062;
}
double f(double x) {
double r51063 = 1.0;
double r51064 = x;
double r51065 = cos(r51064);
double r51066 = r51063 - r51065;
double r51067 = sin(r51064);
double r51068 = r51066 / r51067;
double r51069 = -0.0089592470455667;
bool r51070 = r51068 <= r51069;
double r51071 = 3.0;
double r51072 = pow(r51063, r51071);
double r51073 = pow(r51065, r51071);
double r51074 = r51072 - r51073;
double r51075 = 2.0;
double r51076 = pow(r51065, r51075);
double r51077 = r51063 * r51063;
double r51078 = r51076 - r51077;
double r51079 = r51065 - r51063;
double r51080 = r51078 / r51079;
double r51081 = r51065 * r51080;
double r51082 = r51081 + r51077;
double r51083 = r51082 * r51067;
double r51084 = r51074 / r51083;
double r51085 = 0.0;
bool r51086 = r51068 <= r51085;
double r51087 = 0.041666666666666664;
double r51088 = pow(r51064, r51071);
double r51089 = r51087 * r51088;
double r51090 = 0.004166666666666667;
double r51091 = 5.0;
double r51092 = pow(r51064, r51091);
double r51093 = r51090 * r51092;
double r51094 = 0.5;
double r51095 = r51094 * r51064;
double r51096 = r51093 + r51095;
double r51097 = r51089 + r51096;
double r51098 = log(r51068);
double r51099 = exp(r51098);
double r51100 = r51086 ? r51097 : r51099;
double r51101 = r51070 ? r51084 : r51100;
return r51101;
}




Bits error versus x
Results
| Original | 30.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.0089592470455667Initial program 0.8
rmApplied flip3--0.9
Applied associate-/l/1.0
Simplified1.0
rmApplied flip-+1.0
Simplified1.0
if -0.0089592470455667 < (/ (- 1.0 (cos x)) (sin x)) < 0.0Initial program 59.9
Taylor expanded around 0 0.3
if 0.0 < (/ (- 1.0 (cos x)) (sin x)) Initial program 29.8
rmApplied add-exp-log31.5
Applied add-exp-log31.5
Applied div-exp31.6
Simplified29.9
Final simplification0.7
herbie shell --seed 2019353
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))