Average Error: 19.3 → 5.1
Time: 4.6s
Precision: binary64
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \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.356067420516665 \cdot 10^{+105}:\\ \;\;\;\;\frac{y}{{x}^{2}}\\ \mathbf{elif}\;x \leq -3.65444476764474 \cdot 10^{-20}:\\ \;\;\;\;y \cdot \frac{x}{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right) + \left(x \cdot \left(2 + x \cdot 3\right) + \mathsf{fma}\left(3, x \cdot y, \frac{x}{\frac{y}{x}}\right)\right)}\\ \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.356067420516665e+105)
   (/ y (pow x 2.0))
   (if (<= x -3.65444476764474e-20)
     (* y (/ x (+ (pow (+ x y) 3.0) (pow (+ x y) 2.0))))
     (/
      x
      (+
       (fma y y y)
       (+ (* x (+ 2.0 (* x 3.0))) (fma 3.0 (* x y) (/ x (/ y x)))))))))
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.356067420516665e+105) {
		tmp = y / pow(x, 2.0);
	} else if (x <= -3.65444476764474e-20) {
		tmp = y * (x / (pow((x + y), 3.0) + pow((x + y), 2.0)));
	} else {
		tmp = x / (fma(y, y, y) + ((x * (2.0 + (x * 3.0))) + fma(3.0, (x * y), (x / (y / x)))));
	}
	return tmp;
}
function code(x, y)
	return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0)))
end
function code(x, y)
	tmp = 0.0
	if (x <= -3.356067420516665e+105)
		tmp = Float64(y / (x ^ 2.0));
	elseif (x <= -3.65444476764474e-20)
		tmp = Float64(y * Float64(x / Float64((Float64(x + y) ^ 3.0) + (Float64(x + y) ^ 2.0))));
	else
		tmp = Float64(x / Float64(fma(y, y, y) + Float64(Float64(x * Float64(2.0 + Float64(x * 3.0))) + fma(3.0, Float64(x * y), Float64(x / Float64(y / x))))));
	end
	return tmp
end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[LessEqual[x, -3.356067420516665e+105], N[(y / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.65444476764474e-20], N[(y * N[(x / N[(N[Power[N[(x + y), $MachinePrecision], 3.0], $MachinePrecision] + N[Power[N[(x + y), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(y * y + y), $MachinePrecision] + N[(N[(x * N[(2.0 + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(3.0 * N[(x * y), $MachinePrecision] + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\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.356067420516665 \cdot 10^{+105}:\\
\;\;\;\;\frac{y}{{x}^{2}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right) + \left(x \cdot \left(2 + x \cdot 3\right) + \mathsf{fma}\left(3, x \cdot y, \frac{x}{\frac{y}{x}}\right)\right)}\\


\end{array}

Error

Bits error versus x

Bits error versus y

Target

Original19.3
Target0.1
Herbie5.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 < -3.35606742051666501e105

    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. Simplified13.2

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

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

    if -3.35606742051666501e105 < x < -3.65444476764474005e-20

    1. Initial program 8.6

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

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

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

    if -3.65444476764474005e-20 < x

    1. Initial program 19.6

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(3, y \cdot x, \mathsf{fma}\left(y, y, y\right)\right) + \left(2 \cdot x + \mathsf{fma}\left(3, x \cdot x, \frac{x}{\frac{y}{x}}\right)\right)}} \]
    5. Taylor expanded in y around 0 5.4

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

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, y, y\right) + \left(x \cdot \left(x \cdot 3 + 2\right) + \mathsf{fma}\left(3, x \cdot y, \frac{x}{\frac{y}{x}}\right)\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification5.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.356067420516665 \cdot 10^{+105}:\\ \;\;\;\;\frac{y}{{x}^{2}}\\ \mathbf{elif}\;x \leq -3.65444476764474 \cdot 10^{-20}:\\ \;\;\;\;y \cdot \frac{x}{{\left(x + y\right)}^{3} + {\left(x + y\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(y, y, y\right) + \left(x \cdot \left(2 + x \cdot 3\right) + \mathsf{fma}\left(3, x \cdot y, \frac{x}{\frac{y}{x}}\right)\right)}\\ \end{array} \]

Reproduce

herbie shell --seed 2022153 
(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))))