\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_1 \leq -\infty \lor \neg \left(t_1 \leq 2.6521813933633685 \cdot 10^{+232}\right)
\end{array}:\\
\;\;\;\;\begin{array}{l}
t_2 := t \cdot \frac{z}{a}\\
\mathsf{fma}\left(y, \frac{x}{a}, -t_2\right) + \mathsf{fma}\left(-\frac{z}{a}, t, t_2\right)
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{a} + \frac{z \cdot t}{-a}\\
\end{array}
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
(FPCore (x y z t a)
:precision binary64
(if (let* ((t_1 (- (* x y) (* z t))))
(or (<= t_1 (- INFINITY)) (not (<= t_1 2.6521813933633685e+232))))
(let* ((t_2 (* t (/ z a))))
(+ (fma y (/ x a) (- t_2)) (fma (- (/ z a)) t t_2)))
(+ (/ (* x y) a) (/ (* z t) (- a)))))double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2.6521813933633685e+232)) {
double t_2_1 = t * (z / a);
tmp = fma(y, (x / a), -t_2_1) + fma(-(z / a), t, t_2_1);
} else {
tmp = ((x * y) / a) + ((z * t) / -a);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 7.5 |
|---|---|
| Target | 5.5 |
| Herbie | 0.7 |
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 2.65218139336336853e232 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 45.0
Taylor expanded in x around 0 45.0
Applied *-un-lft-identity_binary6445.0
Applied times-frac_binary6424.0
Applied *-un-lft-identity_binary6424.0
Applied times-frac_binary640.5
Applied prod-diff_binary640.5
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 2.65218139336336853e232Initial program 0.7
Taylor expanded in x around 0 0.7
Applied frac-2neg_binary640.7
Final simplification0.7
herbie shell --seed 2022081
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
: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))