
(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 8 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 (<= y 3.9e-28) (- t_0 z) (if (<= y 1e+91) (- (- 0.0 y) z) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (y <= 3.9e-28) {
tmp = t_0 - z;
} else if (y <= 1e+91) {
tmp = (0.0 - y) - z;
} 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 (y <= 3.9d-28) then
tmp = t_0 - z
else if (y <= 1d+91) then
tmp = (0.0d0 - y) - z
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 (y <= 3.9e-28) {
tmp = t_0 - z;
} else if (y <= 1e+91) {
tmp = (0.0 - y) - z;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if y <= 3.9e-28: tmp = t_0 - z elif y <= 1e+91: tmp = (0.0 - y) - z else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (y <= 3.9e-28) tmp = Float64(t_0 - z); elseif (y <= 1e+91) tmp = Float64(Float64(0.0 - y) - z); 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 (y <= 3.9e-28) tmp = t_0 - z; elseif (y <= 1e+91) tmp = (0.0 - y) - z; 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[y, 3.9e-28], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[y, 1e+91], N[(N[(0.0 - y), $MachinePrecision] - z), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;y \leq 3.9 \cdot 10^{-28}:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;y \leq 10^{+91}:\\
\;\;\;\;\left(0 - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if y < 3.89999999999999999e-28Initial program 99.8%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6494.3%
Simplified94.3%
if 3.89999999999999999e-28 < y < 1.00000000000000008e91Initial 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--.f6485.4%
Simplified85.4%
sub0-negN/A
neg-lowering-neg.f6485.4%
Applied egg-rr85.4%
if 1.00000000000000008e91 < y Initial program 99.9%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6488.0%
Simplified88.0%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* x (log y)) y))) (if (<= x -1.65e+149) t_0 (if (<= x 2.2e+101) (- (- 0.0 y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (x * log(y)) - y;
double tmp;
if (x <= -1.65e+149) {
tmp = t_0;
} else if (x <= 2.2e+101) {
tmp = (0.0 - y) - z;
} 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 <= (-1.65d+149)) then
tmp = t_0
else if (x <= 2.2d+101) then
tmp = (0.0d0 - y) - z
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 <= -1.65e+149) {
tmp = t_0;
} else if (x <= 2.2e+101) {
tmp = (0.0 - y) - z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * math.log(y)) - y tmp = 0 if x <= -1.65e+149: tmp = t_0 elif x <= 2.2e+101: tmp = (0.0 - y) - z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if (x <= -1.65e+149) tmp = t_0; elseif (x <= 2.2e+101) tmp = Float64(Float64(0.0 - y) - z); 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 <= -1.65e+149) tmp = t_0; elseif (x <= 2.2e+101) tmp = (0.0 - y) - z; 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, -1.65e+149], t$95$0, If[LessEqual[x, 2.2e+101], N[(N[(0.0 - y), $MachinePrecision] - z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y - y\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{+149}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+101}:\\
\;\;\;\;\left(0 - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.65e149 or 2.2000000000000001e101 < x Initial program 99.6%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6491.0%
Simplified91.0%
if -1.65e149 < x < 2.2000000000000001e101Initial program 100.0%
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.7%
Simplified88.7%
sub0-negN/A
neg-lowering-neg.f6488.7%
Applied egg-rr88.7%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -1.9e+150) t_0 (if (<= x 2.6e+118) (- (- 0.0 y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -1.9e+150) {
tmp = t_0;
} else if (x <= 2.6e+118) {
tmp = (0.0 - y) - z;
} 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.9d+150)) then
tmp = t_0
else if (x <= 2.6d+118) then
tmp = (0.0d0 - y) - z
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.9e+150) {
tmp = t_0;
} else if (x <= 2.6e+118) {
tmp = (0.0 - y) - z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if x <= -1.9e+150: tmp = t_0 elif x <= 2.6e+118: tmp = (0.0 - y) - z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (x <= -1.9e+150) tmp = t_0; elseif (x <= 2.6e+118) tmp = Float64(Float64(0.0 - y) - z); 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.9e+150) tmp = t_0; elseif (x <= 2.6e+118) tmp = (0.0 - y) - z; 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.9e+150], t$95$0, If[LessEqual[x, 2.6e+118], N[(N[(0.0 - y), $MachinePrecision] - z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+150}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+118}:\\
\;\;\;\;\left(0 - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.89999999999999995e150 or 2.60000000000000016e118 < x Initial program 99.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
log-lowering-log.f6475.2%
Simplified75.2%
if -1.89999999999999995e150 < x < 2.60000000000000016e118Initial program 100.0%
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.3%
Simplified88.3%
sub0-negN/A
neg-lowering-neg.f6488.3%
Applied egg-rr88.3%
Final simplification84.3%
(FPCore (x y z) :precision binary64 (if (<= y 3.6e+91) (- 0.0 z) (- 0.0 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.6e+91) {
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 <= 3.6d+91) 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 <= 3.6e+91) {
tmp = 0.0 - z;
} else {
tmp = 0.0 - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.6e+91: tmp = 0.0 - z else: tmp = 0.0 - y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.6e+91) 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 <= 3.6e+91) tmp = 0.0 - z; else tmp = 0.0 - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.6e+91], N[(0.0 - z), $MachinePrecision], N[(0.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{+91}:\\
\;\;\;\;0 - z\\
\mathbf{else}:\\
\;\;\;\;0 - y\\
\end{array}
\end{array}
if y < 3.6e91Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6449.8%
Simplified49.8%
if 3.6e91 < y Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6466.2%
Simplified66.2%
sub0-negN/A
neg-lowering-neg.f6466.2%
Applied egg-rr66.2%
Final simplification56.3%
(FPCore (x y z) :precision binary64 (- (- 0.0 y) z))
double code(double x, double y, double z) {
return (0.0 - y) - z;
}
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) - z
end function
public static double code(double x, double y, double z) {
return (0.0 - y) - z;
}
def code(x, y, z): return (0.0 - y) - z
function code(x, y, z) return Float64(Float64(0.0 - y) - z) end
function tmp = code(x, y, z) tmp = (0.0 - y) - z; end
code[x_, y_, z_] := N[(N[(0.0 - y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(0 - y\right) - z
\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--.f6469.0%
Simplified69.0%
sub0-negN/A
neg-lowering-neg.f6469.0%
Applied egg-rr69.0%
Final simplification69.0%
(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--.f6435.3%
Simplified35.3%
sub0-negN/A
neg-lowering-neg.f6435.3%
Applied egg-rr35.3%
Final simplification35.3%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\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--.f6469.0%
Simplified69.0%
Applied egg-rr10.1%
Taylor expanded in z around inf
Simplified2.3%
herbie shell --seed 2024155
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))