
(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.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))) (t_1 (- t_0 z)))
(if (<= x -9e+29)
t_1
(if (<= x 3.9e-61) (- (- 0.0 z) y) (if (<= x 2.45e+83) t_1 (- t_0 y))))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double t_1 = t_0 - z;
double tmp;
if (x <= -9e+29) {
tmp = t_1;
} else if (x <= 3.9e-61) {
tmp = (0.0 - z) - y;
} else if (x <= 2.45e+83) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = x * log(y)
t_1 = t_0 - z
if (x <= (-9d+29)) then
tmp = t_1
else if (x <= 3.9d-61) then
tmp = (0.0d0 - z) - y
else if (x <= 2.45d+83) then
tmp = t_1
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 t_1 = t_0 - z;
double tmp;
if (x <= -9e+29) {
tmp = t_1;
} else if (x <= 3.9e-61) {
tmp = (0.0 - z) - y;
} else if (x <= 2.45e+83) {
tmp = t_1;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) t_1 = t_0 - z tmp = 0 if x <= -9e+29: tmp = t_1 elif x <= 3.9e-61: tmp = (0.0 - z) - y elif x <= 2.45e+83: tmp = t_1 else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) t_1 = Float64(t_0 - z) tmp = 0.0 if (x <= -9e+29) tmp = t_1; elseif (x <= 3.9e-61) tmp = Float64(Float64(0.0 - z) - y); elseif (x <= 2.45e+83) tmp = t_1; else tmp = Float64(t_0 - y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); t_1 = t_0 - z; tmp = 0.0; if (x <= -9e+29) tmp = t_1; elseif (x <= 3.9e-61) tmp = (0.0 - z) - y; elseif (x <= 2.45e+83) tmp = t_1; 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]}, Block[{t$95$1 = N[(t$95$0 - z), $MachinePrecision]}, If[LessEqual[x, -9e+29], t$95$1, If[LessEqual[x, 3.9e-61], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], If[LessEqual[x, 2.45e+83], t$95$1, N[(t$95$0 - y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
t_1 := t\_0 - z\\
\mathbf{if}\;x \leq -9 \cdot 10^{+29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-61}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{elif}\;x \leq 2.45 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if x < -9.0000000000000005e29 or 3.90000000000000033e-61 < x < 2.44999999999999989e83Initial program 99.7%
sub-negN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6499.7
Applied egg-rr99.7%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6488.8
Simplified88.8%
if -9.0000000000000005e29 < x < 3.90000000000000033e-61Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6496.0
Simplified96.0%
sub0-negN/A
neg-lowering-neg.f6496.0
Applied egg-rr96.0%
if 2.44999999999999989e83 < x Initial program 99.7%
Taylor expanded in z around 0
--lowering--.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f6491.7
Simplified91.7%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
log-lowering-log.f6491.7
Applied egg-rr91.7%
Final simplification92.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* x (log y)) z))) (if (<= x -1.42e+29) t_0 (if (<= x 5.1e-63) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = (x * log(y)) - z;
double tmp;
if (x <= -1.42e+29) {
tmp = t_0;
} else if (x <= 5.1e-63) {
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)) - z
if (x <= (-1.42d+29)) then
tmp = t_0
else if (x <= 5.1d-63) 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)) - z;
double tmp;
if (x <= -1.42e+29) {
tmp = t_0;
} else if (x <= 5.1e-63) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * math.log(y)) - z tmp = 0 if x <= -1.42e+29: tmp = t_0 elif x <= 5.1e-63: tmp = (0.0 - z) - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * log(y)) - z) tmp = 0.0 if (x <= -1.42e+29) tmp = t_0; elseif (x <= 5.1e-63) 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)) - z; tmp = 0.0; if (x <= -1.42e+29) tmp = t_0; elseif (x <= 5.1e-63) 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] - z), $MachinePrecision]}, If[LessEqual[x, -1.42e+29], t$95$0, If[LessEqual[x, 5.1e-63], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y - z\\
\mathbf{if}\;x \leq -1.42 \cdot 10^{+29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-63}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.42e29 or 5.10000000000000024e-63 < x Initial program 99.7%
sub-negN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6499.7
Applied egg-rr99.7%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6485.6
Simplified85.6%
if -1.42e29 < x < 5.10000000000000024e-63Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6496.0
Simplified96.0%
sub0-negN/A
neg-lowering-neg.f6496.0
Applied egg-rr96.0%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -1.8e+185) t_0 (if (<= x 1.82e+142) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -1.8e+185) {
tmp = t_0;
} else if (x <= 1.82e+142) {
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 <= (-1.8d+185)) then
tmp = t_0
else if (x <= 1.82d+142) 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 <= -1.8e+185) {
tmp = t_0;
} else if (x <= 1.82e+142) {
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 <= -1.8e+185: tmp = t_0 elif x <= 1.82e+142: 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 <= -1.8e+185) tmp = t_0; elseif (x <= 1.82e+142) 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 <= -1.8e+185) tmp = t_0; elseif (x <= 1.82e+142) 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, -1.8e+185], t$95$0, If[LessEqual[x, 1.82e+142], 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 -1.8 \cdot 10^{+185}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.82 \cdot 10^{+142}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.80000000000000014e185 or 1.8200000000000001e142 < x Initial program 99.6%
sub-negN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6499.6
Applied egg-rr99.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
log-lowering-log.f6484.9
Simplified84.9%
if -1.80000000000000014e185 < x < 1.8200000000000001e142Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6481.2
Simplified81.2%
sub0-negN/A
neg-lowering-neg.f6481.2
Applied egg-rr81.2%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.7e+91) (- 0.0 z) (if (<= z 3.5e+98) (- 0.0 y) (- 0.0 z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.7e+91) {
tmp = 0.0 - z;
} else if (z <= 3.5e+98) {
tmp = 0.0 - y;
} else {
tmp = 0.0 - 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) :: tmp
if (z <= (-1.7d+91)) then
tmp = 0.0d0 - z
else if (z <= 3.5d+98) then
tmp = 0.0d0 - y
else
tmp = 0.0d0 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.7e+91) {
tmp = 0.0 - z;
} else if (z <= 3.5e+98) {
tmp = 0.0 - y;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.7e+91: tmp = 0.0 - z elif z <= 3.5e+98: tmp = 0.0 - y else: tmp = 0.0 - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.7e+91) tmp = Float64(0.0 - z); elseif (z <= 3.5e+98) tmp = Float64(0.0 - y); else tmp = Float64(0.0 - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.7e+91) tmp = 0.0 - z; elseif (z <= 3.5e+98) tmp = 0.0 - y; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.7e+91], N[(0.0 - z), $MachinePrecision], If[LessEqual[z, 3.5e+98], N[(0.0 - y), $MachinePrecision], N[(0.0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+91}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+98}:\\
\;\;\;\;0 - y\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if z < -1.7e91 or 3.5e98 < z Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6474.9
Simplified74.9%
if -1.7e91 < z < 3.5e98Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6442.2
Simplified42.2%
sub0-negN/A
neg-lowering-neg.f6442.2
Applied egg-rr42.2%
Final simplification52.1%
(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.8%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6463.5
Simplified63.5%
sub0-negN/A
neg-lowering-neg.f6463.5
Applied egg-rr63.5%
Final simplification63.5%
(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.8%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6432.8
Simplified32.8%
sub0-negN/A
neg-lowering-neg.f6432.8
Applied egg-rr32.8%
Final simplification32.8%
(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.8%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6463.5
Simplified63.5%
flip--N/A
clear-numN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
+-rgt-identityN/A
Applied egg-rr32.1%
Taylor expanded in z around inf
Simplified2.2%
herbie shell --seed 2024195
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))