Average Error: 6.2 → 1.8
Time: 42.9s
Precision: 64
Internal Precision: 384
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -1.2236383726059943 \cdot 10^{-104}:\\
\;\;\;\;\frac{z}{t} \cdot \left(y - x\right) + x\\
\mathbf{if}\;x \le -1.2444038385878892 \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}\]
Target
| Original | 6.2 |
|---|
| Target | 2.0 |
|---|
| Herbie | 1.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
- Split input into 3 regimes
if x < -1.2236383726059943e-104
Initial program 7.2
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
Taylor expanded around 0 7.2
\[\leadsto x + \color{blue}{\left(\frac{z \cdot y}{t} - \frac{z \cdot x}{t}\right)}\]
Applied simplify0.4
\[\leadsto \color{blue}{\frac{z}{t} \cdot \left(y - x\right) + x}\]
if -1.2236383726059943e-104 < x < -1.2444038385878892e-264
Initial program 3.8
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
- Using strategy
rm Applied clear-num3.8
\[\leadsto x + \color{blue}{\frac{1}{\frac{t}{\left(y - x\right) \cdot z}}}\]
if -1.2444038385878892e-264 < x
Initial program 6.3
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
- Using strategy
rm Applied associate-/l*2.1
\[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(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)))