\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.03354068643238588415256273833620070945472:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot \sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 0.00130404089207647086966213034742168019875:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin x \cdot \frac{1}{1 - \cos x}}\\
\end{array}double f(double x) {
double r57903 = 1.0;
double r57904 = x;
double r57905 = cos(r57904);
double r57906 = r57903 - r57905;
double r57907 = sin(r57904);
double r57908 = r57906 / r57907;
return r57908;
}
double f(double x) {
double r57909 = 1.0;
double r57910 = x;
double r57911 = cos(r57910);
double r57912 = r57909 - r57911;
double r57913 = sin(r57910);
double r57914 = r57912 / r57913;
double r57915 = -0.033540686432385884;
bool r57916 = r57914 <= r57915;
double r57917 = 3.0;
double r57918 = pow(r57909, r57917);
double r57919 = pow(r57911, r57917);
double r57920 = r57918 - r57919;
double r57921 = r57911 + r57909;
double r57922 = r57911 * r57921;
double r57923 = r57909 * r57909;
double r57924 = r57922 + r57923;
double r57925 = r57924 * r57913;
double r57926 = r57920 / r57925;
double r57927 = 0.0013040408920764709;
bool r57928 = r57914 <= r57927;
double r57929 = 0.041666666666666664;
double r57930 = pow(r57910, r57917);
double r57931 = r57929 * r57930;
double r57932 = 0.004166666666666667;
double r57933 = 5.0;
double r57934 = pow(r57910, r57933);
double r57935 = r57932 * r57934;
double r57936 = 0.5;
double r57937 = r57936 * r57910;
double r57938 = r57935 + r57937;
double r57939 = r57931 + r57938;
double r57940 = 1.0;
double r57941 = r57940 / r57912;
double r57942 = r57913 * r57941;
double r57943 = r57940 / r57942;
double r57944 = r57928 ? r57939 : r57943;
double r57945 = r57916 ? r57926 : r57944;
return r57945;
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.8 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.033540686432385884Initial program 0.7
rmApplied flip3--0.9
Applied associate-/l/0.9
Simplified0.9
if -0.033540686432385884 < (/ (- 1.0 (cos x)) (sin x)) < 0.0013040408920764709Initial program 59.3
Taylor expanded around 0 0.7
if 0.0013040408920764709 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.0
rmApplied clear-num1.1
rmApplied div-inv1.1
Final simplification0.8
herbie shell --seed 2019294
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))