Average Error: 6.1 → 1.6
Time: 3.2s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \le -5.7257024653564855 \cdot 10^{-285}:\\ \;\;\;\;x + \frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{elif}\;a \le 1.7142068329116636 \cdot 10^{-56}:\\ \;\;\;\;x + \frac{y \cdot z + y \cdot \left(-t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.1
Target0.8
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;y \lt -1.07612662163899753 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.8944268627920891 \cdot 10^{-49}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if a < -5.7257024653564855e-285

    1. Initial program 6.0

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

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

      \[\leadsto x + \frac{\color{blue}{y \cdot z + y \cdot \left(-t\right)}}{a}\]
    5. Using strategy rm
    6. Applied clear-num6.1

      \[\leadsto x + \color{blue}{\frac{1}{\frac{a}{y \cdot z + y \cdot \left(-t\right)}}}\]
    7. Simplified2.4

      \[\leadsto x + \frac{1}{\color{blue}{\frac{\frac{a}{y}}{z - t}}}\]
    8. Using strategy rm
    9. Applied div-inv2.5

      \[\leadsto x + \frac{1}{\color{blue}{\frac{a}{y} \cdot \frac{1}{z - t}}}\]
    10. Applied add-cube-cbrt2.5

      \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{a}{y} \cdot \frac{1}{z - t}}\]
    11. Applied times-frac2.7

      \[\leadsto x + \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{a}{y}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{z - t}}}\]
    12. Simplified2.4

      \[\leadsto x + \color{blue}{\frac{y}{a}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{z - t}}\]
    13. Simplified2.4

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

    if -5.7257024653564855e-285 < a < 1.7142068329116636e-56

    1. Initial program 1.3

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

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

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

    if 1.7142068329116636e-56 < a

    1. Initial program 8.3

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

      \[\leadsto x + \color{blue}{\frac{y}{\frac{a}{z - t}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -5.7257024653564855 \cdot 10^{-285}:\\ \;\;\;\;x + \frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{elif}\;a \le 1.7142068329116636 \cdot 10^{-56}:\\ \;\;\;\;x + \frac{y \cdot z + y \cdot \left(-t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< y -1.0761266216389975e-10) (+ x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))

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