
(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 7 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%
Final simplification99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (or (<= z -3.4e+75) (not (<= z 1.65e+149)))
(- t_1 z)
(- (+ t_1 (log t)) y))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if ((z <= -3.4e+75) || !(z <= 1.65e+149)) {
tmp = t_1 - z;
} else {
tmp = (t_1 + 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) :: t_1
real(8) :: tmp
t_1 = x * log(y)
if ((z <= (-3.4d+75)) .or. (.not. (z <= 1.65d+149))) then
tmp = t_1 - z
else
tmp = (t_1 + log(t)) - y
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 ((z <= -3.4e+75) || !(z <= 1.65e+149)) {
tmp = t_1 - z;
} else {
tmp = (t_1 + Math.log(t)) - y;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if (z <= -3.4e+75) or not (z <= 1.65e+149): tmp = t_1 - z else: tmp = (t_1 + math.log(t)) - y return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if ((z <= -3.4e+75) || !(z <= 1.65e+149)) tmp = Float64(t_1 - z); else tmp = Float64(Float64(t_1 + log(t)) - y); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if ((z <= -3.4e+75) || ~((z <= 1.65e+149))) tmp = t_1 - z; else tmp = (t_1 + log(t)) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[z, -3.4e+75], N[Not[LessEqual[z, 1.65e+149]], $MachinePrecision]], N[(t$95$1 - z), $MachinePrecision], N[(N[(t$95$1 + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{+75} \lor \neg \left(z \leq 1.65 \cdot 10^{+149}\right):\\
\;\;\;\;t\_1 - z\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 + \log t\right) - y\\
\end{array}
\end{array}
if z < -3.40000000000000011e75 or 1.65e149 < z Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in z around inf 93.9%
if -3.40000000000000011e75 < z < 1.65e149Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in z around 0 92.5%
Final simplification92.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.18e+144) (not (<= x 2.45e+39))) (* x (log y)) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.18e+144) || !(x <= 2.45e+39)) {
tmp = x * log(y);
} 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 <= (-1.18d+144)) .or. (.not. (x <= 2.45d+39))) then
tmp = x * log(y)
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 <= -1.18e+144) || !(x <= 2.45e+39)) {
tmp = x * Math.log(y);
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.18e+144) or not (x <= 2.45e+39): tmp = x * math.log(y) else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.18e+144) || !(x <= 2.45e+39)) tmp = Float64(x * log(y)); 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 <= -1.18e+144) || ~((x <= 2.45e+39))) tmp = x * log(y); else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.18e+144], N[Not[LessEqual[x, 2.45e+39]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.18 \cdot 10^{+144} \lor \neg \left(x \leq 2.45 \cdot 10^{+39}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -1.18e144 or 2.44999999999999994e39 < x Initial program 99.7%
associate-+l-99.7%
associate--l-99.7%
Simplified99.7%
add-cube-cbrt98.6%
associate-*r*98.6%
fma-neg98.6%
pow298.6%
associate-+r-98.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 71.0%
*-commutative71.0%
Simplified71.0%
if -1.18e144 < x < 2.44999999999999994e39Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in x around 0 91.8%
Final simplification84.1%
(FPCore (x y z t) :precision binary64 (if (or (<= x -380000000.0) (not (<= x 6.2e+24))) (- (* x (log y)) y) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -380000000.0) || !(x <= 6.2e+24)) {
tmp = (x * log(y)) - y;
} 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 <= (-380000000.0d0)) .or. (.not. (x <= 6.2d+24))) then
tmp = (x * log(y)) - y
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 <= -380000000.0) || !(x <= 6.2e+24)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -380000000.0) or not (x <= 6.2e+24): tmp = (x * math.log(y)) - y else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -380000000.0) || !(x <= 6.2e+24)) tmp = Float64(Float64(x * log(y)) - y); 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 <= -380000000.0) || ~((x <= 6.2e+24))) tmp = (x * log(y)) - y; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -380000000.0], N[Not[LessEqual[x, 6.2e+24]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -380000000 \lor \neg \left(x \leq 6.2 \cdot 10^{+24}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -3.8e8 or 6.20000000000000022e24 < x Initial program 99.8%
associate-+l-99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 86.8%
if -3.8e8 < x < 6.20000000000000022e24Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in x around 0 96.6%
Final simplification91.8%
(FPCore (x y z t) :precision binary64 (if (<= y 1.4e-180) (- z) (if (<= y 6e+67) (* x (log y)) (- y))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.4e-180) {
tmp = -z;
} else if (y <= 6e+67) {
tmp = x * log(y);
} 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 <= 1.4d-180) then
tmp = -z
else if (y <= 6d+67) then
tmp = x * log(y)
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 <= 1.4e-180) {
tmp = -z;
} else if (y <= 6e+67) {
tmp = x * Math.log(y);
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.4e-180: tmp = -z elif y <= 6e+67: tmp = x * math.log(y) else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.4e-180) tmp = Float64(-z); elseif (y <= 6e+67) tmp = Float64(x * log(y)); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.4e-180) tmp = -z; elseif (y <= 6e+67) tmp = x * log(y); else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.4e-180], (-z), If[LessEqual[y, 6e+67], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], (-y)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{-180}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+67}:\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.39999999999999999e-180Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in z around inf 55.1%
mul-1-neg55.1%
Simplified55.1%
if 1.39999999999999999e-180 < y < 6.0000000000000002e67Initial program 99.8%
associate-+l-99.8%
associate--l-99.8%
Simplified99.8%
add-cube-cbrt99.1%
associate-*r*99.1%
fma-neg99.1%
pow299.1%
associate-+r-99.1%
Applied egg-rr99.1%
Taylor expanded in x around inf 46.5%
*-commutative46.5%
Simplified46.5%
if 6.0000000000000002e67 < y Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in y around inf 67.7%
mul-1-neg67.7%
Simplified67.7%
Final simplification56.6%
(FPCore (x y z t) :precision binary64 (if (or (<= y 1.9e+30) (and (not (<= y 1.25e+101)) (<= y 6.8e+143))) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1.9e+30) || (!(y <= 1.25e+101) && (y <= 6.8e+143))) {
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 <= 1.9d+30) .or. (.not. (y <= 1.25d+101)) .and. (y <= 6.8d+143)) 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 <= 1.9e+30) || (!(y <= 1.25e+101) && (y <= 6.8e+143))) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 1.9e+30) or (not (y <= 1.25e+101) and (y <= 6.8e+143)): tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 1.9e+30) || (!(y <= 1.25e+101) && (y <= 6.8e+143))) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 1.9e+30) || (~((y <= 1.25e+101)) && (y <= 6.8e+143))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 1.9e+30], And[N[Not[LessEqual[y, 1.25e+101]], $MachinePrecision], LessEqual[y, 6.8e+143]]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+30} \lor \neg \left(y \leq 1.25 \cdot 10^{+101}\right) \land y \leq 6.8 \cdot 10^{+143}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.9000000000000001e30 or 1.24999999999999997e101 < y < 6.79999999999999964e143Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in z around inf 37.1%
mul-1-neg37.1%
Simplified37.1%
if 1.9000000000000001e30 < y < 1.24999999999999997e101 or 6.79999999999999964e143 < y Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in y around inf 70.8%
mul-1-neg70.8%
Simplified70.8%
Final simplification50.0%
(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%
associate-+l-99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in y around inf 30.9%
mul-1-neg30.9%
Simplified30.9%
Final simplification30.9%
herbie shell --seed 2024066
(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)))