
(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)) y))) (if (<= x -5.3e+76) t_0 (if (<= x 6e+33) (- (- 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 <= -5.3e+76) {
tmp = t_0;
} else if (x <= 6e+33) {
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 <= (-5.3d+76)) then
tmp = t_0
else if (x <= 6d+33) 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 <= -5.3e+76) {
tmp = t_0;
} else if (x <= 6e+33) {
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 <= -5.3e+76: tmp = t_0 elif x <= 6e+33: 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 <= -5.3e+76) tmp = t_0; elseif (x <= 6e+33) 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 <= -5.3e+76) tmp = t_0; elseif (x <= 6e+33) 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, -5.3e+76], t$95$0, If[LessEqual[x, 6e+33], 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 -5.3 \cdot 10^{+76}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+33}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.30000000000000015e76 or 5.99999999999999967e33 < x Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6486.5%
Simplified86.5%
if -5.30000000000000015e76 < x < 5.99999999999999967e33Initial 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--.f6490.0%
Simplified90.0%
sub0-negN/A
neg-lowering-neg.f6490.0%
Applied egg-rr90.0%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -2.7e+81) t_0 (if (<= x 9.5e+114) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -2.7e+81) {
tmp = t_0;
} else if (x <= 9.5e+114) {
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 <= (-2.7d+81)) then
tmp = t_0
else if (x <= 9.5d+114) 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 <= -2.7e+81) {
tmp = t_0;
} else if (x <= 9.5e+114) {
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 <= -2.7e+81: tmp = t_0 elif x <= 9.5e+114: 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 <= -2.7e+81) tmp = t_0; elseif (x <= 9.5e+114) 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 <= -2.7e+81) tmp = t_0; elseif (x <= 9.5e+114) 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, -2.7e+81], t$95$0, If[LessEqual[x, 9.5e+114], 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 -2.7 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+114}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.6999999999999999e81 or 9.5000000000000001e114 < x Initial program 99.8%
Taylor expanded in x around inf
*-lowering-*.f64N/A
log-lowering-log.f6477.3%
Simplified77.3%
if -2.6999999999999999e81 < x < 9.5000000000000001e114Initial 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--.f6486.7%
Simplified86.7%
sub0-negN/A
neg-lowering-neg.f6486.7%
Applied egg-rr86.7%
Final simplification84.1%
(FPCore (x y z) :precision binary64 (if (<= y 3.8e+39) (- 0.0 z) (- 0.0 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.8e+39) {
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.8d+39) 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.8e+39) {
tmp = 0.0 - z;
} else {
tmp = 0.0 - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.8e+39: tmp = 0.0 - z else: tmp = 0.0 - y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.8e+39) 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.8e+39) tmp = 0.0 - z; else tmp = 0.0 - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.8e+39], N[(0.0 - z), $MachinePrecision], N[(0.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{+39}:\\
\;\;\;\;0 - z\\
\mathbf{else}:\\
\;\;\;\;0 - y\\
\end{array}
\end{array}
if y < 3.7999999999999998e39Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6448.8%
Simplified48.8%
if 3.7999999999999998e39 < y Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6460.5%
Simplified60.5%
sub0-negN/A
neg-lowering-neg.f6460.5%
Applied egg-rr60.5%
Final simplification54.0%
(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--.f6468.4%
Simplified68.4%
sub0-negN/A
neg-lowering-neg.f6468.4%
Applied egg-rr68.4%
Final simplification68.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--.f6434.3%
Simplified34.3%
sub0-negN/A
neg-lowering-neg.f6434.3%
Applied egg-rr34.3%
Final simplification34.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--.f6468.4%
Simplified68.4%
Applied egg-rr13.8%
Taylor expanded in y around 0
Simplified2.3%
herbie shell --seed 2024158
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))