
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - z) - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
Initial program 99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))))
(if (<= x -1.1e+74)
(- t_0 z)
(if (<= x 1.25e+110) (- (- 0.0 z) y) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -1.1e+74) {
tmp = t_0 - z;
} else if (x <= 1.25e+110) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0 - y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * log(y)
if (x <= (-1.1d+74)) then
tmp = t_0 - z
else if (x <= 1.25d+110) then
tmp = (0.0d0 - z) - y
else
tmp = t_0 - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.log(y);
double tmp;
if (x <= -1.1e+74) {
tmp = t_0 - z;
} else if (x <= 1.25e+110) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if x <= -1.1e+74: tmp = t_0 - z elif x <= 1.25e+110: tmp = (0.0 - z) - y else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (x <= -1.1e+74) tmp = Float64(t_0 - z); elseif (x <= 1.25e+110) tmp = Float64(Float64(0.0 - z) - y); else tmp = Float64(t_0 - y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); tmp = 0.0; if (x <= -1.1e+74) tmp = t_0 - z; elseif (x <= 1.25e+110) tmp = (0.0 - z) - y; else tmp = t_0 - y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.1e+74], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[x, 1.25e+110], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{+74}:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+110}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if x < -1.1000000000000001e74Initial program 99.8%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6486.7%
Simplified86.7%
if -1.1000000000000001e74 < x < 1.24999999999999995e110Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6490.6%
Simplified90.6%
if 1.24999999999999995e110 < x Initial program 99.7%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6489.7%
Simplified89.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* x (log y)) y))) (if (<= x -2.55e+17) t_0 (if (<= x 8.5e+109) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = (x * log(y)) - y;
double tmp;
if (x <= -2.55e+17) {
tmp = t_0;
} else if (x <= 8.5e+109) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x * log(y)) - y
if (x <= (-2.55d+17)) then
tmp = t_0
else if (x <= 8.5d+109) then
tmp = (0.0d0 - z) - y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * Math.log(y)) - y;
double tmp;
if (x <= -2.55e+17) {
tmp = t_0;
} else if (x <= 8.5e+109) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * math.log(y)) - y tmp = 0 if x <= -2.55e+17: tmp = t_0 elif x <= 8.5e+109: tmp = (0.0 - z) - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if (x <= -2.55e+17) tmp = t_0; elseif (x <= 8.5e+109) tmp = Float64(Float64(0.0 - z) - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * log(y)) - y; tmp = 0.0; if (x <= -2.55e+17) tmp = t_0; elseif (x <= 8.5e+109) tmp = (0.0 - z) - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[x, -2.55e+17], t$95$0, If[LessEqual[x, 8.5e+109], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y - y\\
\mathbf{if}\;x \leq -2.55 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+109}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.55e17 or 8.5000000000000004e109 < x Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6483.9%
Simplified83.9%
if -2.55e17 < x < 8.5000000000000004e109Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6492.4%
Simplified92.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -1.3e+128) t_0 (if (<= x 3.7e+115) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -1.3e+128) {
tmp = t_0;
} else if (x <= 3.7e+115) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * log(y)
if (x <= (-1.3d+128)) then
tmp = t_0
else if (x <= 3.7d+115) then
tmp = (0.0d0 - z) - y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.log(y);
double tmp;
if (x <= -1.3e+128) {
tmp = t_0;
} else if (x <= 3.7e+115) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if x <= -1.3e+128: tmp = t_0 elif x <= 3.7e+115: tmp = (0.0 - z) - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (x <= -1.3e+128) tmp = t_0; elseif (x <= 3.7e+115) tmp = Float64(Float64(0.0 - z) - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); tmp = 0.0; if (x <= -1.3e+128) tmp = t_0; elseif (x <= 3.7e+115) tmp = (0.0 - z) - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.3e+128], t$95$0, If[LessEqual[x, 3.7e+115], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+128}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{+115}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.3e128 or 3.70000000000000006e115 < x Initial program 99.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
log-lowering-log.f6476.1%
Simplified76.1%
if -1.3e128 < x < 3.70000000000000006e115Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6488.5%
Simplified88.5%
(FPCore (x y z) :precision binary64 (if (<= y 6.4e+103) (- 0.0 z) (- 0.0 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e+103) {
tmp = 0.0 - z;
} else {
tmp = 0.0 - y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 6.4d+103) then
tmp = 0.0d0 - z
else
tmp = 0.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e+103) {
tmp = 0.0 - z;
} else {
tmp = 0.0 - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.4e+103: tmp = 0.0 - z else: tmp = 0.0 - y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.4e+103) tmp = Float64(0.0 - z); else tmp = Float64(0.0 - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.4e+103) tmp = 0.0 - z; else tmp = 0.0 - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.4e+103], N[(0.0 - z), $MachinePrecision], N[(0.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{+103}:\\
\;\;\;\;0 - z\\
\mathbf{else}:\\
\;\;\;\;0 - y\\
\end{array}
\end{array}
if y < 6.39999999999999985e103Initial program 99.8%
associate--l-N/A
flip--N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
--lowering--.f64N/A
pow2N/A
pow-lowering-pow.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-commutativeN/A
+-lowering-+.f6454.1%
Applied egg-rr54.1%
Taylor expanded in z around inf
/-lowering-/.f6446.8%
Simplified46.8%
associate-/r/N/A
metadata-evalN/A
neg-mul-1N/A
neg-lowering-neg.f6446.8%
Applied egg-rr46.8%
if 6.39999999999999985e103 < y Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6467.5%
Simplified67.5%
sub0-negN/A
neg-lowering-neg.f6467.5%
Applied egg-rr67.5%
Final simplification54.2%
(FPCore (x y z) :precision binary64 (- (- 0.0 z) y))
double code(double x, double y, double z) {
return (0.0 - z) - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (0.0d0 - z) - y
end function
public static double code(double x, double y, double z) {
return (0.0 - z) - y;
}
def code(x, y, z): return (0.0 - z) - y
function code(x, y, z) return Float64(Float64(0.0 - z) - y) end
function tmp = code(x, y, z) tmp = (0.0 - z) - y; end
code[x_, y_, z_] := N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(0 - z\right) - y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6467.4%
Simplified67.4%
(FPCore (x y z) :precision binary64 (- 0.0 y))
double code(double x, double y, double z) {
return 0.0 - y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.0d0 - y
end function
public static double code(double x, double y, double z) {
return 0.0 - y;
}
def code(x, y, z): return 0.0 - y
function code(x, y, z) return Float64(0.0 - y) end
function tmp = code(x, y, z) tmp = 0.0 - y; end
code[x_, y_, z_] := N[(0.0 - y), $MachinePrecision]
\begin{array}{l}
\\
0 - y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6433.5%
Simplified33.5%
sub0-negN/A
neg-lowering-neg.f6433.5%
Applied egg-rr33.5%
Final simplification33.5%
herbie shell --seed 2024160
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))