Average Error: 19.7 → 7.1
Time: 15.6s
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 -1.1125239315049187 \cdot 10^{+107}:\\ \;\;\;\;\frac{y}{{x}^{2}}\\ \mathbf{elif}\;x \leq -5.763417785668302 \cdot 10^{-162}:\\ \;\;\;\;\begin{array}{l} t_0 := \sqrt[3]{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}\\ \frac{x}{t_0 \cdot t_0} \cdot \frac{y}{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 -1.1125239315049187 \cdot 10^{+107}:\\
\;\;\;\;\frac{y}{{x}^{2}}\\

\mathbf{elif}\;x \leq -5.763417785668302 \cdot 10^{-162}:\\
\;\;\;\;\begin{array}{l}
t_0 := \sqrt[3]{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}\\
\frac{x}{t_0 \cdot t_0} \cdot \frac{y}{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 -1.1125239315049187e+107)
   (/ y (pow x 2.0))
   (if (<= x -5.763417785668302e-162)
     (let* ((t_0 (cbrt (+ (pow (+ x y) 3.0) (pow (+ x y) 2.0)))))
       (* (/ x (* t_0 t_0)) (/ y 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 <= -1.1125239315049187e+107) {
		tmp = y / pow(x, 2.0);
	} else if (x <= -5.763417785668302e-162) {
		double t_0 = cbrt(pow((x + y), 3.0) + pow((x + y), 2.0));
		tmp = (x / (t_0 * t_0)) * (y / 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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.7
Target0.2
Herbie7.1
\[\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.11252393150491872e107

    1. Initial program 25.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. Simplified25.1

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

      \[\leadsto \color{blue}{\frac{y}{{x}^{2}}} \]

    if -1.11252393150491872e107 < x < -5.763417785668302e-162

    1. Initial program 11.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. Simplified11.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_binary6411.6

      \[\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_binary644.6

      \[\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. Simplified4.6

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

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

    if -5.763417785668302e-162 < x

    1. Initial program 22.9

      \[\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.9

      \[\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_binary6423.0

      \[\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_binary6414.8

      \[\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. Simplified14.8

      \[\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. Simplified6.3

      \[\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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1125239315049187 \cdot 10^{+107}:\\ \;\;\;\;\frac{y}{{x}^{2}}\\ \mathbf{elif}\;x \leq -5.763417785668302 \cdot 10^{-162}:\\ \;\;\;\;\frac{x}{\sqrt[3]{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}} \cdot \sqrt[3]{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}} \cdot \frac{y}{\sqrt[3]{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}}\\ \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 2022097 
(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))))