
(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 x (log y) (- (- z) y)))
double code(double x, double y, double z) {
return fma(x, log(y), (-z - y));
}
function code(x, y, z) return fma(x, log(y), Float64(Float64(-z) - y)) end
code[x_, y_, z_] := N[(x * N[Log[y], $MachinePrecision] + N[((-z) - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \log y, \left(-z\right) - y\right)
\end{array}
Initial program 99.8%
associate--l-99.8%
fma-neg99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.4e+14) (not (<= z 2.65e-20))) (- (- z) y) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.4e+14) || !(z <= 2.65e-20)) {
tmp = -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 ((z <= (-3.4d+14)) .or. (.not. (z <= 2.65d-20))) then
tmp = -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 ((z <= -3.4e+14) || !(z <= 2.65e-20)) {
tmp = -z - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.4e+14) or not (z <= 2.65e-20): tmp = -z - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.4e+14) || !(z <= 2.65e-20)) tmp = Float64(Float64(-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 ((z <= -3.4e+14) || ~((z <= 2.65e-20))) tmp = -z - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.4e+14], N[Not[LessEqual[z, 2.65e-20]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+14} \lor \neg \left(z \leq 2.65 \cdot 10^{-20}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -3.4e14 or 2.6500000000000001e-20 < z Initial program 99.9%
Taylor expanded in x around 0 78.3%
neg-mul-178.3%
Simplified78.3%
if -3.4e14 < z < 2.6500000000000001e-20Initial program 99.7%
Taylor expanded in x around inf 91.0%
Final simplification84.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (or (<= z -1.15e-7) (not (<= z 0.0023))) (- t_0 z) (- t_0 y))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if ((z <= -1.15e-7) || !(z <= 0.0023)) {
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 <= (-1.15d-7)) .or. (.not. (z <= 0.0023d0))) 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 <= -1.15e-7) || !(z <= 0.0023)) {
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 <= -1.15e-7) or not (z <= 0.0023): 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 <= -1.15e-7) || !(z <= 0.0023)) 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 <= -1.15e-7) || ~((z <= 0.0023))) 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, -1.15e-7], N[Not[LessEqual[z, 0.0023]], $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 -1.15 \cdot 10^{-7} \lor \neg \left(z \leq 0.0023\right):\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;t_0 - y\\
\end{array}
\end{array}
if z < -1.14999999999999997e-7 or 0.0023 < z Initial program 99.9%
Taylor expanded in y around inf 99.9%
distribute-lft-out99.9%
mul-1-neg99.9%
*-commutative99.9%
log-rec99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in y around 0 89.1%
if -1.14999999999999997e-7 < z < 0.0023Initial program 99.7%
Taylor expanded in x around inf 92.0%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.2e+173) (not (<= x 6.6e+97))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.2e+173) || !(x <= 6.6e+97)) {
tmp = x * log(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 <= (-3.2d+173)) .or. (.not. (x <= 6.6d+97))) then
tmp = x * log(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 <= -3.2e+173) || !(x <= 6.6e+97)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.2e+173) or not (x <= 6.6e+97): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.2e+173) || !(x <= 6.6e+97)) tmp = Float64(x * log(y)); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.2e+173) || ~((x <= 6.6e+97))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.2e+173], N[Not[LessEqual[x, 6.6e+97]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+173} \lor \neg \left(x \leq 6.6 \cdot 10^{+97}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.2000000000000003e173 or 6.6000000000000003e97 < x Initial program 99.6%
Taylor expanded in y around inf 99.6%
distribute-lft-out99.6%
mul-1-neg99.6%
*-commutative99.6%
log-rec99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 72.8%
if -3.2000000000000003e173 < x < 6.6000000000000003e97Initial program 99.9%
Taylor expanded in x around 0 82.4%
neg-mul-182.4%
Simplified82.4%
Final simplification79.4%
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) y) z))
double code(double x, double y, double z) {
return ((x * log(y)) - y) - z;
}
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)) - y) - z
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - y) - z;
}
def code(x, y, z): return ((x * math.log(y)) - y) - z
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - y) - z) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - y) - z; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - y\right) - z
\end{array}
Initial program 99.8%
Taylor expanded in y around inf 99.8%
distribute-lft-out99.8%
mul-1-neg99.8%
*-commutative99.8%
log-rec99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
neg-mul-199.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.9e-7) (- z) (if (<= z 0.0069) (- y) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.9e-7) {
tmp = -z;
} else if (z <= 0.0069) {
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 <= (-1.9d-7)) then
tmp = -z
else if (z <= 0.0069d0) 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 <= -1.9e-7) {
tmp = -z;
} else if (z <= 0.0069) {
tmp = -y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.9e-7: tmp = -z elif z <= 0.0069: tmp = -y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.9e-7) tmp = Float64(-z); elseif (z <= 0.0069) tmp = Float64(-y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.9e-7) tmp = -z; elseif (z <= 0.0069) tmp = -y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.9e-7], (-z), If[LessEqual[z, 0.0069], (-y), (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{-7}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 0.0069:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1.90000000000000007e-7 or 0.0068999999999999999 < z Initial program 99.9%
Taylor expanded in y around inf 99.9%
distribute-lft-out99.9%
mul-1-neg99.9%
*-commutative99.9%
log-rec99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 64.9%
neg-mul-164.9%
Simplified64.9%
if -1.90000000000000007e-7 < z < 0.0068999999999999999Initial program 99.7%
Taylor expanded in y around inf 45.6%
mul-1-neg45.6%
Simplified45.6%
Final simplification55.7%
(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.8%
Taylor expanded in x around 0 65.1%
neg-mul-165.1%
Simplified65.1%
Final simplification65.1%
(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.8%
Taylor expanded in y around inf 27.4%
mul-1-neg27.4%
Simplified27.4%
Final simplification27.4%
(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%
associate--l-99.8%
*-commutative99.8%
add-cube-cbrt99.2%
associate-*r*99.2%
+-commutative99.2%
add-sqr-sqrt69.8%
sqrt-unprod45.7%
sqr-neg45.7%
sqrt-unprod9.8%
add-sqr-sqrt34.0%
fma-neg34.0%
pow234.0%
add-sqr-sqrt9.8%
sqrt-unprod45.7%
sqr-neg45.7%
sqrt-unprod69.8%
add-sqr-sqrt99.2%
add-sqr-sqrt28.9%
sqrt-unprod35.0%
sqr-neg35.0%
Applied egg-rr34.0%
Taylor expanded in z around inf 2.3%
Final simplification2.3%
herbie shell --seed 2023293
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))