
(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 7 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%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.5e+54) (not (<= x 2.9e+147))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+54) || !(x <= 2.9e+147)) {
tmp = (x * log(y)) - y;
} else {
tmp = -z - 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 <= (-5.5d+54)) .or. (.not. (x <= 2.9d+147))) then
tmp = (x * log(y)) - y
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+54) || !(x <= 2.9e+147)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.5e+54) or not (x <= 2.9e+147): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e+54) || !(x <= 2.9e+147)) tmp = Float64(Float64(x * log(y)) - y); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.5e+54) || ~((x <= 2.9e+147))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e+54], N[Not[LessEqual[x, 2.9e+147]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+54} \lor \neg \left(x \leq 2.9 \cdot 10^{+147}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -5.50000000000000026e54 or 2.8999999999999998e147 < x Initial program 99.7%
Taylor expanded in z around 0 87.7%
if -5.50000000000000026e54 < x < 2.8999999999999998e147Initial program 100.0%
Taylor expanded in x around 0 88.1%
mul-1-neg88.1%
distribute-neg-in88.1%
+-commutative88.1%
sub-neg88.1%
Simplified88.1%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (or (<= z -4.2e+38) (not (<= z 5.2e-15))) (- t_0 z) (- t_0 y))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if ((z <= -4.2e+38) || !(z <= 5.2e-15)) {
tmp = t_0 - z;
} 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 ((z <= (-4.2d+38)) .or. (.not. (z <= 5.2d-15))) then
tmp = t_0 - z
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 ((z <= -4.2e+38) || !(z <= 5.2e-15)) {
tmp = t_0 - z;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if (z <= -4.2e+38) or not (z <= 5.2e-15): tmp = t_0 - z else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if ((z <= -4.2e+38) || !(z <= 5.2e-15)) tmp = Float64(t_0 - z); 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 ((z <= -4.2e+38) || ~((z <= 5.2e-15))) tmp = t_0 - z; 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[Or[LessEqual[z, -4.2e+38], N[Not[LessEqual[z, 5.2e-15]], $MachinePrecision]], N[(t$95$0 - z), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+38} \lor \neg \left(z \leq 5.2 \cdot 10^{-15}\right):\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;t_0 - y\\
\end{array}
\end{array}
if z < -4.2e38 or 5.20000000000000009e-15 < z Initial program 99.9%
Taylor expanded in y around 0 87.1%
if -4.2e38 < z < 5.20000000000000009e-15Initial program 99.8%
Taylor expanded in z around 0 91.4%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= z -7.8e+37) (- z) (if (<= z 4.3e-16) (- z y) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e+37) {
tmp = -z;
} else if (z <= 4.3e-16) {
tmp = z - 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 <= (-7.8d+37)) then
tmp = -z
else if (z <= 4.3d-16) then
tmp = z - y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e+37) {
tmp = -z;
} else if (z <= 4.3e-16) {
tmp = z - y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.8e+37: tmp = -z elif z <= 4.3e-16: tmp = z - y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.8e+37) tmp = Float64(-z); elseif (z <= 4.3e-16) tmp = Float64(z - y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.8e+37) tmp = -z; elseif (z <= 4.3e-16) tmp = z - y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.8e+37], (-z), If[LessEqual[z, 4.3e-16], N[(z - y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{+37}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-16}:\\
\;\;\;\;z - y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -7.7999999999999997e37 or 4.2999999999999999e-16 < z Initial program 99.9%
Taylor expanded in z around inf 61.5%
mul-1-neg61.5%
Simplified61.5%
if -7.7999999999999997e37 < z < 4.2999999999999999e-16Initial program 99.8%
flip--74.5%
div-inv74.4%
difference-of-squares74.4%
add-sqr-sqrt29.9%
sqrt-unprod68.5%
sqr-neg68.5%
sqrt-unprod38.6%
add-sqr-sqrt67.5%
sub-neg67.5%
pow267.5%
fma-neg67.5%
add-sqr-sqrt38.6%
sqrt-unprod67.5%
sqr-neg67.5%
sqrt-unprod28.9%
add-sqr-sqrt67.5%
fma-def67.5%
Applied egg-rr67.5%
Taylor expanded in x around 0 46.6%
Final simplification53.8%
(FPCore (x y z) :precision binary64 (if (<= z -6.8e+37) (- z) (if (<= z 4.3e-16) (- y) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.8e+37) {
tmp = -z;
} else if (z <= 4.3e-16) {
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 <= (-6.8d+37)) then
tmp = -z
else if (z <= 4.3d-16) 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 <= -6.8e+37) {
tmp = -z;
} else if (z <= 4.3e-16) {
tmp = -y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.8e+37: tmp = -z elif z <= 4.3e-16: tmp = -y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.8e+37) tmp = Float64(-z); elseif (z <= 4.3e-16) tmp = Float64(-y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.8e+37) tmp = -z; elseif (z <= 4.3e-16) tmp = -y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.8e+37], (-z), If[LessEqual[z, 4.3e-16], (-y), (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.8 \cdot 10^{+37}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-16}:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -6.80000000000000011e37 or 4.2999999999999999e-16 < z Initial program 99.9%
Taylor expanded in z around inf 61.5%
mul-1-neg61.5%
Simplified61.5%
if -6.80000000000000011e37 < z < 4.2999999999999999e-16Initial program 99.8%
Taylor expanded in y around inf 46.5%
neg-mul-146.5%
Simplified46.5%
Final simplification53.8%
(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 63.6%
mul-1-neg63.6%
distribute-neg-in63.6%
+-commutative63.6%
sub-neg63.6%
Simplified63.6%
Final simplification63.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 30.8%
neg-mul-130.8%
Simplified30.8%
Final simplification30.8%
herbie shell --seed 2023257
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))