
(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}
(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}
Initial program 99.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- a 0.5) (log t)))
(t_2 (+ (- (+ (log (+ x y)) (log z)) t) t_1)))
(if (or (<= t_2 -5000.0) (not (<= t_2 2000.0)))
(+ (pow (/ -1.0 t) -1.0) t_1)
(+ (fma -0.5 (log t) (log (+ y x))) (log z)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (a - 0.5) * log(t);
double t_2 = ((log((x + y)) + log(z)) - t) + t_1;
double tmp;
if ((t_2 <= -5000.0) || !(t_2 <= 2000.0)) {
tmp = pow((-1.0 / t), -1.0) + t_1;
} else {
tmp = fma(-0.5, log(t), log((y + x))) + log(z);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(a - 0.5) * log(t)) t_2 = Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + t_1) tmp = 0.0 if ((t_2 <= -5000.0) || !(t_2 <= 2000.0)) tmp = Float64((Float64(-1.0 / t) ^ -1.0) + t_1); else tmp = Float64(fma(-0.5, log(t), log(Float64(y + x))) + log(z)); end return tmp end
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[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5000.0], N[Not[LessEqual[t$95$2, 2000.0]], $MachinePrecision]], N[(N[Power[N[(-1.0 / t), $MachinePrecision], -1.0], $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot \log t\\
t_2 := \left(\left(\log \left(x + y\right) + \log z\right) - t\right) + t\_1\\
\mathbf{if}\;t\_2 \leq -5000 \lor \neg \left(t\_2 \leq 2000\right):\\
\;\;\;\;{\left(\frac{-1}{t}\right)}^{-1} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(y + x\right)\right) + \log z\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < -5e3 or 2e3 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) Initial program 99.8%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites72.5%
Taylor expanded in t around inf
lower-/.f6497.1
Applied rewrites97.1%
if -5e3 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 2e3Initial program 99.2%
Taylor expanded in a around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6498.7
Applied rewrites98.7%
Taylor expanded in t around 0
Applied rewrites97.2%
Final simplification97.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- a 0.5) (log t)))
(t_2 (+ (- (+ (log (+ x y)) (log z)) t) t_1)))
(if (or (<= t_2 -20000000000000.0) (not (<= t_2 1000.0)))
(+ (pow (/ -1.0 t) -1.0) t_1)
(- (log (* z (+ y x))) (- t (* -0.5 (log t)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (a - 0.5) * log(t);
double t_2 = ((log((x + y)) + log(z)) - t) + t_1;
double tmp;
if ((t_2 <= -20000000000000.0) || !(t_2 <= 1000.0)) {
tmp = pow((-1.0 / t), -1.0) + t_1;
} else {
tmp = log((z * (y + x))) - (t - (-0.5 * log(t)));
}
return tmp;
}
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) :: t_2
real(8) :: tmp
t_1 = (a - 0.5d0) * log(t)
t_2 = ((log((x + y)) + log(z)) - t) + t_1
if ((t_2 <= (-20000000000000.0d0)) .or. (.not. (t_2 <= 1000.0d0))) then
tmp = (((-1.0d0) / t) ** (-1.0d0)) + t_1
else
tmp = log((z * (y + x))) - (t - ((-0.5d0) * log(t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (a - 0.5) * Math.log(t);
double t_2 = ((Math.log((x + y)) + Math.log(z)) - t) + t_1;
double tmp;
if ((t_2 <= -20000000000000.0) || !(t_2 <= 1000.0)) {
tmp = Math.pow((-1.0 / t), -1.0) + t_1;
} else {
tmp = Math.log((z * (y + x))) - (t - (-0.5 * Math.log(t)));
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (a - 0.5) * math.log(t) t_2 = ((math.log((x + y)) + math.log(z)) - t) + t_1 tmp = 0 if (t_2 <= -20000000000000.0) or not (t_2 <= 1000.0): tmp = math.pow((-1.0 / t), -1.0) + t_1 else: tmp = math.log((z * (y + x))) - (t - (-0.5 * math.log(t))) return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(a - 0.5) * log(t)) t_2 = Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + t_1) tmp = 0.0 if ((t_2 <= -20000000000000.0) || !(t_2 <= 1000.0)) tmp = Float64((Float64(-1.0 / t) ^ -1.0) + t_1); else tmp = Float64(log(Float64(z * Float64(y + x))) - Float64(t - Float64(-0.5 * log(t)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (a - 0.5) * log(t); t_2 = ((log((x + y)) + log(z)) - t) + t_1; tmp = 0.0; if ((t_2 <= -20000000000000.0) || ~((t_2 <= 1000.0))) tmp = ((-1.0 / t) ^ -1.0) + t_1; else tmp = log((z * (y + x))) - (t - (-0.5 * log(t))); end tmp_2 = tmp; end
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[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -20000000000000.0], N[Not[LessEqual[t$95$2, 1000.0]], $MachinePrecision]], N[(N[Power[N[(-1.0 / t), $MachinePrecision], -1.0], $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(t - N[(-0.5 * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot \log t\\
t_2 := \left(\left(\log \left(x + y\right) + \log z\right) - t\right) + t\_1\\
\mathbf{if}\;t\_2 \leq -20000000000000 \lor \neg \left(t\_2 \leq 1000\right):\\
\;\;\;\;{\left(\frac{-1}{t}\right)}^{-1} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\log \left(z \cdot \left(y + x\right)\right) - \left(t - -0.5 \cdot \log t\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < -2e13 or 1e3 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) Initial program 99.8%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites68.5%
Taylor expanded in t around inf
lower-/.f6494.1
Applied rewrites94.1%
if -2e13 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 1e3Initial program 99.1%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6499.1
Applied rewrites99.1%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
remove-double-divN/A
*-commutativeN/A
lift-*.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-log.f64N/A
lift-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
log-prodN/A
lift-*.f64N/A
lift-log.f64N/A
lower--.f6487.9
Applied rewrites87.9%
Taylor expanded in a around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f6484.6
Applied rewrites84.6%
Final simplification91.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- a 0.5) (log t)))
(t_2 (+ (- (+ (log (+ x y)) (log z)) t) t_1)))
(if (or (<= t_2 -20000000000000.0) (not (<= t_2 1000.0)))
(+ (pow (/ -1.0 t) -1.0) t_1)
(- (fma -0.5 (log t) (log (* (+ y x) z))) t))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (a - 0.5) * log(t);
double t_2 = ((log((x + y)) + log(z)) - t) + t_1;
double tmp;
if ((t_2 <= -20000000000000.0) || !(t_2 <= 1000.0)) {
tmp = pow((-1.0 / t), -1.0) + t_1;
} else {
tmp = fma(-0.5, log(t), log(((y + x) * z))) - t;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(a - 0.5) * log(t)) t_2 = Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + t_1) tmp = 0.0 if ((t_2 <= -20000000000000.0) || !(t_2 <= 1000.0)) tmp = Float64((Float64(-1.0 / t) ^ -1.0) + t_1); else tmp = Float64(fma(-0.5, log(t), log(Float64(Float64(y + x) * z))) - t); end return tmp end
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[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -20000000000000.0], N[Not[LessEqual[t$95$2, 1000.0]], $MachinePrecision]], N[(N[Power[N[(-1.0 / t), $MachinePrecision], -1.0], $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot \log t\\
t_2 := \left(\left(\log \left(x + y\right) + \log z\right) - t\right) + t\_1\\
\mathbf{if}\;t\_2 \leq -20000000000000 \lor \neg \left(t\_2 \leq 1000\right):\\
\;\;\;\;{\left(\frac{-1}{t}\right)}^{-1} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(\left(y + x\right) \cdot z\right)\right) - t\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < -2e13 or 1e3 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) Initial program 99.8%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites68.5%
Taylor expanded in t around inf
lower-/.f6494.1
Applied rewrites94.1%
if -2e13 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 1e3Initial program 99.1%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.1
Applied rewrites87.9%
Taylor expanded in a around 0
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6484.6
Applied rewrites84.6%
Final simplification91.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (or (<= t_1 -800.0) (not (<= t_1 705.0)))
(+ (pow (/ -1.0 t) -1.0) (* (- a 0.5) (log t)))
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double tmp;
if ((t_1 <= -800.0) || !(t_1 <= 705.0)) {
tmp = pow((-1.0 / t), -1.0) + ((a - 0.5) * log(t));
} else {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if ((t_1 <= -800.0) || !(t_1 <= 705.0)) tmp = Float64((Float64(-1.0 / t) ^ -1.0) + Float64(Float64(a - 0.5) * log(t))); else tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -800.0], N[Not[LessEqual[t$95$1, 705.0]], $MachinePrecision]], N[(N[Power[N[(-1.0 / t), $MachinePrecision], -1.0], $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq -800 \lor \neg \left(t\_1 \leq 705\right):\\
\;\;\;\;{\left(\frac{-1}{t}\right)}^{-1} + \left(a - 0.5\right) \cdot \log t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -800 or 705 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.5
Applied rewrites4.9%
Taylor expanded in t around inf
lower-/.f6478.7
Applied rewrites78.7%
if -800 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 705Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.6
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
Final simplification93.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= (- a 0.5) -100.0) (not (<= (- a 0.5) -0.48))) (+ (pow (/ -1.0 t) -1.0) (* (- a 0.5) (log t))) (- (fma -0.5 (log t) (log (+ y x))) (- t (log z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((a - 0.5) <= -100.0) || !((a - 0.5) <= -0.48)) {
tmp = pow((-1.0 / t), -1.0) + ((a - 0.5) * log(t));
} else {
tmp = fma(-0.5, log(t), log((y + x))) - (t - log(z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(a - 0.5) <= -100.0) || !(Float64(a - 0.5) <= -0.48)) tmp = Float64((Float64(-1.0 / t) ^ -1.0) + Float64(Float64(a - 0.5) * log(t))); else tmp = Float64(fma(-0.5, log(t), log(Float64(y + x))) - Float64(t - log(z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(a - 0.5), $MachinePrecision], -100.0], N[Not[LessEqual[N[(a - 0.5), $MachinePrecision], -0.48]], $MachinePrecision]], N[(N[Power[N[(-1.0 / t), $MachinePrecision], -1.0], $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a - 0.5 \leq -100 \lor \neg \left(a - 0.5 \leq -0.48\right):\\
\;\;\;\;{\left(\frac{-1}{t}\right)}^{-1} + \left(a - 0.5\right) \cdot \log t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(y + x\right)\right) - \left(t - \log z\right)\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -100 or -0.47999999999999998 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.7%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites73.3%
Taylor expanded in t around inf
lower-/.f6497.5
Applied rewrites97.5%
if -100 < (-.f64 a #s(literal 1/2 binary64)) < -0.47999999999999998Initial program 99.5%
Taylor expanded in a around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6499.3
Applied rewrites99.3%
Final simplification98.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= (- a 0.5) -100.0) (not (<= (- a 0.5) -0.48))) (+ (pow (/ -1.0 t) -1.0) (* (- a 0.5) (log t))) (- (fma -0.5 (log t) (log y)) (- t (log z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((a - 0.5) <= -100.0) || !((a - 0.5) <= -0.48)) {
tmp = pow((-1.0 / t), -1.0) + ((a - 0.5) * log(t));
} else {
tmp = fma(-0.5, log(t), log(y)) - (t - log(z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(a - 0.5) <= -100.0) || !(Float64(a - 0.5) <= -0.48)) tmp = Float64((Float64(-1.0 / t) ^ -1.0) + Float64(Float64(a - 0.5) * log(t))); else tmp = Float64(fma(-0.5, log(t), log(y)) - Float64(t - log(z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(a - 0.5), $MachinePrecision], -100.0], N[Not[LessEqual[N[(a - 0.5), $MachinePrecision], -0.48]], $MachinePrecision]], N[(N[Power[N[(-1.0 / t), $MachinePrecision], -1.0], $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - N[(t - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a - 0.5 \leq -100 \lor \neg \left(a - 0.5 \leq -0.48\right):\\
\;\;\;\;{\left(\frac{-1}{t}\right)}^{-1} + \left(a - 0.5\right) \cdot \log t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log y\right) - \left(t - \log z\right)\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -100 or -0.47999999999999998 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.7%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites73.3%
Taylor expanded in t around inf
lower-/.f6497.5
Applied rewrites97.5%
if -100 < (-.f64 a #s(literal 1/2 binary64)) < -0.47999999999999998Initial program 99.5%
Taylor expanded in a around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-log.f6499.3
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites58.2%
Final simplification79.2%
(FPCore (x y z t a) :precision binary64 (- (fma (- a 0.5) (log t) (log z)) (- t (log y))))
double code(double x, double y, double z, double t, double a) {
return fma((a - 0.5), log(t), log(z)) - (t - log(y));
}
function code(x, y, z, t, a) return Float64(fma(Float64(a - 0.5), log(t), log(z)) - Float64(t - log(y))) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - N[(t - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, \log t, \log z\right) - \left(t - \log y\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6467.0
Applied rewrites67.0%
(FPCore (x y z t a) :precision binary64 (+ (pow (/ -1.0 t) -1.0) (* (- a 0.5) (log t))))
double code(double x, double y, double z, double t, double a) {
return pow((-1.0 / t), -1.0) + ((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 = (((-1.0d0) / t) ** (-1.0d0)) + ((a - 0.5d0) * log(t))
end function
public static double code(double x, double y, double z, double t, double a) {
return Math.pow((-1.0 / t), -1.0) + ((a - 0.5) * Math.log(t));
}
def code(x, y, z, t, a): return math.pow((-1.0 / t), -1.0) + ((a - 0.5) * math.log(t))
function code(x, y, z, t, a) return Float64((Float64(-1.0 / t) ^ -1.0) + Float64(Float64(a - 0.5) * log(t))) end
function tmp = code(x, y, z, t, a) tmp = ((-1.0 / t) ^ -1.0) + ((a - 0.5) * log(t)); end
code[x_, y_, z_, t_, a_] := N[(N[Power[N[(-1.0 / t), $MachinePrecision], -1.0], $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{-1}{t}\right)}^{-1} + \left(a - 0.5\right) \cdot \log t
\end{array}
Initial program 99.6%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.5
Applied rewrites72.9%
Taylor expanded in t around inf
lower-/.f6476.0
Applied rewrites76.0%
Final simplification76.0%
(FPCore (x y z t a) :precision binary64 (if (<= t 1.85e-12) (* (log t) a) (fma (* a (/ (log t) t)) t (- t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 1.85e-12) {
tmp = log(t) * a;
} else {
tmp = fma((a * (log(t) / t)), t, -t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 1.85e-12) tmp = Float64(log(t) * a); else tmp = fma(Float64(a * Float64(log(t) / t)), t, Float64(-t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 1.85e-12], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], N[(N[(a * N[(N[Log[t], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * t + (-t)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.85 \cdot 10^{-12}:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \frac{\log t}{t}, t, -t\right)\\
\end{array}
\end{array}
if t < 1.84999999999999999e-12Initial program 99.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6446.8
Applied rewrites46.8%
if 1.84999999999999999e-12 < t Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in t around inf
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in a around inf
Applied rewrites96.5%
Final simplification73.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -8200000.0) (not (<= a 2.25e+62))) (* (log t) a) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -8200000.0) || !(a <= 2.25e+62)) {
tmp = log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
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) :: tmp
if ((a <= (-8200000.0d0)) .or. (.not. (a <= 2.25d+62))) then
tmp = log(t) * a
else
tmp = -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -8200000.0) || !(a <= 2.25e+62)) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (a <= -8200000.0) or not (a <= 2.25e+62): tmp = math.log(t) * a else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -8200000.0) || !(a <= 2.25e+62)) tmp = Float64(log(t) * a); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((a <= -8200000.0) || ~((a <= 2.25e+62))) tmp = log(t) * a; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -8200000.0], N[Not[LessEqual[a, 2.25e+62]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8200000 \lor \neg \left(a \leq 2.25 \cdot 10^{+62}\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if a < -8.2e6 or 2.24999999999999999e62 < a Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6474.1
Applied rewrites74.1%
if -8.2e6 < a < 2.24999999999999999e62Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6447.6
Applied rewrites47.6%
Final simplification60.5%
(FPCore (x y z t a) :precision binary64 (- t))
double code(double x, double y, double z, double t, double a) {
return -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 = -t
end function
public static double code(double x, double y, double z, double t, double a) {
return -t;
}
def code(x, y, z, t, a): return -t
function code(x, y, z, t, a) return Float64(-t) end
function tmp = code(x, y, z, t, a) tmp = -t; end
code[x_, y_, z_, t_, a_] := (-t)
\begin{array}{l}
\\
-t
\end{array}
Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6436.9
Applied rewrites36.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 2024324
(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))))