Average Error: 10.3 → 0.3
Time: 3.1s
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 r641310 = x;
        double r641311 = y;
        double r641312 = z;
        double r641313 = r641311 - r641312;
        double r641314 = 1.0;
        double r641315 = r641313 + r641314;
        double r641316 = r641310 * r641315;
        double r641317 = r641316 / r641312;
        return r641317;
}

double f(double x, double y, double z) {
        double r641318 = z;
        double r641319 = -8.507940501724928e+106;
        bool r641320 = r641318 <= r641319;
        double r641321 = 0.1043421466275564;
        bool r641322 = r641318 <= r641321;
        double r641323 = !r641322;
        bool r641324 = r641320 || r641323;
        double r641325 = 1.0;
        double r641326 = cbrt(r641325);
        double r641327 = r641326 * r641326;
        double r641328 = y;
        double r641329 = r641328 - r641318;
        double r641330 = 1.0;
        double r641331 = r641329 + r641330;
        double r641332 = r641318 / r641331;
        double r641333 = r641327 / r641332;
        double r641334 = x;
        double r641335 = r641326 * r641334;
        double r641336 = r641333 * r641335;
        double r641337 = r641334 * r641328;
        double r641338 = r641337 / r641318;
        double r641339 = r641334 / r641318;
        double r641340 = r641330 * r641339;
        double r641341 = r641338 + r641340;
        double r641342 = r641341 - r641334;
        double r641343 = r641324 ? r641336 : r641342;
        return r641343;
}

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))