Average Error: 13.0 → 2.9
Time: 2.1s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;z \le 7.9081657782975312 \cdot 10^{106}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;z \le 3.932326956829358 \cdot 10^{276}:\\ \;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + x \cdot \left(-z\right)}{y}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original13.0
Target3.0
Herbie2.9
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.69397660138285259 \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 z < 7.908165778297531e+106

    1. Initial program 13.1

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

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

    if 7.908165778297531e+106 < z < 3.932326956829358e+276

    1. Initial program 12.3

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/10.6

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

    if 3.932326956829358e+276 < z

    1. Initial program 12.6

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied sub-neg12.6

      \[\leadsto \frac{x \cdot \color{blue}{\left(y + \left(-z\right)\right)}}{y}\]
    4. Applied distribute-lft-in12.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le 7.9081657782975312 \cdot 10^{106}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;z \le 3.932326956829358 \cdot 10^{276}:\\ \;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + x \cdot \left(-z\right)}{y}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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