Average Error: 9.9 → 0.2
Time: 7.5s
Precision: 64
\[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -20890976261.996433258056640625 \lor \neg \left(x \le 4.003006293405846964686451842961573369429 \cdot 10^{-55}\right):\\ \;\;\;\;\left(x \cdot \frac{y}{z} + 1 \cdot \frac{x}{z}\right) - x\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{x \cdot y}{z} + 1 \cdot \frac{x}{z}\right) - x\\ \end{array}\]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -20890976261.996433258056640625 \lor \neg \left(x \le 4.003006293405846964686451842961573369429 \cdot 10^{-55}\right):\\
\;\;\;\;\left(x \cdot \frac{y}{z} + 1 \cdot \frac{x}{z}\right) - x\\

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

\end{array}
double f(double x, double y, double z) {
        double r531604 = x;
        double r531605 = y;
        double r531606 = z;
        double r531607 = r531605 - r531606;
        double r531608 = 1.0;
        double r531609 = r531607 + r531608;
        double r531610 = r531604 * r531609;
        double r531611 = r531610 / r531606;
        return r531611;
}

double f(double x, double y, double z) {
        double r531612 = x;
        double r531613 = -20890976261.996433;
        bool r531614 = r531612 <= r531613;
        double r531615 = 4.003006293405847e-55;
        bool r531616 = r531612 <= r531615;
        double r531617 = !r531616;
        bool r531618 = r531614 || r531617;
        double r531619 = y;
        double r531620 = z;
        double r531621 = r531619 / r531620;
        double r531622 = r531612 * r531621;
        double r531623 = 1.0;
        double r531624 = r531612 / r531620;
        double r531625 = r531623 * r531624;
        double r531626 = r531622 + r531625;
        double r531627 = r531626 - r531612;
        double r531628 = r531612 * r531619;
        double r531629 = r531628 / r531620;
        double r531630 = r531629 + r531625;
        double r531631 = r531630 - r531612;
        double r531632 = r531618 ? r531627 : r531631;
        return r531632;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.9
Target0.5
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt -2.714831067134359919650240696134672137284 \cdot 10^{-162}:\\ \;\;\;\;\left(1 + y\right) \cdot \frac{x}{z} - x\\ \mathbf{elif}\;x \lt 3.874108816439546156869494499878029491333 \cdot 10^{-197}:\\ \;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + y\right) \cdot \frac{x}{z} - x\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -20890976261.996433 or 4.003006293405847e-55 < x

    1. Initial program 22.4

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*0.2

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}}\]
    4. Taylor expanded around 0 7.3

      \[\leadsto \color{blue}{\left(\frac{x \cdot y}{z} + 1 \cdot \frac{x}{z}\right) - x}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity7.3

      \[\leadsto \left(\frac{x \cdot y}{\color{blue}{1 \cdot z}} + 1 \cdot \frac{x}{z}\right) - x\]
    7. Applied times-frac0.3

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

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

    if -20890976261.996433 < x < 4.003006293405847e-55

    1. Initial program 0.1

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*5.6

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}}\]
    4. Taylor expanded around 0 0.1

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

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

Reproduce

herbie shell --seed 2019212 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< x -2.7148310671343599e-162) (- (* (+ 1 y) (/ x z)) x) (if (< x 3.87410881643954616e-197) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x)))

  (/ (* x (+ (- y z) 1)) z))