Average Error: 0.1 → 0.1
Time: 14.9s
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.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
    (+.f64 x (fma.f64 z (-.f64 1 (log.f64 t)) (fma.f64 (+.f64 a -1/2) b y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (fma.f64 z (Rewrite<= unsub-neg_binary64 (+.f64 1 (neg.f64 (log.f64 t)))) (fma.f64 (+.f64 a -1/2) b y))): 22 points increase in error, 0 points decrease in error
    (+.f64 x (fma.f64 z (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (log.f64 t)) 1)) (fma.f64 (+.f64 a -1/2) b y))): 0 points increase in error, 22 points decrease in error
    (+.f64 x (fma.f64 z (+.f64 (neg.f64 (log.f64 t)) 1) (fma.f64 (+.f64 a (Rewrite<= metadata-eval (neg.f64 1/2))) b y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (fma.f64 z (+.f64 (neg.f64 (log.f64 t)) 1) (fma.f64 (Rewrite<= sub-neg_binary64 (-.f64 a 1/2)) b y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (fma.f64 z (+.f64 (neg.f64 (log.f64 t)) 1) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 a 1/2) b) y)))): 22 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (+.f64 (neg.f64 (log.f64 t)) 1)) (+.f64 (*.f64 (-.f64 a 1/2) b) y)))): 0 points increase in error, 22 points decrease in error
    (+.f64 x (+.f64 (Rewrite=> distribute-lft-in_binary64 (+.f64 (*.f64 z (neg.f64 (log.f64 t))) (*.f64 z 1))) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 z (log.f64 t)))) (*.f64 z 1)) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 z (log.f64 t)))) (*.f64 z 1)) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 29 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (+.f64 (-.f64 0 (*.f64 z (log.f64 t))) (Rewrite=> *-rgt-identity_binary64 z)) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 29 points decrease in error
    (+.f64 x (+.f64 (Rewrite=> associate-+l-_binary64 (-.f64 0 (-.f64 (*.f64 z (log.f64 t)) z))) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite=> associate-+l-_binary64 (-.f64 0 (-.f64 (-.f64 (*.f64 z (log.f64 t)) z) (+.f64 (*.f64 (-.f64 a 1/2) b) y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite=> sub0-neg_binary64 (neg.f64 (-.f64 (-.f64 (*.f64 z (log.f64 t)) z) (+.f64 (*.f64 (-.f64 a 1/2) b) y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 (-.f64 (*.f64 z (log.f64 t)) z) (+.f64 (*.f64 (-.f64 a 1/2) b) y))))): 22 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 (-.f64 (*.f64 z (log.f64 t)) z)) (+.f64 (*.f64 (-.f64 a 1/2) b) y)))): 0 points increase in error, 22 points decrease in error
    (+.f64 x (+.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 (*.f64 z (log.f64 t))) z)) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (*.f64 z (log.f64 t)))) z) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 z (neg.f64 (*.f64 z (log.f64 t))))) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite<= sub-neg_binary64 (-.f64 z (*.f64 z (log.f64 t)))) (+.f64 (*.f64 (-.f64 a 1/2) b) y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (-.f64 z (*.f64 z (log.f64 t))) (Rewrite=> +-commutative_binary64 (+.f64 y (*.f64 (-.f64 a 1/2) b))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (-.f64 z (*.f64 z (log.f64 t))) y) (*.f64 (-.f64 a 1/2) b)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 y (-.f64 z (*.f64 z (log.f64 t))))) (*.f64 (-.f64 a 1/2) b))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite=> associate-+r-_binary64 (-.f64 (+.f64 y z) (*.f64 z (log.f64 t)))) (*.f64 (-.f64 a 1/2) b))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite=> sub-neg_binary64 (+.f64 (+.f64 y z) (neg.f64 (*.f64 z (log.f64 t))))) (*.f64 (-.f64 a 1/2) b))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 x (+.f64 (+.f64 y z) (neg.f64 (*.f64 z (log.f64 t))))) (*.f64 (-.f64 a 1/2) b))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 x (+.f64 y z)) (neg.f64 (*.f64 z (log.f64 t))))) (*.f64 (-.f64 a 1/2) b)): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 x y) z)) (neg.f64 (*.f64 z (log.f64 t)))) (*.f64 (-.f64 a 1/2) b)): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= sub-neg_binary64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t)))) (*.f64 (-.f64 a 1/2) b)): 0 points increase in error, 0 points decrease in error
  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
