Average Error: 0.1 → 0.1
Time: 22.4s
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)))): 0 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))): 17 points increase in error, 6 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))))): 2 points increase in error, 0 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, 2 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)): 0 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, 0 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))))): 1 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)))): 2 points increase in error, 0 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))): 0 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
Error7.1
Cost7752
\[\begin{array}{l} t_1 := b \cdot \left(a - 0.5\right)\\ t_2 := \left(z + \left(y + x\right)\right) + t_1\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+129}:\\ \;\;\;\;\left(y + x\right) + z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error7.5
Cost7752
\[\begin{array}{l} t_1 := b \cdot \left(a - 0.5\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\left(t_1 + \left(z + x\right)\right) - z \cdot \log t\\ \mathbf{elif}\;t_1 \leq 10^{+129}:\\ \;\;\;\;\left(y + x\right) + z \cdot \left(1 - \log t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z + \left(y + x\right)\right) + t_1\\ \end{array} \]
Alternative 3
Error0.1
Cost7360
\[\left(\left(z + \left(y + x\right)\right) - z \cdot \log t\right) + b \cdot \left(a - 0.5\right) \]
Alternative 4
Error8.7
Cost7112
\[\begin{array}{l} t_1 := y + z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -3.343845988306505 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5617226917744424 \cdot 10^{+131}:\\ \;\;\;\;\left(z + \left(y + x\right)\right) + b \cdot \left(a - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error10.8
Cost6984
\[\begin{array}{l} t_1 := z - z \cdot \log t\\ \mathbf{if}\;z \leq -3.343845988306505 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.846758155875826 \cdot 10^{+235}:\\ \;\;\;\;\left(z + \left(y + x\right)\right) + b \cdot \left(a - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error10.8
Cost6984
\[\begin{array}{l} t_1 := z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -3.343845988306505 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.846758155875826 \cdot 10^{+235}:\\ \;\;\;\;\left(z + \left(y + x\right)\right) + b \cdot \left(a - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error22.1
Cost1612
\[\begin{array}{l} t_1 := b \cdot \left(a - 0.5\right)\\ t_2 := x + t_1\\ \mathbf{if}\;t_1 \leq -1.4 \cdot 10^{+124}:\\ \;\;\;\;y + t_1\\ \mathbf{elif}\;t_1 \leq -2 \cdot 10^{+25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+129}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error30.3
Cost1376
\[\begin{array}{l} t_1 := y + \left(z + x\right)\\ t_2 := x + -0.5 \cdot b\\ t_3 := y + a \cdot b\\ t_4 := y + -0.5 \cdot b\\ \mathbf{if}\;a \leq -5.9 \cdot 10^{+82}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -8.878685547167745 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.9479860226484547 \cdot 10^{-240}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 5.254623141838424 \cdot 10^{-223}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \leq 1.1552143021857765 \cdot 10^{-166}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 9.886489843315207 \cdot 10^{-133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.669610776298792 \cdot 10^{-43}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{+79}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 9
Error21.8
Cost1224
\[\begin{array}{l} t_1 := b \cdot \left(a - 0.5\right)\\ t_2 := y + t_1\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+129}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Error31.4
Cost848
\[\begin{array}{l} t_1 := y + \left(z + x\right)\\ t_2 := y + a \cdot b\\ \mathbf{if}\;a \leq -5.9 \cdot 10^{+82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3.2026984761125365 \cdot 10^{-299}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 9.507607326391357 \cdot 10^{-196}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{+79}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error30.2
Cost848
\[\begin{array}{l} t_1 := y + \left(z + x\right)\\ t_2 := y + a \cdot b\\ \mathbf{if}\;a \leq -5.9 \cdot 10^{+82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -3.9479860226484547 \cdot 10^{-240}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.669610776298792 \cdot 10^{-43}:\\ \;\;\;\;y + -0.5 \cdot b\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{+79}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error14.9
Cost704
\[\left(z + \left(y + x\right)\right) + b \cdot \left(a - 0.5\right) \]
Alternative 13
Error29.0
Cost584
\[\begin{array}{l} \mathbf{if}\;b \leq -1.55 \cdot 10^{+129}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{elif}\;b \leq 1.12 \cdot 10^{+126}:\\ \;\;\;\;y + \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot b\\ \end{array} \]
Alternative 14
Error15.5
Cost576
\[y + \left(x + b \cdot \left(a - 0.5\right)\right) \]
Alternative 15
Error46.5
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6281301306022861 \cdot 10^{-202}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.149524293987937 \cdot 10^{+80}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 16
Error29.6
Cost456
\[\begin{array}{l} \mathbf{if}\;b \leq -3.3 \cdot 10^{+125}:\\ \;\;\;\;-0.5 \cdot b\\ \mathbf{elif}\;b \leq 1.12 \cdot 10^{+126}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot b\\ \end{array} \]
Alternative 17
Error43.1
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -9.229918763297937 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 18
Error61.5
Cost64
\[z \]
Alternative 19
Error48.0
Cost64
\[y \]

Error

Reproduce

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