Average Error: 0.1 → 0.1
Time: 20.8s
Precision: binary64
Cost: 32832
\[\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 \]
\[\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) \]
(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
 (fma y i (fma (+ b -0.5) (log c) (+ (fma x (log y) z) (+ t a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return fma(y, i, fma((b + -0.5), log(c), (fma(x, log(y), z) + (t + a))));
}
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i))
end
function code(x, y, z, t, a, b, c, i)
	return fma(y, i, fma(Float64(b + -0.5), log(c), Float64(fma(x, log(y), z) + Float64(t + a))))
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * i + N[(N[(b + -0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(N[(x * N[Log[y], $MachinePrecision] + z), $MachinePrecision] + N[(t + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\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
\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)

Error

Derivation

  1. 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 \]
  2. 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, 1 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))))): 3 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
  3. Final simplification0.1

    \[\leadsto \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) \]

Alternatives

Alternative 1
Error0.1
Cost14016
\[\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 2
Error5.0
Cost13896
\[\begin{array}{l} t_1 := \log c \cdot \left(b + -0.5\right)\\ t_2 := t_1 + \left(a + \left(z + x \cdot \log y\right)\right)\\ \mathbf{if}\;x \leq -5.2 \cdot 10^{+98}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+123}:\\ \;\;\;\;y \cdot i + \left(t_1 + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error11.6
Cost13888
\[y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(a + \left(z + x \cdot \log y\right)\right)\right) \]
Alternative 4
Error6.3
Cost13768
\[\begin{array}{l} t_1 := \log c \cdot \left(b + -0.5\right)\\ t_2 := t_1 + \left(z + x \cdot \log y\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+152}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+142}:\\ \;\;\;\;y \cdot i + \left(t_1 + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error6.2
Cost13640
\[\begin{array}{l} t_1 := b \cdot \log c + \left(a + x \cdot \log y\right)\\ \mathbf{if}\;x \leq -4.4 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+128}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error8.2
Cost13384
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.72 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{+175}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, i, t_1\right)\\ \end{array} \]
Alternative 7
Error36.4
Cost7904
\[\begin{array}{l} t_1 := y \cdot i + x \cdot \log y\\ t_2 := \log c \cdot \left(b + -0.5\right)\\ t_3 := t_2 + \left(z + a\right)\\ t_4 := a + t_2\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{+180}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.15 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6 \cdot 10^{+116}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{+20}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-82}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 8
Error35.8
Cost7904
\[\begin{array}{l} t_1 := y \cdot i + x \cdot \log y\\ t_2 := \log c \cdot \left(b + -0.5\right)\\ t_3 := a + t_2\\ t_4 := t_2 + \left(z + a\right)\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{+180}:\\ \;\;\;\;t_2 + \left(a + \left(z + t\right)\right)\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6 \cdot 10^{+116}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+20}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-81}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -5.1 \cdot 10^{-138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 9
Error38.5
Cost7772
\[\begin{array}{l} t_1 := y \cdot i + x \cdot \log y\\ t_2 := a + \log c \cdot \left(b + -0.5\right)\\ t_3 := \left(z + a\right) + -0.5 \cdot \log c\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{+180}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.15 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{+122}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-115}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-223}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-291}:\\ \;\;\;\;y \cdot i + b \cdot \log c\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Error8.2
Cost7624
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.72 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+177}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_1\\ \end{array} \]
Alternative 11
Error38.1
Cost7508
\[\begin{array}{l} t_1 := a + y \cdot i\\ t_2 := a + \log c \cdot \left(b + -0.5\right)\\ t_3 := z + y \cdot i\\ \mathbf{if}\;z \leq -5.6 \cdot 10^{+156}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.2 \cdot 10^{+82}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{+62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8 \cdot 10^{-139}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error18.2
Cost7496
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.72 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+177}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(z + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_1\\ \end{array} \]
Alternative 13
Error37.9
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+122}:\\ \;\;\;\;\left(z + a\right) + -0.5 \cdot \log c\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-140}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;a + \log c \cdot \left(b + -0.5\right)\\ \end{array} \]
Alternative 14
Error41.4
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -2.75 \cdot 10^{+181}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 15
Error40.8
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -2.25 \cdot 10^{+148}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 16
Error48.3
Cost196
\[\begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{+152}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 17
Error51.9
Cost64
\[a \]

Error

Reproduce

herbie shell --seed 2022329 
(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)))