
(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 13 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 (log (+ x y)))
(t_2 (+ (- (+ t_1 (log z)) t) (* (- a 0.5) (log t)))))
(if (<= t_2 -1000000.0)
(- (fma (- a 0.5) (log t) (log (* z y))) t)
(if (<= t_2 2000.0) (+ (fma -0.5 (log t) t_1) (log z)) (* (log t) a)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y));
double t_2 = ((t_1 + log(z)) - t) + ((a - 0.5) * log(t));
double tmp;
if (t_2 <= -1000000.0) {
tmp = fma((a - 0.5), log(t), log((z * y))) - t;
} else if (t_2 <= 2000.0) {
tmp = fma(-0.5, log(t), t_1) + log(z);
} else {
tmp = log(t) * a;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = log(Float64(x + y)) t_2 = Float64(Float64(Float64(t_1 + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) tmp = 0.0 if (t_2 <= -1000000.0) tmp = Float64(fma(Float64(a - 0.5), log(t), log(Float64(z * y))) - t); elseif (t_2 <= 2000.0) tmp = Float64(fma(-0.5, log(t), t_1) + log(z)); else tmp = Float64(log(t) * a); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$1 + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1000000.0], N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$2, 2000.0], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + t$95$1), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right)\\
t_2 := \left(\left(t\_1 + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t\\
\mathbf{if}\;t\_2 \leq -1000000:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot y\right)\right) - t\\
\mathbf{elif}\;t\_2 \leq 2000:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, t\_1\right) + \log z\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\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))) < -1e6Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.9
Applied rewrites99.9%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
Applied rewrites74.9%
Taylor expanded in x around 0
lower-log.f64N/A
*-commutativeN/A
lower-*.f6451.3
Applied rewrites51.3%
if -1e6 < (+.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 t around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-log.f6498.8
Applied rewrites98.8%
Taylor expanded in a around 0
Applied rewrites96.8%
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))) Initial program 99.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6498.2
Applied rewrites98.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 -800.0)
(- t)
(if (<= t_1 700.0)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(* (log t) a)))))
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) {
tmp = -t;
} else if (t_1 <= 700.0) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else {
tmp = log(t) * a;
}
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) tmp = Float64(-t); elseif (t_1 <= 700.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); else tmp = Float64(log(t) * a); 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[LessEqual[t$95$1, -800.0], (-t), If[LessEqual[t$95$1, 700.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq -800:\\
\;\;\;\;-t\\
\mathbf{elif}\;t\_1 \leq 700:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -800Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6444.4
Applied rewrites44.4%
if -800 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/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.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
if 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6439.4
Applied rewrites39.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 -800.0)
(- t)
(if (<= t_1 700.0)
(- (fma (- a 0.5) (log t) (log (* z y))) t)
(* (log t) a)))))
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) {
tmp = -t;
} else if (t_1 <= 700.0) {
tmp = fma((a - 0.5), log(t), log((z * y))) - t;
} else {
tmp = log(t) * a;
}
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) tmp = Float64(-t); elseif (t_1 <= 700.0) tmp = Float64(fma(Float64(a - 0.5), log(t), log(Float64(z * y))) - t); else tmp = Float64(log(t) * a); 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[LessEqual[t$95$1, -800.0], (-t), If[LessEqual[t$95$1, 700.0], N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq -800:\\
\;\;\;\;-t\\
\mathbf{elif}\;t\_1 \leq 700:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot y\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -800Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6444.4
Applied rewrites44.4%
if -800 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.6
Applied rewrites99.6%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
lower-log.f64N/A
*-commutativeN/A
lower-*.f6456.5
Applied rewrites56.5%
if 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6439.4
Applied rewrites39.4%
(FPCore (x y z t a)
:precision binary64
(if (<= t 7.5e-6)
(+ (fma (log t) (- a 0.5) (log z)) (log y))
(if (<= t 1.6e+227)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(+ (fma -0.5 (log t) (log y)) (- (log z) t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 7.5e-6) {
tmp = fma(log(t), (a - 0.5), log(z)) + log(y);
} else if (t <= 1.6e+227) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else {
tmp = fma(-0.5, log(t), log(y)) + (log(z) - t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 7.5e-6) tmp = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)); elseif (t <= 1.6e+227) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); else tmp = Float64(fma(-0.5, log(t), log(y)) + Float64(log(z) - t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 7.5e-6], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.6e+227], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 7.5 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log z\right) + \log y\\
\mathbf{elif}\;t \leq 1.6 \cdot 10^{+227}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log y\right) + \left(\log z - t\right)\\
\end{array}
\end{array}
if t < 7.50000000000000019e-6Initial program 99.4%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-log.f6499.2
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites60.4%
if 7.50000000000000019e-6 < t < 1.59999999999999994e227Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6479.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.7
Applied rewrites79.7%
if 1.59999999999999994e227 < t Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6462.9
Applied rewrites62.9%
Taylor expanded in a around 0
Applied rewrites55.8%
(FPCore (x y z t a)
:precision binary64
(if (<= t 7.5e-6)
(+ (fma (log t) (- a 0.5) (log z)) (log y))
(if (<= t 1.6e+227)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(- t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 7.5e-6) {
tmp = fma(log(t), (a - 0.5), log(z)) + log(y);
} else if (t <= 1.6e+227) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else {
tmp = -t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 7.5e-6) tmp = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)); elseif (t <= 1.6e+227) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); else tmp = Float64(-t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 7.5e-6], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.6e+227], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 7.5 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log z\right) + \log y\\
\mathbf{elif}\;t \leq 1.6 \cdot 10^{+227}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 7.50000000000000019e-6Initial program 99.4%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-log.f6499.2
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites60.4%
if 7.50000000000000019e-6 < t < 1.59999999999999994e227Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6479.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.7
Applied rewrites79.7%
if 1.59999999999999994e227 < t Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6492.9
Applied rewrites92.9%
(FPCore (x y z t a) :precision binary64 (+ (fma (log t) (- a 0.5) (log (+ y x))) (- (log z) t)))
double code(double x, double y, double z, double t, double a) {
return fma(log(t), (a - 0.5), log((y + x))) + (log(z) - t);
}
function code(x, y, z, t, a) return Float64(fma(log(t), Float64(a - 0.5), log(Float64(y + x))) + Float64(log(z) - t)) end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log t, a - 0.5, \log \left(y + x\right)\right) + \left(\log z - t\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a) :precision binary64 (- (fma (- a 0.5) (log t) (+ (log y) (log z))) t))
double code(double x, double y, double z, double t, double a) {
return fma((a - 0.5), log(t), (log(y) + log(z))) - t;
}
function code(x, y, z, t, a) return Float64(fma(Float64(a - 0.5), log(t), Float64(log(y) + log(z))) - t) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, \log t, \log y + \log z\right) - t
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.6
Applied rewrites99.6%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
Applied rewrites74.0%
Taylor expanded in y around inf
+-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f6462.7
Applied rewrites62.7%
(FPCore (x y z t a) :precision binary64 (+ (fma (log t) (- a 0.5) (log y)) (- (log z) t)))
double code(double x, double y, double z, double t, double a) {
return fma(log(t), (a - 0.5), log(y)) + (log(z) - t);
}
function code(x, y, z, t, a) return Float64(fma(log(t), Float64(a - 0.5), log(y)) + Float64(log(z) - t)) end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log t, a - 0.5, \log y\right) + \left(\log z - t\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6462.7
Applied rewrites62.7%
(FPCore (x y z t a) :precision binary64 (+ (fma (+ -0.5 a) (log t) (log z)) (- (log y) t)))
double code(double x, double y, double z, double t, double a) {
return fma((-0.5 + a), log(t), log(z)) + (log(y) - t);
}
function code(x, y, z, t, a) return Float64(fma(Float64(-0.5 + a), log(t), log(z)) + Float64(log(y) - t)) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 + a, \log t, \log z\right) + \left(\log y - t\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/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.f6462.7
Applied rewrites62.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= (- a 0.5) -1e+21) (not (<= (- a 0.5) 40000000.0))) (* (log t) a) (- (fma -0.5 (log t) (log (* z y))) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((a - 0.5) <= -1e+21) || !((a - 0.5) <= 40000000.0)) {
tmp = log(t) * a;
} else {
tmp = fma(-0.5, log(t), log((z * y))) - t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(a - 0.5) <= -1e+21) || !(Float64(a - 0.5) <= 40000000.0)) tmp = Float64(log(t) * a); else tmp = Float64(fma(-0.5, log(t), log(Float64(z * y))) - t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(a - 0.5), $MachinePrecision], -1e+21], N[Not[LessEqual[N[(a - 0.5), $MachinePrecision], 40000000.0]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a - 0.5 \leq -1 \cdot 10^{+21} \lor \neg \left(a - 0.5 \leq 40000000\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(z \cdot y\right)\right) - t\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -1e21 or 4e7 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6481.3
Applied rewrites81.3%
if -1e21 < (-.f64 a #s(literal 1/2 binary64)) < 4e7Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.5
Applied rewrites99.5%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
Applied rewrites73.8%
Taylor expanded in x around 0
lower-log.f64N/A
*-commutativeN/A
lower-*.f6441.5
Applied rewrites41.5%
Taylor expanded in a around 0
Applied rewrites40.2%
Final simplification59.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -7e+65) (not (<= a 110000000000.0))) (* (log t) a) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -7e+65) || !(a <= 110000000000.0)) {
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 <= (-7d+65)) .or. (.not. (a <= 110000000000.0d0))) 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 <= -7e+65) || !(a <= 110000000000.0)) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (a <= -7e+65) or not (a <= 110000000000.0): tmp = math.log(t) * a else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -7e+65) || !(a <= 110000000000.0)) 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 <= -7e+65) || ~((a <= 110000000000.0))) tmp = log(t) * a; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -7e+65], N[Not[LessEqual[a, 110000000000.0]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{+65} \lor \neg \left(a \leq 110000000000\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if a < -7.0000000000000002e65 or 1.1e11 < a Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.9
Applied rewrites83.9%
if -7.0000000000000002e65 < a < 1.1e11Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6448.9
Applied rewrites48.9%
Final simplification63.9%
(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.f6435.4
Applied rewrites35.4%
(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 2024329
(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))))