Average Error: 0.3 → 0.3
Time: 1.3min
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) + \left(a + -0.5\right) \cdot \log t \]
(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)) (* (+ a -0.5) (log 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) - t)) + ((a + -0.5) * log(t));
}
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)) + ((a + (-0.5d0)) * log(t))
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)) + ((a + -0.5) * Math.log(t));
}
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)) + ((a + -0.5) * math.log(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(Float64(log(Float64(x + y)) + Float64(log(z) - t)) + Float64(Float64(a + -0.5) * log(t)))
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)) + ((a + -0.5) * log(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[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(N[(a + -0.5), $MachinePrecision] * N[Log[t], $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) + \left(a + -0.5\right) \cdot \log t

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))): 3 points increase in error, 1 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) + \left(a + -0.5\right) \cdot \log t \]

Alternatives

Alternative 1
Error12.8
Cost19908
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot \log t\\ \mathbf{if}\;t \leq 7.2 \cdot 10^{-17}:\\ \;\;\;\;\log z + \left(t_1 + \log y\right)\\ \mathbf{elif}\;t \leq 270000000:\\ \;\;\;\;\left(t_1 + \log \left(y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;a \cdot \log t - t\\ \end{array} \]
Alternative 2
Error12.8
Cost19908
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot \log t\\ \mathbf{if}\;t \leq 7.2 \cdot 10^{-17}:\\ \;\;\;\;t_1 + \left(\log z + \log y\right)\\ \mathbf{elif}\;t \leq 250000000:\\ \;\;\;\;\left(t_1 + \log \left(y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;a \cdot \log t - t\\ \end{array} \]
Alternative 3
Error20.3
Cost19904
\[\left(\log z - t\right) + \left(\left(a + -0.5\right) \cdot \log t + \log y\right) \]
Alternative 4
Error20.3
Cost19904
\[\left(\left(a + -0.5\right) \cdot \log t + \left(\log z + \log y\right)\right) - t \]
Alternative 5
Error9.0
Cost14288
\[\begin{array}{l} t_1 := \left(\log \left(\left(x + y\right) \cdot z\right) - t\right) + \frac{a + -0.5}{\frac{1}{\log t}}\\ t_2 := \log z - t\\ \mathbf{if}\;a \leq -1.5 \cdot 10^{+14}:\\ \;\;\;\;t_2 + a \cdot \log t\\ \mathbf{elif}\;a \leq -6.2 \cdot 10^{-252}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 6.5 \cdot 10^{-268}:\\ \;\;\;\;\log \left(x + y\right) + t_2\\ \mathbf{elif}\;a \leq 5800000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(a + -0.5\right) \cdot \log t - t\\ \end{array} \]
Alternative 6
Error9.4
Cost14032
\[\begin{array}{l} t_1 := \log \left(\left(x + y\right) \cdot z\right) + \left(-0.5 \cdot \log t - t\right)\\ t_2 := \log z - t\\ t_3 := t_2 + a \cdot \log t\\ \mathbf{if}\;a \leq -2.1 \cdot 10^{-16}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -2.1 \cdot 10^{-253}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 8 \cdot 10^{-268}:\\ \;\;\;\;\log \left(x + y\right) + t_2\\ \mathbf{elif}\;a \leq 3.5 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error9.4
Cost14032
\[\begin{array}{l} t_1 := \log \left(\left(x + y\right) \cdot z\right)\\ t_2 := \log z - t\\ t_3 := t_2 + a \cdot \log t\\ t_4 := -0.5 \cdot \log t\\ \mathbf{if}\;a \leq -1.65 \cdot 10^{-19}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -3.4 \cdot 10^{-254}:\\ \;\;\;\;t_1 + \left(t_4 - t\right)\\ \mathbf{elif}\;a \leq 6.5 \cdot 10^{-268}:\\ \;\;\;\;\log \left(x + y\right) + t_2\\ \mathbf{elif}\;a \leq 3.5 \cdot 10^{-24}:\\ \;\;\;\;\left(t_1 + t_4\right) - t\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error17.0
Cost14032
\[\begin{array}{l} t_1 := \left(a + -0.5\right) \cdot \log t\\ t_2 := \left(t_1 + \log \left(y \cdot z\right)\right) - t\\ t_3 := \log z - t\\ \mathbf{if}\;a \leq -1.16 \cdot 10^{+14}:\\ \;\;\;\;t_3 + a \cdot \log t\\ \mathbf{elif}\;a \leq -2.5 \cdot 10^{-254}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 5 \cdot 10^{-268}:\\ \;\;\;\;\log \left(x + y\right) + t_3\\ \mathbf{elif}\;a \leq 19000000:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 - t\\ \end{array} \]
Alternative 9
Error16.8
Cost13904
\[\begin{array}{l} t_1 := \left(\log \left(y \cdot z\right) + -0.5 \cdot \log t\right) - t\\ t_2 := \log z - t\\ t_3 := t_2 + a \cdot \log t\\ \mathbf{if}\;a \leq -1.35 \cdot 10^{-16}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -2.5 \cdot 10^{-254}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 4.8 \cdot 10^{-268}:\\ \;\;\;\;\log \left(x + y\right) + t_2\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 10
Error15.8
Cost13776
\[\begin{array}{l} t_1 := \log \left(y \cdot z\right) + -0.5 \cdot \log t\\ t_2 := \left(a + -0.5\right) \cdot \log t - t\\ \mathbf{if}\;t \leq 7 \cdot 10^{-202}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3 \cdot 10^{-185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.3 \cdot 10^{-18}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 100:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \log t - t\\ \end{array} \]
Alternative 11
Error17.3
Cost13776
\[\begin{array}{l} t_1 := \log \left(y \cdot z\right) + -0.5 \cdot \log t\\ t_2 := \left(a + -0.5\right) \cdot \log t - t\\ \mathbf{if}\;a \leq -2.3 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -6.5 \cdot 10^{-76}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.8 \cdot 10^{-213}:\\ \;\;\;\;\log \left(x + y\right) + \left(\log z - t\right)\\ \mathbf{elif}\;a \leq 1.24 \cdot 10^{-85}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error17.4
Cost13776
\[\begin{array}{l} t_1 := \log \left(y \cdot z\right) + -0.5 \cdot \log t\\ t_2 := \log z - t\\ \mathbf{if}\;a \leq -4 \cdot 10^{-19}:\\ \;\;\;\;t_2 + a \cdot \log t\\ \mathbf{elif}\;a \leq -1.85 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.6 \cdot 10^{-213}:\\ \;\;\;\;\log \left(x + y\right) + t_2\\ \mathbf{elif}\;a \leq 1.24 \cdot 10^{-85}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(a + -0.5\right) \cdot \log t - t\\ \end{array} \]
Alternative 13
Error16.8
Cost13772
\[\begin{array}{l} t_1 := a \cdot \log t\\ t_2 := \left(a + -0.5\right) \cdot \log t + \log \left(y \cdot z\right)\\ \mathbf{if}\;t \leq 4.6 \cdot 10^{-62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.6 \cdot 10^{-18}:\\ \;\;\;\;\log z + t_1\\ \mathbf{elif}\;t \leq 100:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\left(\log z - t\right) + t_1\\ \end{array} \]
Alternative 14
Error15.6
Cost13712
\[\begin{array}{l} t_1 := \log \left(y \cdot \left(z \cdot {t}^{-0.5}\right)\right)\\ t_2 := \left(a + -0.5\right) \cdot \log t - t\\ \mathbf{if}\;t \leq 2.8485 \cdot 10^{-197}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.15 \cdot 10^{-185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.2 \cdot 10^{-17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 100:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \log t - t\\ \end{array} \]
Alternative 15
Error14.7
Cost6984
\[\begin{array}{l} t_1 := a \cdot \log t - t\\ \mathbf{if}\;a \leq -0.075:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{-33}:\\ \;\;\;\;\log z - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 16
Error23.8
Cost6856
\[\begin{array}{l} t_1 := a \cdot \log t\\ \mathbf{if}\;a \leq -2.05 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.2 \cdot 10^{+21}:\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 17
Error22.1
Cost6856
\[\begin{array}{l} t_1 := a \cdot \log t\\ \mathbf{if}\;a \leq -1.1 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 6.5 \cdot 10^{+21}:\\ \;\;\;\;\log z - t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 18
Error14.5
Cost6848
\[\left(a + -0.5\right) \cdot \log t - t \]
Alternative 19
Error39.9
Cost128
\[-t \]

Error

Reproduce

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