Average Error: 7.4 → 5.2
Time: 21.6s
Precision: 64
Internal precision: 128
\[\frac{x \cdot y - z \cdot t}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;a \le -5.7933311388628865 \cdot 10^{+190}:\\
\;\;\;\;\frac{y}{\frac{a}{x}} - \frac{z}{\frac{a}{t}}\\
\mathbf{if}\;a \le 3.8124686331119876 \cdot 10^{+40}:\\
\;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{a}{x}} - \frac{z}{\frac{a}{t}}\\
\end{array}\]
Target
| Original | 7.4 |
| Comparison | 5.7 |
| Herbie | 5.2 |
\[ \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 a < -5.7933311388628865e+190 or 3.8124686331119876e+40 < a
Initial program 12.4
\[\frac{x \cdot y - z \cdot t}{a}\]
Applied taylor 12.4
\[\leadsto \frac{y \cdot x}{a} - \frac{z \cdot t}{a}\]
Taylor expanded around 0 12.4
\[\leadsto \color{blue}{\frac{y \cdot x}{a} - \frac{z \cdot t}{a}}\]
- Using strategy
rm
Applied associate-/l* 10.3
\[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} - \frac{z \cdot t}{a}\]
- Using strategy
rm
Applied associate-/l* 7.0
\[\leadsto \frac{y}{\frac{a}{x}} - \color{blue}{\frac{z}{\frac{a}{t}}}\]
if -5.7933311388628865e+190 < a < 3.8124686331119876e+40
Initial program 3.8
\[\frac{x \cdot y - z \cdot t}{a}\]
- Using strategy
rm
Applied clear-num 3.9
\[\leadsto \color{blue}{\frac{1}{\frac{a}{x \cdot y - z \cdot t}}}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(824151755 2405658847 3886254275 1998256265 327824978 334083030)'
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
: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))