\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}\begin{array}{l}
\mathbf{if}\;\frac{\tan \left(\frac{x}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)} \le 1.859438286531938988588308347971178591251:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)}\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}double f(double x, double y) {
double r478102 = x;
double r478103 = y;
double r478104 = 2.0;
double r478105 = r478103 * r478104;
double r478106 = r478102 / r478105;
double r478107 = tan(r478106);
double r478108 = sin(r478106);
double r478109 = r478107 / r478108;
return r478109;
}
double f(double x, double y) {
double r478110 = x;
double r478111 = 2.0;
double r478112 = y;
double r478113 = r478111 * r478112;
double r478114 = r478110 / r478113;
double r478115 = tan(r478114);
double r478116 = sin(r478114);
double r478117 = r478115 / r478116;
double r478118 = 1.859438286531939;
bool r478119 = r478117 <= r478118;
double r478120 = expm1(r478117);
double r478121 = expm1(r478120);
double r478122 = log1p(r478121);
double r478123 = log1p(r478122);
double r478124 = 1.0;
double r478125 = r478119 ? r478123 : r478124;
return r478125;
}




Bits error versus x




Bits error versus y
Results
| Original | 35.7 |
|---|---|
| Target | 28.8 |
| Herbie | 27.6 |
if (/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0)))) < 1.859438286531939Initial program 24.3
rmApplied log1p-expm1-u24.4
Simplified24.4
rmApplied log1p-expm1-u24.4
Simplified24.4
if 1.859438286531939 < (/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0)))) Initial program 62.2
Taylor expanded around 0 35.1
Final simplification27.6
herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y)
:name "Diagrams.TwoD.Layout.CirclePacking:approxRadius from diagrams-contrib-1.3.0.5"
:herbie-target
(if (< y -1.2303690911306994e+114) 1.0 (if (< y -9.102852406811914e-222) (/ (sin (/ x (* y 2.0))) (* (sin (/ x (* y 2.0))) (log (exp (cos (/ x (* y 2.0))))))) 1.0))
(/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0)))))