
(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 10 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 (- (- 0.0 z) y)))
double code(double x, double y, double z) {
return fma(log(y), x, ((0.0 - z) - y));
}
function code(x, y, z) return fma(log(y), x, Float64(Float64(0.0 - z) - y)) end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] * x + N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(0 - z\right) - y\right)
\end{array}
Initial program 99.8%
associate--l-N/A
*-commutativeN/A
fmm-defN/A
fma-lowering-fma.f64N/A
log-lowering-log.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6499.8%
Applied egg-rr99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (log y) x)) (t_1 (- t_0 z))) (if (<= z -1.12e+76) t_1 (if (<= z 7e+116) (- 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 <= -1.12e+76) {
tmp = t_1;
} else if (z <= 7e+116) {
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 <= (-1.12d+76)) then
tmp = t_1
else if (z <= 7d+116) 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 <= -1.12e+76) {
tmp = t_1;
} else if (z <= 7e+116) {
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 <= -1.12e+76: tmp = t_1 elif z <= 7e+116: 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 <= -1.12e+76) tmp = t_1; elseif (z <= 7e+116) 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 <= -1.12e+76) tmp = t_1; elseif (z <= 7e+116) 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, -1.12e+76], t$95$1, If[LessEqual[z, 7e+116], 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 -1.12 \cdot 10^{+76}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7 \cdot 10^{+116}:\\
\;\;\;\;t\_0 - y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.12000000000000005e76 or 6.99999999999999993e116 < z Initial program 99.9%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6487.2%
Simplified87.2%
if -1.12000000000000005e76 < z < 6.99999999999999993e116Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6491.6%
Simplified91.6%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (- 0.0 z) y))) (if (<= z -3.3e+129) t_0 (if (<= z 2.1e+125) (- (* (log y) x) y) t_0))))
double code(double x, double y, double z) {
double t_0 = (0.0 - z) - y;
double tmp;
if (z <= -3.3e+129) {
tmp = t_0;
} else if (z <= 2.1e+125) {
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 = (0.0d0 - z) - y
if (z <= (-3.3d+129)) then
tmp = t_0
else if (z <= 2.1d+125) 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 = (0.0 - z) - y;
double tmp;
if (z <= -3.3e+129) {
tmp = t_0;
} else if (z <= 2.1e+125) {
tmp = (Math.log(y) * x) - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (0.0 - z) - y tmp = 0 if z <= -3.3e+129: tmp = t_0 elif z <= 2.1e+125: tmp = (math.log(y) * x) - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(0.0 - z) - y) tmp = 0.0 if (z <= -3.3e+129) tmp = t_0; elseif (z <= 2.1e+125) tmp = Float64(Float64(log(y) * x) - y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (0.0 - z) - y; tmp = 0.0; if (z <= -3.3e+129) tmp = t_0; elseif (z <= 2.1e+125) tmp = (log(y) * x) - y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[z, -3.3e+129], t$95$0, If[LessEqual[z, 2.1e+125], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0 - z\right) - y\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+125}:\\
\;\;\;\;\log y \cdot x - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.2999999999999999e129 or 2.1000000000000001e125 < z 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--.f6489.9%
Simplified89.9%
sub0-negN/A
neg-lowering-neg.f6489.9%
Applied egg-rr89.9%
if -3.2999999999999999e129 < z < 2.1000000000000001e125Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6489.3%
Simplified89.3%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (log y) x))) (if (<= x -3.8e+153) t_0 (if (<= x 5.4e+71) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = log(y) * x;
double tmp;
if (x <= -3.8e+153) {
tmp = t_0;
} else if (x <= 5.4e+71) {
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 = log(y) * x
if (x <= (-3.8d+153)) then
tmp = t_0
else if (x <= 5.4d+71) 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 = Math.log(y) * x;
double tmp;
if (x <= -3.8e+153) {
tmp = t_0;
} else if (x <= 5.4e+71) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.log(y) * x tmp = 0 if x <= -3.8e+153: tmp = t_0 elif x <= 5.4e+71: tmp = (0.0 - z) - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(log(y) * x) tmp = 0.0 if (x <= -3.8e+153) tmp = t_0; elseif (x <= 5.4e+71) tmp = Float64(Float64(0.0 - 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 <= -3.8e+153) tmp = t_0; elseif (x <= 5.4e+71) tmp = (0.0 - 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, -3.8e+153], t$95$0, If[LessEqual[x, 5.4e+71], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot x\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+71}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.79999999999999966e153 or 5.39999999999999993e71 < x Initial program 99.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
log-lowering-log.f6477.3%
Simplified77.3%
if -3.79999999999999966e153 < x < 5.39999999999999993e71Initial 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--.f6480.6%
Simplified80.6%
sub0-negN/A
neg-lowering-neg.f6480.6%
Applied egg-rr80.6%
Final simplification79.6%
(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.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.1e+82) (- 0.0 z) (if (<= z 1.1e+120) (- z y) (- 0.0 z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+82) {
tmp = 0.0 - z;
} else if (z <= 1.1e+120) {
tmp = z - 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.1d+82)) then
tmp = 0.0d0 - z
else if (z <= 1.1d+120) then
tmp = z - 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.1e+82) {
tmp = 0.0 - z;
} else if (z <= 1.1e+120) {
tmp = z - y;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1e+82: tmp = 0.0 - z elif z <= 1.1e+120: tmp = z - y else: tmp = 0.0 - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1e+82) tmp = Float64(0.0 - z); elseif (z <= 1.1e+120) tmp = Float64(z - y); else tmp = Float64(0.0 - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.1e+82) tmp = 0.0 - z; elseif (z <= 1.1e+120) tmp = z - y; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1e+82], N[(0.0 - z), $MachinePrecision], If[LessEqual[z, 1.1e+120], N[(z - y), $MachinePrecision], N[(0.0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+82}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+120}:\\
\;\;\;\;z - y\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if z < -1.1000000000000001e82 or 1.1000000000000001e120 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6472.1%
Simplified72.1%
if -1.1000000000000001e82 < z < 1.1000000000000001e120Initial program 99.8%
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--.f6452.2%
Simplified52.2%
flip3--N/A
metadata-evalN/A
sub-negN/A
metadata-evalN/A
cube-negN/A
sub0-negN/A
sqr-powN/A
pow-prod-downN/A
sub0-negN/A
sub0-negN/A
sqr-negN/A
pow-prod-downN/A
sqr-powN/A
fma-defineN/A
mul0-lftN/A
metadata-evalN/A
fmm-defN/A
mul0-lftN/A
flip3-+N/A
+-lft-identityN/A
Applied egg-rr45.4%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e+78) (- 0.0 z) (if (<= z 8.8e+119) (- 0.0 y) (- 0.0 z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e+78) {
tmp = 0.0 - z;
} else if (z <= 8.8e+119) {
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 <= (-2.1d+78)) then
tmp = 0.0d0 - z
else if (z <= 8.8d+119) 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 <= -2.1e+78) {
tmp = 0.0 - z;
} else if (z <= 8.8e+119) {
tmp = 0.0 - y;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e+78: tmp = 0.0 - z elif z <= 8.8e+119: tmp = 0.0 - y else: tmp = 0.0 - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e+78) tmp = Float64(0.0 - z); elseif (z <= 8.8e+119) 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 <= -2.1e+78) tmp = 0.0 - z; elseif (z <= 8.8e+119) tmp = 0.0 - y; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e+78], N[(0.0 - z), $MachinePrecision], If[LessEqual[z, 8.8e+119], N[(0.0 - y), $MachinePrecision], N[(0.0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{+78}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{+119}:\\
\;\;\;\;0 - y\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if z < -2.1000000000000001e78 or 8.8000000000000005e119 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6472.1%
Simplified72.1%
if -2.1000000000000001e78 < z < 8.8000000000000005e119Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6445.2%
Simplified45.2%
sub0-negN/A
neg-lowering-neg.f6445.2%
Applied egg-rr45.2%
Final simplification53.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
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6461.4%
Simplified61.4%
sub0-negN/A
neg-lowering-neg.f6461.4%
Applied egg-rr61.4%
Final simplification61.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.8%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6435.8%
Simplified35.8%
sub0-negN/A
neg-lowering-neg.f6435.8%
Applied egg-rr35.8%
Final simplification35.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
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6461.4%
Simplified61.4%
flip3--N/A
metadata-evalN/A
+-lft-identityN/A
distribute-rgt-outN/A
+-commutativeN/A
+-lft-identityN/A
/-lowering-/.f64N/A
metadata-evalN/A
sub0-negN/A
cube-negN/A
sub0-negN/A
sqr-powN/A
pow-prod-downN/A
sub0-negN/A
sub0-negN/A
sqr-negN/A
pow-prod-downN/A
sqr-powN/A
cube-multN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6417.9%
Applied egg-rr17.9%
Taylor expanded in z around inf
Simplified2.5%
herbie shell --seed 2024152
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))