\frac{x + y}{\left(x \cdot 2\right) \cdot y}\begin{array}{l}
\mathbf{if}\;x \le -5.2211876626416346 \cdot 10^{-12}:\\
\;\;\;\;\frac{x + y}{x \cdot 2} \cdot \frac{1}{y}\\
\mathbf{elif}\;x \le 9.43358736000154189 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{1}{x}}{\frac{y}{\frac{x + y}{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y}{x}, 0.5\right)}{y}\\
\end{array}double f(double x, double y) {
double r2779 = x;
double r2780 = y;
double r2781 = r2779 + r2780;
double r2782 = 2.0;
double r2783 = r2779 * r2782;
double r2784 = r2783 * r2780;
double r2785 = r2781 / r2784;
return r2785;
}
double f(double x, double y) {
double r2786 = x;
double r2787 = -5.221187662641635e-12;
bool r2788 = r2786 <= r2787;
double r2789 = y;
double r2790 = r2786 + r2789;
double r2791 = 2.0;
double r2792 = r2786 * r2791;
double r2793 = r2790 / r2792;
double r2794 = 1.0;
double r2795 = r2794 / r2789;
double r2796 = r2793 * r2795;
double r2797 = 9.433587360001542e-18;
bool r2798 = r2786 <= r2797;
double r2799 = r2794 / r2786;
double r2800 = r2790 / r2791;
double r2801 = r2789 / r2800;
double r2802 = r2799 / r2801;
double r2803 = 0.5;
double r2804 = r2789 / r2786;
double r2805 = fma(r2803, r2804, r2803);
double r2806 = r2805 / r2789;
double r2807 = r2798 ? r2802 : r2806;
double r2808 = r2788 ? r2796 : r2807;
return r2808;
}




Bits error versus x




Bits error versus y
| Original | 15.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.1 |
if x < -5.221187662641635e-12Initial program 15.5
rmApplied associate-/r*0.2
rmApplied div-inv0.2
if -5.221187662641635e-12 < x < 9.433587360001542e-18Initial program 15.5
rmApplied associate-/r*16.6
rmApplied *-un-lft-identity16.6
Applied times-frac16.6
Applied associate-/l*0.1
if 9.433587360001542e-18 < x Initial program 14.6
rmApplied associate-/r*0.2
Taylor expanded around 0 0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2020025 +o rules:numerics
(FPCore (x y)
:name "Linear.Projection:inversePerspective from linear-1.19.1.3, C"
:precision binary64
:herbie-target
(+ (/ 0.5 x) (/ 0.5 y))
(/ (+ x y) (* (* x 2) y)))