
(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 11 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 (fma (log y) x (- (- z) y)))
double code(double x, double y, double z) {
return fma(log(y), x, (-z - y));
}
function code(x, y, z) return fma(log(y), x, Float64(Float64(-z) - y)) end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] * x + N[((-z) - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(-z\right) - y\right)
\end{array}
Initial program 99.9%
sub-negN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
neg-lowering-neg.f6499.9
Applied egg-rr99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* (log y) x) z))) (if (<= z -9.6e+54) t_0 (if (<= z 1.95e+39) (fma (log y) x (- y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (log(y) * x) - z;
double tmp;
if (z <= -9.6e+54) {
tmp = t_0;
} else if (z <= 1.95e+39) {
tmp = fma(log(y), x, -y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(log(y) * x) - z) tmp = 0.0 if (z <= -9.6e+54) tmp = t_0; elseif (z <= 1.95e+39) tmp = fma(log(y), x, Float64(-y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[z, -9.6e+54], t$95$0, If[LessEqual[z, 1.95e+39], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot x - z\\
\mathbf{if}\;z \leq -9.6 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9.59999999999999993e54 or 1.95e39 < z Initial program 99.9%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6486.2
Simplified86.2%
if -9.59999999999999993e54 < z < 1.95e39Initial program 99.8%
sub-negN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
neg-lowering-neg.f6499.8
Applied egg-rr99.8%
Taylor expanded in z around 0
mul-1-negN/A
neg-lowering-neg.f6493.6
Simplified93.6%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (log y) x)) (t_1 (- t_0 z))) (if (<= z -6.8e+58) t_1 (if (<= z 1.65e+39) (- t_0 y) t_1))))
double code(double x, double y, double z) {
double t_0 = log(y) * x;
double t_1 = t_0 - z;
double tmp;
if (z <= -6.8e+58) {
tmp = t_1;
} else if (z <= 1.65e+39) {
tmp = t_0 - y;
} else {
tmp = t_1;
}
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 = log(y) * x
t_1 = t_0 - z
if (z <= (-6.8d+58)) then
tmp = t_1
else if (z <= 1.65d+39) then
tmp = t_0 - y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.log(y) * x;
double t_1 = t_0 - z;
double tmp;
if (z <= -6.8e+58) {
tmp = t_1;
} else if (z <= 1.65e+39) {
tmp = t_0 - y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = math.log(y) * x t_1 = t_0 - z tmp = 0 if z <= -6.8e+58: tmp = t_1 elif z <= 1.65e+39: tmp = t_0 - y else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(log(y) * x) t_1 = Float64(t_0 - z) tmp = 0.0 if (z <= -6.8e+58) tmp = t_1; elseif (z <= 1.65e+39) tmp = Float64(t_0 - y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = log(y) * x; t_1 = t_0 - z; tmp = 0.0; if (z <= -6.8e+58) tmp = t_1; elseif (z <= 1.65e+39) tmp = t_0 - y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - z), $MachinePrecision]}, If[LessEqual[z, -6.8e+58], t$95$1, If[LessEqual[z, 1.65e+39], N[(t$95$0 - y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot x\\
t_1 := t\_0 - z\\
\mathbf{if}\;z \leq -6.8 \cdot 10^{+58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+39}:\\
\;\;\;\;t\_0 - y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -6.8000000000000001e58 or 1.6500000000000001e39 < z Initial program 99.9%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6486.2
Simplified86.2%
if -6.8000000000000001e58 < z < 1.6500000000000001e39Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6493.6
Simplified93.6%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (- z) y))) (if (<= z -8.2e+80) t_0 (if (<= z 3.7e+80) (- (* (log y) x) y) t_0))))
double code(double x, double y, double z) {
double t_0 = -z - y;
double tmp;
if (z <= -8.2e+80) {
tmp = t_0;
} else if (z <= 3.7e+80) {
tmp = (log(y) * x) - 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 = -z - y
if (z <= (-8.2d+80)) then
tmp = t_0
else if (z <= 3.7d+80) then
tmp = (log(y) * x) - y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -z - y;
double tmp;
if (z <= -8.2e+80) {
tmp = t_0;
} else if (z <= 3.7e+80) {
tmp = (Math.log(y) * x) - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -z - y tmp = 0 if z <= -8.2e+80: tmp = t_0 elif z <= 3.7e+80: tmp = (math.log(y) * x) - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-z) - y) tmp = 0.0 if (z <= -8.2e+80) tmp = t_0; elseif (z <= 3.7e+80) tmp = Float64(Float64(log(y) * x) - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -z - y; tmp = 0.0; if (z <= -8.2e+80) tmp = t_0; elseif (z <= 3.7e+80) tmp = (log(y) * x) - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) - y), $MachinePrecision]}, If[LessEqual[z, -8.2e+80], t$95$0, If[LessEqual[z, 3.7e+80], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) - y\\
\mathbf{if}\;z \leq -8.2 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+80}:\\
\;\;\;\;\log y \cdot x - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -8.20000000000000003e80 or 3.69999999999999996e80 < z Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
neg-lowering-neg.f6483.8
Simplified83.8%
if -8.20000000000000003e80 < z < 3.69999999999999996e80Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6491.6
Simplified91.6%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (log y) x))) (if (<= x -2.6e+185) t_0 (if (<= x 7e+201) (- (- z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = log(y) * x;
double tmp;
if (x <= -2.6e+185) {
tmp = t_0;
} else if (x <= 7e+201) {
tmp = -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 = log(y) * x
if (x <= (-2.6d+185)) then
tmp = t_0
else if (x <= 7d+201) then
tmp = -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 = Math.log(y) * x;
double tmp;
if (x <= -2.6e+185) {
tmp = t_0;
} else if (x <= 7e+201) {
tmp = -z - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.log(y) * x tmp = 0 if x <= -2.6e+185: tmp = t_0 elif x <= 7e+201: tmp = -z - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(log(y) * x) tmp = 0.0 if (x <= -2.6e+185) tmp = t_0; elseif (x <= 7e+201) tmp = Float64(Float64(-z) - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = log(y) * x; tmp = 0.0; if (x <= -2.6e+185) tmp = t_0; elseif (x <= 7e+201) tmp = -z - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -2.6e+185], t$95$0, If[LessEqual[x, 7e+201], N[((-z) - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot x\\
\mathbf{if}\;x \leq -2.6 \cdot 10^{+185}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+201}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.60000000000000001e185 or 7.0000000000000004e201 < x Initial program 99.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
log-lowering-log.f6482.3
Simplified82.3%
if -2.60000000000000001e185 < x < 7.0000000000000004e201Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
neg-lowering-neg.f6481.1
Simplified81.1%
Final simplification81.4%
(FPCore (x y z) :precision binary64 (- (- (* (log y) x) z) y))
double code(double x, double y, double z) {
return ((log(y) * x) - 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 = ((log(y) * x) - z) - y
end function
public static double code(double x, double y, double z) {
return ((Math.log(y) * x) - z) - y;
}
def code(x, y, z): return ((math.log(y) * x) - z) - y
function code(x, y, z) return Float64(Float64(Float64(log(y) * x) - z) - y) end
function tmp = code(x, y, z) tmp = ((log(y) * x) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\log y \cdot x - z\right) - y
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.7e+55) (- y z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.7e+55) {
tmp = y - 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 (y <= 1.7d+55) then
tmp = y - z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.7e+55) {
tmp = y - z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.7e+55: tmp = y - z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.7e+55) tmp = Float64(y - z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.7e+55) tmp = y - z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.7e+55], N[(y - z), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{+55}:\\
\;\;\;\;y - z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.6999999999999999e55Initial program 99.8%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
neg-lowering-neg.f6457.7
Simplified57.7%
Applied egg-rr49.3%
if 1.6999999999999999e55 < y Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
neg-lowering-neg.f6464.4
Simplified64.4%
Final simplification55.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.1e+56) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.1e+56) {
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 (y <= 1.1d+56) 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 (y <= 1.1e+56) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.1e+56: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.1e+56) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.1e+56) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.1e+56], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+56}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.10000000000000008e56Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
neg-lowering-neg.f6449.2
Simplified49.2%
if 1.10000000000000008e56 < y Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
neg-lowering-neg.f6464.4
Simplified64.4%
(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
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
neg-lowering-neg.f6466.6
Simplified66.6%
(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
mul-1-negN/A
neg-lowering-neg.f6433.6
Simplified33.6%
(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
mul-1-negN/A
neg-lowering-neg.f6433.6
Simplified33.6%
neg-sub0N/A
flip3--N/A
/-lowering-/.f64N/A
metadata-evalN/A
--lowering--.f64N/A
cube-multN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
+-lowering-+.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f648.8
Applied egg-rr8.8%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lft-identityN/A
distribute-rgt-outN/A
+-rgt-identityN/A
*-lowering-*.f64N/A
sub0-negN/A
neg-lowering-neg.f64N/A
+-rgt-identityN/A
distribute-rgt-outN/A
+-lft-identityN/A
*-lowering-*.f64N/A
+-lft-identityN/A
distribute-rgt-outN/A
+-rgt-identityN/A
*-lowering-*.f648.8
Applied egg-rr8.8%
neg-mul-1N/A
Applied egg-rr2.3%
herbie shell --seed 2024199
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))