
(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:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
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) (fma (log t) (+ a -0.5) (- (/ x y) 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) + fma(log(t), (a + -0.5), ((x / y) - t)));
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(log(y) + Float64(log(z) + fma(log(t), Float64(a + -0.5), Float64(Float64(x / y) - 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[Log[y], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + N[(N[(x / y), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\log y + \left(\log z + \mathsf{fma}\left(\log t, a + -0.5, \frac{x}{y} - t\right)\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-/.f6457.6
Applied rewrites57.6%
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 (+ x y))))
(t_2 (+ (log y) (fma (log t) (+ a -0.5) (- t)))))
(if (<= t_1 -750.0)
t_2
(if (<= t_1 700.0)
(+ (log (* z (+ x y))) (- (* (log t) (+ a -0.5)) t))
t_2))))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((x + y));
double t_2 = log(y) + fma(log(t), (a + -0.5), -t);
double tmp;
if (t_1 <= -750.0) {
tmp = t_2;
} else if (t_1 <= 700.0) {
tmp = log((z * (x + y))) + ((log(t) * (a + -0.5)) - t);
} else {
tmp = t_2;
}
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(x + y))) t_2 = Float64(log(y) + fma(log(t), Float64(a + -0.5), Float64(-t))) tmp = 0.0 if (t_1 <= -750.0) tmp = t_2; elseif (t_1 <= 700.0) tmp = Float64(log(Float64(z * Float64(x + y))) + Float64(Float64(log(t) * Float64(a + -0.5)) - t)); else tmp = t_2; 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[(x + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -750.0], t$95$2, If[LessEqual[t$95$1, 700.0], N[(N[Log[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \log z + \log \left(x + y\right)\\
t_2 := \log y + \mathsf{fma}\left(\log t, a + -0.5, -t\right)\\
\mathbf{if}\;t\_1 \leq -750:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 700:\\
\;\;\;\;\log \left(z \cdot \left(x + y\right)\right) + \left(\log t \cdot \left(a + -0.5\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750 or 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
+-commutativeN/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6458.7
Applied rewrites58.7%
Taylor expanded in t around inf
Applied rewrites44.6%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.5%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
lower--.f6499.5
lift--.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval99.5
Applied rewrites99.5%
Final simplification84.3%
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 (+ x y))))
(t_2 (+ (log y) (fma (log t) (+ a -0.5) (- t)))))
(if (<= t_1 -750.0)
t_2
(if (<= t_1 700.0) (- (fma (log t) (+ a -0.5) (log (* y z))) t) t_2))))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((x + y));
double t_2 = log(y) + fma(log(t), (a + -0.5), -t);
double tmp;
if (t_1 <= -750.0) {
tmp = t_2;
} else if (t_1 <= 700.0) {
tmp = fma(log(t), (a + -0.5), log((y * z))) - t;
} else {
tmp = t_2;
}
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(x + y))) t_2 = Float64(log(y) + fma(log(t), Float64(a + -0.5), Float64(-t))) tmp = 0.0 if (t_1 <= -750.0) tmp = t_2; elseif (t_1 <= 700.0) tmp = Float64(fma(log(t), Float64(a + -0.5), log(Float64(y * z))) - t); else tmp = t_2; 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[(x + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -750.0], t$95$2, If[LessEqual[t$95$1, 700.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \log z + \log \left(x + y\right)\\
t_2 := \log y + \mathsf{fma}\left(\log t, a + -0.5, -t\right)\\
\mathbf{if}\;t\_1 \leq -750:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 700:\\
\;\;\;\;\mathsf{fma}\left(\log t, a + -0.5, \log \left(y \cdot z\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750 or 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
+-commutativeN/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6458.7
Applied rewrites58.7%
Taylor expanded in t around inf
Applied rewrites44.6%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
div-invN/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-+.f6477.4
Applied rewrites77.4%
lift-/.f64N/A
lift-+.f64N/A
flip-+N/A
sub-negN/A
metadata-evalN/A
lift-+.f64N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
sub-negN/A
metadata-evalN/A
metadata-evalN/A
lift-fma.f6475.8
Applied rewrites75.8%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower-log.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
Final simplification60.7%
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 (<= (- a 0.5) -1.0)
(+ (log y) (fma (log t) (+ a -0.5) (- t)))
(if (<= (- a 0.5) -0.499)
(+ (log y) (- (fma (log t) -0.5 (log z)) t))
(+ (* (log t) (- a 0.5)) (- 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 ((a - 0.5) <= -1.0) {
tmp = log(y) + fma(log(t), (a + -0.5), -t);
} else if ((a - 0.5) <= -0.499) {
tmp = log(y) + (fma(log(t), -0.5, log(z)) - t);
} else {
tmp = (log(t) * (a - 0.5)) + -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 (Float64(a - 0.5) <= -1.0) tmp = Float64(log(y) + fma(log(t), Float64(a + -0.5), Float64(-t))); elseif (Float64(a - 0.5) <= -0.499) tmp = Float64(log(y) + Float64(fma(log(t), -0.5, log(z)) - t)); else tmp = Float64(Float64(log(t) * Float64(a - 0.5)) + Float64(-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[N[(a - 0.5), $MachinePrecision], -1.0], N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a - 0.5), $MachinePrecision], -0.499], N[(N[Log[y], $MachinePrecision] + N[(N[(N[Log[t], $MachinePrecision] * -0.5 + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision] + (-t)), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a - 0.5 \leq -1:\\
\;\;\;\;\log y + \mathsf{fma}\left(\log t, a + -0.5, -t\right)\\
\mathbf{elif}\;a - 0.5 \leq -0.499:\\
\;\;\;\;\log y + \left(\mathsf{fma}\left(\log t, -0.5, \log z\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot \left(a - 0.5\right) + \left(-t\right)\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -1Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
+-commutativeN/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6471.6
Applied rewrites71.6%
Taylor expanded in t around inf
Applied rewrites71.6%
if -1 < (-.f64 a #s(literal 1/2 binary64)) < -0.499Initial program 99.5%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
+-commutativeN/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6463.3
Applied rewrites63.3%
Taylor expanded in a around 0
Applied rewrites61.3%
if -0.499 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6499.6
Applied rewrites99.6%
Final simplification73.2%
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 z) (log (+ x y))) t) (* (log t) (- a 0.5))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return ((log(z) + log((x + y))) - t) + (log(t) * (a - 0.5));
}
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(z) + log((x + y))) - t) + (log(t) * (a - 0.5d0))
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(z) + Math.log((x + y))) - t) + (Math.log(t) * (a - 0.5));
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return ((math.log(z) + math.log((x + y))) - t) + (math.log(t) * (a - 0.5))
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(Float64(log(z) + log(Float64(x + y))) - t) + Float64(log(t) * Float64(a - 0.5))) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = ((log(z) + log((x + y))) - t) + (log(t) * (a - 0.5));
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[z], $MachinePrecision] + N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\left(\left(\log z + \log \left(x + y\right)\right) - t\right) + \log t \cdot \left(a - 0.5\right)
\end{array}
Initial program 99.6%
Final simplification99.6%
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 29.5) (+ (log y) (fma (log t) (+ a -0.5) (log z))) (+ (* (log t) (- a 0.5)) (- 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 <= 29.5) {
tmp = log(y) + fma(log(t), (a + -0.5), log(z));
} else {
tmp = (log(t) * (a - 0.5)) + -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 <= 29.5) tmp = Float64(log(y) + fma(log(t), Float64(a + -0.5), log(z))); else tmp = Float64(Float64(log(t) * Float64(a - 0.5)) + Float64(-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, 29.5], N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $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 29.5:\\
\;\;\;\;\log y + \mathsf{fma}\left(\log t, a + -0.5, \log z\right)\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot \left(a - 0.5\right) + \left(-t\right)\\
\end{array}
\end{array}
if t < 29.5Initial program 99.2%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
+-commutativeN/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6460.9
Applied rewrites60.9%
Taylor expanded in t around 0
Applied rewrites60.9%
if 29.5 < t Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6498.2
Applied rewrites98.2%
Final simplification79.7%
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) (fma (log t) (+ a -0.5) (- (log z) 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) + fma(log(t), (a + -0.5), (log(z) - t));
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(log(y) + fma(log(t), Float64(a + -0.5), Float64(log(z) - 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[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\log y + \mathsf{fma}\left(\log t, a + -0.5, \log z - t\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
+-commutativeN/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6467.6
Applied rewrites67.6%
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) (fma (log t) (+ a -0.5) (- 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) + fma(log(t), (a + -0.5), -t);
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(log(y) + fma(log(t), Float64(a + -0.5), Float64(-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[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a + -0.5), $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\log y + \mathsf{fma}\left(\log t, a + -0.5, -t\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
+-commutativeN/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6467.6
Applied rewrites67.6%
Taylor expanded in t around inf
Applied rewrites54.5%
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) -0.502)
t_1
(if (<= (- a 0.5) 5e+91) (+ (log y) (- 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) <= -0.502) {
tmp = t_1;
} else if ((a - 0.5) <= 5e+91) {
tmp = log(y) + -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) <= (-0.502d0)) then
tmp = t_1
else if ((a - 0.5d0) <= 5d+91) then
tmp = log(y) + -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) <= -0.502) {
tmp = t_1;
} else if ((a - 0.5) <= 5e+91) {
tmp = Math.log(y) + -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) <= -0.502: tmp = t_1 elif (a - 0.5) <= 5e+91: tmp = math.log(y) + -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) <= -0.502) tmp = t_1; elseif (Float64(a - 0.5) <= 5e+91) tmp = Float64(log(y) + Float64(-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) <= -0.502)
tmp = t_1;
elseif ((a - 0.5) <= 5e+91)
tmp = log(y) + -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], -0.502], t$95$1, If[LessEqual[N[(a - 0.5), $MachinePrecision], 5e+91], N[(N[Log[y], $MachinePrecision] + (-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 -0.502:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a - 0.5 \leq 5 \cdot 10^{+91}:\\
\;\;\;\;\log y + \left(-t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -0.502 or 5.0000000000000002e91 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.5
Applied rewrites83.5%
if -0.502 < (-.f64 a #s(literal 1/2 binary64)) < 5.0000000000000002e91Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lower-log.f64N/A
associate--l+N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64N/A
lower-/.f6454.0
Applied rewrites54.0%
Taylor expanded in t around inf
Applied rewrites40.5%
Final simplification57.3%
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) -0.5001) t_1 (if (<= (- a 0.5) 5e+91) (- 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) <= -0.5001) {
tmp = t_1;
} else if ((a - 0.5) <= 5e+91) {
tmp = -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) <= (-0.5001d0)) then
tmp = t_1
else if ((a - 0.5d0) <= 5d+91) then
tmp = -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) <= -0.5001) {
tmp = t_1;
} else if ((a - 0.5) <= 5e+91) {
tmp = -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) <= -0.5001: tmp = t_1 elif (a - 0.5) <= 5e+91: tmp = -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) <= -0.5001) tmp = t_1; elseif (Float64(a - 0.5) <= 5e+91) tmp = Float64(-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) <= -0.5001)
tmp = t_1;
elseif ((a - 0.5) <= 5e+91)
tmp = -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], -0.5001], t$95$1, If[LessEqual[N[(a - 0.5), $MachinePrecision], 5e+91], (-t), 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 -0.5001:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a - 0.5 \leq 5 \cdot 10^{+91}:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -0.50009999999999999 or 5.0000000000000002e91 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6482.8
Applied rewrites82.8%
if -0.50009999999999999 < (-.f64 a #s(literal 1/2 binary64)) < 5.0000000000000002e91Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6448.6
Applied rewrites48.6%
Final simplification62.1%
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 t) (- a 0.5)) (- t)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return (log(t) * (a - 0.5)) + -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(t) * (a - 0.5d0)) + -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(t) * (a - 0.5)) + -t;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return (math.log(t) * (a - 0.5)) + -t
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(log(t) * Float64(a - 0.5)) + Float64(-t)) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = (log(t) * (a - 0.5)) + -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[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision] + (-t)), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\log t \cdot \left(a - 0.5\right) + \left(-t\right)
\end{array}
Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6473.4
Applied rewrites73.4%
Final simplification73.4%
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 (- t))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return -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 = -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 -t;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return -t
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(-t) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = -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_] := (-t)
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
-t
\end{array}
Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6434.9
Applied rewrites34.9%
(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}
herbie shell --seed 2024222
(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))))