Average Error: 8.4 → 4.0
Time: 1.8s
Precision: binary64
\[x0 = 1.855 \land x1 = 0.000209 \lor x0 = 2.985 \land x1 = 0.0186\]
\[\frac{x0}{1 - x1} - x0\]
\[\begin{array}{l} \mathbf{if}\;1 - x1 \leq 0.9814:\\ \;\;\;\;\frac{\frac{x0}{1 - x1} \cdot \frac{x0}{1 - x1} - x0 \cdot x0}{x0 + \frac{x0}{1 - x1}}\\ \mathbf{else}:\\ \;\;\;\;\left(x1 + x1 \cdot x1\right) \cdot \left(x0 + x1 \cdot \left(x1 \cdot x0\right)\right)\\ \end{array}\]
\frac{x0}{1 - x1} - x0
\begin{array}{l}
\mathbf{if}\;1 - x1 \leq 0.9814:\\
\;\;\;\;\frac{\frac{x0}{1 - x1} \cdot \frac{x0}{1 - x1} - x0 \cdot x0}{x0 + \frac{x0}{1 - x1}}\\

\mathbf{else}:\\
\;\;\;\;\left(x1 + x1 \cdot x1\right) \cdot \left(x0 + x1 \cdot \left(x1 \cdot x0\right)\right)\\

\end{array}
(FPCore (x0 x1) :precision binary64 (- (/ x0 (- 1.0 x1)) x0))
(FPCore (x0 x1)
 :precision binary64
 (if (<= (- 1.0 x1) 0.9814)
   (/
    (- (* (/ x0 (- 1.0 x1)) (/ x0 (- 1.0 x1))) (* x0 x0))
    (+ x0 (/ x0 (- 1.0 x1))))
   (* (+ x1 (* x1 x1)) (+ x0 (* x1 (* x1 x0))))))
double code(double x0, double x1) {
	return (x0 / (1.0 - x1)) - x0;
}
double code(double x0, double x1) {
	double tmp;
	if ((1.0 - x1) <= 0.9814) {
		tmp = (((x0 / (1.0 - x1)) * (x0 / (1.0 - x1))) - (x0 * x0)) / (x0 + (x0 / (1.0 - x1)));
	} else {
		tmp = (x1 + (x1 * x1)) * (x0 + (x1 * (x1 * x0)));
	}
	return tmp;
}

Error

Bits error versus x0

Bits error versus x1

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original8.4
Target0.5
Herbie4.0
\[\frac{x0 \cdot x1}{1 - x1}\]

Derivation

  1. Split input into 2 regimes
  2. if (-.f64 1 x1) < 0.98140000000000005

    1. Initial program 5.5

      \[\frac{x0}{1 - x1} - x0\]
    2. Using strategy rm
    3. Applied flip--_binary64_31224.0

      \[\leadsto \color{blue}{\frac{\frac{x0}{1 - x1} \cdot \frac{x0}{1 - x1} - x0 \cdot x0}{\frac{x0}{1 - x1} + x0}}\]

    if 0.98140000000000005 < (-.f64 1 x1)

    1. Initial program 11.3

      \[\frac{x0}{1 - x1} - x0\]
    2. Taylor expanded around 0 3.9

      \[\leadsto \color{blue}{x0 \cdot {x1}^{2} + \left(x0 \cdot {x1}^{3} + \left(x0 \cdot x1 + x0 \cdot {x1}^{4}\right)\right)}\]
    3. Simplified3.9

      \[\leadsto \color{blue}{\left(x1 + x1 \cdot x1\right) \cdot \left(x0 + x1 \cdot \left(x1 \cdot x0\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - x1 \leq 0.9814:\\ \;\;\;\;\frac{\frac{x0}{1 - x1} \cdot \frac{x0}{1 - x1} - x0 \cdot x0}{x0 + \frac{x0}{1 - x1}}\\ \mathbf{else}:\\ \;\;\;\;\left(x1 + x1 \cdot x1\right) \cdot \left(x0 + x1 \cdot \left(x1 \cdot x0\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2021059 
(FPCore (x0 x1)
  :name "(- (/ x0 (- 1 x1)) x0)"
  :precision binary64
  :pre (or (and (== x0 1.855) (== x1 0.000209)) (and (== x0 2.985) (== x1 0.0186)))

  :herbie-target
  (/ (* x0 x1) (- 1.0 x1))

  (- (/ x0 (- 1.0 x1)) x0))