\[\begin{array}{l}
t_1 := \mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+155}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, -t, x \cdot y\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
↓
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma -1.0 (/ t (/ a z)) (/ y (/ a x)))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 4e+155) (/ (fma z (- t) (* x y)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
(fma.f64 -1 (/.f64 t (/.f64 a z)) (/.f64 y (/.f64 a x))): 0 points increase in error, 0 points decrease in error
(fma.f64 -1 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 t z) a)) (/.f64 y (/.f64 a x))): 27 points increase in error, 28 points decrease in error
(fma.f64 -1 (/.f64 (*.f64 t z) a) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 y x) a))): 28 points increase in error, 35 points decrease in error
(Rewrite<= fma-def_binary64 (+.f64 (*.f64 -1 (/.f64 (*.f64 t z) a)) (/.f64 (*.f64 y x) a))): 0 points increase in error, 0 points decrease in error
(Rewrite=> +-commutative_binary64 (+.f64 (/.f64 (*.f64 y x) a) (*.f64 -1 (/.f64 (*.f64 t z) a)))): 0 points increase in error, 0 points decrease in error
(+.f64 (/.f64 (*.f64 y x) a) (Rewrite=> mul-1-neg_binary64 (neg.f64 (/.f64 (*.f64 t z) a)))): 0 points increase in error, 0 points decrease in error
(Rewrite=> unsub-neg_binary64 (-.f64 (/.f64 (*.f64 y x) a) (/.f64 (*.f64 t z) a))): 0 points increase in error, 0 points decrease in error
(Rewrite<= div-sub_binary64 (/.f64 (-.f64 (*.f64 y x) (*.f64 t z)) a)): 3 points increase in error, 0 points decrease in error
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.00000000000000003e155
Initial program 0.8
\[\frac{x \cdot y - z \cdot t}{a}
\]
Simplified0.8
\[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, -t, x \cdot y\right)}{a}}
\]
Proof
(/.f64 (fma.f64 z (neg.f64 t) (*.f64 x y)) a): 0 points increase in error, 0 points decrease in error
(/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (neg.f64 t)) (*.f64 x y))) a): 1 points increase in error, 0 points decrease in error
(/.f64 (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 z t))) (*.f64 x y)) a): 0 points increase in error, 0 points decrease in error
(/.f64 (+.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 z) t)) (*.f64 x y)) a): 0 points increase in error, 0 points decrease in error
(/.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x y) (*.f64 (neg.f64 z) t))) a): 0 points increase in error, 0 points decrease in error
(/.f64 (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 x y) (*.f64 z t))) a): 0 points increase in error, 0 points decrease in error
Recombined 2 regimes into one program.
Final simplification0.9
\[\leadsto \begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\
\mathbf{elif}\;x \cdot y - z \cdot t \leq 4 \cdot 10^{+155}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, -t, x \cdot y\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\
\end{array}
\]
Alternatives
Alternative 1
Error
0.9
Cost
7944
\[\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_2 := x \cdot \frac{y}{a} - t \cdot \frac{z}{a}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+295}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+186}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, -t, x \cdot y\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 2
Error
0.9
Cost
1736
\[\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_2 := x \cdot \frac{y}{a} - t \cdot \frac{z}{a}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+295}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+186}:\\
\;\;\;\;\frac{t_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 3
Error
5.0
Cost
1616
\[\begin{array}{l}
t_1 := \frac{x \cdot y - z \cdot t}{a}\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+260}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{-248}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot y \leq 10^{-286}:\\
\;\;\;\;z \cdot \frac{-t}{a}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+166}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\]
herbie shell --seed 2022306
(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))