Numeric.SpecFunctions:logGammaL from math-functions-0.1.5.2

Percentage Accurate: 99.6% → 99.2%
Time: 13.8s
Alternatives: 8
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \end{array} \]
(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));
}
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));
}
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 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]
\begin{array}{l}

\\
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}

Sampling outcomes in binary64 precision:

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.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
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.

Initial Program: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \end{array} \]
(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));
}
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));
}
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 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]
\begin{array}{l}

\\
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}

Alternative 1: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \left(\left(\log y + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (+ (- (+ (log y) (log z)) t) (* (- a 0.5) (log t))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	return ((log(y) + log(z)) - t) + ((a - 0.5) * log(t));
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this 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(y) + log(z)) - t) + ((a - 0.5d0) * log(t))
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	return ((Math.log(y) + Math.log(z)) - t) + ((a - 0.5) * Math.log(t));
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	return ((math.log(y) + math.log(z)) - t) + ((a - 0.5) * math.log(t))
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	return Float64(Float64(Float64(log(y) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t)))
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
	tmp = ((log(y) + log(z)) - t) + ((a - 0.5) * log(t));
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[y], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\left(\left(\log y + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}
Derivation
  1. Initial program 99.6%

    \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
  4. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
    2. log-lowering-log.f64N/A

      \[\leadsto \left(\left(\color{blue}{\log y} + \log z\right) - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
    3. log-lowering-log.f6466.9

      \[\leadsto \left(\left(\log y + \color{blue}{\log z}\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
  5. Simplified66.9%

    \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - 0.5\right) \cdot \log t \]
  6. Add Preprocessing

Alternative 2: 97.5% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := \left(a - 0.5\right) \cdot \log t\\ t_2 := t\_1 + \left(\left(\log z + \log \left(y + x\right)\right) - t\right)\\ \mathbf{if}\;t\_2 \leq -1 \cdot 10^{+23}:\\ \;\;\;\;a \cdot \log t - t\\ \mathbf{elif}\;t\_2 \leq 2000:\\ \;\;\;\;\log y + \left(\mathsf{fma}\left(\log t, -0.5, \log z\right) - t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1 - t\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (- a 0.5) (log t)))
        (t_2 (+ t_1 (- (+ (log z) (log (+ y x))) t))))
   (if (<= t_2 -1e+23)
     (- (* a (log t)) t)
     (if (<= t_2 2000.0)
       (+ (log y) (- (fma (log t) -0.5 (log z)) t))
       (- t_1 t)))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (a - 0.5) * log(t);
	double t_2 = t_1 + ((log(z) + log((y + x))) - t);
	double tmp;
	if (t_2 <= -1e+23) {
		tmp = (a * log(t)) - t;
	} else if (t_2 <= 2000.0) {
		tmp = log(y) + (fma(log(t), -0.5, log(z)) - t);
	} else {
		tmp = t_1 - t;
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(a - 0.5) * log(t))
	t_2 = Float64(t_1 + Float64(Float64(log(z) + log(Float64(y + x))) - t))
	tmp = 0.0
	if (t_2 <= -1e+23)
		tmp = Float64(Float64(a * log(t)) - t);
	elseif (t_2 <= 2000.0)
		tmp = Float64(log(y) + Float64(fma(log(t), -0.5, log(z)) - t));
	else
		tmp = Float64(t_1 - t);
	end
	return tmp
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(N[(N[Log[z], $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+23], N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$2, 2000.0], N[(N[Log[y], $MachinePrecision] + N[(N[(N[Log[t], $MachinePrecision] * -0.5 + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(t$95$1 - t), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot \log t\\
t_2 := t\_1 + \left(\left(\log z + \log \left(y + x\right)\right) - t\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+23}:\\
\;\;\;\;a \cdot \log t - t\\

\mathbf{elif}\;t\_2 \leq 2000:\\
\;\;\;\;\log y + \left(\mathsf{fma}\left(\log t, -0.5, \log z\right) - t\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1 - t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < -9.9999999999999992e22

    1. Initial program 99.9%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(a - \frac{1}{2}\right) \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right)} \]
      2. flip3--N/A

        \[\leadsto \color{blue}{\frac{{a}^{3} - {\frac{1}{2}}^{3}}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      4. div-invN/A

        \[\leadsto \color{blue}{\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t\right) \cdot \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t, \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}, \left(\log \left(x + y\right) + \log z\right) - t\right)} \]
    4. Applied egg-rr55.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a, a \cdot a, -0.125\right) \cdot \log t, \frac{1}{\mathsf{fma}\left(a, a, \mathsf{fma}\left(a, 0.5, 0.25\right)\right)}, \log \left(\left(x + y\right) \cdot z\right) - t\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
    6. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
    7. Simplified40.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log t, \frac{\mathsf{fma}\left(a, a \cdot a, -0.125\right)}{\mathsf{fma}\left(a, a + 0.5, 0.25\right)}, \log \left(z \cdot x\right)\right) - t} \]
    8. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot \log t} - t \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\log t \cdot a} - t \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\log t \cdot a} - t \]
      3. log-lowering-log.f6499.9

        \[\leadsto \color{blue}{\log t} \cdot a - t \]
    10. Simplified99.9%

      \[\leadsto \color{blue}{\log t \cdot a} - t \]

    if -9.9999999999999992e22 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 2e3

    1. Initial program 99.2%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
      2. log-lowering-log.f64N/A

        \[\leadsto \left(\left(\color{blue}{\log y} + \log z\right) - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
      3. log-lowering-log.f6454.1

        \[\leadsto \left(\left(\log y + \color{blue}{\log z}\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    5. Simplified54.1%

      \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - 0.5\right) \cdot \log t \]
    6. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\left(\log y + \left(\log z + \frac{-1}{2} \cdot \log t\right)\right) - t} \]
    7. Step-by-step derivation
      1. associate--l+N/A

        \[\leadsto \color{blue}{\log y + \left(\left(\log z + \frac{-1}{2} \cdot \log t\right) - t\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto \color{blue}{\log y + \left(\left(\log z + \frac{-1}{2} \cdot \log t\right) - t\right)} \]
      3. log-lowering-log.f64N/A

        \[\leadsto \color{blue}{\log y} + \left(\left(\log z + \frac{-1}{2} \cdot \log t\right) - t\right) \]
      4. --lowering--.f64N/A

        \[\leadsto \log y + \color{blue}{\left(\left(\log z + \frac{-1}{2} \cdot \log t\right) - t\right)} \]
      5. +-commutativeN/A

        \[\leadsto \log y + \left(\color{blue}{\left(\frac{-1}{2} \cdot \log t + \log z\right)} - t\right) \]
      6. *-commutativeN/A

        \[\leadsto \log y + \left(\left(\color{blue}{\log t \cdot \frac{-1}{2}} + \log z\right) - t\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \log y + \left(\color{blue}{\mathsf{fma}\left(\log t, \frac{-1}{2}, \log z\right)} - t\right) \]
      8. log-lowering-log.f64N/A

        \[\leadsto \log y + \left(\mathsf{fma}\left(\color{blue}{\log t}, \frac{-1}{2}, \log z\right) - t\right) \]
      9. log-lowering-log.f6454.1

        \[\leadsto \log y + \left(\mathsf{fma}\left(\log t, -0.5, \color{blue}{\log z}\right) - t\right) \]
    8. Simplified54.1%

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

    if 2e3 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t)))

    1. Initial program 99.6%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf

      \[\leadsto \color{blue}{-1 \cdot t} + \left(a - \frac{1}{2}\right) \cdot \log t \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t\right)\right)} + \left(a - \frac{1}{2}\right) \cdot \log t \]
      2. neg-sub0N/A

        \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - \frac{1}{2}\right) \cdot \log t \]
      3. --lowering--.f6498.8

        \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - 0.5\right) \cdot \log t \]
    5. Simplified98.8%

      \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - 0.5\right) \cdot \log t \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a - 0.5\right) \cdot \log t + \left(\left(\log z + \log \left(y + x\right)\right) - t\right) \leq -1 \cdot 10^{+23}:\\ \;\;\;\;a \cdot \log t - t\\ \mathbf{elif}\;\left(a - 0.5\right) \cdot \log t + \left(\left(\log z + \log \left(y + x\right)\right) - t\right) \leq 2000:\\ \;\;\;\;\log y + \left(\mathsf{fma}\left(\log t, -0.5, \log z\right) - t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a - 0.5\right) \cdot \log t - t\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 93.4% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := \log z + \log \left(y + x\right)\\ \mathbf{if}\;t\_1 \leq -700:\\ \;\;\;\;a \cdot \log t - t\\ \mathbf{elif}\;t\_1 \leq 700:\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, \log t, \log \left(y \cdot z\right) - t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a - 0.5\right) \cdot \log t - t\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (+ (log z) (log (+ y x)))))
   (if (<= t_1 -700.0)
     (- (* a (log t)) t)
     (if (<= t_1 700.0)
       (fma (+ a -0.5) (log t) (- (log (* y z)) t))
       (- (* (- a 0.5) (log t)) t)))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = log(z) + log((y + x));
	double tmp;
	if (t_1 <= -700.0) {
		tmp = (a * log(t)) - t;
	} else if (t_1 <= 700.0) {
		tmp = fma((a + -0.5), log(t), (log((y * z)) - t));
	} else {
		tmp = ((a - 0.5) * log(t)) - t;
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(log(z) + log(Float64(y + x)))
	tmp = 0.0
	if (t_1 <= -700.0)
		tmp = Float64(Float64(a * log(t)) - t);
	elseif (t_1 <= 700.0)
		tmp = fma(Float64(a + -0.5), log(t), Float64(log(Float64(y * z)) - t));
	else
		tmp = Float64(Float64(Float64(a - 0.5) * log(t)) - t);
	end
	return tmp
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[z], $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -700.0], N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$1, 700.0], N[(N[(a + -0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \log z + \log \left(y + x\right)\\
\mathbf{if}\;t\_1 \leq -700:\\
\;\;\;\;a \cdot \log t - t\\

\mathbf{elif}\;t\_1 \leq 700:\\
\;\;\;\;\mathsf{fma}\left(a + -0.5, \log t, \log \left(y \cdot z\right) - t\right)\\

\mathbf{else}:\\
\;\;\;\;\left(a - 0.5\right) \cdot \log t - t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -700

    1. Initial program 99.9%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(a - \frac{1}{2}\right) \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right)} \]
      2. flip3--N/A

        \[\leadsto \color{blue}{\frac{{a}^{3} - {\frac{1}{2}}^{3}}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      4. div-invN/A

        \[\leadsto \color{blue}{\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t\right) \cdot \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t, \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}, \left(\log \left(x + y\right) + \log z\right) - t\right)} \]
    4. Applied egg-rr2.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a, a \cdot a, -0.125\right) \cdot \log t, \frac{1}{\mathsf{fma}\left(a, a, \mathsf{fma}\left(a, 0.5, 0.25\right)\right)}, \log \left(\left(x + y\right) \cdot z\right) - t\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
    6. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
    7. Simplified2.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log t, \frac{\mathsf{fma}\left(a, a \cdot a, -0.125\right)}{\mathsf{fma}\left(a, a + 0.5, 0.25\right)}, \log \left(z \cdot x\right)\right) - t} \]
    8. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot \log t} - t \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\log t \cdot a} - t \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\log t \cdot a} - t \]
      3. log-lowering-log.f6484.0

        \[\leadsto \color{blue}{\log t} \cdot a - t \]
    10. Simplified84.0%

      \[\leadsto \color{blue}{\log t \cdot a} - t \]

    if -700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700

    1. Initial program 99.6%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
      2. log-lowering-log.f64N/A

        \[\leadsto \left(\left(\color{blue}{\log y} + \log z\right) - t\right) + \left(a - \frac{1}{2}\right) \cdot \log t \]
      3. log-lowering-log.f6468.0

        \[\leadsto \left(\left(\log y + \color{blue}{\log z}\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    5. Simplified68.0%

      \[\leadsto \left(\color{blue}{\left(\log y + \log z\right)} - t\right) + \left(a - 0.5\right) \cdot \log t \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(a - \frac{1}{2}\right) \cdot \log t + \left(\left(\log y + \log z\right) - t\right)} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(a - \frac{1}{2}, \log t, \left(\log y + \log z\right) - t\right)} \]
      3. sub-negN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{a + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, \log t, \left(\log y + \log z\right) - t\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(a + \color{blue}{\frac{-1}{2}}, \log t, \left(\log y + \log z\right) - t\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{a + \frac{-1}{2}}, \log t, \left(\log y + \log z\right) - t\right) \]
      6. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(a + \frac{-1}{2}, \color{blue}{\log t}, \left(\log y + \log z\right) - t\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{fma}\left(a + \frac{-1}{2}, \log t, \color{blue}{\left(\log y + \log z\right) - t}\right) \]
      8. sum-logN/A

        \[\leadsto \mathsf{fma}\left(a + \frac{-1}{2}, \log t, \color{blue}{\log \left(y \cdot z\right)} - t\right) \]
      9. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(a + \frac{-1}{2}, \log t, \color{blue}{\log \left(y \cdot z\right)} - t\right) \]
      10. *-lowering-*.f6464.0

        \[\leadsto \mathsf{fma}\left(a + -0.5, \log t, \log \color{blue}{\left(y \cdot z\right)} - t\right) \]
    7. Applied egg-rr64.0%

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

    if 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z))

    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. Add Preprocessing
    3. Taylor expanded in t around inf

      \[\leadsto \color{blue}{-1 \cdot t} + \left(a - \frac{1}{2}\right) \cdot \log t \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t\right)\right)} + \left(a - \frac{1}{2}\right) \cdot \log t \]
      2. neg-sub0N/A

        \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - \frac{1}{2}\right) \cdot \log t \]
      3. --lowering--.f6492.3

        \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - 0.5\right) \cdot \log t \]
    5. Simplified92.3%

      \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - 0.5\right) \cdot \log t \]
  3. Recombined 3 regimes into one program.
  4. Final simplification70.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\log z + \log \left(y + x\right) \leq -700:\\ \;\;\;\;a \cdot \log t - t\\ \mathbf{elif}\;\log z + \log \left(y + x\right) \leq 700:\\ \;\;\;\;\mathsf{fma}\left(a + -0.5, \log t, \log \left(y \cdot z\right) - t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a - 0.5\right) \cdot \log t - t\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;t \leq 380:\\ \;\;\;\;\mathsf{fma}\left(\log t, a + -0.5, \log z + \log \left(y + x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \log t - t\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= t 380.0)
   (fma (log t) (+ a -0.5) (+ (log z) (log (+ y x))))
   (- (* a (log t)) t)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (t <= 380.0) {
		tmp = fma(log(t), (a + -0.5), (log(z) + log((y + x))));
	} else {
		tmp = (a * log(t)) - t;
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	tmp = 0.0
	if (t <= 380.0)
		tmp = fma(log(t), Float64(a + -0.5), Float64(log(z) + log(Float64(y + x))));
	else
		tmp = Float64(Float64(a * log(t)) - t);
	end
	return tmp
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 380.0], N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + N[(N[Log[z], $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 380:\\
\;\;\;\;\mathsf{fma}\left(\log t, a + -0.5, \log z + \log \left(y + x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;a \cdot \log t - t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 380

    1. Initial program 99.3%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

      \[\leadsto \color{blue}{\log z + \left(\log \left(x + y\right) + \log t \cdot \left(a - \frac{1}{2}\right)\right)} \]
    4. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\log z + \log \left(x + y\right)\right) + \log t \cdot \left(a - \frac{1}{2}\right)} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\log t \cdot \left(a - \frac{1}{2}\right) + \left(\log z + \log \left(x + y\right)\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log t, a - \frac{1}{2}, \log z + \log \left(x + y\right)\right)} \]
      4. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log t}, a - \frac{1}{2}, \log z + \log \left(x + y\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{fma}\left(\log t, \color{blue}{a + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, \log z + \log \left(x + y\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\log t, a + \color{blue}{\frac{-1}{2}}, \log z + \log \left(x + y\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\log t, \color{blue}{a + \frac{-1}{2}}, \log z + \log \left(x + y\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\log t, a + \frac{-1}{2}, \color{blue}{\log z + \log \left(x + y\right)}\right) \]
      9. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log t, a + \frac{-1}{2}, \color{blue}{\log z} + \log \left(x + y\right)\right) \]
      10. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log t, a + \frac{-1}{2}, \log z + \color{blue}{\log \left(x + y\right)}\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\log t, a + \frac{-1}{2}, \log z + \log \color{blue}{\left(y + x\right)}\right) \]
      12. +-lowering-+.f6497.2

        \[\leadsto \mathsf{fma}\left(\log t, a + -0.5, \log z + \log \color{blue}{\left(y + x\right)}\right) \]
    5. Simplified97.2%

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

    if 380 < t

    1. Initial program 99.9%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(a - \frac{1}{2}\right) \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right)} \]
      2. flip3--N/A

        \[\leadsto \color{blue}{\frac{{a}^{3} - {\frac{1}{2}}^{3}}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      4. div-invN/A

        \[\leadsto \color{blue}{\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t\right) \cdot \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t, \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}, \left(\log \left(x + y\right) + \log z\right) - t\right)} \]
    4. Applied egg-rr56.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a, a \cdot a, -0.125\right) \cdot \log t, \frac{1}{\mathsf{fma}\left(a, a, \mathsf{fma}\left(a, 0.5, 0.25\right)\right)}, \log \left(\left(x + y\right) \cdot z\right) - t\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
    6. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
    7. Simplified40.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log t, \frac{\mathsf{fma}\left(a, a \cdot a, -0.125\right)}{\mathsf{fma}\left(a, a + 0.5, 0.25\right)}, \log \left(z \cdot x\right)\right) - t} \]
    8. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot \log t} - t \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\log t \cdot a} - t \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\log t \cdot a} - t \]
      3. log-lowering-log.f6499.2

        \[\leadsto \color{blue}{\log t} \cdot a - t \]
    10. Simplified99.2%

      \[\leadsto \color{blue}{\log t \cdot a} - t \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 380:\\ \;\;\;\;\mathsf{fma}\left(\log t, a + -0.5, \log z + \log \left(y + x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \log t - t\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 62.2% accurate, 2.6× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := a \cdot \log t\\ \mathbf{if}\;a - 0.5 \leq -5 \cdot 10^{+39}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;a - 0.5 \leq 5000000000000:\\ \;\;\;\;0 - t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* a (log t))))
   (if (<= (- a 0.5) -5e+39)
     t_1
     (if (<= (- a 0.5) 5000000000000.0) (- 0.0 t) t_1))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = a * log(t);
	double tmp;
	if ((a - 0.5) <= -5e+39) {
		tmp = t_1;
	} else if ((a - 0.5) <= 5000000000000.0) {
		tmp = 0.0 - t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this 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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = a * log(t)
    if ((a - 0.5d0) <= (-5d+39)) then
        tmp = t_1
    else if ((a - 0.5d0) <= 5000000000000.0d0) then
        tmp = 0.0d0 - t
    else
        tmp = t_1
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = a * Math.log(t);
	double tmp;
	if ((a - 0.5) <= -5e+39) {
		tmp = t_1;
	} else if ((a - 0.5) <= 5000000000000.0) {
		tmp = 0.0 - t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	t_1 = a * math.log(t)
	tmp = 0
	if (a - 0.5) <= -5e+39:
		tmp = t_1
	elif (a - 0.5) <= 5000000000000.0:
		tmp = 0.0 - t
	else:
		tmp = t_1
	return tmp
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(a * log(t))
	tmp = 0.0
	if (Float64(a - 0.5) <= -5e+39)
		tmp = t_1;
	elseif (Float64(a - 0.5) <= 5000000000000.0)
		tmp = Float64(0.0 - t);
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
	t_1 = a * log(t);
	tmp = 0.0;
	if ((a - 0.5) <= -5e+39)
		tmp = t_1;
	elseif ((a - 0.5) <= 5000000000000.0)
		tmp = 0.0 - t;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a - 0.5), $MachinePrecision], -5e+39], t$95$1, If[LessEqual[N[(a - 0.5), $MachinePrecision], 5000000000000.0], N[(0.0 - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := a \cdot \log t\\
\mathbf{if}\;a - 0.5 \leq -5 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;a - 0.5 \leq 5000000000000:\\
\;\;\;\;0 - t\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 a #s(literal 1/2 binary64)) < -5.00000000000000015e39 or 5e12 < (-.f64 a #s(literal 1/2 binary64))

    1. Initial program 99.6%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot \log t} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\log t \cdot a} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\log t \cdot a} \]
      3. log-lowering-log.f6480.5

        \[\leadsto \color{blue}{\log t} \cdot a \]
    5. Simplified80.5%

      \[\leadsto \color{blue}{\log t \cdot a} \]

    if -5.00000000000000015e39 < (-.f64 a #s(literal 1/2 binary64)) < 5e12

    1. Initial program 99.6%

      \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf

      \[\leadsto \color{blue}{-1 \cdot t} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(t\right)} \]
      2. neg-sub0N/A

        \[\leadsto \color{blue}{0 - t} \]
      3. --lowering--.f6457.4

        \[\leadsto \color{blue}{0 - t} \]
    5. Simplified57.4%

      \[\leadsto \color{blue}{0 - t} \]
    6. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(t\right)} \]
      2. neg-lowering-neg.f6457.4

        \[\leadsto \color{blue}{-t} \]
    7. Applied egg-rr57.4%

      \[\leadsto \color{blue}{-t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a - 0.5 \leq -5 \cdot 10^{+39}:\\ \;\;\;\;a \cdot \log t\\ \mathbf{elif}\;a - 0.5 \leq 5000000000000:\\ \;\;\;\;0 - t\\ \mathbf{else}:\\ \;\;\;\;a \cdot \log t\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 76.5% accurate, 2.9× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \left(a - 0.5\right) \cdot \log t - t \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a) :precision binary64 (- (* (- a 0.5) (log t)) t))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	return ((a - 0.5) * log(t)) - t;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this 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 = ((a - 0.5d0) * log(t)) - t
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	return ((a - 0.5) * Math.log(t)) - t;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	return ((a - 0.5) * math.log(t)) - t
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	return Float64(Float64(Float64(a - 0.5) * log(t)) - t)
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
	tmp = ((a - 0.5) * log(t)) - t;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\left(a - 0.5\right) \cdot \log t - t
