
(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)) (fma (log t) (- a 0.5) (- (log z) t))))
double code(double x, double y, double z, double t, double a) {
return log((x + y)) + fma(log(t), (a - 0.5), (log(z) - t));
}
function code(x, y, z, t, a) return Float64(log(Float64(x + y)) + fma(log(t), Float64(a - 0.5), Float64(log(z) - t))) end
code[x_, y_, z_, t_, a_] := N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(x + y\right) + \mathsf{fma}\left(\log t, a - 0.5, \log z - t\right)
\end{array}
Initial program 99.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6499.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
(t_2 (* a (log t))))
(if (<= t_1 -2e+182)
(- t)
(if (<= t_1 -4e+135)
t_2
(if (<= t_1 -500.0)
(- t)
(if (<= t_1 950.0) (fma (log t) -0.5 (log (* (+ x y) z))) t_2))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
double t_2 = a * log(t);
double tmp;
if (t_1 <= -2e+182) {
tmp = -t;
} else if (t_1 <= -4e+135) {
tmp = t_2;
} else if (t_1 <= -500.0) {
tmp = -t;
} else if (t_1 <= 950.0) {
tmp = fma(log(t), -0.5, log(((x + y) * z)));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) t_2 = Float64(a * log(t)) tmp = 0.0 if (t_1 <= -2e+182) tmp = Float64(-t); elseif (t_1 <= -4e+135) tmp = t_2; elseif (t_1 <= -500.0) tmp = Float64(-t); elseif (t_1 <= 950.0) tmp = fma(log(t), -0.5, log(Float64(Float64(x + y) * z))); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = 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]}, Block[{t$95$2 = N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+182], (-t), If[LessEqual[t$95$1, -4e+135], t$95$2, If[LessEqual[t$95$1, -500.0], (-t), If[LessEqual[t$95$1, 950.0], N[(N[Log[t], $MachinePrecision] * -0.5 + N[Log[N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t\\
t_2 := a \cdot \log t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+182}:\\
\;\;\;\;-t\\
\mathbf{elif}\;t\_1 \leq -4 \cdot 10^{+135}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -500:\\
\;\;\;\;-t\\
\mathbf{elif}\;t\_1 \leq 950:\\
\;\;\;\;\mathsf{fma}\left(\log t, -0.5, \log \left(\left(x + y\right) \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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))) < -2.0000000000000001e182 or -3.99999999999999985e135 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < -500Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6466.7
Applied rewrites66.7%
if -2.0000000000000001e182 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < -3.99999999999999985e135 or 950 < (+.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.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6479.3
Applied rewrites79.3%
if -500 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 950Initial program 98.3%
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.f6495.3
Applied rewrites95.3%
Taylor expanded in t around 0
Applied rewrites93.8%
Applied rewrites92.5%
Final simplification75.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z)))
(t_2 (- (fma -0.5 (log t) (log y)) (- t (log z)))))
(if (<= t_1 -800.0)
t_2
(if (<= t_1 720.0)
(- (fma (log t) (- a 0.5) (log (* (+ x y) z))) t)
t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double t_2 = fma(-0.5, log(t), log(y)) - (t - log(z));
double tmp;
if (t_1 <= -800.0) {
tmp = t_2;
} else if (t_1 <= 720.0) {
tmp = fma(log(t), (a - 0.5), log(((x + y) * z))) - t;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) t_2 = Float64(fma(-0.5, log(t), log(y)) - Float64(t - log(z))) tmp = 0.0 if (t_1 <= -800.0) tmp = t_2; elseif (t_1 <= 720.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(Float64(x + y) * z))) - t); else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - N[(t - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -800.0], t$95$2, If[LessEqual[t$95$1, 720.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
t_2 := \mathsf{fma}\left(-0.5, \log t, \log y\right) - \left(t - \log z\right)\\
\mathbf{if}\;t\_1 \leq -800:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 720:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(\left(x + y\right) \cdot z\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -800 or 720 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
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.f6458.1
Applied rewrites58.1%
Taylor expanded in x around 0
Applied rewrites46.6%
if -800 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 720Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.4
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6498.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
Final simplification88.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* a (log t))) (t_2 (+ (log (+ x y)) (log z))))
(if (<= t_2 -700.0)
(/ 1.0 (/ 1.0 t_1))
(if (<= t_2 700.0)
(- (fma (log t) (- a 0.5) (log (* (+ x y) z))) t)
t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = a * log(t);
double t_2 = log((x + y)) + log(z);
double tmp;
if (t_2 <= -700.0) {
tmp = 1.0 / (1.0 / t_1);
} else if (t_2 <= 700.0) {
tmp = fma(log(t), (a - 0.5), log(((x + y) * z))) - t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(a * log(t)) t_2 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_2 <= -700.0) tmp = Float64(1.0 / Float64(1.0 / t_1)); elseif (t_2 <= 700.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(Float64(x + y) * z))) - t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -700.0], N[(1.0 / N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 700.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \log t\\
t_2 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_2 \leq -700:\\
\;\;\;\;\frac{1}{\frac{1}{t\_1}}\\
\mathbf{elif}\;t\_2 \leq 700:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(\left(x + y\right) \cdot z\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -700Initial program 99.2%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites12.6%
Taylor expanded in a around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6452.6
Applied rewrites52.6%
if -700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.4
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
if 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6444.2
Applied rewrites44.2%
Final simplification88.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* a (log t))) (t_2 (+ (log (+ x y)) (log z))))
(if (<= t_2 -700.0)
(/ 1.0 (/ 1.0 t_1))
(if (<= t_2 700.0) (- (fma (log t) (- a 0.5) (log (* y z))) t) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = a * log(t);
double t_2 = log((x + y)) + log(z);
double tmp;
if (t_2 <= -700.0) {
tmp = 1.0 / (1.0 / t_1);
} else if (t_2 <= 700.0) {
tmp = fma(log(t), (a - 0.5), log((y * z))) - t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(a * log(t)) t_2 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_2 <= -700.0) tmp = Float64(1.0 / Float64(1.0 / t_1)); elseif (t_2 <= 700.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(y * z))) - t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -700.0], N[(1.0 / N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 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$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \log t\\
t_2 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_2 \leq -700:\\
\;\;\;\;\frac{1}{\frac{1}{t\_1}}\\
\mathbf{elif}\;t\_2 \leq 700:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(y \cdot z\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -700Initial program 99.2%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites12.6%
Taylor expanded in a around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6452.6
Applied rewrites52.6%
if -700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.4%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites99.5%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6465.8
Applied rewrites65.8%
if 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6444.2
Applied rewrites44.2%
Final simplification61.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (log (+ x y))))
(if (<= t 240000.0)
(+ (fma (- a 0.5) (log t) t_1) (log z))
(- (fma -0.5 (log t) t_1) (- t (log z))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y));
double tmp;
if (t <= 240000.0) {
tmp = fma((a - 0.5), log(t), t_1) + log(z);
} else {
tmp = fma(-0.5, log(t), t_1) - (t - log(z));
}
return tmp;
}
function code(x, y, z, t, a) t_1 = log(Float64(x + y)) tmp = 0.0 if (t <= 240000.0) tmp = Float64(fma(Float64(a - 0.5), log(t), t_1) + log(z)); else tmp = Float64(fma(-0.5, log(t), t_1) - Float64(t - log(z))); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, 240000.0], N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + t$95$1), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + t$95$1), $MachinePrecision] - N[(t - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right)\\
\mathbf{if}\;t \leq 240000:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, t\_1\right) + \log z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, t\_1\right) - \left(t - \log z\right)\\
\end{array}
\end{array}
if t < 2.4e5Initial program 99.1%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/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.1
Applied rewrites98.1%
if 2.4e5 < t Initial program 99.8%
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.f6483.1
Applied rewrites83.1%
Final simplification91.5%
(FPCore (x y z t a) :precision binary64 (if (<= t 240000.0) (+ (fma (- a 0.5) (log t) (log (+ x y))) (log z)) (- (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 (t <= 240000.0) {
tmp = fma((a - 0.5), log(t), log((x + y))) + log(z);
} 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 (t <= 240000.0) tmp = Float64(fma(Float64(a - 0.5), log(t), log(Float64(x + y))) + log(z)); 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[LessEqual[t, 240000.0], N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[Log[z], $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}\;t \leq 240000:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(x + y\right)\right) + \log z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log y\right) - \left(t - \log z\right)\\
\end{array}
\end{array}
if t < 2.4e5Initial program 99.1%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/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.1
Applied rewrites98.1%
if 2.4e5 < t Initial program 99.8%
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.f6483.1
Applied rewrites83.1%
Taylor expanded in x around 0
Applied rewrites65.4%
Final simplification83.7%
(FPCore (x y z t a) :precision binary64 (+ (* (- a 0.5) (log t)) (- (+ (log y) (log z)) t)))
double code(double x, double y, double z, double t, double a) {
return ((a - 0.5) * log(t)) + ((log(y) + log(z)) - 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 = ((a - 0.5d0) * log(t)) + ((log(y) + log(z)) - t)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((a - 0.5) * Math.log(t)) + ((Math.log(y) + Math.log(z)) - t);
}
def code(x, y, z, t, a): return ((a - 0.5) * math.log(t)) + ((math.log(y) + math.log(z)) - t)
function code(x, y, z, t, a) return Float64(Float64(Float64(a - 0.5) * log(t)) + Float64(Float64(log(y) + log(z)) - t)) end
function tmp = code(x, y, z, t, a) tmp = ((a - 0.5) * log(t)) + ((log(y) + log(z)) - t); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Log[y], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a - 0.5\right) \cdot \log t + \left(\left(\log y + \log z\right) - t\right)
\end{array}
Initial program 99.4%
Taylor expanded in x around 0
lower-log.f6472.1
Applied rewrites72.1%
Final simplification72.1%
(FPCore (x y z t a) :precision binary64 (- (+ (fma (log t) (- a 0.5) (log z)) (log y)) t))
double code(double x, double y, double z, double t, double a) {
return (fma(log(t), (a - 0.5), log(z)) + log(y)) - t;
}
function code(x, y, z, t, a) return Float64(Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)) - t) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\log t, a - 0.5, \log z\right) + \log y\right) - t
\end{array}
Initial program 99.4%
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.4
Applied rewrites99.4%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f6472.1
Applied rewrites72.1%
(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.4%
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.f6472.1
Applied rewrites72.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* a (log t))))
(if (<= (- a 0.5) -2e+50)
t_1
(if (<= (- a 0.5) 4e+17)
(- (fma -0.5 (log t) (log (* (+ x y) z))) t)
t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = a * log(t);
double tmp;
if ((a - 0.5) <= -2e+50) {
tmp = t_1;
} else if ((a - 0.5) <= 4e+17) {
tmp = fma(-0.5, log(t), log(((x + y) * z))) - t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(a * log(t)) tmp = 0.0 if (Float64(a - 0.5) <= -2e+50) tmp = t_1; elseif (Float64(a - 0.5) <= 4e+17) tmp = Float64(fma(-0.5, log(t), log(Float64(Float64(x + y) * z))) - t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a - 0.5), $MachinePrecision], -2e+50], t$95$1, If[LessEqual[N[(a - 0.5), $MachinePrecision], 4e+17], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \log t\\
\mathbf{if}\;a - 0.5 \leq -2 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a - 0.5 \leq 4 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(\left(x + y\right) \cdot z\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -2.0000000000000002e50 or 4e17 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6480.5
Applied rewrites80.5%
if -2.0000000000000002e50 < (-.f64 a #s(literal 1/2 binary64)) < 4e17Initial program 99.2%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites81.6%
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-+.f6478.0
Applied rewrites78.0%
Final simplification79.1%
(FPCore (x y z t a) :precision binary64 (if (<= t 56000000.0) (* a (log t)) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 56000000.0) {
tmp = a * log(t);
} 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 (t <= 56000000.0d0) then
tmp = a * log(t)
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 (t <= 56000000.0) {
tmp = a * Math.log(t);
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 56000000.0: tmp = a * math.log(t) else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 56000000.0) tmp = Float64(a * log(t)); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= 56000000.0) tmp = a * log(t); else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 56000000.0], N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 56000000:\\
\;\;\;\;a \cdot \log t\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 5.6e7Initial program 99.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6455.6
Applied rewrites55.6%
if 5.6e7 < t Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6482.3
Applied rewrites82.3%
Final simplification67.4%
(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.4%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6437.9
Applied rewrites37.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 2024332
(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))))