Average Error: 0.1 → 0.1
Time: 15.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 \]
\[y + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + -0.5, b, x\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
 (+ y (fma z (- 1.0 (log t)) (fma (+ a -0.5) b x))))
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 y + fma(z, (1.0 - log(t)), fma((a + -0.5), b, x));
}
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(y + fma(z, Float64(1.0 - log(t)), fma(Float64(a + -0.5), b, x)))
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[(y + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + N[(N[(a + -0.5), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
y + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + -0.5, b, x\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}{y + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + -0.5, b, x\right)\right)} \]
    Proof
    (+.f64 y (fma.f64 z (-.f64 1 (log.f64 t)) (fma.f64 (+.f64 a -1/2) b x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (fma.f64 z (Rewrite<= unsub-neg_binary64 (+.f64 1 (neg.f64 (log.f64 t)))) (fma.f64 (+.f64 a -1/2) b x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (fma.f64 z (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (log.f64 t)) 1)) (fma.f64 (+.f64 a -1/2) b x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (fma.f64 z (+.f64 (neg.f64 (log.f64 t)) 1) (fma.f64 (+.f64 a (Rewrite<= metadata-eval (neg.f64 1/2))) b x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (fma.f64 z (+.f64 (neg.f64 (log.f64 t)) 1) (fma.f64 (Rewrite<= sub-neg_binary64 (-.f64 a 1/2)) b x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (fma.f64 z (+.f64 (neg.f64 (log.f64 t)) 1) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 a 1/2) b) x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (+.f64 (neg.f64 (log.f64 t)) 1)) (+.f64 (*.f64 (-.f64 a 1/2) b) x)))): 1 points increase in error, 0 points decrease in error
    (+.f64 y (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 (neg.f64 (log.f64 t)) 1) z)) (+.f64 (*.f64 (-.f64 a 1/2) b) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (+.f64 (Rewrite<= distribute-rgt1-in_binary64 (+.f64 z (*.f64 (neg.f64 (log.f64 t)) z))) (+.f64 (*.f64 (-.f64 a 1/2) b) x))): 9 points increase in error, 2 points decrease in error
    (+.f64 y (+.f64 (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 z (*.f64 (log.f64 t) z))) (+.f64 (*.f64 (-.f64 a 1/2) b) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (+.f64 (-.f64 z (Rewrite<= *-commutative_binary64 (*.f64 z (log.f64 t)))) (+.f64 (*.f64 (-.f64 a 1/2) b) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (Rewrite=> associate-+l-_binary64 (-.f64 z (-.f64 (*.f64 z (log.f64 t)) (+.f64 (*.f64 (-.f64 a 1/2) b) x))))): 0 points increase in error, 1 points decrease in error
    (+.f64 y (-.f64 z (Rewrite<= associate--l-_binary64 (-.f64 (-.f64 (*.f64 z (log.f64 t)) (*.f64 (-.f64 a 1/2) b)) x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 z (-.f64 (*.f64 z (log.f64 t)) (*.f64 (-.f64 a 1/2) b))) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (+.f64 (-.f64 z (Rewrite=> cancel-sign-sub-inv_binary64 (+.f64 (*.f64 z (log.f64 t)) (*.f64 (neg.f64 (-.f64 a 1/2)) b)))) x)): 0 points increase in error, 0 points decrease in error
    (+.f64 y (+.f64 (Rewrite=> associate--r+_binary64 (-.f64 (-.f64 z (*.f64 z (log.f64 t))) (*.f64 (neg.f64 (-.f64 a 1/2)) b))) x)): 1 points increase in error, 0 points decrease in error
    (+.f64 y (Rewrite=> associate-+l-_binary64 (-.f64 (-.f64 z (*.f64 z (log.f64 t))) (-.f64 (*.f64 (neg.f64 (-.f64 a 1/2)) b) x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 (-.f64 z (*.f64 z (log.f64 t))) (*.f64 (neg.f64 (-.f64 a 1/2)) b)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 y (+.f64 (Rewrite<= associate--r+_binary64 (-.f64 z (+.f64 (*.f64 z (log.f64 t)) (*.f64 (neg.f64 (-.f64 a 1/2)) b)))) x)): 0 points increase in error, 1 points decrease in error
    (+.f64 y (+.f64 (-.f64 z (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 z (log.f64 t)) (*.f64 (-.f64 a 1/2) b)))) x)): 0 points increase in error, 0 points decrease in error
    (+.f64 y (Rewrite<= +-commutative_binary64 (+.f64 x (-.f64 z (-.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 y x) (-.f64 z (-.f64 (*.f64 z (log.f64 t)) (*.f64 (-.f64 a 1/2) b))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 x y)) (-.f64 z (-.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 (+.f64 x y) z) (-.f64 (*.f64 z (log.f64 t)) (*.f64 (-.f64 a 1/2) b)))): 1 points increase in error, 2 points decrease in error
    (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a 1/2) b))): 1 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error0.1
Cost13632
\[\mathsf{fma}\left(a + -0.5, b, z + \left(\left(y + x\right) - z \cdot \log t\right)\right) \]
Alternative 2
Error7.5
Cost7752
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ t_2 := \left(z + \left(y + x\right)\right) + t_1\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+140}:\\ \;\;\;\;y + \left(x + \left(z - z \cdot \log t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error7.5
Cost7752
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ t_2 := \left(z + \left(y + x\right)\right) + t_1\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+140}:\\ \;\;\;\;\left(y + \left(z + x\right)\right) - z \cdot \log t\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error10.0
Cost7640
\[\begin{array}{l} t_1 := \left(z + \left(y + x\right)\right) + \left(a + -0.5\right) \cdot b\\ t_2 := y + z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -6.2 \cdot 10^{+198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5 \cdot 10^{+85}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+112}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{+202}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error9.7
Cost7376
\[\begin{array}{l} t_1 := \left(z + \left(y + x\right)\right) + \left(a + -0.5\right) \cdot b\\ t_2 := y + z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -9 \cdot 10^{+198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.75 \cdot 10^{+81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{+111}:\\ \;\;\;\;y + \left(z - z \cdot \log t\right)\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+201}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error10.6
Cost7372
\[\begin{array}{l} t_1 := z \cdot \log t\\ t_2 := \left(a + -0.5\right) \cdot b\\ t_3 := \left(z + \left(y + x\right)\right) + t_2\\ \mathbf{if}\;y \leq 8.5 \cdot 10^{+49}:\\ \;\;\;\;\left(t_2 + \left(z + x\right)\right) - t_1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+103}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+174}:\\ \;\;\;\;y + \left(x + \left(z - t_1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error0.1
Cost7360
\[\left(a + -0.5\right) \cdot b + \left(\left(y + x\right) + \left(z - z \cdot \log t\right)\right) \]
Alternative 8
Error0.1
Cost7360
\[\left(\left(z + \left(y + x\right)\right) - z \cdot \log t\right) + \left(a + -0.5\right) \cdot b \]
Alternative 9
Error10.1
Cost6984
\[\begin{array}{l} t_1 := z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{+199}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+206}:\\ \;\;\;\;\left(z + \left(y + x\right)\right) + \left(a + -0.5\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error23.2
Cost1224
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ t_2 := x + t_1\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+136}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error25.1
Cost1096
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+167}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+136}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error44.7
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+20}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-89}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-183}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-105}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 13
Error30.0
Cost720
\[\begin{array}{l} \mathbf{if}\;b \leq -5.2 \cdot 10^{+181}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{elif}\;b \leq 4.8 \cdot 10^{+60}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{+119}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq 1.26 \cdot 10^{+167}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot b\\ \end{array} \]
Alternative 14
Error15.4
Cost704
\[\left(z + \left(y + x\right)\right) + \left(a + -0.5\right) \cdot b \]
Alternative 15
Error26.3
Cost580
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot b\\ \mathbf{if}\;x \leq -1.75 \cdot 10^{+23}:\\ \;\;\;\;x + t_1\\ \mathbf{else}:\\ \;\;\;\;y + t_1\\ \end{array} \]
Alternative 16
Error43.7
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 17
Error48.0
Cost64
\[x \]

Error

Reproduce

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