
(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.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -5e+28) (not (<= x 4.5e+77))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+28) || !(x <= 4.5e+77)) {
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 <= (-5d+28)) .or. (.not. (x <= 4.5d+77))) 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 <= -5e+28) || !(x <= 4.5e+77)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5e+28) or not (x <= 4.5e+77): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5e+28) || !(x <= 4.5e+77)) 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 <= -5e+28) || ~((x <= 4.5e+77))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5e+28], N[Not[LessEqual[x, 4.5e+77]], $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 -5 \cdot 10^{+28} \lor \neg \left(x \leq 4.5 \cdot 10^{+77}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -4.99999999999999957e28 or 4.50000000000000024e77 < x Initial program 99.7%
Taylor expanded in z around 0 84.5%
if -4.99999999999999957e28 < x < 4.50000000000000024e77Initial program 99.9%
Taylor expanded in x around 0 89.3%
neg-mul-189.3%
+-commutative89.3%
distribute-neg-in89.3%
sub-neg89.3%
Simplified89.3%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (or (<= z -3.15e-27) (not (<= z 7.2e+78))) (- t_0 z) (- t_0 y))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if ((z <= -3.15e-27) || !(z <= 7.2e+78)) {
tmp = t_0 - 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 ((z <= (-3.15d-27)) .or. (.not. (z <= 7.2d+78))) then
tmp = t_0 - 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 ((z <= -3.15e-27) || !(z <= 7.2e+78)) {
tmp = t_0 - z;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if (z <= -3.15e-27) or not (z <= 7.2e+78): tmp = t_0 - z else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if ((z <= -3.15e-27) || !(z <= 7.2e+78)) tmp = Float64(t_0 - 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 ((z <= -3.15e-27) || ~((z <= 7.2e+78))) tmp = t_0 - 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[Or[LessEqual[z, -3.15e-27], N[Not[LessEqual[z, 7.2e+78]], $MachinePrecision]], N[(t$95$0 - z), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;z \leq -3.15 \cdot 10^{-27} \lor \neg \left(z \leq 7.2 \cdot 10^{+78}\right):\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if z < -3.15000000000000005e-27 or 7.20000000000000039e78 < z Initial program 99.9%
Taylor expanded in y around 0 88.4%
if -3.15000000000000005e-27 < z < 7.20000000000000039e78Initial program 99.7%
Taylor expanded in z around 0 92.0%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e+32) (not (<= x 1e+154))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e+32) || !(x <= 1e+154)) {
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 <= (-1d+32)) .or. (.not. (x <= 1d+154))) 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 <= -1e+32) || !(x <= 1e+154)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1e+32) or not (x <= 1e+154): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1e+32) || !(x <= 1e+154)) 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 <= -1e+32) || ~((x <= 1e+154))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e+32], N[Not[LessEqual[x, 1e+154]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+32} \lor \neg \left(x \leq 10^{+154}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -1.00000000000000005e32 or 1.00000000000000004e154 < x Initial program 99.6%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
unsub-neg99.6%
Simplified99.6%
Taylor expanded in x around inf 75.4%
if -1.00000000000000005e32 < x < 1.00000000000000004e154Initial program 99.9%
Taylor expanded in x around 0 85.6%
neg-mul-185.6%
+-commutative85.6%
distribute-neg-in85.6%
sub-neg85.6%
Simplified85.6%
Final simplification81.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -3e-27) (not (<= z 2.5e+80))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3e-27) || !(z <= 2.5e+80)) {
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 <= (-3d-27)) .or. (.not. (z <= 2.5d+80))) 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 <= -3e-27) || !(z <= 2.5e+80)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3e-27) or not (z <= 2.5e+80): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3e-27) || !(z <= 2.5e+80)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3e-27) || ~((z <= 2.5e+80))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3e-27], N[Not[LessEqual[z, 2.5e+80]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-27} \lor \neg \left(z \leq 2.5 \cdot 10^{+80}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -3.0000000000000001e-27 or 2.4999999999999998e80 < z Initial program 99.9%
Taylor expanded in z around inf 67.1%
neg-mul-167.1%
Simplified67.1%
if -3.0000000000000001e-27 < z < 2.4999999999999998e80Initial program 99.7%
Taylor expanded in y around inf 42.0%
neg-mul-142.0%
Simplified42.0%
Final simplification53.8%
(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.8%
Taylor expanded in x around 0 63.2%
neg-mul-163.2%
+-commutative63.2%
distribute-neg-in63.2%
sub-neg63.2%
Simplified63.2%
Final simplification63.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.8%
Taylor expanded in y around inf 28.1%
neg-mul-128.1%
Simplified28.1%
Final simplification28.1%
herbie shell --seed 2024084
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))