?

Average Accuracy: 99.8% → 99.9%
Time: 25.1s
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

Original99.8%
Target99.4%
Herbie99.9%
\[\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 99.8%

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

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

    [Start]99.8

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

    sub-neg [=>]99.8

    \[ \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+ [=>]99.8

    \[ \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+ [=>]99.8

    \[ \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+ [=>]99.8

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

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

    associate-+r- [<=]99.8

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

    +-commutative [=>]99.8

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

    associate-+l+ [=>]99.8

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

    +-commutative [<=]99.8

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

    sub-neg [=>]99.8

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

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

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

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

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

    \[ 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 simplification99.9%

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

Alternatives

Alternative 1
Accuracy93.3%
Cost7497
\[\begin{array}{l} t_1 := z + \left(x + y\right)\\ \mathbf{if}\;z \leq -2.35 \cdot 10^{-51} \lor \neg \left(z \leq 2.7 \cdot 10^{+67}\right):\\ \;\;\;\;\left(t_1 - z \cdot \log t\right) + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1 + b \cdot \left(a + -0.5\right)\\ \end{array} \]
Alternative 2
Accuracy99.8%
Cost7360
\[\left(\left(z + \left(x + y\right)\right) - z \cdot \log t\right) + b \cdot \left(a + -0.5\right) \]
Alternative 3
Accuracy89.5%
Cost7241
\[\begin{array}{l} \mathbf{if}\;z \leq -56000 \lor \neg \left(z \leq 1.05 \cdot 10^{+71}\right):\\ \;\;\;\;\left(x + y\right) + z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \end{array} \]
Alternative 4
Accuracy89.5%
Cost7240
\[\begin{array}{l} \mathbf{if}\;z \leq -56000:\\ \;\;\;\;\left(x + y\right) + z \cdot \left(1 - \log t\right)\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+70}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y + \left(x + z\right)\right) - z \cdot \log t\\ \end{array} \]
Alternative 5
Accuracy86.5%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+174} \lor \neg \left(z \leq 6.8 \cdot 10^{+105}\right):\\ \;\;\;\;x + z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \end{array} \]
Alternative 6
Accuracy86.5%
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+174}:\\ \;\;\;\;x + z \cdot \left(1 - \log t\right)\\ \mathbf{elif}\;z \leq 1.46 \cdot 10^{+106}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - z \cdot \log t\right)\\ \end{array} \]
Alternative 7
Accuracy86.6%
Cost7112
\[\begin{array}{l} t_1 := z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -4 \cdot 10^{+175}:\\ \;\;\;\;x + t_1\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{+96}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 8
Accuracy86.6%
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -2.25 \cdot 10^{+175}:\\ \;\;\;\;x + z \cdot \left(1 - \log t\right)\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{+98}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y + \left(z - z \cdot \log t\right)\\ \end{array} \]
Alternative 9
Accuracy85.1%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+177} \lor \neg \left(z \leq 1.62 \cdot 10^{+193}\right):\\ \;\;\;\;z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \end{array} \]
Alternative 10
Accuracy85.0%
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+175}:\\ \;\;\;\;z \cdot \left(1 - \log t\right)\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+191}:\\ \;\;\;\;\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z - z \cdot \log t\\ \end{array} \]
Alternative 11
Accuracy60.5%
Cost1097
\[\begin{array}{l} t_1 := b \cdot \left(a + -0.5\right)\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+155} \lor \neg \left(t_1 \leq 10^{+165}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 12
Accuracy31.5%
Cost984
\[\begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+104}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{+53}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -8.8 \cdot 10^{+47}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-27}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-52}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-106}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 13
Accuracy51.1%
Cost840
\[\begin{array}{l} \mathbf{if}\;x + y \leq -1 \cdot 10^{+37}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{+37}:\\ \;\;\;\;b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 14
Accuracy43.5%
Cost840
\[\begin{array}{l} \mathbf{if}\;x + y \leq -1 \cdot 10^{+37}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{elif}\;x + y \leq 4 \cdot 10^{-5}:\\ \;\;\;\;b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y + a \cdot b\\ \end{array} \]
Alternative 15
Accuracy51.3%
Cost712
\[\begin{array}{l} \mathbf{if}\;x + y \leq -1 \cdot 10^{+48}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{+37}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 16
Accuracy48.7%
Cost708
\[\begin{array}{l} \mathbf{if}\;x + y \leq 4 \cdot 10^{-5}:\\ \;\;\;\;x + b \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y + a \cdot b\\ \end{array} \]
Alternative 17
Accuracy52.3%
Cost708
\[\begin{array}{l} t_1 := b \cdot \left(a + -0.5\right)\\ \mathbf{if}\;x + y \leq -2 \cdot 10^{-185}:\\ \;\;\;\;x + t_1\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 18
Accuracy76.8%
Cost704
\[\left(z + \left(x + y\right)\right) + b \cdot \left(a + -0.5\right) \]
Alternative 19
Accuracy31.1%
Cost460
\[\begin{array}{l} \mathbf{if}\;y \leq 5.1 \cdot 10^{-257}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.82 \cdot 10^{-134}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{+70}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 20
Accuracy32.6%
Cost196
\[\begin{array}{l} \mathbf{if}\;y \leq 3.7 \cdot 10^{+71}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 21
Accuracy25.4%
Cost64
\[x \]

Error

Reproduce?

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