\end{array}
Derivation
  1. Initial program 99.6%

    \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
  2. Add Preprocessing
  3. Taylor expanded in t around inf

    \[\leadsto \color{blue}{-1 \cdot t} + \left(a - \frac{1}{2}\right) \cdot \log t \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t\right)\right)} + \left(a - \frac{1}{2}\right) \cdot \log t \]
    2. neg-sub0N/A

      \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - \frac{1}{2}\right) \cdot \log t \]
    3. --lowering--.f6476.5

      \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - 0.5\right) \cdot \log t \]
  5. Simplified76.5%

    \[\leadsto \color{blue}{\left(0 - t\right)} + \left(a - 0.5\right) \cdot \log t \]
  6. Final simplification76.5%

    \[\leadsto \left(a - 0.5\right) \cdot \log t - t \]
  7. Add Preprocessing

Alternative 7: 73.8% accurate, 2.9× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ a \cdot \log t - t \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a) :precision binary64 (- (* a (log t)) t))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	return (a * log(t)) - t;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this 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 = (a * log(t)) - t
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	return (a * Math.log(t)) - t;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	return (a * math.log(t)) - t
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	return Float64(Float64(a * log(t)) - t)
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
	tmp = (a * log(t)) - t;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
a \cdot \log t - t
\end{array}
Derivation
  1. Initial program 99.6%

    \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\left(a - \frac{1}{2}\right) \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right)} \]
    2. flip3--N/A

      \[\leadsto \color{blue}{\frac{{a}^{3} - {\frac{1}{2}}^{3}}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} \cdot \log t + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
    3. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
    4. div-invN/A

      \[\leadsto \color{blue}{\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t\right) \cdot \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}} + \left(\left(\log \left(x + y\right) + \log z\right) - t\right) \]
    5. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left({a}^{3} - {\frac{1}{2}}^{3}\right) \cdot \log t, \frac{1}{a \cdot a + \left(\frac{1}{2} \cdot \frac{1}{2} + a \cdot \frac{1}{2}\right)}, \left(\log \left(x + y\right) + \log z\right) - t\right)} \]
  4. Applied egg-rr58.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a, a \cdot a, -0.125\right) \cdot \log t, \frac{1}{\mathsf{fma}\left(a, a, \mathsf{fma}\left(a, 0.5, 0.25\right)\right)}, \log \left(\left(x + y\right) \cdot z\right) - t\right)} \]
  5. Taylor expanded in y around 0

    \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
  6. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \color{blue}{\left(\log \left(x \cdot z\right) + \frac{\log t \cdot \left({a}^{3} - \frac{1}{8}\right)}{\frac{1}{4} + \left(\frac{1}{2} \cdot a + {a}^{2}\right)}\right) - t} \]
  7. Simplified38.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log t, \frac{\mathsf{fma}\left(a, a \cdot a, -0.125\right)}{\mathsf{fma}\left(a, a + 0.5, 0.25\right)}, \log \left(z \cdot x\right)\right) - t} \]
  8. Taylor expanded in a around inf

    \[\leadsto \color{blue}{a \cdot \log t} - t \]
  9. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{\log t \cdot a} - t \]
    2. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\log t \cdot a} - t \]
    3. log-lowering-log.f6473.7

      \[\leadsto \color{blue}{\log t} \cdot a - t \]
  10. Simplified73.7%

    \[\leadsto \color{blue}{\log t \cdot a} - t \]
  11. Final simplification73.7%

    \[\leadsto a \cdot \log t - t \]
  12. Add Preprocessing