Error9.4
Cost35409
\[\begin{array}{l} t_1 := \left(z + \left(x + y\right)\right) - z \cdot \log t\\ t_2 := t_1 + -0.5 \cdot b\\ t_3 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;t_1 \leq -1.7 \cdot 10^{+84}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-65}:\\ \;\;\;\;x + t_3\\ \mathbf{elif}\;t_1 \leq 4 \cdot 10^{+29} \lor \neg \left(t_1 \leq 2 \cdot 10^{+122}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;y + t_3\\ \end{array} \]
Alternative 2
Error10.2
Cost8528
\[\begin{array}{l} t_1 := x + \left(y + z \cdot \left(1 - \log t\right)\right)\\ t_2 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+140}:\\ \;\;\;\;x + t_2\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 10^{+100}:\\ \;\;\;\;y + t_2\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+167}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + \left(-0.5 \cdot b + a \cdot b\right)\\ \end{array} \]
Alternative 3
Error23.3
Cost7624
\[\begin{array}{l} t_1 := z \cdot \log t\\ t_2 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;x + y \leq -1 \cdot 10^{+63}:\\ \;\;\;\;x + t_2\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-65}:\\ \;\;\;\;\left(z - t_1\right) + t_2\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot b + \left(\left(z + y\right) - t_1\right)\\ \end{array} \]
Alternative 4
Error0.1
Cost7488
\[\left(\left(z + \left(x + y\right)\right) - z \cdot \log t\right) + \left(-0.5 \cdot b + a \cdot b\right) \]
Alternative 5
Error30.8
Cost7368
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;x + y \leq -5 \cdot 10^{-113}:\\ \;\;\;\;x + t_1\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-166}:\\ \;\;\;\;x + z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 6
Error0.1
Cost7360
\[\left(\left(x + y\right) + \left(z - z \cdot \log t\right)\right) + \left(a + -0.5\right) \cdot b \]
Alternative 7
Error30.9
Cost7240
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;x + y \leq -5 \cdot 10^{-113}:\\ \;\;\;\;x + t_1\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-166}:\\ \;\;\;\;z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 8
Error33.4
Cost1228
\[\begin{array}{l} t_1 := x + \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;x + y \leq 2 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{+53}:\\ \;\;\;\;y + -0.5 \cdot b\\ \mathbf{elif}\;x + y \leq 10^{+88}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + a \cdot b\\ \end{array} \]
Alternative 9
Error39.3
Cost1101
\[\begin{array}{l} \mathbf{if}\;x + y \leq 2 \cdot 10^{-65}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{elif}\;x + y \leq 5 \cdot 10^{+57} \lor \neg \left(x + y \leq 2 \cdot 10^{+122}\right):\\ \;\;\;\;y + -0.5 \cdot b\\ \mathbf{else}:\\ \;\;\;\;y + a \cdot b\\ \end{array} \]
Alternative 10
Error28.0
Cost848
\[\begin{array}{l} t_1 := x + a \cdot b\\ t_2 := x + -0.5 \cdot b\\ \mathbf{if}\;b \leq -6.6 \cdot 10^{+93}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -1.15 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 6.2 \cdot 10^{-13}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+206}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error31.1
Cost712
\[\begin{array}{l} \mathbf{if}\;x + y \leq -0.001:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-65}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 12
Error36.2
Cost712
\[\begin{array}{l} \mathbf{if}\;x + y \leq -0.001:\\ \;\;\;\;x + -0.5 \cdot b\\ \mathbf{elif}\;x + y \leq 2 \cdot 10^{-65}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 13
Error30.4
Cost708
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;x + y \leq 2 \cdot 10^{-211}:\\ \;\;\;\;x + t_1\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 14
Error39.4
Cost580
\[\begin{array}{l} \mathbf{if}\;x + y \leq 2 \cdot 10^{-65}:\\ \;\;\;\;x + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;y + -0.5 \cdot b\\ \end{array} \]
Alternative 15
Error48.6
Cost324
\[\begin{array}{l} \mathbf{if}\;x \leq -5.7 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 16
Error48.2
Cost64
\[x \]

Error

Reproduce

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