Average Error: 0.3 → 0.3
Time: 21.3s
Precision: binary64
Cost: 20032
\[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
\[\left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \log t \cdot \left(a + -0.5\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) t)) (* (log t) (+ a -0.5))))
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) - t)) + (log(t) * (a + -0.5));
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = ((log((x + y)) + log(z)) - t) + ((a - 0.5d0) * log(t))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = (log((x + y)) + (log(z) - t)) + (log(t) * (a + (-0.5d0)))
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((Math.log((x + y)) + Math.log(z)) - t) + ((a - 0.5) * Math.log(t));
}
public static double code(double x, double y, double z, double t, double a) {
	return (Math.log((x + y)) + (Math.log(z) - t)) + (Math.log(t) * (a + -0.5));
}
def code(x, y, z, t, a):
	return ((math.log((x + y)) + math.log(z)) - t) + ((a - 0.5) * math.log(t))
def code(x, y, z, t, a):
	return (math.log((x + y)) + (math.log(z) - t)) + (math.log(t) * (a + -0.5))
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(Float64(log(Float64(x + y)) + Float64(log(z) - t)) + Float64(log(t) * Float64(a + -0.5)))
end
function tmp = code(x, y, z, t, a)
	tmp = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
end
function tmp = code(x, y, z, t, a)
	tmp = (log((x + y)) + (log(z) - t)) + (log(t) * (a + -0.5));
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[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \log t \cdot \left(a + -0.5\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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}{\left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \left(a + -0.5\right) \cdot \log t} \]
    Proof
    (+.f64 (+.f64 (log.f64 (+.f64 x y)) (-.f64 (log.f64 z) t)) (*.f64 (+.f64 a -1/2) (log.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t)) (*.f64 (+.f64 a -1/2) (log.f64 t))): 1 points increase in error, 0 points decrease in error
    (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (+.f64 a (Rewrite<= metadata-eval (neg.f64 1/2))) (log.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (Rewrite<= sub-neg_binary64 (-.f64 a 1/2)) (log.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (-.f64 a 1/2)))) (log.f64 t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (Rewrite<= distribute-lft-neg-in_binary64 (neg.f64 (*.f64 (neg.f64 (-.f64 a 1/2)) (log.f64 t))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= sub-neg_binary64 (-.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (neg.f64 (-.f64 a 1/2)) (log.f64 t)))): 0 points increase in error, 0 points decrease in error
    (Rewrite=> cancel-sign-sub_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 \left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \log t \cdot \left(a + -0.5\right) \]

Alternatives

Alternative 1
Error20.3
Cost46152
\[\begin{array}{l} t_1 := \log \left(x + y\right) + \log z\\ t_2 := \left(\log z - t\right) + a \cdot \log t\\ \mathbf{if}\;t_1 \leq -750:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 700:\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, \log t, \log \left(y \cdot z\right) - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error20.3
Cost39880
\[\begin{array}{l} t_1 := \log \left(x + y\right) + \log z\\ t_2 := \left(\log z - t\right) + a \cdot \log t\\ \mathbf{if}\;t_1 \leq -750:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 700:\\ \;\;\;\;\left(\log t \cdot \left(a + -0.5\right) + \log \left(y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error1.1
Cost20424
\[\begin{array}{l} t_1 := \left(\log z - t\right) + a \cdot \log t\\ \mathbf{if}\;a + -0.5 \leq -2 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a + -0.5 \leq -0.48:\\ \;\;\;\;\left(-0.5 \cdot \log t + \left(\log \left(x + y\right) + \log z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error17.2
Cost13896
\[\begin{array}{l} t_1 := \left(\log z - t\right) + a \cdot \log t\\ \mathbf{if}\;a + -0.5 \leq -0.501:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a + -0.5 \leq -0.48:\\ \;\;\;\;\left(-0.5 \cdot \log t + \log \left(y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error15.8
Cost13576
\[\begin{array}{l} \mathbf{if}\;t \leq 6.1 \cdot 10^{-161}:\\ \;\;\;\;\log t \cdot \left(a + -0.5\right) - t\\ \mathbf{elif}\;t \leq 2.15 \cdot 10^{-131}:\\ \;\;\;\;\log \left(\left(y \cdot z\right) \cdot {t}^{\left(a + -0.5\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\log z - t\right) + a \cdot \log t\\ \end{array} \]
Alternative 6
Error17.1
Cost13508
\[\begin{array}{l} t_1 := \log t \cdot \left(a + -0.5\right)\\ \mathbf{if}\;t \leq 5.2 \cdot 10^{-14}:\\ \;\;\;\;t_1 + \log \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 - t\\ \end{array} \]
Alternative 7
Error22.7
Cost6984
\[\begin{array}{l} t_1 := a \cdot \log t\\ \mathbf{if}\;a \leq -3.2 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.4 \cdot 10^{+56}:\\ \;\;\;\;-0.5 \cdot \log t - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error22.5
Cost6984
\[\begin{array}{l} t_1 := a \cdot \log t\\ \mathbf{if}\;a \leq -2 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.9 \cdot 10^{+57}:\\ \;\;\;\;\log \left(x + y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error14.7
Cost6984
\[\begin{array}{l} t_1 := a \cdot \log t - t\\ \mathbf{if}\;a \leq -16000000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 0.039:\\ \;\;\;\;\log \left(x + y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error14.8
Cost6848
\[\log t \cdot \left(a + -0.5\right) - t \]
Alternative 11
Error24.3
Cost6724
\[\begin{array}{l} \mathbf{if}\;t \leq 780:\\ \;\;\;\;a \cdot \log t\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 12
Error39.6
Cost128
\[-t \]

Error

Reproduce

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