Average Error: 12.7 → 3.0
Time: 4.3s
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 r531800 = x;
        double r531801 = y;
        double r531802 = z;
        double r531803 = r531801 - r531802;
        double r531804 = r531800 * r531803;
        double r531805 = r531804 / r531801;
        return r531805;
}

double f(double x, double y, double z) {
        double r531806 = x;
        double r531807 = y;
        double r531808 = z;
        double r531809 = r531807 - r531808;
        double r531810 = r531807 / r531809;
        double r531811 = r531806 / r531810;
        return r531811;
}

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.7
Target3.2
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. Split input into 3 regimes
  2. if x < -2.580679840002735e-172

    1. Initial program 13.9

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 4.8

      \[\leadsto \color{blue}{x - \frac{x \cdot z}{y}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity4.8

      \[\leadsto x - \frac{x \cdot z}{\color{blue}{1 \cdot y}}\]
    7. Applied times-frac1.4

      \[\leadsto x - \color{blue}{\frac{x}{1} \cdot \frac{z}{y}}\]
    8. Simplified1.4

      \[\leadsto x - \color{blue}{x} \cdot \frac{z}{y}\]

    if -2.580679840002735e-172 < x < 1.5245638983253773e-157

    1. Initial program 8.9

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 4.6

      \[\leadsto \color{blue}{x - \frac{x \cdot z}{y}}\]

    if 1.5245638983253773e-157 < x

    1. Initial program 14.3

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.0

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

Reproduce

herbie shell --seed 2019304 
(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))