Average Error: 22.2 → 0.0
Time: 4.7s
Precision: binary64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
\[\begin{array}{l} t_0 := \left(\left(x + \frac{x}{y \cdot y}\right) + \frac{1}{{y}^{3}}\right) - \left(\frac{x}{{y}^{3}} + \left(\frac{1}{y \cdot y} + \frac{x + -1}{y}\right)\right)\\ \mathbf{if}\;y \leq -16205.4911207915:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 11649.159016303365:\\ \;\;\;\;\mathsf{fma}\left(\frac{y \cdot \left(x + -1\right)}{1 - y \cdot y}, 1 - y, 1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0
         (-
          (+ (+ x (/ x (* y y))) (/ 1.0 (pow y 3.0)))
          (+ (/ x (pow y 3.0)) (+ (/ 1.0 (* y y)) (/ (+ x -1.0) y))))))
   (if (<= y -16205.4911207915)
     t_0
     (if (<= y 11649.159016303365)
       (fma (/ (* y (+ x -1.0)) (- 1.0 (* y y))) (- 1.0 y) 1.0)
       t_0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
	double t_0 = ((x + (x / (y * y))) + (1.0 / pow(y, 3.0))) - ((x / pow(y, 3.0)) + ((1.0 / (y * y)) + ((x + -1.0) / y)));
	double tmp;
	if (y <= -16205.4911207915) {
		tmp = t_0;
	} else if (y <= 11649.159016303365) {
		tmp = fma(((y * (x + -1.0)) / (1.0 - (y * y))), (1.0 - y), 1.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function code(x, y)
	t_0 = Float64(Float64(Float64(x + Float64(x / Float64(y * y))) + Float64(1.0 / (y ^ 3.0))) - Float64(Float64(x / (y ^ 3.0)) + Float64(Float64(1.0 / Float64(y * y)) + Float64(Float64(x + -1.0) / y))))
	tmp = 0.0
	if (y <= -16205.4911207915)
		tmp = t_0;
	elseif (y <= 11649.159016303365)
		tmp = fma(Float64(Float64(y * Float64(x + -1.0)) / Float64(1.0 - Float64(y * y))), Float64(1.0 - y), 1.0);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x + N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(x / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -16205.4911207915], t$95$0, If[LessEqual[y, 11649.159016303365], N[(N[(N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - y), $MachinePrecision] + 1.0), $MachinePrecision], t$95$0]]]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
t_0 := \left(\left(x + \frac{x}{y \cdot y}\right) + \frac{1}{{y}^{3}}\right) - \left(\frac{x}{{y}^{3}} + \left(\frac{1}{y \cdot y} + \frac{x + -1}{y}\right)\right)\\
\mathbf{if}\;y \leq -16205.4911207915:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 11649.159016303365:\\
\;\;\;\;\mathsf{fma}\left(\frac{y \cdot \left(x + -1\right)}{1 - y \cdot y}, 1 - y, 1\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Bits error versus x

Bits error versus y

Target

Original22.2
Target0.2
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;y < -3693.8482788297247:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y < 6799310503.41891:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if y < -16205.491120791499 or 11649.159016303365 < y

    1. Initial program 45.6

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{y} + \left(\frac{1}{{y}^{3}} + \left(\frac{x}{{y}^{2}} + x\right)\right)\right) - \left(\frac{x}{y} + \left(\frac{x}{{y}^{3}} + \frac{1}{{y}^{2}}\right)\right)} \]
    4. Simplified0.0

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

    if -16205.491120791499 < y < 11649.159016303365

    1. Initial program 0.1

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

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

      \[\leadsto \color{blue}{\left(1 + \frac{y \cdot x}{1 + y}\right) - \frac{y}{1 + y}} \]
    4. Simplified0.1

      \[\leadsto \color{blue}{1 + \frac{y}{1 + y} \cdot \left(x + -1\right)} \]
    5. Applied egg-rr0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -16205.4911207915:\\ \;\;\;\;\left(\left(x + \frac{x}{y \cdot y}\right) + \frac{1}{{y}^{3}}\right) - \left(\frac{x}{{y}^{3}} + \left(\frac{1}{y \cdot y} + \frac{x + -1}{y}\right)\right)\\ \mathbf{elif}\;y \leq 11649.159016303365:\\ \;\;\;\;\mathsf{fma}\left(\frac{y \cdot \left(x + -1\right)}{1 - y \cdot y}, 1 - y, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + \frac{x}{y \cdot y}\right) + \frac{1}{{y}^{3}}\right) - \left(\frac{x}{{y}^{3}} + \left(\frac{1}{y \cdot y} + \frac{x + -1}{y}\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022134 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))

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