
(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 (+ (fma x (log y) (- (- y) z)) (log t)))
double code(double x, double y, double z, double t) {
return fma(x, log(y), (-y - z)) + log(t);
}
function code(x, y, z, t) return Float64(fma(x, log(y), Float64(Float64(-y) - z)) + log(t)) end
code[x_, y_, z_, t_] := N[(N[(x * N[Log[y], $MachinePrecision] + N[((-y) - z), $MachinePrecision]), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \log y, \left(-y\right) - z\right) + \log t
\end{array}
Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (or (<= t_1 -5000.0) (not (<= t_1 1e-8)))
(- t_1 z)
(- (log (* t (pow y x))) z))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if ((t_1 <= -5000.0) || !(t_1 <= 1e-8)) {
tmp = t_1 - z;
} else {
tmp = log((t * pow(y, x))) - 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) :: t_1
real(8) :: tmp
t_1 = (x * log(y)) - y
if ((t_1 <= (-5000.0d0)) .or. (.not. (t_1 <= 1d-8))) then
tmp = t_1 - z
else
tmp = log((t * (y ** x))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * Math.log(y)) - y;
double tmp;
if ((t_1 <= -5000.0) || !(t_1 <= 1e-8)) {
tmp = t_1 - z;
} else {
tmp = Math.log((t * Math.pow(y, x))) - z;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - y tmp = 0 if (t_1 <= -5000.0) or not (t_1 <= 1e-8): tmp = t_1 - z else: tmp = math.log((t * math.pow(y, x))) - z return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if ((t_1 <= -5000.0) || !(t_1 <= 1e-8)) tmp = Float64(t_1 - z); else tmp = Float64(log(Float64(t * (y ^ x))) - z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * log(y)) - y; tmp = 0.0; if ((t_1 <= -5000.0) || ~((t_1 <= 1e-8))) tmp = t_1 - z; else tmp = log((t * (y ^ x))) - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5000.0], N[Not[LessEqual[t$95$1, 1e-8]], $MachinePrecision]], N[(t$95$1 - z), $MachinePrecision], N[(N[Log[N[(t * N[Power[y, x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t_1 \leq -5000 \lor \neg \left(t_1 \leq 10^{-8}\right):\\
\;\;\;\;t_1 - z\\
\mathbf{else}:\\
\;\;\;\;\log \left(t \cdot {y}^{x}\right) - z\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -5e3 or 1e-8 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in z around inf 99.2%
if -5e3 < (-.f64 (*.f64 x (log.f64 y)) y) < 1e-8Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around 0 99.8%
remove-double-neg99.8%
mul-1-neg99.8%
log-rec99.8%
log-rec99.8%
mul-1-neg99.8%
remove-double-neg99.8%
log-pow99.8%
log-prod99.8%
Simplified99.8%
Final simplification99.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (or (<= t_1 -5e+31) (not (<= t_1 1e-8)))
(- t_1 z)
(- (log t) (+ y z)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if ((t_1 <= -5e+31) || !(t_1 <= 1e-8)) {
tmp = t_1 - z;
} else {
tmp = log(t) - (y + 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) :: t_1
real(8) :: tmp
t_1 = (x * log(y)) - y
if ((t_1 <= (-5d+31)) .or. (.not. (t_1 <= 1d-8))) then
tmp = t_1 - z
else
tmp = log(t) - (y + z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * Math.log(y)) - y;
double tmp;
if ((t_1 <= -5e+31) || !(t_1 <= 1e-8)) {
tmp = t_1 - z;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - y tmp = 0 if (t_1 <= -5e+31) or not (t_1 <= 1e-8): tmp = t_1 - z else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if ((t_1 <= -5e+31) || !(t_1 <= 1e-8)) tmp = Float64(t_1 - z); else tmp = Float64(log(t) - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * log(y)) - y; tmp = 0.0; if ((t_1 <= -5e+31) || ~((t_1 <= 1e-8))) tmp = t_1 - z; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+31], N[Not[LessEqual[t$95$1, 1e-8]], $MachinePrecision]], N[(t$95$1 - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+31} \lor \neg \left(t_1 \leq 10^{-8}\right):\\
\;\;\;\;t_1 - z\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -5.00000000000000027e31 or 1e-8 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in z around inf 99.6%
if -5.00000000000000027e31 < (-.f64 (*.f64 x (log.f64 y)) y) < 1e-8Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 98.4%
Final simplification99.2%
(FPCore (x y z t) :precision binary64 (+ (log t) (- (- (* x (log y)) y) z)))
double code(double x, double y, double z, double t) {
return log(t) + (((x * log(y)) - 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) + (((x * log(y)) - y) - z)
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t) + (((x * Math.log(y)) - y) - z);
}
def code(x, y, z, t): return math.log(t) + (((x * math.log(y)) - y) - z)
function code(x, y, z, t) return Float64(log(t) + Float64(Float64(Float64(x * log(y)) - y) - z)) end
function tmp = code(x, y, z, t) tmp = log(t) + (((x * log(y)) - y) - z); end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] + N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log t + \left(\left(x \cdot \log y - y\right) - z\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.2e+89) (not (<= z 20000000000.0))) (- z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.2e+89) || !(z <= 20000000000.0)) {
tmp = -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 ((z <= (-5.2d+89)) .or. (.not. (z <= 20000000000.0d0))) then
tmp = -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 ((z <= -5.2e+89) || !(z <= 20000000000.0)) {
tmp = -z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.2e+89) or not (z <= 20000000000.0): tmp = -z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.2e+89) || !(z <= 20000000000.0)) tmp = Float64(-z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.2e+89) || ~((z <= 20000000000.0))) tmp = -z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.2e+89], N[Not[LessEqual[z, 20000000000.0]], $MachinePrecision]], (-z), N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+89} \lor \neg \left(z \leq 20000000000\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -5.2000000000000001e89 or 2e10 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in z around inf 60.2%
neg-mul-160.2%
Simplified60.2%
Taylor expanded in z around inf 60.2%
mul-1-neg60.2%
Simplified60.2%
if -5.2000000000000001e89 < z < 2e10Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 96.6%
fma-neg96.6%
Simplified96.6%
Taylor expanded in x around 0 63.2%
Final simplification61.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.5e+18) (not (<= z 1.7e-23))) (- z) (log t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.5e+18) || !(z <= 1.7e-23)) {
tmp = -z;
} else {
tmp = log(t);
}
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 ((z <= (-2.5d+18)) .or. (.not. (z <= 1.7d-23))) then
tmp = -z
else
tmp = log(t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.5e+18) || !(z <= 1.7e-23)) {
tmp = -z;
} else {
tmp = Math.log(t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.5e+18) or not (z <= 1.7e-23): tmp = -z else: tmp = math.log(t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.5e+18) || !(z <= 1.7e-23)) tmp = Float64(-z); else tmp = log(t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.5e+18) || ~((z <= 1.7e-23))) tmp = -z; else tmp = log(t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.5e+18], N[Not[LessEqual[z, 1.7e-23]], $MachinePrecision]], (-z), N[Log[t], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+18} \lor \neg \left(z \leq 1.7 \cdot 10^{-23}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\log t\\
\end{array}
\end{array}
if z < -2.5e18 or 1.7e-23 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in z around inf 54.9%
neg-mul-154.9%
Simplified54.9%
Taylor expanded in z around inf 55.0%
mul-1-neg55.0%
Simplified55.0%
if -2.5e18 < z < 1.7e-23Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 26.7%
neg-mul-126.7%
Simplified26.7%
Taylor expanded in z around 0 25.8%
Final simplification41.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1e+117) (- (log t) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1e+117) {
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 <= 1d+117) 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 <= 1e+117) {
tmp = Math.log(t) - z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1e+117: tmp = math.log(t) - z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1e+117) 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 <= 1e+117) tmp = log(t) - z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1e+117], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+117}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if y < 1.00000000000000005e117Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 55.9%
neg-mul-155.9%
Simplified55.9%
Taylor expanded in z around 0 55.9%
mul-1-neg55.9%
sub-neg55.9%
Simplified55.9%
if 1.00000000000000005e117 < y Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 83.7%
fma-neg83.7%
Simplified83.7%
Taylor expanded in x around 0 71.0%
Final simplification61.4%
(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(log(t) - Float64(y + z)) end
function tmp = code(x, y, z, t) tmp = log(t) - (y + z); end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log t - \left(y + z\right)
\end{array}
Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around 0 71.9%
Final simplification71.9%
(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%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in z around inf 41.4%
neg-mul-141.4%
Simplified41.4%
Taylor expanded in z around inf 29.8%
mul-1-neg29.8%
Simplified29.8%
Final simplification29.8%
herbie shell --seed 2024011
(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)))