Average Error: 7.2 → 6.5
Time: 1.5m
Precision: 64
Internal Precision: 384
\[\frac{x \cdot y - z \cdot t}{a}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -6.7291158904237084 \cdot 10^{+66}:\\
\;\;\;\;\frac{y \cdot x}{a} - \frac{z}{\frac{a}{t}}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\
\end{array}\]
Target
| Original | 7.2 |
|---|
| Target | 5.8 |
|---|
| Herbie | 6.5 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z \lt 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\end{array}\]
Derivation
- Split input into 2 regimes
if (- (* x y) (* z t)) < -6.7291158904237084e+66
Initial program 13.5
\[\frac{x \cdot y - z \cdot t}{a}\]
Taylor expanded around 0 13.5
\[\leadsto \color{blue}{\frac{y \cdot x}{a} - \frac{z \cdot t}{a}}\]
- Using strategy
rm Applied associate-/l*10.5
\[\leadsto \frac{y \cdot x}{a} - \color{blue}{\frac{z}{\frac{a}{t}}}\]
if -6.7291158904237084e+66 < (- (* x y) (* z t))
Initial program 5.1
\[\frac{x \cdot y - z \cdot t}{a}\]
- Using strategy
rm Applied div-inv5.2
\[\leadsto \color{blue}{\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}}\]
- Recombined 2 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 a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:herbie-target
(if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))
(/ (- (* x y) (* z t)) a))