Average Error: 19.3 → 7.2
Time: 4.4s
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} t_0 := \mathsf{hypot}\left(x + y, {\left(x + y\right)}^{1.5}\right)\\ \mathbf{if}\;x \leq -1.7172951296258227 \cdot 10^{+112}:\\ \;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\ \mathbf{elif}\;x \leq -5.664768576413203 \cdot 10^{-146}:\\ \;\;\;\;\frac{y}{\frac{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t_0} \cdot \frac{y}{t_0}\\ \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}
t_0 := \mathsf{hypot}\left(x + y, {\left(x + y\right)}^{1.5}\right)\\
\mathbf{if}\;x \leq -1.7172951296258227 \cdot 10^{+112}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\

\mathbf{elif}\;x \leq -5.664768576413203 \cdot 10^{-146}:\\
\;\;\;\;\frac{y}{\frac{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t_0} \cdot \frac{y}{t_0}\\


\end{array}
(FPCore (x y)
 :precision binary64
 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (hypot (+ x y) (pow (+ x y) 1.5))))
   (if (<= x -1.7172951296258227e+112)
     (/ y (fma x x x))
     (if (<= x -5.664768576413203e-146)
       (/ y (/ (+ (pow (+ x y) 3.0) (pow (+ x y) 2.0)) x))
       (* (/ x t_0) (/ y t_0))))))
double code(double x, double y) {
	return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
double code(double x, double y) {
	double t_0 = hypot((x + y), pow((x + y), 1.5));
	double tmp;
	if (x <= -1.7172951296258227e+112) {
		tmp = y / fma(x, x, x);
	} else if (x <= -5.664768576413203e-146) {
		tmp = y / ((pow((x + y), 3.0) + pow((x + y), 2.0)) / x);
	} else {
		tmp = (x / t_0) * (y / t_0);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Target

Original19.3
Target0.1
Herbie7.2
\[\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 < -1.7172951296258227e112

    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 egg-rr54.9

      \[\leadsto \color{blue}{\frac{x}{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}} \cdot y} \]
    4. Applied egg-rr54.9

      \[\leadsto \color{blue}{{\left(\frac{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}{x}\right)}^{-1}} \cdot y \]
    5. Taylor expanded in x around inf 16.4

      \[\leadsto {\color{blue}{\left(3 \cdot \left(y \cdot x\right) + \left(2 \cdot y + \left(3 \cdot {y}^{2} + \left({x}^{2} + x\right)\right)\right)\right)}}^{-1} \cdot y \]
    6. Simplified16.4

      \[\leadsto {\color{blue}{\left(\mathsf{fma}\left(3, y \cdot x, \mathsf{fma}\left(y, 2, \mathsf{fma}\left(3, y \cdot y, \mathsf{fma}\left(x, x, x\right)\right)\right)\right)\right)}}^{-1} \cdot y \]
    7. Taylor expanded in y around 0 10.6

      \[\leadsto \color{blue}{\frac{y}{{x}^{2} + x}} \]
    8. Simplified10.6

      \[\leadsto \color{blue}{\frac{y}{\mathsf{fma}\left(x, x, x\right)}} \]

    if -1.7172951296258227e112 < x < -5.664768576413203e-146

    1. Initial program 10.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. Simplified10.0

      \[\leadsto \color{blue}{\frac{x \cdot y}{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \]
    3. Applied egg-rr4.6

      \[\leadsto \color{blue}{\frac{x}{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}} \cdot y} \]
    4. Applied egg-rr4.7

      \[\leadsto \color{blue}{\frac{y}{\frac{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}{x}}} \]

    if -5.664768576413203e-146 < x

    1. Initial program 22.3

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}} \]
    3. Applied egg-rr6.8

      \[\leadsto \color{blue}{\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)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7172951296258227 \cdot 10^{+112}:\\ \;\;\;\;\frac{y}{\mathsf{fma}\left(x, x, x\right)}\\ \mathbf{elif}\;x \leq -5.664768576413203 \cdot 10^{-146}:\\ \;\;\;\;\frac{y}{\frac{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}{x}}\\ \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 2022130 
(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))))