\[\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \leq -21 \lor \neg \left(x \leq 2.8 \cdot 10^{-24}\right):\\
\;\;\;\;y \cdot i + \left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + b \cdot \log c\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\
\end{array}
\]
(FPCore (x y z t a b c i)
:precision binary64
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
↓
(FPCore (x y z t a b c i)
:precision binary64
(if (or (<= x -21.0) (not (<= x 2.8e-24)))
(+ (* y i) (+ (+ a (+ t (+ z (* x (log y))))) (* b (log c))))
(fma y i (+ a (+ (* (log c) (+ b -0.5)) (+ z t))))))
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
↓
\begin{array}{l}
\mathbf{if}\;x \leq -21 \lor \neg \left(x \leq 2.8 \cdot 10^{-24}\right):\\
\;\;\;\;y \cdot i + \left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + b \cdot \log c\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\
\end{array}
Error
Derivation
Split input into 2 regimes
if x < -21 or 2.8000000000000002e-24 < x
Initial program 0.1
\[\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\]
Taylor expanded in b around inf 0.2
\[\leadsto \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \color{blue}{\log c \cdot b}\right) + y \cdot i
\]
if -21 < x < 2.8000000000000002e-24
Initial program 0.1
\[\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\]
Simplified0.1
\[\leadsto \color{blue}{\mathsf{fma}\left(y, i, \mathsf{fma}\left(b + -0.5, \log c, \mathsf{fma}\left(x, \log y, z\right) + \left(t + a\right)\right)\right)}
\]
Proof
(fma.f64 y i (fma.f64 (+.f64 b -1/2) (log.f64 c) (+.f64 (fma.f64 x (log.f64 y) z) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
(fma.f64 y i (fma.f64 (+.f64 b (Rewrite<= metadata-eval (neg.f64 1/2))) (log.f64 c) (+.f64 (fma.f64 x (log.f64 y) z) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
(fma.f64 y i (fma.f64 (Rewrite<= sub-neg_binary64 (-.f64 b 1/2)) (log.f64 c) (+.f64 (fma.f64 x (log.f64 y) z) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
(fma.f64 y i (fma.f64 (-.f64 b 1/2) (log.f64 c) (+.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (log.f64 y)) z)) (+.f64 t a)))): 0 points increase in error, 0 points decrease in error
(fma.f64 y i (fma.f64 (-.f64 b 1/2) (log.f64 c) (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a)))): 0 points increase in error, 0 points decrease in error
(fma.f64 y i (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 b 1/2) (log.f64 c)) (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a)))): 0 points increase in error, 0 points decrease in error
(fma.f64 y i (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b 1/2) (log.f64 c))))): 0 points increase in error, 0 points decrease in error
(Rewrite<= fma-def_binary64 (+.f64 (*.f64 y i) (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b 1/2) (log.f64 c))))): 0 points increase in error, 0 points decrease in error
(Rewrite<= +-commutative_binary64 (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b 1/2) (log.f64 c))) (*.f64 y i))): 0 points increase in error, 0 points decrease in error
Taylor expanded in x around 0 0.1
\[\leadsto \mathsf{fma}\left(y, i, \color{blue}{a + \left(\log c \cdot \left(b - 0.5\right) + \left(t + z\right)\right)}\right)
\]
Recombined 2 regimes into one program.
Final simplification0.2
\[\leadsto \begin{array}{l}
\mathbf{if}\;x \leq -21 \lor \neg \left(x \leq 2.8 \cdot 10^{-24}\right):\\
\;\;\;\;y \cdot i + \left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + b \cdot \log c\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\
\end{array}
\]
Alternatives
Alternative 1
Error
0.1
Cost
32832
\[\mathsf{fma}\left(y, i, \mathsf{fma}\left(b + -0.5, \log c, \mathsf{fma}\left(x, \log y, z\right) + \left(t + a\right)\right)\right)
\]
Alternative 2
Error
0.1
Cost
14016
\[\left(\left(a + \left(t + \left(z + x \cdot \log y\right)\right)\right) + \log c \cdot \left(b + -0.5\right)\right) + y \cdot i
\]
Alternative 3
Error
3.1
Cost
13896
\[\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -2.3 \cdot 10^{+22}:\\
\;\;\;\;a + \left(t_1 + \left(t + \left(z + b \cdot \log c\right)\right)\right)\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+147}:\\
\;\;\;\;\mathsf{fma}\left(y, i, a + \left(\log c \cdot \left(b + -0.5\right) + \left(z + t\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot i + \left(t_1 + \left(a + \left(z + t\right)\right)\right)\\
\end{array}
\]
herbie shell --seed 2022343
(FPCore (x y z t a b c i)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
:precision binary64
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))