Average Error: 6.2 → 1.8
Time: 39.4s
Precision: 64
Internal Precision: 384
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.906465135771799 \cdot 10^{-107}:\\ \;\;\;\;\frac{z}{t} \cdot \left(y - x\right) + x\\ \mathbf{if}\;x \le -1.2396732347310702 \cdot 10^{-264}:\\ \;\;\;\;x + \frac{1}{\frac{t}{\left(y - x\right) \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.2
Target2.0
Herbie1.8
\[\begin{array}{l} \mathbf{if}\;x \lt -9.025511195533005 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{if}\;x \lt 4.275032163700715 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -6.906465135771799e-107

    1. Initial program 7.2

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Taylor expanded around 0 7.2

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

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

    if -6.906465135771799e-107 < x < -1.2396732347310702e-264

    1. Initial program 3.8

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

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

    if -1.2396732347310702e-264 < x

    1. Initial program 6.3

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

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 39.4s)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

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