Average Error: 0.3 → 0.3
Time: 34.9s
Precision: binary64
Cost: 26304
\[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
\[\log \left(x + y\right) + \left(\log z - \mathsf{fma}\left(\log t, 0.5 - a, t\right)\right) \]
(FPCore (x y z t a)
 :precision binary64
 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
(FPCore (x y z t a)
 :precision binary64
 (+ (log (+ x y)) (- (log z) (fma (log t) (- 0.5 a) t))))
double code(double x, double y, double z, double t, double a) {
	return ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
}
double code(double x, double y, double z, double t, double a) {
	return log((x + y)) + (log(z) - fma(log(t), (0.5 - a), t));
}
function code(x, y, z, t, a)
	return Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t)))
end
function code(x, y, z, t, a)
	return Float64(log(Float64(x + y)) + Float64(log(z) - fma(log(t), Float64(0.5 - a), t)))
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * N[(0.5 - a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\log \left(x + y\right) + \left(\log z - \mathsf{fma}\left(\log t, 0.5 - a, t\right)\right)

Error

Target

Original0.3
Target0.3
Herbie0.3
\[\log \left(x + y\right) + \left(\left(\log z - t\right) + \left(a - 0.5\right) \cdot \log t\right) \]

Derivation

  1. Initial program 0.3

    \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
  2. Simplified0.3

    \[\leadsto \color{blue}{\log \left(x + y\right) + \left(\log z - \mathsf{fma}\left(\log t, 0.5 - a, t\right)\right)} \]
    Proof
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (fma.f64 (log.f64 t) (-.f64 1/2 a) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (fma.f64 (log.f64 t) (Rewrite<= unsub-neg_binary64 (+.f64 1/2 (neg.f64 a))) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (fma.f64 (log.f64 t) (Rewrite=> +-commutative_binary64 (+.f64 (neg.f64 a) 1/2)) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (fma.f64 (log.f64 t) (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 a)) 1/2) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (fma.f64 (log.f64 t) (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 a 1/2))) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (fma.f64 (log.f64 t) (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 a 1/2))) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (log.f64 t) (neg.f64 (-.f64 a 1/2))) t)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (neg.f64 (-.f64 a 1/2)) (log.f64 t))) t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (Rewrite<= +-commutative_binary64 (+.f64 t (*.f64 (neg.f64 (-.f64 a 1/2)) (log.f64 t)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 t (*.f64 (-.f64 a 1/2) (log.f64 t)))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) (-.f64 t (*.f64 (-.f64 a 1/2) (log.f64 t))))): 10 points increase in error, 10 points decrease in error
    (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a 1/2) (log.f64 t)))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.3

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

Alternatives

Alternative 1
Error1.2
Cost20424
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a + -0.5 \leq -0.6:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a + -0.5 \leq -0.5:\\ \;\;\;\;\log \left(x + y\right) + \left(\log z + \left(\log t \cdot -0.5 - t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error12.4
Cost20040
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -0.24513292104280143:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.116410142397736 \cdot 10^{-18}:\\ \;\;\;\;\left(\log z + \left(\log y - \log t \cdot 0.5\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error0.3
Cost20032
\[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \log t \cdot \left(a + -0.5\right) \]
Alternative 4
Error15.0
Cost19976
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -0.24513292104280143:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.116410142397736 \cdot 10^{-18}:\\ \;\;\;\;\left(\log z + \log \left(y \cdot {t}^{-0.5}\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error12.2
Cost19908
\[\begin{array}{l} \mathbf{if}\;t \leq 0.18645025240305188:\\ \;\;\;\;\left(\log z + \log y\right) + \log t \cdot \left(a + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log t \cdot a - t\\ \end{array} \]
Alternative 6
Error20.1
Cost19904
\[\left(\left(\log z + \log y\right) + \log t \cdot \left(a + -0.5\right)\right) - t \]
Alternative 7
Error8.7
Cost13896
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -162345336576131.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 203815.09080347212:\\ \;\;\;\;\left(\log \left(\left(x + y\right) \cdot z\right) + \log t \cdot \left(a + -0.5\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error14.8
Cost13772
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -0.24513292104280143:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.131262678680714 \cdot 10^{-260}:\\ \;\;\;\;\log \left(z \cdot \left(\left(x + y\right) \cdot \sqrt{\frac{1}{t}}\right)\right) - t\\ \mathbf{elif}\;a \leq 3.116410142397736 \cdot 10^{-18}:\\ \;\;\;\;\left(\log \left(y \cdot z\right) + \log t \cdot -0.5\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error17.4
Cost13768
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -162345336576131.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 203815.09080347212:\\ \;\;\;\;\left(\log \left(y \cdot z\right) + \log t \cdot \left(a + -0.5\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error18.0
Cost13644
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -9.403220079671976 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.0285700114875274 \cdot 10^{-277}:\\ \;\;\;\;\log \left(x + y\right) - t\\ \mathbf{elif}\;a \leq 1.7338104982083062 \cdot 10^{-96}:\\ \;\;\;\;\log \left(y \cdot z\right) + \log t \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error17.7
Cost13644
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -0.24513292104280143:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.0285700114875274 \cdot 10^{-277}:\\ \;\;\;\;\log \left(x + y\right) + \left(\log z - t\right)\\ \mathbf{elif}\;a \leq 1.7338104982083062 \cdot 10^{-96}:\\ \;\;\;\;\log \left(y \cdot z\right) + \log t \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error17.3
Cost13640
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -0.24513292104280143:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.116410142397736 \cdot 10^{-18}:\\ \;\;\;\;\left(\log \left(y \cdot z\right) + \log t \cdot -0.5\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error18.7
Cost13576
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -0.24513292104280143:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.116410142397736 \cdot 10^{-18}:\\ \;\;\;\;\log \left({t}^{-0.5} \cdot \left(y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error18.8
Cost13576
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -0.24513292104280143:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.116410142397736 \cdot 10^{-18}:\\ \;\;\;\;\log \left(z \cdot \left(y \cdot {t}^{-0.5}\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 15
Error14.4
Cost6984
\[\begin{array}{l} t_1 := \log t \cdot a - t\\ \mathbf{if}\;a \leq -9.403220079671976 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.5842936917718207 \cdot 10^{-24}:\\ \;\;\;\;\log \left(x + y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 16
Error24.0
Cost6856
\[\begin{array}{l} t_1 := \log t \cdot a\\ \mathbf{if}\;a \leq -162345336576131.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.1871528846494894 \cdot 10^{+52}:\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 17
Error16.1
Cost6720
\[\log t \cdot a - t \]
Alternative 18
Error39.7
Cost128
\[-t \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x y z t a)
  :name "Numeric.SpecFunctions:logGammaL from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (+ (log (+ x y)) (+ (- (log z) t) (* (- a 0.5) (log t))))

  (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))