
(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 (or (<= z -2.65e+47) (not (<= z 1.25e+149))) (- (log t) (+ y z)) (- (+ (* x (log y)) (log t)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.65e+47) || !(z <= 1.25e+149)) {
tmp = log(t) - (y + z);
} else {
tmp = ((x * log(y)) + 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 <= (-2.65d+47)) .or. (.not. (z <= 1.25d+149))) then
tmp = log(t) - (y + z)
else
tmp = ((x * log(y)) + 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 <= -2.65e+47) || !(z <= 1.25e+149)) {
tmp = Math.log(t) - (y + z);
} else {
tmp = ((x * Math.log(y)) + Math.log(t)) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.65e+47) or not (z <= 1.25e+149): tmp = math.log(t) - (y + z) else: tmp = ((x * math.log(y)) + math.log(t)) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.65e+47) || !(z <= 1.25e+149)) tmp = Float64(log(t) - Float64(y + z)); else tmp = Float64(Float64(Float64(x * log(y)) + log(t)) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.65e+47) || ~((z <= 1.25e+149))) tmp = log(t) - (y + z); else tmp = ((x * log(y)) + log(t)) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.65e+47], N[Not[LessEqual[z, 1.25e+149]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.65 \cdot 10^{+47} \lor \neg \left(z \leq 1.25 \cdot 10^{+149}\right):\\
\;\;\;\;\log t - \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log y + \log t\right) - y\\
\end{array}
\end{array}
if z < -2.65e47 or 1.24999999999999998e149 < z Initial program 100.0%
Taylor expanded in x around 0 89.1%
if -2.65e47 < z < 1.24999999999999998e149Initial program 99.8%
Taylor expanded in z around 0 96.0%
Final simplification93.6%
(FPCore (x y z t) :precision binary64 (if (or (<= x -5.2e+200) (not (<= x 1.85e+157))) (+ (* x (log y)) (log t)) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -5.2e+200) || !(x <= 1.85e+157)) {
tmp = (x * log(y)) + log(t);
} 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) :: tmp
if ((x <= (-5.2d+200)) .or. (.not. (x <= 1.85d+157))) then
tmp = (x * log(y)) + log(t)
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 tmp;
if ((x <= -5.2e+200) || !(x <= 1.85e+157)) {
tmp = (x * Math.log(y)) + Math.log(t);
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -5.2e+200) or not (x <= 1.85e+157): tmp = (x * math.log(y)) + math.log(t) else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -5.2e+200) || !(x <= 1.85e+157)) tmp = Float64(Float64(x * log(y)) + log(t)); else tmp = Float64(log(t) - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -5.2e+200) || ~((x <= 1.85e+157))) tmp = (x * log(y)) + log(t); else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -5.2e+200], N[Not[LessEqual[x, 1.85e+157]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+200} \lor \neg \left(x \leq 1.85 \cdot 10^{+157}\right):\\
\;\;\;\;x \cdot \log y + \log t\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -5.2000000000000003e200 or 1.8499999999999999e157 < x Initial program 99.6%
Taylor expanded in y around inf 59.3%
associate--r+59.3%
mul-1-neg59.3%
log-rec59.3%
mul-1-neg59.3%
associate-/l*59.3%
distribute-rgt-neg-in59.3%
fma-neg59.3%
mul-1-neg59.3%
distribute-frac-neg59.3%
remove-double-neg59.3%
metadata-eval59.3%
Simplified59.3%
Taylor expanded in z around -inf 45.0%
Taylor expanded in x around inf 80.1%
if -5.2000000000000003e200 < x < 1.8499999999999999e157Initial program 99.9%
Taylor expanded in x around 0 88.3%
Final simplification86.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.9e+27) (- (+ (* x (log y)) (log t)) z) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.9e+27) {
tmp = ((x * log(y)) + log(t)) - 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) :: tmp
if (y <= 1.9d+27) then
tmp = ((x * log(y)) + log(t)) - 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 tmp;
if (y <= 1.9e+27) {
tmp = ((x * Math.log(y)) + Math.log(t)) - z;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.9e+27: tmp = ((x * math.log(y)) + math.log(t)) - z else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.9e+27) tmp = Float64(Float64(Float64(x * log(y)) + log(t)) - z); else tmp = Float64(log(t) - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.9e+27) tmp = ((x * log(y)) + log(t)) - z; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.9e+27], N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+27}:\\
\;\;\;\;\left(x \cdot \log y + \log t\right) - z\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if y < 1.90000000000000011e27Initial program 99.8%
Taylor expanded in y around 0 99.2%
if 1.90000000000000011e27 < y Initial program 99.9%
Taylor expanded in x around 0 84.5%
Final simplification92.1%
(FPCore (x y z t)
:precision binary64
(if (<= y 3.3e-298)
(log t)
(if (<= y 2.5e-95)
(- z)
(if (<= y 1.8e-46) (log t) (if (<= y 5.2e+44) (- z) (- y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.3e-298) {
tmp = log(t);
} else if (y <= 2.5e-95) {
tmp = -z;
} else if (y <= 1.8e-46) {
tmp = log(t);
} else if (y <= 5.2e+44) {
tmp = -z;
} else {
tmp = -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.3d-298) then
tmp = log(t)
else if (y <= 2.5d-95) then
tmp = -z
else if (y <= 1.8d-46) then
tmp = log(t)
else if (y <= 5.2d+44) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.3e-298) {
tmp = Math.log(t);
} else if (y <= 2.5e-95) {
tmp = -z;
} else if (y <= 1.8e-46) {
tmp = Math.log(t);
} else if (y <= 5.2e+44) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.3e-298: tmp = math.log(t) elif y <= 2.5e-95: tmp = -z elif y <= 1.8e-46: tmp = math.log(t) elif y <= 5.2e+44: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.3e-298) tmp = log(t); elseif (y <= 2.5e-95) tmp = Float64(-z); elseif (y <= 1.8e-46) tmp = log(t); elseif (y <= 5.2e+44) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.3e-298) tmp = log(t); elseif (y <= 2.5e-95) tmp = -z; elseif (y <= 1.8e-46) tmp = log(t); elseif (y <= 5.2e+44) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.3e-298], N[Log[t], $MachinePrecision], If[LessEqual[y, 2.5e-95], (-z), If[LessEqual[y, 1.8e-46], N[Log[t], $MachinePrecision], If[LessEqual[y, 5.2e+44], (-z), (-y)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{-298}:\\
\;\;\;\;\log t\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-95}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-46}:\\
\;\;\;\;\log t\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+44}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 3.3000000000000002e-298 or 2.4999999999999999e-95 < y < 1.8e-46Initial program 99.9%
Taylor expanded in y around inf 90.8%
associate--r+90.8%
mul-1-neg90.8%
log-rec90.8%
mul-1-neg90.8%
associate-/l*90.8%
distribute-rgt-neg-in90.8%
fma-neg90.8%
mul-1-neg90.8%
distribute-frac-neg90.8%
remove-double-neg90.8%
metadata-eval90.8%
Simplified90.8%
Taylor expanded in x around inf 91.2%
associate-*r/91.2%
Simplified91.2%
Taylor expanded in x around 0 62.7%
if 3.3000000000000002e-298 < y < 2.4999999999999999e-95 or 1.8e-46 < y < 5.1999999999999998e44Initial program 99.8%
Taylor expanded in z around inf 43.8%
neg-mul-143.8%
Simplified43.8%
if 5.1999999999999998e44 < y Initial program 99.9%
Taylor expanded in y around inf 70.4%
neg-mul-170.4%
Simplified70.4%
(FPCore (x y z t) :precision binary64 (if (<= y 6e+44) (- (log t) z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6e+44) {
tmp = log(t) - z;
} else {
tmp = -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 <= 6d+44) then
tmp = log(t) - z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6e+44) {
tmp = Math.log(t) - z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6e+44: tmp = math.log(t) - z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6e+44) tmp = Float64(log(t) - z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 6e+44) tmp = log(t) - z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6e+44], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{+44}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 5.99999999999999974e44Initial program 99.8%
Taylor expanded in y around 0 97.8%
Taylor expanded in x around 0 64.3%
if 5.99999999999999974e44 < y Initial program 99.9%
Taylor expanded in y around inf 70.4%
neg-mul-170.4%
Simplified70.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%
Taylor expanded in x around 0 74.8%
(FPCore (x y z t) :precision binary64 (if (<= y 5e+44) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5e+44) {
tmp = -z;
} else {
tmp = -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 <= 5d+44) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5e+44) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5e+44: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5e+44) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5e+44) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5e+44], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+44}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 4.9999999999999996e44Initial program 99.8%
Taylor expanded in z around inf 38.1%
neg-mul-138.1%
Simplified38.1%
if 4.9999999999999996e44 < y Initial program 99.9%
Taylor expanded in y around inf 70.4%
neg-mul-170.4%
Simplified70.4%
(FPCore (x y z t) :precision binary64 (- y))
double code(double x, double y, double z, double t) {
return -y;
}
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 = -y
end function
public static double code(double x, double y, double z, double t) {
return -y;
}
def code(x, y, z, t): return -y
function code(x, y, z, t) return Float64(-y) end
function tmp = code(x, y, z, t) tmp = -y; end
code[x_, y_, z_, t_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 34.0%
neg-mul-134.0%
Simplified34.0%
herbie shell --seed 2024096
(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)))