(FPCore (x y z t a b)
:precision binary64
(/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
↓
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ y (+ x t)))
(t_2 (* z (/ (+ x y) t_1)))
(t_3 (+ a t_2))
(t_4 (* (+ y t) a))
(t_5 (/ (- (+ t_4 (* z (+ x y))) (* y b)) t_1)))
(if (<= t_5 -4e+304)
t_3
(if (<= t_5 2e+282) (+ t_2 (/ (- t_4 (* y b)) t_1)) t_3))))
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -3.9999999999999998e304 or 2.00000000000000007e282 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y))
Initial program 63.0
\[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\]
(+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (*.f64 (/.f64 (+.f64 y x) (+.f64 y (+.f64 t x))) z)): 0 points increase in error, 0 points decrease in error
(+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (Rewrite<= associate-/r/_binary64 (/.f64 (+.f64 y x) (/.f64 (+.f64 y (+.f64 t x)) z)))): 22 points increase in error, 1 points decrease in error
(+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))))): 45 points increase in error, 19 points decrease in error
(Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error
(+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (Rewrite=> div-sub_binary64 (-.f64 (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x)))))): 2 points increase in error, 1 points decrease in error
(Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x)))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error
(+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (*.f64 (/.f64 (+.f64 y x) (+.f64 y (+.f64 t x))) z)): 0 points increase in error, 0 points decrease in error
(+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (Rewrite<= associate-/r/_binary64 (/.f64 (+.f64 y x) (/.f64 (+.f64 y (+.f64 t x)) z)))): 22 points increase in error, 1 points decrease in error
(+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))))): 45 points increase in error, 19 points decrease in error
(Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error
(+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (Rewrite=> div-sub_binary64 (-.f64 (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x)))))): 2 points increase in error, 1 points decrease in error
(Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x)))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error
Recombined 2 regimes into one program.
Final simplification8.3
\[\leadsto \begin{array}{l}
\mathbf{if}\;\frac{\left(\left(y + t\right) \cdot a + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)} \leq -4 \cdot 10^{+304}:\\
\;\;\;\;a + z \cdot \frac{x + y}{y + \left(x + t\right)}\\
\mathbf{elif}\;\frac{\left(\left(y + t\right) \cdot a + z \cdot \left(x + y\right)\right) - y \cdot b}{y + \left(x + t\right)} \leq 2 \cdot 10^{+282}:\\
\;\;\;\;z \cdot \frac{x + y}{y + \left(x + t\right)} + \frac{\left(y + t\right) \cdot a - y \cdot b}{y + \left(x + t\right)}\\
\mathbf{else}:\\
\;\;\;\;a + z \cdot \frac{x + y}{y + \left(x + t\right)}\\
\end{array}
\]
Alternatives
Alternative 1
Error
8.2
Cost
4168
\[\begin{array}{l}
t_1 := y + \left(x + t\right)\\
t_2 := \frac{\left(\left(y + t\right) \cdot a + z \cdot \left(x + y\right)\right) - y \cdot b}{t_1}\\
t_3 := a + z \cdot \frac{x + y}{t_1}\\
\mathbf{if}\;t_2 \leq -4 \cdot 10^{+304}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+282}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\]
herbie shell --seed 2022298
(FPCore (x y z t a b)
:name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
:precision binary64
:herbie-target
(if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3.5813117084150564e+153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e+82) (/ 1.0 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b)))
(/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))