Average Error: 6.7 → 0.8
Time: 3.9s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} = -inf.0 \lor \neg \left(x + \frac{y \cdot \left(z - x\right)}{t} \le 1.7151056671430132 \cdot 10^{307}\right):\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z + y \cdot \left(-x\right)}{t}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.7
Target1.8
Herbie0.8
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if (+ x (/ (* y (- z x)) t)) < -inf.0 or 1.7151056671430132e307 < (+ x (/ (* y (- z x)) t))

    1. Initial program 63.2

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

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

    if -inf.0 < (+ x (/ (* y (- z x)) t)) < 1.7151056671430132e307

    1. Initial program 0.8

      \[x + \frac{y \cdot \left(z - x\right)}{t}\]
    2. Using strategy rm
    3. Applied sub-neg0.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} = -inf.0 \lor \neg \left(x + \frac{y \cdot \left(z - x\right)}{t} \le 1.7151056671430132 \cdot 10^{307}\right):\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z + y \cdot \left(-x\right)}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020149 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

  :herbie-target
  (- x (+ (* x (/ y t)) (* (neg z) (/ y t))))

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