?

Average Error: 0.1 → 0.1
Time: 26.9s
Precision: binary64
Cost: 32832

?

\[ \begin{array}{c}[z, t, a] = \mathsf{sort}([z, t, a])\\ \end{array} \]
\[\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 \]
\[z + \left(t + \mathsf{fma}\left(x, \log y, \mathsf{fma}\left(b + -0.5, \log c, \mathsf{fma}\left(y, i, a\right)\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
 (+ z (+ t (fma x (log y) (fma (+ b -0.5) (log c) (fma y i 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 z + (t + fma(x, log(y), fma((b + -0.5), log(c), fma(y, i, 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(z + Float64(t + fma(x, log(y), fma(Float64(b + -0.5), log(c), fma(y, i, 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[(z + N[(t + N[(x * N[Log[y], $MachinePrecision] + N[(N[(b + -0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(y * i + a), $MachinePrecision]), $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
z + \left(t + \mathsf{fma}\left(x, \log y, \mathsf{fma}\left(b + -0.5, \log c, \mathsf{fma}\left(y, i, a\right)\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}{z + \left(t + \mathsf{fma}\left(x, \log y, \mathsf{fma}\left(b + -0.5, \log c, \mathsf{fma}\left(y, i, a\right)\right)\right)\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 \]

    associate-+l+ [=>]0.1

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

    +-commutative [=>]0.1

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

    +-commutative [=>]0.1

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

    associate-+l+ [=>]0.1

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

    associate-+r+ [=>]0.1

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

    associate-+r+ [=>]0.1

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

    +-commutative [=>]0.1

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

    associate-+l+ [=>]0.1

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

    associate-+r+ [=>]0.1

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

    +-commutative [<=]0.1

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

    +-commutative [<=]0.1

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

    fma-def [=>]0.1

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

    associate-+r+ [=>]0.1

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

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

Alternatives

Alternative 1
Error3.7
Cost14153
\[\begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+121} \lor \neg \left(x \leq 3 \cdot 10^{+51}\right):\\ \;\;\;\;z + \left(t + \left(x \cdot \log y + \left(a + \left(y \cdot i + -0.5 \cdot \log c\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z + \left(t + \left(\log c \cdot \left(b + -0.5\right) + \left(a + y \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 2
Error3.2
Cost14025
\[\begin{array}{l} t_1 := \log c \cdot \left(b + -0.5\right)\\ \mathbf{if}\;x \leq -1.85 \cdot 10^{+89} \lor \neg \left(x \leq 5 \cdot 10^{+162}\right):\\ \;\;\;\;t_1 + \left(x \cdot \log y + \left(a + \left(z + t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z + \left(t + \left(t_1 + \left(a + y \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 3
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 4
Error17.8
Cost7896
\[\begin{array}{l} t_1 := t + \left(z + y \cdot i\right)\\ t_2 := a + t_1\\ t_3 := t_1 + b \cdot \log c\\ t_4 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{+90}:\\ \;\;\;\;z + t_4\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-214}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-97}:\\ \;\;\;\;a + \left(z + \log c \cdot \left(b + -0.5\right)\right)\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+43}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+170}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_4\\ \end{array} \]
Alternative 5
Error17.4
Cost7896
\[\begin{array}{l} t_1 := t + \left(z + y \cdot i\right)\\ t_2 := a + t_1\\ t_3 := t_1 + b \cdot \log c\\ t_4 := x \cdot \log y\\ \mathbf{if}\;x \leq -1 \cdot 10^{+90}:\\ \;\;\;\;z + t_4\\ \mathbf{elif}\;x \leq -7.2 \cdot 10^{-129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-101}:\\ \;\;\;\;\log c \cdot \left(b + -0.5\right) + \left(a + \left(z + t\right)\right)\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+42}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+171}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_4\\ \end{array} \]
Alternative 6
Error7.7
Cost7624
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.8 \cdot 10^{+123}:\\ \;\;\;\;z + t_1\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+172}:\\ \;\;\;\;z + \left(t + \left(\log c \cdot \left(b + -0.5\right) + \left(a + y \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_1\\ \end{array} \]
Alternative 7
Error16.8
Cost7376
\[\begin{array}{l} t_1 := a + \left(t + \left(z + y \cdot i\right)\right)\\ t_2 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{+90}:\\ \;\;\;\;z + t_2\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-7}:\\ \;\;\;\;a + \left(z + \log c \cdot \left(b + -0.5\right)\right)\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_2\\ \end{array} \]
Alternative 8
Error18.7
Cost7112
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{+90}:\\ \;\;\;\;z + t_1\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+153}:\\ \;\;\;\;a + \left(t + \left(z + y \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot i + t_1\\ \end{array} \]
Alternative 9
Error18.2
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{+88} \lor \neg \left(x \leq 1.45 \cdot 10^{+166}\right):\\ \;\;\;\;z + x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;a + \left(t + \left(z + y \cdot i\right)\right)\\ \end{array} \]
Alternative 10
Error19.3
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+202} \lor \neg \left(x \leq 2.35 \cdot 10^{+168}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;a + \left(t + \left(z + y \cdot i\right)\right)\\ \end{array} \]
Alternative 11
Error21.9
Cost6724
\[\begin{array}{l} \mathbf{if}\;b \leq 6.5 \cdot 10^{+226}:\\ \;\;\;\;a + \left(t + \left(z + y \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \log c\\ \end{array} \]
Alternative 12
Error31.4
Cost717
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+204}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -3 \cdot 10^{+141} \lor \neg \left(z \leq -2.5 \cdot 10^{+122}\right):\\ \;\;\;\;a + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;z + t\\ \end{array} \]
Alternative 13
Error27.6
Cost717
\[\begin{array}{l} \mathbf{if}\;a \leq 1.5 \cdot 10^{+40}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{elif}\;a \leq 6.8 \cdot 10^{+216} \lor \neg \left(a \leq 5 \cdot 10^{+285}\right):\\ \;\;\;\;z + \left(t + a\right)\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 14
Error37.2
Cost588
\[\begin{array}{l} \mathbf{if}\;a \leq 1.85 \cdot 10^{-208}:\\ \;\;\;\;z + t\\ \mathbf{elif}\;a \leq 1.95 \cdot 10^{-89}:\\ \;\;\;\;y \cdot i\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{+123}:\\ \;\;\;\;z + t\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 15
Error23.9
Cost576
\[a + \left(t + \left(z + y \cdot i\right)\right) \]
Alternative 16
Error37.4
Cost460
\[\begin{array}{l} \mathbf{if}\;a \leq 5 \cdot 10^{-209}:\\ \;\;\;\;z\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{-89}:\\ \;\;\;\;y \cdot i\\ \mathbf{elif}\;a \leq 7.6 \cdot 10^{+121}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 17
Error28.7
Cost452
\[\begin{array}{l} \mathbf{if}\;a \leq 1.35 \cdot 10^{+122}:\\ \;\;\;\;z + y \cdot i\\ \mathbf{else}:\\ \;\;\;\;a + y \cdot i\\ \end{array} \]
Alternative 18
Error36.2
Cost196
\[\begin{array}{l} \mathbf{if}\;a \leq 1.3 \cdot 10^{+123}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 19
Error47.7
Cost64
\[a \]

Error

Reproduce?

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