
(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 9 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.9%
Applied egg-rr0
(FPCore (x y z) :precision binary64 (if (<= x -1.9e+69) (* x (- (log y) (/ z x))) (if (<= x 2.6e+25) (- (- 0.0 z) y) (- (* x (log y)) y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+69) {
tmp = x * (log(y) - (z / x));
} else if (x <= 2.6e+25) {
tmp = (0.0 - z) - y;
} else {
tmp = (x * log(y)) - 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 <= (-1.9d+69)) then
tmp = x * (log(y) - (z / x))
else if (x <= 2.6d+25) then
tmp = (0.0d0 - z) - y
else
tmp = (x * log(y)) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+69) {
tmp = x * (Math.log(y) - (z / x));
} else if (x <= 2.6e+25) {
tmp = (0.0 - z) - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.9e+69: tmp = x * (math.log(y) - (z / x)) elif x <= 2.6e+25: tmp = (0.0 - z) - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.9e+69) tmp = Float64(x * Float64(log(y) - Float64(z / x))); elseif (x <= 2.6e+25) tmp = Float64(Float64(0.0 - z) - y); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.9e+69) tmp = x * (log(y) - (z / x)); elseif (x <= 2.6e+25) tmp = (0.0 - z) - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.9e+69], N[(x * N[(N[Log[y], $MachinePrecision] - N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e+25], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+69}:\\
\;\;\;\;x \cdot \left(\log y - \frac{z}{x}\right)\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+25}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if x < -1.90000000000000014e69Initial program 99.6%
Applied egg-rr0
Taylor expanded in x around inf 0
Simplified0
Taylor expanded in y around 0 0
Simplified0
if -1.90000000000000014e69 < x < 2.5999999999999998e25Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
if 2.5999999999999998e25 < x Initial program 99.8%
Taylor expanded in z around 0 0
Simplified0
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))))
(if (<= x -1.45e+69)
(- t_0 z)
(if (<= x 1.7e+23) (- (- 0.0 z) y) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -1.45e+69) {
tmp = t_0 - z;
} else if (x <= 1.7e+23) {
tmp = (0.0 - z) - y;
} 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 (x <= (-1.45d+69)) then
tmp = t_0 - z
else if (x <= 1.7d+23) then
tmp = (0.0d0 - z) - y
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 (x <= -1.45e+69) {
tmp = t_0 - z;
} else if (x <= 1.7e+23) {
tmp = (0.0 - z) - y;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if x <= -1.45e+69: tmp = t_0 - z elif x <= 1.7e+23: tmp = (0.0 - z) - y else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (x <= -1.45e+69) tmp = Float64(t_0 - z); elseif (x <= 1.7e+23) tmp = Float64(Float64(0.0 - z) - y); 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 (x <= -1.45e+69) tmp = t_0 - z; elseif (x <= 1.7e+23) tmp = (0.0 - z) - y; 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[LessEqual[x, -1.45e+69], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[x, 1.7e+23], N[(N[(0.0 - z), $MachinePrecision] - y), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{+69}:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+23}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if x < -1.4499999999999999e69Initial program 99.6%
Taylor expanded in y around 0 0
Simplified0
if -1.4499999999999999e69 < x < 1.69999999999999996e23Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
if 1.69999999999999996e23 < x Initial program 99.8%
Taylor expanded in z around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* x (log y)) y))) (if (<= x -5.6e+73) t_0 (if (<= x 2.3e+25) (- (- 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 <= -5.6e+73) {
tmp = t_0;
} else if (x <= 2.3e+25) {
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 <= (-5.6d+73)) then
tmp = t_0
else if (x <= 2.3d+25) 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 <= -5.6e+73) {
tmp = t_0;
} else if (x <= 2.3e+25) {
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 <= -5.6e+73: tmp = t_0 elif x <= 2.3e+25: 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 <= -5.6e+73) tmp = t_0; elseif (x <= 2.3e+25) 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 <= -5.6e+73) tmp = t_0; elseif (x <= 2.3e+25) 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, -5.6e+73], t$95$0, If[LessEqual[x, 2.3e+25], 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 -5.6 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+25}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.60000000000000016e73 or 2.2999999999999998e25 < x Initial program 99.7%
Taylor expanded in z around 0 0
Simplified0
if -5.60000000000000016e73 < x < 2.2999999999999998e25Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -3.3e+75) t_0 (if (<= x 9e+99) (- (- 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.3e+75) {
tmp = t_0;
} else if (x <= 9e+99) {
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.3d+75)) then
tmp = t_0
else if (x <= 9d+99) 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.3e+75) {
tmp = t_0;
} else if (x <= 9e+99) {
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.3e+75: tmp = t_0 elif x <= 9e+99: 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.3e+75) tmp = t_0; elseif (x <= 9e+99) 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.3e+75) tmp = t_0; elseif (x <= 9e+99) 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.3e+75], t$95$0, If[LessEqual[x, 9e+99], 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.3 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+99}:\\
\;\;\;\;\left(0 - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.29999999999999998e75 or 8.9999999999999999e99 < x Initial program 99.7%
Taylor expanded in x around inf 0
Simplified0
if -3.29999999999999998e75 < x < 8.9999999999999999e99Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
(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 (if (<= z -5.5e+77) (- z) (if (<= z 1e+92) (- y) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+77) {
tmp = -z;
} else if (z <= 1e+92) {
tmp = -y;
} else {
tmp = -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 <= (-5.5d+77)) then
tmp = -z
else if (z <= 1d+92) then
tmp = -y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+77) {
tmp = -z;
} else if (z <= 1e+92) {
tmp = -y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.5e+77: tmp = -z elif z <= 1e+92: tmp = -y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.5e+77) tmp = Float64(-z); elseif (z <= 1e+92) tmp = Float64(-y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.5e+77) tmp = -z; elseif (z <= 1e+92) tmp = -y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.5e+77], (-z), If[LessEqual[z, 1e+92], (-y), (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+77}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 10^{+92}:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -5.50000000000000036e77 or 1e92 < z Initial program 99.9%
Taylor expanded in z around inf 0
Simplified0
Applied egg-rr0
if -5.50000000000000036e77 < z < 1e92Initial program 99.8%
Taylor expanded in y around inf 0
Simplified0
Applied egg-rr0
(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 0
Simplified0
(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 0
Simplified0
Applied egg-rr0
herbie shell --seed 2024110
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))