Average Error: 0.1 → 0.1
Time: 23.1s
Precision: binary64
Cost: 19904
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\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.4
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)} \]

    sub0-neg [<=]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)} \]

    associate-+l- [<=]0.1

    \[ x + \color{blue}{\left(\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 + \left(\color{blue}{\left(\left(0 - 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(-z \cdot \log t\right)} + z\right) + \left(\left(a - 0.5\right) \cdot b + y\right)\right) \]

    *-commutative [=>]0.1

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

    distribute-lft-neg-in [=>]0.1

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

    distribute-lft1-in [=>]0.1

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

    *-commutative [=>]0.1

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

    fma-def [=>]0.1

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

    +-commutative [=>]0.1

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

    unsub-neg [=>]0.1

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

    fma-def [=>]0.1

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

    sub-neg [=>]0.1

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

    metadata-eval [=>]0.1

    \[ x + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + \color{blue}{-0.5}, b, y\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
Error10.9
Cost8528
\[\begin{array}{l} t_1 := \left(x + y\right) + z \cdot \left(1 - \log t\right)\\ t_2 := \left(a + -0.5\right) \cdot b\\ t_3 := \mathsf{fma}\left(a + -0.5, b, y\right)\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+190}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq -4000000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 10^{+128}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(y + -0.5 \cdot b\right)\\ \end{array} \]
Alternative 2
Error11.1
Cost8528
\[\begin{array}{l} t_1 := z \cdot \left(1 - \log t\right)\\ t_2 := \left(a + -0.5\right) \cdot b\\ t_3 := \left(x + y\right) + t_1\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+208}:\\ \;\;\;\;t_2 + t_1\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{+49}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq -4000000000:\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, b, y\right)\\ \mathbf{elif}\;t_2 \leq 10^{+128}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(y + -0.5 \cdot b\right)\\ \end{array} \]
Alternative 3
Error10.5
Cost8528
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ t_2 := \left(x + y\right) + z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+208}:\\ \;\;\;\;\left(\left(x + z\right) + t_1\right) - z \cdot \log t\\ \mathbf{elif}\;t_1 \leq -2.2 \cdot 10^{+43}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq -4000000000:\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, b, y\right)\\ \mathbf{elif}\;t_1 \leq 10^{+128}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(y + -0.5 \cdot b\right)\\ \end{array} \]
Alternative 4
Error19.9
Cost7760
\[\begin{array}{l} t_1 := z \cdot \left(1 - \log t\right)\\ t_2 := x + a \cdot b\\ \mathbf{if}\;x + y \leq -5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq -5 \cdot 10^{+92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + y \leq -5 \cdot 10^{+15}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + \left(a + -0.5\right) \cdot b\\ \end{array} \]
Alternative 5
Error19.9
Cost7760
\[\begin{array}{l} t_1 := z - z \cdot \log t\\ t_2 := x + a \cdot b\\ \mathbf{if}\;x + y \leq -5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq -5 \cdot 10^{+92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + y \leq -5 \cdot 10^{+15}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + \left(a + -0.5\right) \cdot b\\ \end{array} \]
Alternative 6
Error19.9
Cost7760
\[\begin{array}{l} t_1 := z - z \cdot \log t\\ t_2 := x + a \cdot b\\ \mathbf{if}\;x + y \leq -5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq -5 \cdot 10^{+92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + y \leq -5 \cdot 10^{+15}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, b, y\right)\\ \end{array} \]
Alternative 7
Error17.1
Cost7629
\[\begin{array}{l} t_1 := z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;x + y \leq 2 \cdot 10^{-169}:\\ \;\;\;\;x + t_1\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{+106} \lor \neg \left(x + y \leq 4.5 \cdot 10^{+160}\right):\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, b, y\right)\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 8
Error0.1
Cost7488
\[\left(a \cdot b + \left(-0.5 \cdot b + \left(y + \left(x + z\right)\right)\right)\right) - z \cdot \log t \]
Alternative 9
Error0.1
Cost7360
\[\left(\left(x + y\right) + \left(z - z \cdot \log t\right)\right) + \left(a + -0.5\right) \cdot b \]
Alternative 10
Error17.0
Cost7108
\[\begin{array}{l} \mathbf{if}\;x + y \leq 2 \cdot 10^{-169}:\\ \;\;\;\;x + z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, b, y\right)\\ \end{array} \]
Alternative 11
Error31.0
Cost1492
\[\begin{array}{l} \mathbf{if}\;x + y \leq -5 \cdot 10^{+34}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-46}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-11}:\\ \;\;\;\;y\\ \mathbf{elif}\;x + y \leq 200:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{+39}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 12
Error25.1
Cost1097
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+208} \lor \neg \left(t_1 \leq 10^{+172}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 13
Error22.1
Cost840
\[\begin{array}{l} \mathbf{if}\;x + y \leq -5 \cdot 10^{-18}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{+39}:\\ \;\;\;\;\left(a + -0.5\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;y + -0.5 \cdot b\\ \end{array} \]
Alternative 14
Error18.4
Cost836
\[\begin{array}{l} \mathbf{if}\;x + y \leq -5 \cdot 10^{-18}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(y + -0.5 \cdot b\right)\\ \end{array} \]
Alternative 15
Error18.4
Cost708
\[\begin{array}{l} \mathbf{if}\;x + y \leq -5 \cdot 10^{-18}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;y + \left(a + -0.5\right) \cdot b\\ \end{array} \]
Alternative 16
Error36.7
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -9.8 \cdot 10^{+44}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 17
Error48.1
Cost64
\[x \]

Error

Reproduce

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