
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * log(y)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * log(y)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * log(y)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
Initial program 99.9%
(FPCore (x y z t) :precision binary64 (if (<= (+ (- (- (* x (log y)) y) z) (log t)) 1000.0) (- (log t) y) (- z)))
double code(double x, double y, double z, double t) {
double tmp;
if (((((x * log(y)) - y) - z) + log(t)) <= 1000.0) {
tmp = log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((((x * log(y)) - y) - z) + log(t)) <= 1000.0d0) then
tmp = log(t) - y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((((x * Math.log(y)) - y) - z) + Math.log(t)) <= 1000.0) {
tmp = Math.log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((((x * math.log(y)) - y) - z) + math.log(t)) <= 1000.0: tmp = math.log(t) - y else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) <= 1000.0) tmp = Float64(log(t) - y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((((x * log(y)) - y) - z) + log(t)) <= 1000.0) tmp = log(t) - y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision], 1000.0], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x \cdot \log y - y\right) - z\right) + \log t \leq 1000:\\
\;\;\;\;\log t - y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (+.f64 (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) (log.f64 t)) < 1e3Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6482.9
Applied rewrites82.9%
Taylor expanded in x around 0
Applied rewrites68.0%
if 1e3 < (+.f64 (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) (log.f64 t)) Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6446.2
Applied rewrites46.2%
(FPCore (x y z t) :precision binary64 (if (<= (- (* x (log y)) y) 5e+21) (- (- (log t) y) z) (* (* (/ (log y) y) x) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * log(y)) - y) <= 5e+21) {
tmp = (log(t) - y) - z;
} else {
tmp = ((log(y) / y) * x) * y;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x * log(y)) - y) <= 5d+21) then
tmp = (log(t) - y) - z
else
tmp = ((log(y) / y) * x) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * Math.log(y)) - y) <= 5e+21) {
tmp = (Math.log(t) - y) - z;
} else {
tmp = ((Math.log(y) / y) * x) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x * math.log(y)) - y) <= 5e+21: tmp = (math.log(t) - y) - z else: tmp = ((math.log(y) / y) * x) * y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * log(y)) - y) <= 5e+21) tmp = Float64(Float64(log(t) - y) - z); else tmp = Float64(Float64(Float64(log(y) / y) * x) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x * log(y)) - y) <= 5e+21) tmp = (log(t) - y) - z; else tmp = ((log(y) / y) * x) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], 5e+21], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(N[Log[y], $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot \log y - y \leq 5 \cdot 10^{+21}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\log y}{y} \cdot x\right) \cdot y\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < 5e21Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6486.1
Applied rewrites86.1%
if 5e21 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites59.8%
Taylor expanded in z around inf
Applied rewrites7.9%
Taylor expanded in x around inf
Applied rewrites53.2%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.3e+25) (not (<= x 2.05e+68))) (- (fma (log y) x (log t)) y) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.3e+25) || !(x <= 2.05e+68)) {
tmp = fma(log(y), x, log(t)) - y;
} else {
tmp = (log(t) - y) - z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.3e+25) || !(x <= 2.05e+68)) tmp = Float64(fma(log(y), x, log(t)) - y); else tmp = Float64(Float64(log(t) - y) - z); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.3e+25], N[Not[LessEqual[x, 2.05e+68]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+25} \lor \neg \left(x \leq 2.05 \cdot 10^{+68}\right):\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if x < -1.2999999999999999e25 or 2.05e68 < x Initial program 99.7%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6483.9
Applied rewrites83.9%
if -1.2999999999999999e25 < x < 2.05e68Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6496.9
Applied rewrites96.9%
Final simplification91.6%
(FPCore (x y z t) :precision binary64 (if (<= y 6.7e-6) (- (fma (log y) x (log t)) z) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.7e-6) {
tmp = fma(log(y), x, log(t)) - z;
} else {
tmp = (log(t) - y) - z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.7e-6) tmp = Float64(fma(log(y), x, log(t)) - z); else tmp = Float64(Float64(log(t) - y) - z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.7e-6], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.7 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if y < 6.7e-6Initial program 99.8%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
if 6.7e-6 < y Initial program 99.9%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6484.2
Applied rewrites84.2%
(FPCore (x y z t) :precision binary64 (if (<= y 1.55e-6) (- (log t) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.55e-6) {
tmp = log(t) - z;
} else {
tmp = log(t) - y;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.55d-6) then
tmp = log(t) - z
else
tmp = log(t) - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.55e-6) {
tmp = Math.log(t) - z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.55e-6: tmp = math.log(t) - z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.55e-6) tmp = Float64(log(t) - z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.55e-6) tmp = log(t) - z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.55e-6], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{-6}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if y < 1.55e-6Initial program 99.8%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites63.5%
if 1.55e-6 < y Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6479.3
Applied rewrites79.3%
Taylor expanded in x around 0
Applied rewrites63.6%
(FPCore (x y z t) :precision binary64 (- (- (log t) y) z))
double code(double x, double y, double z, double t) {
return (log(t) - y) - z;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (log(t) - y) - z
end function
public static double code(double x, double y, double z, double t) {
return (Math.log(t) - y) - z;
}
def code(x, y, z, t): return (math.log(t) - y) - z
function code(x, y, z, t) return Float64(Float64(log(t) - y) - z) end
function tmp = code(x, y, z, t) tmp = (log(t) - y) - z; end
code[x_, y_, z_, t_] := N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\log t - y\right) - z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6473.6
Applied rewrites73.6%
(FPCore (x y z t) :precision binary64 (if (<= y 3.5e+33) (- z) (* -1.0 y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+33) {
tmp = -z;
} else {
tmp = -1.0 * y;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 3.5d+33) then
tmp = -z
else
tmp = (-1.0d0) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+33) {
tmp = -z;
} else {
tmp = -1.0 * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.5e+33: tmp = -z else: tmp = -1.0 * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.5e+33) tmp = Float64(-z); else tmp = Float64(-1.0 * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.5e+33) tmp = -z; else tmp = -1.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.5e+33], (-z), N[(-1.0 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+33}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot y\\
\end{array}
\end{array}
if y < 3.5000000000000001e33Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6432.5
Applied rewrites32.5%
if 3.5000000000000001e33 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites67.1%
(FPCore (x y z t) :precision binary64 (- z))
double code(double x, double y, double z, double t) {
return -z;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = -z
end function
public static double code(double x, double y, double z, double t) {
return -z;
}
def code(x, y, z, t): return -z
function code(x, y, z, t) return Float64(-z) end
function tmp = code(x, y, z, t) tmp = -z; end
code[x_, y_, z_, t_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6427.4
Applied rewrites27.4%
herbie shell --seed 2024326
(FPCore (x y z t)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (- (* x (log y)) y) z) (log t)))