Average Error: 19.5 → 7.3
Time: 1.0min
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \\]
\[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -3.3388667508241876 \cdot 10^{+104}:\\ \;\;\;\;\frac{y}{x \cdot x}\\ \mathbf{elif}\;x \leq -6.798182670312745 \cdot 10^{-244}:\\ \;\;\;\;\begin{array}{l} t_0 := \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}\\ \frac{x \cdot \frac{y}{t_0}}{t_0 \cdot t_0} \end{array}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \mathsf{hypot}\left(x + y, {\left(x + y\right)}^{1.5}\right)\\ \frac{x}{t_1} \cdot \frac{y}{t_1} \end{array}\\ \end{array} \]
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\begin{array}{l}
\mathbf{if}\;x \leq -3.3388667508241876 \cdot 10^{+104}:\\
\;\;\;\;\frac{y}{x \cdot x}\\

\mathbf{elif}\;x \leq -6.798182670312745 \cdot 10^{-244}:\\
\;\;\;\;\begin{array}{l}
t_0 := \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}\\
\frac{x \cdot \frac{y}{t_0}}{t_0 \cdot t_0}
\end{array}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \mathsf{hypot}\left(x + y, {\left(x + y\right)}^{1.5}\right)\\
\frac{x}{t_1} \cdot \frac{y}{t_1}
\end{array}\\


\end{array}
(FPCore (x y)
 :precision binary64
 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
(FPCore (x y)
 :precision binary64
 (if (<= x -3.3388667508241876e+104)
   (/ y (* x x))
   (if (<= x -6.798182670312745e-244)
     (let* ((t_0 (cbrt (fma (+ x y) (+ x y) (pow (+ x y) 3.0)))))
       (/ (* x (/ y t_0)) (* t_0 t_0)))
     (let* ((t_1 (hypot (+ x y) (pow (+ x y) 1.5))))
       (* (/ x t_1) (/ y t_1))))))
double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
double code(double x, double y) {
	double tmp;
	if (x <= -3.3388667508241876e+104) {
		tmp = y / (x * x);
	} else if (x <= -6.798182670312745e-244) {
		double t_0 = cbrt(fma((x + y), (x + y), pow((x + y), 3.0)));
		tmp = (x * (y / t_0)) / (t_0 * t_0);
	} else {
		double t_1 = hypot((x + y), pow((x + y), 1.5));
		tmp = (x / t_1) * (y / t_1);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Target

Original19.5
Target0.1
Herbie7.3
\[\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}} \]

Derivation

  1. Split input into 3 regimes
  2. if x < -3.33886675082418757e104

    1. Initial program 25.5

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Simplified25.5

      \[\leadsto \color{blue}{\frac{x \cdot y}{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \]
    3. Applied add-cube-cbrt_binary6425.5

      \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}} \]
    4. Applied times-frac_binary6413.2

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \cdot \frac{y}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}} \]
    5. Taylor expanded in x around inf 9.9

      \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]
    6. Simplified9.9

      \[\leadsto \color{blue}{\frac{y}{x \cdot x}} \]

    if -3.33886675082418757e104 < x < -6.7981826703127447e-244

    1. Initial program 14.0

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Simplified14.0

      \[\leadsto \color{blue}{\frac{x \cdot y}{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \]
    3. Applied add-cube-cbrt_binary6414.4

      \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}} \]
    4. Applied times-frac_binary648.0

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \cdot \frac{y}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}} \]
    5. Applied associate-*l/_binary649.0

      \[\leadsto \color{blue}{\frac{x \cdot \frac{y}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}} \]

    if -6.7981826703127447e-244 < x

    1. Initial program 21.1

      \[\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)} \]
    2. Simplified21.1

      \[\leadsto \color{blue}{\frac{x \cdot y}{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \]
    3. Applied add-sqr-sqrt_binary6421.2

      \[\leadsto \frac{x \cdot y}{\color{blue}{\sqrt{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)} \cdot \sqrt{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}} \]
    4. Applied times-frac_binary6412.2

      \[\leadsto \color{blue}{\frac{x}{\sqrt{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \cdot \frac{y}{\sqrt{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}} \]
    5. Simplified12.2

      \[\leadsto \color{blue}{\frac{x}{\mathsf{hypot}\left(y + x, {\left(y + x\right)}^{1.5}\right)}} \cdot \frac{y}{\sqrt{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \]
    6. Simplified2.7

      \[\leadsto \frac{x}{\mathsf{hypot}\left(y + x, {\left(y + x\right)}^{1.5}\right)} \cdot \color{blue}{\frac{y}{\mathsf{hypot}\left(y + x, {\left(y + x\right)}^{1.5}\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.3388667508241876 \cdot 10^{+104}:\\ \;\;\;\;\frac{y}{x \cdot x}\\ \mathbf{elif}\;x \leq -6.798182670312745 \cdot 10^{-244}:\\ \;\;\;\;\frac{x \cdot \frac{y}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}}{\sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\mathsf{hypot}\left(x + y, {\left(x + y\right)}^{1.5}\right)} \cdot \frac{y}{\mathsf{hypot}\left(x + y, {\left(x + y\right)}^{1.5}\right)}\\ \end{array} \]

Reproduce

herbie shell --seed 2022088 
(FPCore (x y)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))

  (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))