\frac{1 - \cos x}{\sin x}\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \le -0.002585231506460964:\\
\;\;\;\;\frac{e^{\log \left(1 - \cos x\right)}}{\sin x}\\
\mathbf{elif}\;\frac{1 - \cos x}{\sin x} \le 1.53832503201192376 \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{e^{\log \left({1}^{3} - {\left(\cos x\right)}^{3}\right)}}{\sin x \cdot \left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right)}\\
\end{array}double f(double x) {
double r30740 = 1.0;
double r30741 = x;
double r30742 = cos(r30741);
double r30743 = r30740 - r30742;
double r30744 = sin(r30741);
double r30745 = r30743 / r30744;
return r30745;
}
double f(double x) {
double r30746 = 1.0;
double r30747 = x;
double r30748 = cos(r30747);
double r30749 = r30746 - r30748;
double r30750 = sin(r30747);
double r30751 = r30749 / r30750;
double r30752 = -0.0025852315064609638;
bool r30753 = r30751 <= r30752;
double r30754 = log(r30749);
double r30755 = exp(r30754);
double r30756 = r30755 / r30750;
double r30757 = 1.5383250320119238e-08;
bool r30758 = r30751 <= r30757;
double r30759 = 0.041666666666666664;
double r30760 = 3.0;
double r30761 = pow(r30747, r30760);
double r30762 = r30759 * r30761;
double r30763 = 0.004166666666666667;
double r30764 = 5.0;
double r30765 = pow(r30747, r30764);
double r30766 = r30763 * r30765;
double r30767 = 0.5;
double r30768 = r30767 * r30747;
double r30769 = r30766 + r30768;
double r30770 = r30762 + r30769;
double r30771 = pow(r30746, r30760);
double r30772 = pow(r30748, r30760);
double r30773 = r30771 - r30772;
double r30774 = log(r30773);
double r30775 = exp(r30774);
double r30776 = r30748 + r30746;
double r30777 = r30748 * r30776;
double r30778 = r30746 * r30746;
double r30779 = r30777 + r30778;
double r30780 = r30750 * r30779;
double r30781 = r30775 / r30780;
double r30782 = r30758 ? r30770 : r30781;
double r30783 = r30753 ? r30756 : r30782;
return r30783;
}




Bits error versus x
Results
| Original | 30.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.6 |
if (/ (- 1.0 (cos x)) (sin x)) < -0.0025852315064609638Initial program 0.9
rmApplied add-exp-log0.9
rmApplied *-un-lft-identity0.9
if -0.0025852315064609638 < (/ (- 1.0 (cos x)) (sin x)) < 1.5383250320119238e-08Initial program 60.3
Taylor expanded around 0 0.1
if 1.5383250320119238e-08 < (/ (- 1.0 (cos x)) (sin x)) Initial program 1.3
rmApplied add-exp-log1.3
rmApplied *-un-lft-identity1.3
rmApplied flip3--1.4
Applied log-div1.5
Applied exp-diff1.4
Applied associate-*r/1.4
Applied associate-/l/1.4
Simplified1.4
Final simplification0.6
herbie shell --seed 2019199
(FPCore (x)
:name "tanhf (example 3.4)"
:herbie-expected 2
:herbie-target
(tan (/ x 2.0))
(/ (- 1.0 (cos x)) (sin x)))