Average Error: 10.3 → 0.3
Time: 3.2s
Precision: 64
\[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.50794050172492778 \cdot 10^{106} \lor \neg \left(z \le 0.104342146627556406\right):\\ \;\;\;\;\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{z}{\left(y - z\right) + 1}} \cdot \left(\sqrt[3]{1} \cdot x\right)\\ \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}\;z \le -8.50794050172492778 \cdot 10^{106} \lor \neg \left(z \le 0.104342146627556406\right):\\
\;\;\;\;\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{z}{\left(y - z\right) + 1}} \cdot \left(\sqrt[3]{1} \cdot x\right)\\

\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 r780974 = x;
        double r780975 = y;
        double r780976 = z;
        double r780977 = r780975 - r780976;
        double r780978 = 1.0;
        double r780979 = r780977 + r780978;
        double r780980 = r780974 * r780979;
        double r780981 = r780980 / r780976;
        return r780981;
}

double f(double x, double y, double z) {
        double r780982 = z;
        double r780983 = -8.507940501724928e+106;
        bool r780984 = r780982 <= r780983;
        double r780985 = 0.1043421466275564;
        bool r780986 = r780982 <= r780985;
        double r780987 = !r780986;
        bool r780988 = r780984 || r780987;
        double r780989 = 1.0;
        double r780990 = cbrt(r780989);
        double r780991 = r780990 * r780990;
        double r780992 = y;
        double r780993 = r780992 - r780982;
        double r780994 = 1.0;
        double r780995 = r780993 + r780994;
        double r780996 = r780982 / r780995;
        double r780997 = r780991 / r780996;
        double r780998 = x;
        double r780999 = r780990 * r780998;
        double r781000 = r780997 * r780999;
        double r781001 = r780998 * r780992;
        double r781002 = r781001 / r780982;
        double r781003 = r780998 / r780982;
        double r781004 = r780994 * r781003;
        double r781005 = r781002 + r781004;
        double r781006 = r781005 - r780998;
        double r781007 = r780988 ? r781000 : r781006;
        return r781007;
}

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

Original10.3
Target0.4
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;x \lt -2.7148310671343599 \cdot 10^{-162}:\\ \;\;\;\;\left(1 + y\right) \cdot \frac{x}{z} - x\\ \mathbf{elif}\;x \lt 3.87410881643954616 \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 z < -8.507940501724928e+106 or 0.1043421466275564 < z

    1. Initial program 19.4

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}}\]
    4. Using strategy rm
    5. Applied clear-num0.2

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{z}{\left(y - z\right) + 1}}{x}}}\]
    6. Using strategy rm
    7. Applied div-inv0.3

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

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

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

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

    if -8.507940501724928e+106 < z < 0.1043421466275564

    1. Initial program 1.2

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

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

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

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

Reproduce

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

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

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