
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
double code(double x, double y, double z, double t, double a) {
return ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((log((x + y)) + log(z)) - t) + ((a - 0.5d0) * log(t))
end function
public static double code(double x, double y, double z, double t, double a) {
return ((Math.log((x + y)) + Math.log(z)) - t) + ((a - 0.5) * Math.log(t));
}
def code(x, y, z, t, a): return ((math.log((x + y)) + math.log(z)) - t) + ((a - 0.5) * math.log(t))
function code(x, y, z, t, a) return Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) end
function tmp = code(x, y, z, t, a) tmp = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t)); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (+ (- (+ (log y) (log z)) t) (* (- a 0.5) (log t))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return ((log(y) + log(z)) - t) + ((a - 0.5) * log(t));
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((log(y) + log(z)) - t) + ((a - 0.5d0) * log(t))
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return ((Math.log(y) + Math.log(z)) - t) + ((a - 0.5) * Math.log(t));
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return ((math.log(y) + math.log(z)) - t) + ((a - 0.5) * math.log(t))
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(Float64(log(y) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = ((log(y) + log(z)) - t) + ((a - 0.5) * log(t));
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[y], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\left(\left(\log y + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
lower-log.f6466.5
Applied rewrites66.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t)))))
(if (<= t_1 -200000.0)
(* (fma (* (- (log t)) (/ (- a 0.5) t)) -1.0 -1.0) t)
(if (<= t_1 1100.0)
(- (fma -0.5 (log t) (log (* y z))) t)
(* (log t) a)))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
double tmp;
if (t_1 <= -200000.0) {
tmp = fma((-log(t) * ((a - 0.5) / t)), -1.0, -1.0) * t;
} else if (t_1 <= 1100.0) {
tmp = fma(-0.5, log(t), log((y * z))) - t;
} else {
tmp = log(t) * a;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) 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 <= -200000.0) tmp = Float64(fma(Float64(Float64(-log(t)) * Float64(Float64(a - 0.5) / t)), -1.0, -1.0) * t); elseif (t_1 <= 1100.0) tmp = Float64(fma(-0.5, log(t), log(Float64(y * z))) - t); else tmp = Float64(log(t) * a); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(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, -200000.0], N[(N[(N[((-N[Log[t], $MachinePrecision]) * N[(N[(a - 0.5), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * -1.0 + -1.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$1, 1100.0], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\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 -200000:\\
\;\;\;\;\mathsf{fma}\left(\left(-\log t\right) \cdot \frac{a - 0.5}{t}, -1, -1\right) \cdot t\\
\mathbf{elif}\;t\_1 \leq 1100:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(y \cdot z\right)\right) - t\\
\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))) < -2e5Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6467.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f6467.0
Applied rewrites67.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.7%
Taylor expanded in t around inf
Applied rewrites90.3%
if -2e5 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 1100Initial program 99.1%
Taylor expanded in x around 0
lower-log.f6450.1
Applied rewrites50.1%
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.f6450.0
Applied rewrites50.0%
Taylor expanded in a around 0
Applied rewrites49.9%
Applied rewrites44.5%
if 1100 < (+.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.f6484.2
Applied rewrites84.2%
Final simplification79.0%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t)))))
(if (<= t_1 -200000.0)
(* (fma (* (- (log t)) (/ (- a 0.5) t)) -1.0 -1.0) t)
(if (<= t_1 700.0) (- (log (* (pow t -0.5) (* y z))) t) (* (log t) a)))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
double tmp;
if (t_1 <= -200000.0) {
tmp = fma((-log(t) * ((a - 0.5) / t)), -1.0, -1.0) * t;
} else if (t_1 <= 700.0) {
tmp = log((pow(t, -0.5) * (y * z))) - t;
} else {
tmp = log(t) * a;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) 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 <= -200000.0) tmp = Float64(fma(Float64(Float64(-log(t)) * Float64(Float64(a - 0.5) / t)), -1.0, -1.0) * t); elseif (t_1 <= 700.0) tmp = Float64(log(Float64((t ^ -0.5) * Float64(y * z))) - t); else tmp = Float64(log(t) * a); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(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, -200000.0], N[(N[(N[((-N[Log[t], $MachinePrecision]) * N[(N[(a - 0.5), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * -1.0 + -1.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$1, 700.0], N[(N[Log[N[(N[Power[t, -0.5], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\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 -200000:\\
\;\;\;\;\mathsf{fma}\left(\left(-\log t\right) \cdot \frac{a - 0.5}{t}, -1, -1\right) \cdot t\\
\mathbf{elif}\;t\_1 \leq 700:\\
\;\;\;\;\log \left({t}^{-0.5} \cdot \left(y \cdot z\right)\right) - t\\
\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))) < -2e5Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6467.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f6467.0
Applied rewrites67.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.7%
Taylor expanded in t around inf
Applied rewrites90.3%
if -2e5 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 700Initial program 99.1%
Taylor expanded in x around 0
lower-log.f6452.0
Applied rewrites52.0%
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.f6451.7
Applied rewrites51.7%
Taylor expanded in a around 0
Applied rewrites51.7%
Applied rewrites51.6%
if 700 < (+.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.f6472.2
Applied rewrites72.2%
Final simplification78.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (or (<= t_1 -750.0) (not (<= t_1 640.0)))
(* (fma (* (- (log t)) (/ (- a 0.5) t)) -1.0 -1.0) t)
(fma (- a 0.5) (log t) (- (log (* z y)) t)))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double tmp;
if ((t_1 <= -750.0) || !(t_1 <= 640.0)) {
tmp = fma((-log(t) * ((a - 0.5) / t)), -1.0, -1.0) * t;
} else {
tmp = fma((a - 0.5), log(t), (log((z * y)) - t));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if ((t_1 <= -750.0) || !(t_1 <= 640.0)) tmp = Float64(fma(Float64(Float64(-log(t)) * Float64(Float64(a - 0.5) / t)), -1.0, -1.0) * t); else tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * y)) - t)); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -750.0], N[Not[LessEqual[t$95$1, 640.0]], $MachinePrecision]], N[(N[(N[((-N[Log[t], $MachinePrecision]) * N[(N[(a - 0.5), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * -1.0 + -1.0), $MachinePrecision] * t), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq -750 \lor \neg \left(t\_1 \leq 640\right):\\
\;\;\;\;\mathsf{fma}\left(\left(-\log t\right) \cdot \frac{a - 0.5}{t}, -1, -1\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot y\right) - t\right)\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750 or 640 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6478.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f6478.0
Applied rewrites78.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.9%
Taylor expanded in t around inf
Applied rewrites74.5%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 640Initial program 99.5%
lift-*.f64N/A
lift--.f64N/A
flip3--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-eval62.7
Applied rewrites62.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift--.f64N/A
lift-pow.f64N/A
metadata-evalN/A
lift-fma.f64N/A
lift-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
*-commutativeN/A
flip3--N/A
lift--.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6464.0
Applied rewrites64.0%
Final simplification66.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= t 155.0) (+ (fma (log t) (- a 0.5) (log z)) (log y)) (* (fma (* (- (log t)) (/ (- a 0.5) t)) -1.0 -1.0) t)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 155.0) {
tmp = fma(log(t), (a - 0.5), log(z)) + log(y);
} else {
tmp = fma((-log(t) * ((a - 0.5) / t)), -1.0, -1.0) * t;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (t <= 155.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)); else tmp = Float64(fma(Float64(Float64(-log(t)) * Float64(Float64(a - 0.5) / t)), -1.0, -1.0) * t); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[t, 155.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision], N[(N[(N[((-N[Log[t], $MachinePrecision]) * N[(N[(a - 0.5), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * -1.0 + -1.0), $MachinePrecision] * t), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 155:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log z\right) + \log y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-\log t\right) \cdot \frac{a - 0.5}{t}, -1, -1\right) \cdot t\\
\end{array}
\end{array}
if t < 155Initial 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.f6498.4
Applied rewrites98.4%
Taylor expanded in x around 0
Applied rewrites58.9%
if 155 < t Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6457.1
lift-+.f64N/A
+-commutativeN/A
lower-+.f6457.1
Applied rewrites57.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in t around inf
Applied rewrites98.4%
Final simplification77.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (+ (fma (+ -0.5 a) (log t) (log z)) (- (log y) t)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return fma((-0.5 + a), log(t), log(z)) + (log(y) - t);
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(fma(Float64(-0.5 + a), log(t), log(z)) + Float64(log(y) - t)) end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(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}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\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.f6466.5
Applied rewrites66.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= t 2.8e-33) (fma (+ -0.5 a) (log t) (log (* (+ y x) z))) (* (fma (* (- (log t)) (/ (- a 0.5) t)) -1.0 -1.0) t)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 2.8e-33) {
tmp = fma((-0.5 + a), log(t), log(((y + x) * z)));
} else {
tmp = fma((-log(t) * ((a - 0.5) / t)), -1.0, -1.0) * t;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (t <= 2.8e-33) tmp = fma(Float64(-0.5 + a), log(t), log(Float64(Float64(y + x) * z))); else tmp = Float64(fma(Float64(Float64(-log(t)) * Float64(Float64(a - 0.5) / t)), -1.0, -1.0) * t); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[t, 2.8e-33], N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[((-N[Log[t], $MachinePrecision]) * N[(N[(a - 0.5), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * -1.0 + -1.0), $MachinePrecision] * t), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 2.8 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, \log t, \log \left(\left(y + x\right) \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-\log t\right) \cdot \frac{a - 0.5}{t}, -1, -1\right) \cdot t\\
\end{array}
\end{array}
if t < 2.8e-33Initial program 99.3%
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%
Applied rewrites78.6%
if 2.8e-33 < t Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6461.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6461.9
Applied rewrites61.9%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in t around inf
Applied rewrites95.7%
Final simplification87.6%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= t 2.15e-49) (* (log t) a) (* (fma (* (- (log t)) (/ (- a 0.5) t)) -1.0 -1.0) t)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 2.15e-49) {
tmp = log(t) * a;
} else {
tmp = fma((-log(t) * ((a - 0.5) / t)), -1.0, -1.0) * t;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (t <= 2.15e-49) tmp = Float64(log(t) * a); else tmp = Float64(fma(Float64(Float64(-log(t)) * Float64(Float64(a - 0.5) / t)), -1.0, -1.0) * t); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[t, 2.15e-49], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], N[(N[(N[((-N[Log[t], $MachinePrecision]) * N[(N[(a - 0.5), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * -1.0 + -1.0), $MachinePrecision] * t), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 2.15 \cdot 10^{-49}:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-\log t\right) \cdot \frac{a - 0.5}{t}, -1, -1\right) \cdot t\\
\end{array}
\end{array}
if t < 2.15000000000000008e-49Initial program 99.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6453.6
Applied rewrites53.6%
if 2.15000000000000008e-49 < t Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6463.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6463.7
Applied rewrites63.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in t around inf
Applied rewrites92.9%
Final simplification75.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= a -6.5e+27) (not (<= a 6e+47))) (* (log t) a) (- t)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -6.5e+27) || !(a <= 6e+47)) {
tmp = log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((a <= (-6.5d+27)) .or. (.not. (a <= 6d+47))) then
tmp = log(t) * a
else
tmp = -t
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -6.5e+27) || !(a <= 6e+47)) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (a <= -6.5e+27) or not (a <= 6e+47): tmp = math.log(t) * a else: tmp = -t return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if ((a <= -6.5e+27) || !(a <= 6e+47)) tmp = Float64(log(t) * a); else tmp = Float64(-t); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((a <= -6.5e+27) || ~((a <= 6e+47)))
tmp = log(t) * a;
else
tmp = -t;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -6.5e+27], N[Not[LessEqual[a, 6e+47]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.5 \cdot 10^{+27} \lor \neg \left(a \leq 6 \cdot 10^{+47}\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if a < -6.5000000000000005e27 or 6.0000000000000003e47 < a Initial program 99.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.9
Applied rewrites83.9%
if -6.5000000000000005e27 < a < 6.0000000000000003e47Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6452.1
Applied rewrites52.1%
Final simplification65.9%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (- t))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return -t;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = -t
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return -t;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return -t
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(-t) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = -t;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := (-t)
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
-t
\end{array}
Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6436.1
Applied rewrites36.1%
(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 2024326
(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))))