Average Error: 1.9 → 1.5
Time: 3.4s
Precision: 64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.02201526273658355 \cdot 10^{-55}:\\ \;\;\;\;\frac{x}{\frac{y}{z - t}} + t\\ \mathbf{elif}\;y \le 1.9593859466949988 \cdot 10^{-131}:\\ \;\;\;\;\left(x \cdot \left(z - t\right)\right) \cdot \frac{1}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{x}{y} \cdot z + \frac{x}{y} \cdot \left(-t\right)\right) + t\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original1.9
Target2.2
Herbie1.5
\[\begin{array}{l} \mathbf{if}\;z \lt 2.7594565545626922 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z \lt 2.326994450874436 \cdot 10^{-110}:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if y < -2.0220152627365835e-55

    1. Initial program 1.2

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} + t\]
    4. Using strategy rm
    5. Applied associate-/l*1.0

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

    if -2.0220152627365835e-55 < y < 1.9593859466949988e-131

    1. Initial program 4.2

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} + t\]
    4. Using strategy rm
    5. Applied div-inv2.7

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

    if 1.9593859466949988e-131 < y

    1. Initial program 1.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.02201526273658355 \cdot 10^{-55}:\\ \;\;\;\;\frac{x}{\frac{y}{z - t}} + t\\ \mathbf{elif}\;y \le 1.9593859466949988 \cdot 10^{-131}:\\ \;\;\;\;\left(x \cdot \left(z - t\right)\right) \cdot \frac{1}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{x}{y} \cdot z + \frac{x}{y} \cdot \left(-t\right)\right) + t\\ \end{array}\]

Reproduce

herbie shell --seed 2020126 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

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