?

Average Error: 0.1 → 0.1
Time: 35.7s
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(x, \log y, \mathsf{fma}\left(b + -0.5, \log c, t\right)\right) + \mathsf{fma}\left(y, i, z + a\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 x (log y) (fma (+ b -0.5) (log c) t)) (fma y i (+ z 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(x, log(y), fma((b + -0.5), log(c), t)) + fma(y, i, (z + 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 Float64(fma(x, log(y), fma(Float64(b + -0.5), log(c), t)) + fma(y, i, Float64(z + 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[(N[(x * N[Log[y], $MachinePrecision] + N[(N[(b + -0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * i + N[(z + a), $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(x, \log y, \mathsf{fma}\left(b + -0.5, \log c, t\right)\right) + \mathsf{fma}\left(y, i, z + a\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(x, \log y, \mathsf{fma}\left(b + -0.5, \log c, t\right)\right) + \mathsf{fma}\left(y, i, z + a\right)} \]
    Proof

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

    +-commutative [=>]0.1

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

    associate-+l+ [=>]0.1

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

    +-commutative [=>]0.1

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

    associate-+l+ [=>]0.1

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

    +-commutative [=>]0.1

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

    associate-+l+ [=>]0.1

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

    associate-+l+ [=>]0.1

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

    associate-+r+ [=>]0.1

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

    +-commutative [<=]0.1

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

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

Alternatives

Alternative 1
Error3.4
Cost14409
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;b + -0.5 \leq -5 \cdot 10^{+176} \lor \neg \left(b + -0.5 \leq 5 \cdot 10^{+145}\right):\\ \;\;\;\;t_1 + \left(a + \left(\log c \cdot \left(b + -0.5\right) + \left(t + z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a + \left(t + \left(z + t_1\right)\right)\right) + -0.5 \cdot \log c\right) + y \cdot i\\ \end{array} \]
Alternative 2
Error4.1
Cost14024
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.55 \cdot 10^{+174}:\\ \;\;\;\;\mathsf{fma}\left(y, i, z + a\right) + t_1\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+14}:\\ \;\;\;\;y \cdot i + \left(a + \mathsf{fma}\left(\log c, b + -0.5, t + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 + \left(a + \left(\log c \cdot \left(b + -0.5\right) + \left(t + z\right)\right)\right)\\ \end{array} \]
Alternative 3
Error0.1
Cost14016
\[\log c \cdot \left(b + -0.5\right) + \left(a + \left(x \cdot \log y + \left(t + \left(z + y \cdot i\right)\right)\right)\right) \]
Alternative 4
Error5.7
Cost13897
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+174} \lor \neg \left(x \leq 3.2 \cdot 10^{+147}\right):\\ \;\;\;\;\mathsf{fma}\left(y, i, z + a\right) + x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(a + \mathsf{fma}\left(\log c, b + -0.5, t + z\right)\right)\\ \end{array} \]
Alternative 5
Error6.1
Cost13641
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+183} \lor \neg \left(x \leq 2.9 \cdot 10^{+160}\right):\\ \;\;\;\;x \cdot \log y + \left(a + b \cdot \log c\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(a + \left(t + z\right)\right)\right)\\ \end{array} \]
Alternative 6
Error5.7
Cost13641
\[\begin{array}{l} \mathbf{if}\;x \leq -1.72 \cdot 10^{+174} \lor \neg \left(x \leq 2.3 \cdot 10^{+146}\right):\\ \;\;\;\;\mathsf{fma}\left(y, i, z + a\right) + x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(a + \left(t + z\right)\right)\right)\\ \end{array} \]
Alternative 7
Error23.0
Cost8288
\[\begin{array}{l} t_1 := \log c \cdot \left(b + -0.5\right)\\ t_2 := \left(t_1 + \left(t + z\right)\right) + y \cdot i\\ t_3 := t_1 + \left(a + \left(t + z\right)\right)\\ t_4 := x \cdot \log y + \left(z + a\right)\\ t_5 := t_1 + \left(a + y \cdot i\right)\\ \mathbf{if}\;b \leq -3.6 \cdot 10^{+87}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq -1.7 \cdot 10^{-39}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq -6 \cdot 10^{-97}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -4.3 \cdot 10^{-160}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \leq 1.62 \cdot 10^{+121}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq 6.2 \cdot 10^{+153}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \leq 8.6 \cdot 10^{+179}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq 6.8 \cdot 10^{+210}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error38.2
Cost7905
\[\begin{array}{l} t_1 := x \cdot \log y\\ t_2 := z + t_1\\ \mathbf{if}\;a \leq 1.45 \cdot 10^{-43}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{-18}:\\ \;\;\;\;y \cdot i + b \cdot \log c\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{+67}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{+76}:\\ \;\;\;\;a + y \cdot i\\ \mathbf{elif}\;a \leq 4.2 \cdot 10^{+85}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.32 \cdot 10^{+91}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{elif}\;a \leq 9.4 \cdot 10^{+173} \lor \neg \left(a \leq 9.5 \cdot 10^{+236}\right):\\ \;\;\;\;a + \log c \cdot \left(b + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;a + t_1\\ \end{array} \]
Alternative 9
Error6.5
Cost7625
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+183} \lor \neg \left(x \leq 10^{+156}\right):\\ \;\;\;\;x \cdot \log y + \left(z + a\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + \left(\log c \cdot \left(b + -0.5\right) + \left(a + \left(t + z\right)\right)\right)\\ \end{array} \]
Alternative 10
Error35.7
Cost7384
\[\begin{array}{l} t_1 := z + x \cdot \log y\\ t_2 := b \cdot \log c\\ \mathbf{if}\;b \leq -9.6 \cdot 10^{+215}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -1.15 \cdot 10^{+62}:\\ \;\;\;\;z + a\\ \mathbf{elif}\;b \leq -125:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2.15 \cdot 10^{-185}:\\ \;\;\;\;z + a\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+181}:\\ \;\;\;\;z + a\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error13.9
Cost7369
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+174} \lor \neg \left(x \leq 3.1 \cdot 10^{+153}\right):\\ \;\;\;\;x \cdot \log y + \left(z + a\right)\\ \mathbf{else}:\\ \;\;\;\;\log c \cdot \left(b + -0.5\right) + \left(a + \left(t + z\right)\right)\\ \end{array} \]
Alternative 12
Error37.0
Cost7245
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+64}:\\ \;\;\;\;z + t_1\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{+46} \lor \neg \left(z \leq -1.52 \cdot 10^{-34}\right):\\ \;\;\;\;a + \log c \cdot \left(b + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;a + t_1\\ \end{array} \]
Alternative 13
Error23.0
Cost7241
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+174} \lor \neg \left(x \leq 1.65 \cdot 10^{+133}\right):\\ \;\;\;\;x \cdot \log y + \left(z + a\right)\\ \mathbf{else}:\\ \;\;\;\;\log c \cdot \left(b + -0.5\right) + \left(z + a\right)\\ \end{array} \]
Alternative 14
Error25.4
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{+184} \lor \neg \left(x \leq 2.9 \cdot 10^{+153}\right):\\ \;\;\;\;a + x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;b \cdot \log c + \left(z + a\right)\\ \end{array} \]
Alternative 15
Error24.6
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+174} \lor \neg \left(x \leq 3.1 \cdot 10^{-11}\right):\\ \;\;\;\;x \cdot \log y + \left(z + a\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \log c + \left(z + a\right)\\ \end{array} \]
Alternative 16
Error34.5
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -5.4 \cdot 10^{+180} \lor \neg \left(x \leq 5.2 \cdot 10^{+110}\right):\\ \;\;\;\;a + x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;z + a\\ \end{array} \]
Alternative 17
Error35.9
Cost6857
\[\begin{array}{l} \mathbf{if}\;b \leq -2.65 \cdot 10^{+218} \lor \neg \left(b \leq 1.12 \cdot 10^{+181}\right):\\ \;\;\;\;b \cdot \log c\\ \mathbf{else}:\\ \;\;\;\;z + a\\ \end{array} \]
Alternative 18
Error41.5
Cost456
\[\begin{array}{l} \mathbf{if}\;i \leq 1.85 \cdot 10^{+170}:\\ \;\;\;\;z + a\\ \mathbf{elif}\;i \leq 1.9 \cdot 10^{+186}:\\ \;\;\;\;y \cdot i\\ \mathbf{else}:\\ \;\;\;\;z + a\\ \end{array} \]
Alternative 19
Error40.2
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -1.08 \cdot 10^{+55}:\\ \;\;\;\;z + a\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 20
Error40.4
Cost452
\[\begin{array}{l} \mathbf{if}\;a \leq 5.2 \cdot 10^{+91}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;z + a\\ \end{array} \]
Alternative 21
Error48.3
Cost196
\[\begin{array}{l} \mathbf{if}\;a \leq 1.5 \cdot 10^{+122}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 22
Error52.0
Cost64
\[a \]

Error

Reproduce?

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