
(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 (- (- z) y)) (t_1 (* x (log y))))
(if (<= z -6.6e+81)
t_0
(if (<= z 8.6e-30) (- t_1 y) (if (<= z 620000000000.0) t_0 (- t_1 z))))))
double code(double x, double y, double z) {
double t_0 = -z - y;
double t_1 = x * log(y);
double tmp;
if (z <= -6.6e+81) {
tmp = t_0;
} else if (z <= 8.6e-30) {
tmp = t_1 - y;
} else if (z <= 620000000000.0) {
tmp = t_0;
} else {
tmp = t_1 - z;
}
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) :: t_1
real(8) :: tmp
t_0 = -z - y
t_1 = x * log(y)
if (z <= (-6.6d+81)) then
tmp = t_0
else if (z <= 8.6d-30) then
tmp = t_1 - y
else if (z <= 620000000000.0d0) then
tmp = t_0
else
tmp = t_1 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -z - y;
double t_1 = x * Math.log(y);
double tmp;
if (z <= -6.6e+81) {
tmp = t_0;
} else if (z <= 8.6e-30) {
tmp = t_1 - y;
} else if (z <= 620000000000.0) {
tmp = t_0;
} else {
tmp = t_1 - z;
}
return tmp;
}
def code(x, y, z): t_0 = -z - y t_1 = x * math.log(y) tmp = 0 if z <= -6.6e+81: tmp = t_0 elif z <= 8.6e-30: tmp = t_1 - y elif z <= 620000000000.0: tmp = t_0 else: tmp = t_1 - z return tmp
function code(x, y, z) t_0 = Float64(Float64(-z) - y) t_1 = Float64(x * log(y)) tmp = 0.0 if (z <= -6.6e+81) tmp = t_0; elseif (z <= 8.6e-30) tmp = Float64(t_1 - y); elseif (z <= 620000000000.0) tmp = t_0; else tmp = Float64(t_1 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = -z - y; t_1 = x * log(y); tmp = 0.0; if (z <= -6.6e+81) tmp = t_0; elseif (z <= 8.6e-30) tmp = t_1 - y; elseif (z <= 620000000000.0) tmp = t_0; else tmp = t_1 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) - y), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.6e+81], t$95$0, If[LessEqual[z, 8.6e-30], N[(t$95$1 - y), $MachinePrecision], If[LessEqual[z, 620000000000.0], t$95$0, N[(t$95$1 - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) - y\\
t_1 := x \cdot \log y\\
\mathbf{if}\;z \leq -6.6 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8.6 \cdot 10^{-30}:\\
\;\;\;\;t\_1 - y\\
\mathbf{elif}\;z \leq 620000000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1 - z\\
\end{array}
\end{array}
if z < -6.6e81 or 8.59999999999999932e-30 < z < 6.2e11Initial program 100.0%
Taylor expanded in x around 0 86.5%
neg-mul-186.5%
+-commutative86.5%
distribute-neg-in86.5%
sub-neg86.5%
Simplified86.5%
if -6.6e81 < z < 8.59999999999999932e-30Initial program 99.8%
Taylor expanded in z around 0 91.2%
if 6.2e11 < z Initial program 100.0%
Taylor expanded in y around 0 86.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.2e-33) (not (<= x 4.3e+129))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.2e-33) || !(x <= 4.3e+129)) {
tmp = (x * log(y)) - y;
} else {
tmp = -z - 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 ((x <= (-2.2d-33)) .or. (.not. (x <= 4.3d+129))) then
tmp = (x * log(y)) - y
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.2e-33) || !(x <= 4.3e+129)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.2e-33) or not (x <= 4.3e+129): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.2e-33) || !(x <= 4.3e+129)) tmp = Float64(Float64(x * log(y)) - y); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.2e-33) || ~((x <= 4.3e+129))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.2e-33], N[Not[LessEqual[x, 4.3e+129]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{-33} \lor \neg \left(x \leq 4.3 \cdot 10^{+129}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -2.20000000000000005e-33 or 4.30000000000000021e129 < x Initial program 99.8%
Taylor expanded in z around 0 86.1%
if -2.20000000000000005e-33 < x < 4.30000000000000021e129Initial program 99.9%
Taylor expanded in x around 0 87.9%
neg-mul-187.9%
+-commutative87.9%
distribute-neg-in87.9%
sub-neg87.9%
Simplified87.9%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.5e+124) (not (<= x 1.4e+130))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.5e+124) || !(x <= 1.4e+130)) {
tmp = x * log(y);
} else {
tmp = -z - 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 ((x <= (-3.5d+124)) .or. (.not. (x <= 1.4d+130))) then
tmp = x * log(y)
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.5e+124) || !(x <= 1.4e+130)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.5e+124) or not (x <= 1.4e+130): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.5e+124) || !(x <= 1.4e+130)) tmp = Float64(x * log(y)); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.5e+124) || ~((x <= 1.4e+130))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.5e+124], N[Not[LessEqual[x, 1.4e+130]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{+124} \lor \neg \left(x \leq 1.4 \cdot 10^{+130}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.5000000000000001e124 or 1.3999999999999999e130 < x Initial program 99.8%
Taylor expanded in x around inf 84.8%
if -3.5000000000000001e124 < x < 1.3999999999999999e130Initial program 99.9%
Taylor expanded in x around 0 82.8%
neg-mul-182.8%
+-commutative82.8%
distribute-neg-in82.8%
sub-neg82.8%
Simplified82.8%
Final simplification83.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.65e+155) (not (<= z 1800000000.0))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.65e+155) || !(z <= 1800000000.0)) {
tmp = -z;
} else {
tmp = -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 ((z <= (-1.65d+155)) .or. (.not. (z <= 1800000000.0d0))) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.65e+155) || !(z <= 1800000000.0)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.65e+155) or not (z <= 1800000000.0): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.65e+155) || !(z <= 1800000000.0)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.65e+155) || ~((z <= 1800000000.0))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.65e+155], N[Not[LessEqual[z, 1800000000.0]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+155} \lor \neg \left(z \leq 1800000000\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -1.6499999999999999e155 or 1.8e9 < z Initial program 100.0%
Taylor expanded in z around inf 68.1%
neg-mul-168.1%
Simplified68.1%
if -1.6499999999999999e155 < z < 1.8e9Initial program 99.8%
Taylor expanded in y around inf 42.4%
neg-mul-142.4%
Simplified42.4%
Final simplification50.6%
(FPCore (x y z) :precision binary64 (- (- z) y))
double code(double x, double y, double z) {
return -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 = -z - y
end function
public static double code(double x, double y, double z) {
return -z - y;
}
def code(x, y, z): return -z - y
function code(x, y, z) return Float64(Float64(-z) - y) end
function tmp = code(x, y, z) tmp = -z - y; end
code[x_, y_, z_] := N[((-z) - y), $MachinePrecision]
\begin{array}{l}
\\
\left(-z\right) - y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 63.2%
neg-mul-163.2%
+-commutative63.2%
distribute-neg-in63.2%
sub-neg63.2%
Simplified63.2%
(FPCore (x y z) :precision binary64 (- y))
double code(double x, double y, double z) {
return -y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -y
end function
public static double code(double x, double y, double z) {
return -y;
}
def code(x, y, z): return -y
function code(x, y, z) return Float64(-y) end
function tmp = code(x, y, z) tmp = -y; end
code[x_, y_, z_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 33.1%
neg-mul-133.1%
Simplified33.1%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 33.1%
neg-mul-133.1%
Simplified33.1%
neg-sub033.1%
sub-neg33.1%
add-sqr-sqrt0.0%
sqrt-unprod2.4%
sqr-neg2.4%
sqrt-unprod2.4%
add-sqr-sqrt2.4%
Applied egg-rr2.4%
+-lft-identity2.4%
Simplified2.4%
herbie shell --seed 2024138
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))