\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.001308568773005096318520767972870544326724:\\
\;\;\;\;\log \left(e^{\frac{1 - \cos x}{\sin x}}\right)\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 4.957178312169810962668929968898134941213 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{24} \cdot {x}^{3} + \left(\frac{1}{240} \cdot {x}^{5} + \frac{1}{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \cos x}{\sqrt{\sin x}} \cdot \frac{\sqrt[3]{1}}{\sqrt{\sin x}}\\
\end{array}double f(double x) {
double r59122 = 1.0;
double r59123 = x;
double r59124 = cos(r59123);
double r59125 = r59122 - r59124;
double r59126 = sin(r59123);
double r59127 = r59125 / r59126;
return r59127;
}
double f(double x) {
double r59128 = 1.0;
double r59129 = x;
double r59130 = cos(r59129);
double r59131 = r59128 - r59130;
double r59132 = sin(r59129);
double r59133 = r59131 / r59132;
double r59134 = -0.0013085687730050963;
bool r59135 = r59133 <= r59134;
double r59136 = exp(r59133);
double r59137 = log(r59136);
double r59138 = 4.957178312169811e-08;
bool r59139 = r59133 <= r59138;
double r59140 = 0.041666666666666664;
double r59141 = 3.0;
double r59142 = pow(r59129, r59141);
double r59143 = r59140 * r59142;
double r59144 = 0.004166666666666667;
double r59145 = 5.0;
double r59146 = pow(r59129, r59145);
double r59147 = r59144 * r59146;
double r59148 = 0.5;
double r59149 = r59148 * r59129;
double r59150 = r59147 + r59149;
double r59151 = r59143 + r59150;
double r59152 = sqrt(r59132);
double r59153 = r59131 / r59152;
double r59154 = 1.0;
double r59155 = cbrt(r59154);
double r59156 = r59155 / r59152;
double r59157 = r59153 * r59156;
double r59158 = r59139 ? r59151 : r59157;
double r59159 = r59135 ? r59137 : r59158;
return r59159;
}




Bits error versus x
Results
| Original | 30.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.0013085687730050963Initial program 0.9
rmApplied add-log-exp1.1
if -0.0013085687730050963 < (/ (- 1.0 (cos x)) (sin x)) < 4.957178312169811e-08Initial program 60.2
Taylor expanded around 0 0.0
if 4.957178312169811e-08 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.3
rmApplied add-exp-log1.3
rmApplied div-inv1.3
rmApplied add-sqr-sqrt1.5
Applied add-cube-cbrt1.5
Applied times-frac1.6
Applied associate-*r*1.6
Simplified1.5
Final simplification0.6
herbie shell --seed 2019347
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:herbie-expected 2
:herbie-target
(tan (/ x 2))
(/ (- 1 (cos x)) (sin x)))