
(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 (- (- 0.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 = (0.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 = (0.0d0 - 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 = (0.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 = (0.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(0.0 - 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 = (0.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[(N[(0.0 - z), $MachinePrecision] - 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(0 - 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
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
--lowering--.f6486.5%
Simplified86.5%
sub0-negN/A
neg-lowering-neg.f6486.5%
Applied egg-rr86.5%
if -6.6e81 < z < 8.59999999999999932e-30Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6491.2%
Simplified91.2%
if 6.2e11 < z Initial program 100.0%
Taylor expanded in y around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6486.7%
Simplified86.7%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* x (log y)) y))) (if (<= x -2.2e-33) t_0 (if (<= x 4.3e+129) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = (x * log(y)) - y;
double tmp;
if (x <= -2.2e-33) {
tmp = t_0;
} else if (x <= 4.3e+129) {
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)) - y
if (x <= (-2.2d-33)) then
tmp = t_0
else if (x <= 4.3d+129) 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)) - y;
double tmp;
if (x <= -2.2e-33) {
tmp = t_0;
} else if (x <= 4.3e+129) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * math.log(y)) - y tmp = 0 if x <= -2.2e-33: tmp = t_0 elif x <= 4.3e+129: tmp = (0.0 - z) - y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if (x <= -2.2e-33) tmp = t_0; elseif (x <= 4.3e+129) 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)) - y; tmp = 0.0; if (x <= -2.2e-33) tmp = t_0; elseif (x <= 4.3e+129) 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] - y), $MachinePrecision]}, If[LessEqual[x, -2.2e-33], t$95$0, If[LessEqual[x, 4.3e+129], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y - y\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{+129}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.20000000000000005e-33 or 4.30000000000000021e129 < x Initial program 99.8%
Taylor expanded in z around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f6486.1%
Simplified86.1%
if -2.20000000000000005e-33 < x < 4.30000000000000021e129Initial 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--.f6487.9%
Simplified87.9%
sub0-negN/A
neg-lowering-neg.f6487.9%
Applied egg-rr87.9%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -3.5e+124) t_0 (if (<= x 1.4e+130) (- (- 0.0 z) y) t_0))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -3.5e+124) {
tmp = t_0;
} else if (x <= 1.4e+130) {
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 <= (-3.5d+124)) then
tmp = t_0
else if (x <= 1.4d+130) 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 <= -3.5e+124) {
tmp = t_0;
} else if (x <= 1.4e+130) {
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 <= -3.5e+124: tmp = t_0 elif x <= 1.4e+130: 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 <= -3.5e+124) tmp = t_0; elseif (x <= 1.4e+130) 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 <= -3.5e+124) tmp = t_0; elseif (x <= 1.4e+130) 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, -3.5e+124], t$95$0, If[LessEqual[x, 1.4e+130], 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 -3.5 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+130}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.5000000000000001e124 or 1.3999999999999999e130 < x Initial program 99.8%
Taylor expanded in x around inf
*-lowering-*.f64N/A
log-lowering-log.f6484.8%
Simplified84.8%
if -3.5000000000000001e124 < x < 1.3999999999999999e130Initial 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--.f6482.8%
Simplified82.8%
sub0-negN/A
neg-lowering-neg.f6482.8%
Applied egg-rr82.8%
Final simplification83.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.65e+155) (- 0.0 z) (if (<= z 1800000000.0) (- 0.0 y) (- 0.0 z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.65e+155) {
tmp = 0.0 - z;
} else if (z <= 1800000000.0) {
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.65d+155)) then
tmp = 0.0d0 - z
else if (z <= 1800000000.0d0) 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.65e+155) {
tmp = 0.0 - z;
} else if (z <= 1800000000.0) {
tmp = 0.0 - y;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.65e+155: tmp = 0.0 - z elif z <= 1800000000.0: tmp = 0.0 - y else: tmp = 0.0 - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.65e+155) tmp = Float64(0.0 - z); elseif (z <= 1800000000.0) 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.65e+155) tmp = 0.0 - z; elseif (z <= 1800000000.0) tmp = 0.0 - y; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.65e+155], N[(0.0 - z), $MachinePrecision], If[LessEqual[z, 1800000000.0], N[(0.0 - y), $MachinePrecision], N[(0.0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+155}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;z \leq 1800000000:\\
\;\;\;\;0 - y\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if z < -1.6499999999999999e155 or 1.8e9 < z Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6468.1%
Simplified68.1%
if -1.6499999999999999e155 < z < 1.8e9Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6442.4%
Simplified42.4%
sub0-negN/A
neg-lowering-neg.f6442.4%
Applied egg-rr42.4%
Final simplification50.6%
(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.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--.f6463.2%
Simplified63.2%
sub0-negN/A
neg-lowering-neg.f6463.2%
Applied egg-rr63.2%
Final simplification63.2%
(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.9%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6433.1%
Simplified33.1%
sub0-negN/A
neg-lowering-neg.f6433.1%
Applied egg-rr33.1%
Final simplification33.1%
(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.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--.f6463.2%
Simplified63.2%
flip--N/A
clear-numN/A
/-lowering-/.f64N/A
+-lft-identityN/A
metadata-evalN/A
neg-sub0N/A
distribute-lft-neg-inN/A
sub0-negN/A
Applied egg-rr29.8%
Taylor expanded in z around inf
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))