
(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)) (log z))))
(if (<= t_1 -750.0)
(- (fma -0.5 (log t) (+ (log y) (log z))) t)
(if (<= t_1 750.0)
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t))
(if (<= t_1 1078.0)
(+ (log y) (- (fma -0.5 (log t) (log z)) t))
(+ (fma (log t) (- a 0.5) (log z)) (log y)))))))
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 <= -750.0) {
tmp = fma(-0.5, log(t), (log(y) + log(z))) - t;
} else if (t_1 <= 750.0) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else if (t_1 <= 1078.0) {
tmp = log(y) + (fma(-0.5, log(t), log(z)) - t);
} else {
tmp = fma(log(t), (a - 0.5), log(z)) + log(y);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_1 <= -750.0) tmp = Float64(fma(-0.5, log(t), Float64(log(y) + log(z))) - t); elseif (t_1 <= 750.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); elseif (t_1 <= 1078.0) tmp = Float64(log(y) + Float64(fma(-0.5, log(t), log(z)) - t)); else tmp = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)); 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, -750.0], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$1, 750.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1078.0], N[(N[Log[y], $MachinePrecision] + N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq -750:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log y + \log z\right) - t\\
\mathbf{elif}\;t\_1 \leq 750:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 1078:\\
\;\;\;\;\log y + \left(\mathsf{fma}\left(-0.5, \log t, \log z\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log z\right) + \log y\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750Initial program 99.8%
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.f6474.8
Applied rewrites74.8%
Taylor expanded in t around inf
Applied rewrites74.8%
Taylor expanded in a around 0
Applied rewrites55.3%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 750Initial 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.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
if 750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 1078Initial program 99.8%
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.f6465.0
Applied rewrites65.0%
Taylor expanded in a around 0
Applied rewrites45.7%
if 1078 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.9%
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.f6480.0
Applied rewrites80.0%
Taylor expanded in t around 0
Applied rewrites70.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z)))
(t_2 (+ (log y) (- (fma -0.5 (log t) (log z)) t))))
(if (<= t_1 -750.0)
t_2
(if (<= t_1 750.0)
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t))
(if (<= t_1 1078.0) t_2 (+ (fma (log t) (- a 0.5) (log z)) (log y)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double t_2 = log(y) + (fma(-0.5, log(t), log(z)) - t);
double tmp;
if (t_1 <= -750.0) {
tmp = t_2;
} else if (t_1 <= 750.0) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else if (t_1 <= 1078.0) {
tmp = t_2;
} else {
tmp = fma(log(t), (a - 0.5), log(z)) + log(y);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) t_2 = Float64(log(y) + Float64(fma(-0.5, log(t), log(z)) - t)) tmp = 0.0 if (t_1 <= -750.0) tmp = t_2; elseif (t_1 <= 750.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); elseif (t_1 <= 1078.0) tmp = t_2; else tmp = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)); 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[Log[y], $MachinePrecision] + N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -750.0], t$95$2, If[LessEqual[t$95$1, 750.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1078.0], t$95$2, N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
t_2 := \log y + \left(\mathsf{fma}\left(-0.5, \log t, \log z\right) - t\right)\\
\mathbf{if}\;t\_1 \leq -750:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 750:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 1078:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log z\right) + \log y\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750 or 750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 1078Initial program 99.8%
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.f6466.8
Applied rewrites66.8%
Taylor expanded in a around 0
Applied rewrites47.4%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 750Initial 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.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
if 1078 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.9%
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.f6480.0
Applied rewrites80.0%
Taylor expanded in t around 0
Applied rewrites70.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z)))
(t_2 (+ (log y) (- (fma -0.5 (log t) (log z)) t))))
(if (<= t_1 -750.0)
t_2
(if (<= t_1 750.0)
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t))
(if (<= t_1 1078.0) t_2 (* (log t) a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double t_2 = log(y) + (fma(-0.5, log(t), log(z)) - t);
double tmp;
if (t_1 <= -750.0) {
tmp = t_2;
} else if (t_1 <= 750.0) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else if (t_1 <= 1078.0) {
tmp = t_2;
} else {
tmp = log(t) * a;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) t_2 = Float64(log(y) + Float64(fma(-0.5, log(t), log(z)) - t)) tmp = 0.0 if (t_1 <= -750.0) tmp = t_2; elseif (t_1 <= 750.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); elseif (t_1 <= 1078.0) tmp = t_2; 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]}, Block[{t$95$2 = N[(N[Log[y], $MachinePrecision] + N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -750.0], t$95$2, If[LessEqual[t$95$1, 750.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1078.0], t$95$2, N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
t_2 := \log y + \left(\mathsf{fma}\left(-0.5, \log t, \log z\right) - t\right)\\
\mathbf{if}\;t\_1 \leq -750:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 750:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 1078:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750 or 750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 1078Initial program 99.8%
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.f6466.8
Applied rewrites66.8%
Taylor expanded in a around 0
Applied rewrites47.4%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 750Initial 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.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
if 1078 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6464.6
Applied rewrites64.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t)))))
(if (<= t_1 -500.0)
(- t)
(if (<= t_1 1050.0)
(fma (log t) -0.5 (log (* (+ x y) z)))
(* (log t) a)))))
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 tmp;
if (t_1 <= -500.0) {
tmp = -t;
} else if (t_1 <= 1050.0) {
tmp = fma(log(t), -0.5, log(((x + y) * z)));
} else {
tmp = log(t) * a;
}
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))) tmp = 0.0 if (t_1 <= -500.0) tmp = Float64(-t); elseif (t_1 <= 1050.0) tmp = fma(log(t), -0.5, log(Float64(Float64(x + y) * z))); else tmp = Float64(log(t) * a); 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]}, If[LessEqual[t$95$1, -500.0], (-t), If[LessEqual[t$95$1, 1050.0], N[(N[Log[t], $MachinePrecision] * -0.5 + N[Log[N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]
\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\\
\mathbf{if}\;t\_1 \leq -500:\\
\;\;\;\;-t\\
\mathbf{elif}\;t\_1 \leq 1050:\\
\;\;\;\;\mathsf{fma}\left(\log t, -0.5, \log \left(\left(x + y\right) \cdot z\right)\right)\\
\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))) < -500Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6463.0
Applied rewrites63.0%
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))) < 1050Initial program 98.9%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites93.0%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6492.2
Applied rewrites92.2%
Taylor expanded in a around 0
Applied rewrites89.3%
if 1050 < (+.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.f6476.6
Applied rewrites76.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 750.0)
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t))
(if (<= t_1 1078.0) (- 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 <= 750.0) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else if (t_1 <= 1078.0) {
tmp = -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 <= 750.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); elseif (t_1 <= 1078.0) tmp = Float64(-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, 750.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1078.0], (-t), 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 750:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 1078:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 750Initial 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-*.f6495.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6495.9
Applied rewrites95.9%
if 750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 1078Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6443.1
Applied rewrites43.1%
if 1078 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6464.6
Applied rewrites64.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 750.0)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(if (<= t_1 1078.0) (- 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 <= 750.0) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else if (t_1 <= 1078.0) {
tmp = -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 <= 750.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); elseif (t_1 <= 1078.0) tmp = Float64(-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, 750.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], If[LessEqual[t$95$1, 1078.0], (-t), 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 750:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{elif}\;t\_1 \leq 1078:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 750Initial 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-*.f6495.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6495.9
Applied rewrites95.9%
if 750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 1078Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6443.1
Applied rewrites43.1%
if 1078 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6464.6
Applied rewrites64.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 750.0)
(fma (- a 0.5) (log t) (- (log (* z y)) t))
(if (<= t_1 1078.0) (- 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 <= 750.0) {
tmp = fma((a - 0.5), log(t), (log((z * y)) - t));
} else if (t_1 <= 1078.0) {
tmp = -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 <= 750.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * y)) - t)); elseif (t_1 <= 1078.0) tmp = Float64(-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, 750.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1078.0], (-t), 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 750:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 1078:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 750Initial 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-*.f6495.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6464.7
Applied rewrites64.7%
if 750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 1078Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6443.1
Applied rewrites43.1%
if 1078 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6464.6
Applied rewrites64.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 750.0)
(- (fma (log t) (- a 0.5) (log (* z y))) t)
(if (<= t_1 1078.0) (- 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 <= 750.0) {
tmp = fma(log(t), (a - 0.5), log((z * y))) - t;
} else if (t_1 <= 1078.0) {
tmp = -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 <= 750.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * y))) - t); elseif (t_1 <= 1078.0) tmp = Float64(-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, 750.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$1, 1078.0], (-t), 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 750:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot y\right)\right) - t\\
\mathbf{elif}\;t\_1 \leq 1078:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 750Initial program 99.6%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites95.8%
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-*.f6464.7
Applied rewrites64.7%
if 750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 1078Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6443.1
Applied rewrites43.1%
if 1078 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6464.6
Applied rewrites64.6%
(FPCore (x y z t a) :precision binary64 (if (<= t 6.2e-14) (fma (log t) (- a 0.5) (log (* z y))) (if (<= t 9.8e+36) (pow (pow (* (log t) a) -1.0) -1.0) (- t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 6.2e-14) {
tmp = fma(log(t), (a - 0.5), log((z * y)));
} else if (t <= 9.8e+36) {
tmp = pow(pow((log(t) * a), -1.0), -1.0);
} else {
tmp = -t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 6.2e-14) tmp = fma(log(t), Float64(a - 0.5), log(Float64(z * y))); elseif (t <= 9.8e+36) tmp = (Float64(log(t) * a) ^ -1.0) ^ -1.0; else tmp = Float64(-t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 6.2e-14], N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 9.8e+36], N[Power[N[Power[N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], -1.0], $MachinePrecision], -1.0], $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 6.2 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot y\right)\right)\\
\mathbf{elif}\;t \leq 9.8 \cdot 10^{+36}:\\
\;\;\;\;{\left({\left(\log t \cdot a\right)}^{-1}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 6.20000000000000009e-14Initial program 99.3%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites80.7%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6480.8
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites52.6%
if 6.20000000000000009e-14 < t < 9.79999999999999962e36Initial program 99.6%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites53.6%
Taylor expanded in a around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6456.3
Applied rewrites56.3%
if 9.79999999999999962e36 < t Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6482.1
Applied rewrites82.1%
Final simplification65.6%
(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.f6469.8
Applied rewrites69.8%
(FPCore (x y z t a) :precision binary64 (if (<= t 9.8e+36) (* (log t) a) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 9.8e+36) {
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 (t <= 9.8d+36) 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 (t <= 9.8e+36) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 9.8e+36: tmp = math.log(t) * a else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 9.8e+36) 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 (t <= 9.8e+36) tmp = log(t) * a; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 9.8e+36], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 9.8 \cdot 10^{+36}:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 9.79999999999999962e36Initial program 99.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6455.2
Applied rewrites55.2%
if 9.79999999999999962e36 < t Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6482.1
Applied rewrites82.1%
(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.f6438.3
Applied rewrites38.3%
(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 2024318
(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))))