Average Error: 12.6 → 3.0
Time: 3.6s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\frac{x}{\frac{y}{y - z}}\]
\frac{x \cdot \left(y - z\right)}{y}
\frac{x}{\frac{y}{y - z}}
double f(double x, double y, double z) {
        double r684489 = x;
        double r684490 = y;
        double r684491 = z;
        double r684492 = r684490 - r684491;
        double r684493 = r684489 * r684492;
        double r684494 = r684493 / r684490;
        return r684494;
}

double f(double x, double y, double z) {
        double r684495 = x;
        double r684496 = y;
        double r684497 = z;
        double r684498 = r684496 - r684497;
        double r684499 = r684496 / r684498;
        double r684500 = r684495 / r684499;
        return r684500;
}

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

Original12.6
Target3.0
Herbie3.0
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739024383612783691266533098 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.693976601382852594702773997610248441465 \cdot 10^{213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array}\]

Derivation

  1. Initial program 12.6

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

    \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
  4. Final simplification3.0

    \[\leadsto \frac{x}{\frac{y}{y - z}}\]

Reproduce

herbie shell --seed 2019322 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e104) (- x (/ (* z x) y)) (if (< z 1.69397660138285259e213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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