?

Average Error: 0.17% → 0.15%
Time: 26.4s
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.17

    \[\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.15

    \[\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

    [Start]0.17

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

    +-commutative [=>]0.17

    \[ \color{blue}{y \cdot i + \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right)} \]

    fma-def [=>]0.16

    \[ \color{blue}{\mathsf{fma}\left(y, i, \left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right)} \]

    +-commutative [=>]0.16

    \[ \mathsf{fma}\left(y, i, \color{blue}{\left(b - 0.5\right) \cdot \log c + \left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right)}\right) \]

    fma-def [=>]0.15

    \[ \mathsf{fma}\left(y, i, \color{blue}{\mathsf{fma}\left(b - 0.5, \log c, \left(\left(x \cdot \log y + z\right) + t\right) + a\right)}\right) \]

    sub-neg [=>]0.15

    \[ \mathsf{fma}\left(y, i, \mathsf{fma}\left(\color{blue}{b + \left(-0.5\right)}, \log c, \left(\left(x \cdot \log y + z\right) + t\right) + a\right)\right) \]

    metadata-eval [=>]0.15

    \[ \mathsf{fma}\left(y, i, \mathsf{fma}\left(b + \color{blue}{-0.5}, \log c, \left(\left(x \cdot \log y + z\right) + t\right) + a\right)\right) \]

    associate-+l+ [=>]0.15

    \[ \mathsf{fma}\left(y, i, \mathsf{fma}\left(b + -0.5, \log c, \color{blue}{\left(x \cdot \log y + z\right) + \left(t + a\right)}\right)\right) \]

    fma-def [=>]0.15

    \[ \mathsf{fma}\left(y, i, \mathsf{fma}\left(b + -0.5, \log c, \color{blue}{\mathsf{fma}\left(x, \log y, z\right)} + \left(t + a\right)\right)\right) \]
  3. Final simplification0.15

    \[\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
Error4.51%
Cost14025
\[\begin{array}{l} \mathbf{if}\;x \leq -2.75 \cdot 10^{+35} \lor \neg \left(x \leq 6.5 \cdot 10^{+67}\right):\\ \;\;\;\;\log c \cdot \left(b + -0.5\right) + \left(x \cdot \log y + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \mathsf{fma}\left(\log c, b + -0.5, z + t\right)\right)\\ \end{array} \]
Alternative 2
Error0.17%
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 3
Error8.99%
Cost13896
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{\frac{1}{\left(z + t\right) + \mathsf{fma}\left(x, \log y, a\right)}}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+191}:\\ \;\;\;\;y \cdot i + \left(a + \mathsf{fma}\left(\log c, b + -0.5, z + t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(z + x \cdot \log y\right)\\ \end{array} \]
Alternative 4
Error9.01%
Cost13636
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{\frac{1}{\left(z + t\right) + \mathsf{fma}\left(x, \log y, a\right)}}\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+193}:\\ \;\;\;\;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 + \left(z + x \cdot \log y\right)\\ \end{array} \]
Alternative 5
Error33.53%
Cost7905
\[\begin{array}{l} t_1 := y \cdot i + b \cdot \log c\\ t_2 := x \cdot \log y\\ t_3 := a + t_2\\ t_4 := z + \left(t + t_3\right)\\ \mathbf{if}\;b \leq -2.5 \cdot 10^{+195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -2.8 \cdot 10^{+19}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq -1.05 \cdot 10^{-254}:\\ \;\;\;\;y \cdot i + \left(z + t_2\right)\\ \mathbf{elif}\;b \leq 3.3 \cdot 10^{+81}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq 3.7 \cdot 10^{+112}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{+171} \lor \neg \left(b \leq 8.5 \cdot 10^{+222}\right) \land b \leq 1.02 \cdot 10^{+239}:\\ \;\;\;\;z + t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error40.78%
Cost7641
\[\begin{array}{l} t_1 := z + \left(a + x \cdot \log y\right)\\ t_2 := y \cdot i + b \cdot \log c\\ \mathbf{if}\;b \leq -2.9 \cdot 10^{+196}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 3.3 \cdot 10^{+81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 3.55 \cdot 10^{+112}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{+171} \lor \neg \left(b \leq 6.2 \cdot 10^{+224}\right) \land b \leq 1.02 \cdot 10^{+239}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error27.09%
Cost7641
\[\begin{array}{l} t_1 := a + x \cdot \log y\\ t_2 := y \cdot i + b \cdot \log c\\ \mathbf{if}\;b \leq -3 \cdot 10^{+190}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{+81}:\\ \;\;\;\;z + \left(t + t_1\right)\\ \mathbf{elif}\;b \leq 3.55 \cdot 10^{+112}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{elif}\;b \leq 1.5 \cdot 10^{+171} \lor \neg \left(b \leq 1.1 \cdot 10^{+226}\right) \land b \leq 4.3 \cdot 10^{+239}:\\ \;\;\;\;z + t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error11.2%
Cost7624
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -9.5 \cdot 10^{+73}:\\ \;\;\;\;z + \left(a + t_1\right)\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+192}:\\ \;\;\;\;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 + \left(z + t_1\right)\\ \end{array} \]
Alternative 9
Error49.5%
Cost7377
\[\begin{array}{l} t_1 := z + \left(a + x \cdot \log y\right)\\ \mathbf{if}\;y \leq 1.35 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-7}:\\ \;\;\;\;y \cdot i + \left(z + t\right)\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+43} \lor \neg \left(y \leq 1.3 \cdot 10^{+84}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 10
Error44.9%
Cost7252
\[\begin{array}{l} t_1 := a + \left(z + t\right)\\ t_2 := x \cdot \log y\\ \mathbf{if}\;x \leq -2.6 \cdot 10^{+123}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.9 \cdot 10^{-30}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+223}:\\ \;\;\;\;y \cdot i + \left(z + t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error44.99%
Cost7244
\[\begin{array}{l} t_1 := y \cdot i + \left(z + t\right)\\ t_2 := z + \left(t + x \cdot \log y\right)\\ \mathbf{if}\;a \leq 5 \cdot 10^{-255}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.75 \cdot 10^{-12}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a + \left(z + t\right)\\ \end{array} \]
Alternative 12
Error75.77%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{+103}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-18}:\\ \;\;\;\;y \cdot i\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 13
Error64.51%
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+153}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 14
Error61.25%
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{+103}:\\ \;\;\;\;a + \left(z + t\right)\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 15
Error75.19%
Cost196
\[\begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+102}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 16
Error80.88%
Cost64
\[a \]

Error

Reproduce?

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