Average Error: 21.7 → 7.5
Time: 4.0s
Precision: binary64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -17818768960305848 \lor \neg \left(y \le 5.30519557848643 \cdot 10^{76}\right):\\ \;\;\;\;x + \frac{x}{y} \cdot \left(\frac{1}{y} - 1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(y \cdot \frac{x - 1}{1 \cdot 1 - y \cdot y}\right) \cdot \left(1 - y\right)\\ \end{array}\]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \le -17818768960305848 \lor \neg \left(y \le 5.30519557848643 \cdot 10^{76}\right):\\
\;\;\;\;x + \frac{x}{y} \cdot \left(\frac{1}{y} - 1\right)\\

\mathbf{else}:\\
\;\;\;\;1 + \left(y \cdot \frac{x - 1}{1 \cdot 1 - y \cdot y}\right) \cdot \left(1 - y\right)\\

\end{array}
double code(double x, double y) {
	return ((double) (1.0 - ((double) (((double) (((double) (1.0 - x)) * y)) / ((double) (y + 1.0))))));
}
double code(double x, double y) {
	double VAR;
	if (((y <= -17818768960305848.0) || !(y <= 5.30519557848643e+76))) {
		VAR = ((double) (x + ((double) (((double) (x / y)) * ((double) (((double) (1.0 / y)) - 1.0))))));
	} else {
		VAR = ((double) (1.0 + ((double) (((double) (y * ((double) (((double) (x - 1.0)) / ((double) (((double) (1.0 * 1.0)) - ((double) (y * y)))))))) * ((double) (1.0 - y))))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original21.7
Target0.2
Herbie7.5
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.84827882972468:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891003:\\ \;\;\;\;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 < -17818768960305848 or 5.30519557848643e76 < y

    1. Initial program 47.1

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

      \[\leadsto \color{blue}{1 + y \cdot \frac{x - 1}{1 + y}}\]
    3. Taylor expanded around inf 13.7

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

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

    if -17818768960305848 < y < 5.30519557848643e76

    1. Initial program 3.6

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

      \[\leadsto \color{blue}{1 + y \cdot \frac{x - 1}{1 + y}}\]
    3. Using strategy rm
    4. Applied flip-+3.1

      \[\leadsto 1 + y \cdot \frac{x - 1}{\color{blue}{\frac{1 \cdot 1 - y \cdot y}{1 - y}}}\]
    5. Applied associate-/r/3.1

      \[\leadsto 1 + y \cdot \color{blue}{\left(\frac{x - 1}{1 \cdot 1 - y \cdot y} \cdot \left(1 - y\right)\right)}\]
    6. Applied associate-*r*3.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -17818768960305848 \lor \neg \left(y \le 5.30519557848643 \cdot 10^{76}\right):\\ \;\;\;\;x + \frac{x}{y} \cdot \left(\frac{1}{y} - 1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(y \cdot \frac{x - 1}{1 \cdot 1 - y \cdot y}\right) \cdot \left(1 - y\right)\\ \end{array}\]

Reproduce

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