?

Average Error: 0.1 → 0.1
Time: 16.3s
Precision: binary64
Cost: 19904

?

\[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
\[x + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + -0.5, b, y\right)\right) \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
(FPCore (x y z t a b)
 :precision binary64
 (+ x (fma z (- 1.0 (log t)) (fma (+ a -0.5) b y))))
double code(double x, double y, double z, double t, double a, double b) {
	return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	return x + fma(z, (1.0 - log(t)), fma((a + -0.5), b, y));
}
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b))
end
function code(x, y, z, t, a, b)
	return Float64(x + fma(z, Float64(1.0 - log(t)), fma(Float64(a + -0.5), b, y)))
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := N[(x + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + N[(N[(a + -0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
x + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + -0.5, b, y\right)\right)

Error?

Target

Original0.1
Target0.3
Herbie0.1
\[\left(\left(x + y\right) + \frac{\left(1 - {\log t}^{2}\right) \cdot z}{1 + \log t}\right) + \left(a - 0.5\right) \cdot b \]

Derivation?

  1. Initial program 0.1

    \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
  2. Simplified0.1

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

    [Start]0.1

    \[ \left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]

    sub-neg [=>]0.1

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

    associate-+l+ [=>]0.1

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

    associate-+l+ [=>]0.1

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

    associate-+l+ [=>]0.1

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

    sub-neg [<=]0.1

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

    associate-+r- [<=]0.1

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

    +-commutative [=>]0.1

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

    associate-+l+ [=>]0.1

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

    +-commutative [<=]0.1

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

    sub-neg [=>]0.1

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

    +-commutative [=>]0.1

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

    neg-sub0 [=>]0.1

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

    associate-+l- [=>]0.1

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

    associate-+l- [=>]0.1

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

    sub0-neg [=>]0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost7360
\[\left(\left(z + \left(x + y\right)\right) - z \cdot \log t\right) + b \cdot \left(a + -0.5\right) \]
Alternative 2
Error9.9
Cost7250
\[\begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+185} \lor \neg \left(z \leq -1.05 \cdot 10^{+163} \lor \neg \left(z \leq -2.65 \cdot 10^{+131}\right) \land z \leq 2.4 \cdot 10^{+186}\right):\\ \;\;\;\;z - z \cdot \log t\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a + -0.5\right) + \frac{1}{\frac{1}{x + y}}\\ \end{array} \]
Alternative 3
Error9.7
Cost7248
\[\begin{array}{l} t_1 := b \cdot \left(a + -0.5\right) + \frac{1}{\frac{1}{x + y}}\\ t_2 := z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -7.5 \cdot 10^{+184}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -9 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+132}:\\ \;\;\;\;z - z \cdot \log t\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+186}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error6.6
Cost7241
\[\begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+113} \lor \neg \left(z \leq 2.5 \cdot 10^{+185}\right):\\ \;\;\;\;x + \left(y + z \cdot \left(1 - \log t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a + -0.5\right) + \frac{1}{\frac{1}{x + y}}\\ \end{array} \]
Alternative 5
Error8.4
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+132} \lor \neg \left(z \leq 2 \cdot 10^{+186}\right):\\ \;\;\;\;x + z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a + -0.5\right) + \frac{1}{\frac{1}{x + y}}\\ \end{array} \]
Alternative 6
Error8.4
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+129} \lor \neg \left(z \leq 1.7 \cdot 10^{+186}\right):\\ \;\;\;\;\left(z + y\right) - z \cdot \log t\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a + -0.5\right) + \frac{1}{\frac{1}{x + y}}\\ \end{array} \]
Alternative 7
Error36.6
Cost1620
\[\begin{array}{l} t_1 := b \cdot \left(a + -0.5\right)\\ t_2 := y + -0.5 \cdot b\\ \mathbf{if}\;x + y \leq -2 \cdot 10^{+25}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{-37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + y \leq 10^{+39}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{+176}:\\ \;\;\;\;y + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error33.7
Cost1360
\[\begin{array}{l} t_1 := y + -0.5 \cdot b\\ t_2 := x + b \cdot \left(a + -0.5\right)\\ \mathbf{if}\;x + y \leq 5 \cdot 10^{-37}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{+176}:\\ \;\;\;\;y + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error16.0
Cost1225
\[\begin{array}{l} t_1 := \frac{1}{\frac{1}{x + y}}\\ \mathbf{if}\;a + -0.5 \leq -5000 \lor \neg \left(a + -0.5 \leq -0.499995\right):\\ \;\;\;\;t_1 + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1 + -0.5 \cdot b\\ \end{array} \]
Alternative 10
Error26.1
Cost840
\[\begin{array}{l} \mathbf{if}\;x + y \leq -4 \cdot 10^{+49}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{+53}:\\ \;\;\;\;b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 11
Error31.1
Cost840
\[\begin{array}{l} \mathbf{if}\;x + y \leq -2 \cdot 10^{+25}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{+53}:\\ \;\;\;\;b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 12
Error36.6
Cost840
\[\begin{array}{l} \mathbf{if}\;x + y \leq -2 \cdot 10^{+25}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{-37}:\\ \;\;\;\;b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y + -0.5 \cdot b\\ \end{array} \]
Alternative 13
Error15.6
Cost832
\[b \cdot \left(a + -0.5\right) + \frac{1}{\frac{1}{x + y}} \]
Alternative 14
Error43.3
Cost720
\[\begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{+212}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{elif}\;b \leq -1.15 \cdot 10^{+19}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq 8.6 \cdot 10^{+67}:\\ \;\;\;\;y\\ \mathbf{elif}\;b \leq 4.8 \cdot 10^{+154}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot b\\ \end{array} \]
Alternative 15
Error30.9
Cost712
\[\begin{array}{l} \mathbf{if}\;x + y \leq -4 \cdot 10^{+49}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{-37}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 16
Error31.0
Cost708
\[\begin{array}{l} t_1 := b \cdot \left(a + -0.5\right)\\ \mathbf{if}\;x + y \leq 4 \cdot 10^{-105}:\\ \;\;\;\;x + t_1\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 17
Error48.8
Cost324
\[\begin{array}{l} \mathbf{if}\;y \leq 1.15 \cdot 10^{+59}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 18
Error48.0
Cost64
\[y \]

Error

Reproduce?

herbie shell --seed 2023039 
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (+ (+ (+ x y) (/ (* (- 1.0 (pow (log t) 2.0)) z) (+ 1.0 (log t)))) (* (- a 0.5) b))

  (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))