Numeric.SpecFunctions:logGammaL from math-functions-0.1.5.2

?

Percentage Accurate: 99.6% → 99.6%
Time: 48.4s
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

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 18 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original99.6%
Target99.6%
Herbie99.6%
\[\log \left(x + y\right) + \left(\left(\log z - t\right) + \left(a - 0.5\right) \cdot \log t\right) \]

Derivation?

  1. Initial program 99.7%

    \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
  2. Simplified99.7%

    \[\leadsto \color{blue}{\left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \left(a + -0.5\right) \cdot \log t} \]
    Step-by-step derivation

    [Start]99.7%

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

    associate--l+ [=>]99.7%

    \[ \color{blue}{\left(\log \left(x + y\right) + \left(\log z - t\right)\right)} + \left(a - 0.5\right) \cdot \log t \]

    sub-neg [=>]99.7%

    \[ \left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \color{blue}{\left(a + \left(-0.5\right)\right)} \cdot \log t \]

    metadata-eval [=>]99.7%

    \[ \left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \left(a + \color{blue}{-0.5}\right) \cdot \log t \]
  3. Final simplification99.7%

    \[\leadsto \left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \left(a + -0.5\right) \cdot \log t \]

Alternatives

Alternative 1
Accuracy99.6%
Cost20032
\[\left(\log \left(x + y\right) + \left(\log z - t\right)\right) + \left(a + -0.5\right) \cdot \log t \]
Alternative 2
Accuracy86.3%
Cost20164
\[\begin{array}{l} \mathbf{if}\;\log z \leq 72:\\ \;\;\;\;\left(\left(a + -0.5\right) \cdot \log t + \log \left(\left(x + y\right) \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(\log z - t\right) - a \cdot \log \left(\frac{1}{t}\right)\\ \end{array} \]
Alternative 3
Accuracy68.1%
Cost20036
\[\begin{array}{l} \mathbf{if}\;\log z \leq 72:\\ \;\;\;\;\left(\log t \cdot \left(a - 0.5\right) + \log \left(y \cdot z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(\log z - t\right) - a \cdot \log \left(\frac{1}{t}\right)\\ \end{array} \]
Alternative 4
Accuracy80.7%
Cost19908
\[\begin{array}{l} \mathbf{if}\;t \leq 450:\\ \;\;\;\;\log t \cdot \left(a - 0.5\right) + \left(\log z + \log y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\log z - t\right) - a \cdot \log \left(\frac{1}{t}\right)\\ \end{array} \]
Alternative 5
Accuracy69.1%
Cost19904
\[\left(\log z - t\right) + \left(\log t \cdot \left(a - 0.5\right) + \log y\right) \]
Alternative 6
Accuracy69.1%
Cost19904
\[\left(\log t \cdot \left(a - 0.5\right) + \left(\log z + \log y\right)\right) - t \]
Alternative 7
Accuracy74.6%
Cost13641
\[\begin{array}{l} \mathbf{if}\;a \leq -7.2 \cdot 10^{-95} \lor \neg \left(a \leq 4.9 \cdot 10^{-52}\right):\\ \;\;\;\;\left(\log z - t\right) + a \cdot \log t\\ \mathbf{else}:\\ \;\;\;\;\left(-0.5 \cdot \log t + \log \left(y \cdot z\right)\right) - t\\ \end{array} \]
Alternative 8
Accuracy86.4%
Cost13636
\[\begin{array}{l} \mathbf{if}\;t \leq 5.6 \cdot 10^{-35}:\\ \;\;\;\;\left(a + -0.5\right) \cdot \log t + \log \left(\left(x + y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\log z - t\right) + a \cdot \log t\\ \end{array} \]
Alternative 9
Accuracy86.4%
Cost13636
\[\begin{array}{l} \mathbf{if}\;t \leq 5.4 \cdot 10^{-35}:\\ \;\;\;\;\left(a + -0.5\right) \cdot \log t + \log \left(\left(x + y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\log z - t\right) - a \cdot \log \left(\frac{1}{t}\right)\\ \end{array} \]
Alternative 10
Accuracy65.1%
Cost13385
\[\begin{array}{l} \mathbf{if}\;a \leq -21 \lor \neg \left(a \leq 1.75 \cdot 10^{+14}\right):\\ \;\;\;\;\log z + a \cdot \log t\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + y\right) - t\\ \end{array} \]
Alternative 11
Accuracy65.1%
Cost13384
\[\begin{array}{l} \mathbf{if}\;a \leq -21:\\ \;\;\;\;\log t \cdot \left(\left(-a\right) \cdot \sqrt[3]{-1}\right)\\ \mathbf{elif}\;a \leq 3700000000000:\\ \;\;\;\;\log \left(x + y\right) - t\\ \mathbf{else}:\\ \;\;\;\;\log z + a \cdot \log t\\ \end{array} \]
Alternative 12
Accuracy65.1%
Cost13384
\[\begin{array}{l} t_1 := \log \left(x + y\right)\\ t_2 := a \cdot \log t\\ \mathbf{if}\;a \leq -21:\\ \;\;\;\;t_1 + t_2\\ \mathbf{elif}\;a \leq 9 \cdot 10^{+17}:\\ \;\;\;\;t_1 - t\\ \mathbf{else}:\\ \;\;\;\;\log z + t_2\\ \end{array} \]
Alternative 13
Accuracy76.8%
Cost13248
\[\left(\log z - t\right) + a \cdot \log t \]
Alternative 14
Accuracy25.9%
Cost6848
\[\left(\log y + \frac{x}{y}\right) - t \]
Alternative 15
Accuracy41.4%
Cost6724
\[\begin{array}{l} \mathbf{if}\;t \leq 3.2:\\ \;\;\;\;\log \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 16
Accuracy41.4%
Cost6720
\[\log \left(x + y\right) - t \]
Alternative 17
Accuracy30.8%
Cost6592
\[\log y - t \]
Alternative 18
Accuracy38.1%
Cost128
\[-t \]

Reproduce?

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