
(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 8 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) z))) (if (or (<= t_1 -1e+31) (not (<= t_1 5e-11))) t_1 (- (log t) (+ y z)))))
double code(double x, double y, double z, double t) {
double t_1 = ((x * log(y)) - y) - z;
double tmp;
if ((t_1 <= -1e+31) || !(t_1 <= 5e-11)) {
tmp = t_1;
} 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) - z
if ((t_1 <= (-1d+31)) .or. (.not. (t_1 <= 5d-11))) then
tmp = t_1
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) - z;
double tmp;
if ((t_1 <= -1e+31) || !(t_1 <= 5e-11)) {
tmp = t_1;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): t_1 = ((x * math.log(y)) - y) - z tmp = 0 if (t_1 <= -1e+31) or not (t_1 <= 5e-11): tmp = t_1 else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(x * log(y)) - y) - z) tmp = 0.0 if ((t_1 <= -1e+31) || !(t_1 <= 5e-11)) tmp = t_1; 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) - z; tmp = 0.0; if ((t_1 <= -1e+31) || ~((t_1 <= 5e-11))) tmp = t_1; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+31], N[Not[LessEqual[t$95$1, 5e-11]], $MachinePrecision]], t$95$1, N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \log y - y\right) - z\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+31} \lor \neg \left(t_1 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < -9.9999999999999996e30 or 5.00000000000000018e-11 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) Initial program 99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 99.5%
if -9.9999999999999996e30 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < 5.00000000000000018e-11Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* x (log y)))) (if (<= y 0.096) (- (+ (log t) t_1) z) (- (- t_1 y) z))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if (y <= 0.096) {
tmp = (log(t) + t_1) - z;
} else {
tmp = (t_1 - 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)
if (y <= 0.096d0) then
tmp = (log(t) + t_1) - z
else
tmp = (t_1 - 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);
double tmp;
if (y <= 0.096) {
tmp = (Math.log(t) + t_1) - z;
} else {
tmp = (t_1 - y) - z;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if y <= 0.096: tmp = (math.log(t) + t_1) - z else: tmp = (t_1 - y) - z return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (y <= 0.096) tmp = Float64(Float64(log(t) + t_1) - z); else tmp = Float64(Float64(t_1 - y) - z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if (y <= 0.096) tmp = (log(t) + t_1) - z; else tmp = (t_1 - y) - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 0.096], N[(N[(N[Log[t], $MachinePrecision] + t$95$1), $MachinePrecision] - z), $MachinePrecision], N[(N[(t$95$1 - y), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;y \leq 0.096:\\
\;\;\;\;\left(\log t + t_1\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(t_1 - y\right) - z\\
\end{array}
\end{array}
if y < 0.096000000000000002Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around 0 99.7%
if 0.096000000000000002 < y Initial program 99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 98.6%
Final simplification99.1%
(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 -1.7e+50) (not (<= z 6.8e+55))) (- z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.7e+50) || !(z <= 6.8e+55)) {
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 <= (-1.7d+50)) .or. (.not. (z <= 6.8d+55))) 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 <= -1.7e+50) || !(z <= 6.8e+55)) {
tmp = -z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.7e+50) or not (z <= 6.8e+55): tmp = -z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.7e+50) || !(z <= 6.8e+55)) 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 <= -1.7e+50) || ~((z <= 6.8e+55))) tmp = -z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.7e+50], N[Not[LessEqual[z, 6.8e+55]], $MachinePrecision]], (-z), N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+50} \lor \neg \left(z \leq 6.8 \cdot 10^{+55}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -1.6999999999999999e50 or 6.7999999999999996e55 < z Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 82.3%
Taylor expanded in z around inf 64.0%
neg-mul-164.0%
Simplified64.0%
if -1.6999999999999999e50 < z < 6.7999999999999996e55Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around inf 67.8%
mul-1-neg67.8%
Simplified67.8%
Taylor expanded in y around 0 67.8%
mul-1-neg67.8%
sub-neg67.8%
Simplified67.8%
Final simplification66.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -200.0) (not (<= z 1.04e-16))) (- z) (log t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -200.0) || !(z <= 1.04e-16)) {
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 <= (-200.0d0)) .or. (.not. (z <= 1.04d-16))) 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 <= -200.0) || !(z <= 1.04e-16)) {
tmp = -z;
} else {
tmp = Math.log(t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -200.0) or not (z <= 1.04e-16): tmp = -z else: tmp = math.log(t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -200.0) || !(z <= 1.04e-16)) tmp = Float64(-z); else tmp = log(t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -200.0) || ~((z <= 1.04e-16))) tmp = -z; else tmp = log(t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -200.0], N[Not[LessEqual[z, 1.04e-16]], $MachinePrecision]], (-z), N[Log[t], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -200 \lor \neg \left(z \leq 1.04 \cdot 10^{-16}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\log t\\
\end{array}
\end{array}
if z < -200 or 1.04000000000000001e-16 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around 0 80.5%
Taylor expanded in z around inf 51.8%
neg-mul-151.8%
Simplified51.8%
if -200 < z < 1.04000000000000001e-16Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around inf 67.4%
mul-1-neg67.4%
Simplified67.4%
Taylor expanded in y around 0 31.0%
Final simplification40.7%
(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 73.6%
Final simplification73.6%
(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 x around 0 73.6%
Taylor expanded in z around inf 25.5%
neg-mul-125.5%
Simplified25.5%
Final simplification25.5%
herbie shell --seed 2023315
(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)))