Alternative 8: 37.4% accurate, 80.3× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ 0 - t \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a) :precision binary64 (- 0.0 t))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	return 0.0 - t;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this 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 = 0.0d0 - t
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	return 0.0 - t;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	return 0.0 - t
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	return Float64(0.0 - t)
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
	tmp = 0.0 - t;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := N[(0.0 - t), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
0 - t
\end{array}
Derivation
  1. Initial program 99.6%

    \[\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t \]
  2. Add Preprocessing
  3. Taylor expanded in t around inf

    \[\leadsto \color{blue}{-1 \cdot t} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(t\right)} \]
    2. neg-sub0N/A

      \[\leadsto \color{blue}{0 - t} \]
    3. --lowering--.f6443.2

      \[\leadsto \color{blue}{0 - t} \]
  5. Simplified43.2%

    \[\leadsto \color{blue}{0 - t} \]
  6. Step-by-step derivation
    1. sub0-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(t\right)} \]
    2. neg-lowering-neg.f6443.2

      \[\leadsto \color{blue}{-t} \]
  7. Applied egg-rr43.2%

    \[\leadsto \color{blue}{-t} \]
  8. Final simplification43.2%

    \[\leadsto 0 - t \]
  9. Add Preprocessing

Developer Target 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \log \left(x + y\right) + \left(\left(\log z - t\right) + \left(a - 0.5\right) \cdot \log t\right) \end{array} \]
(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)));
}
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)));
}
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(log(Float64(x + y)) + Float64(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
code[x_, y_, z_, t_, a_] := N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\log \left(x + y\right) + \left(\left(\log z - t\right) + \left(a - 0.5\right) \cdot \log t\right)
\end{array}

Reproduce

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

  :alt
  (! :herbie-platform default (+ (log (+ x y)) (+ (- (log z) t) (* (- a 1/2) (log t)))))

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