
(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 5 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 -8.2e+162)
(and (not (<= x -5.675e+131))
(or (<= x -6.6e+99)
(and (not (<= x -1080000000.0))
(or (<= x -5.5e-12)
(and (not (<= x 2.4e+60))
(or (<= x 8.5e+90) (not (<= x 8e+141)))))))))
(* x (log y))
(- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.2e+162) || (!(x <= -5.675e+131) && ((x <= -6.6e+99) || (!(x <= -1080000000.0) && ((x <= -5.5e-12) || (!(x <= 2.4e+60) && ((x <= 8.5e+90) || !(x <= 8e+141)))))))) {
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 <= (-8.2d+162)) .or. (.not. (x <= (-5.675d+131))) .and. (x <= (-6.6d+99)) .or. (.not. (x <= (-1080000000.0d0))) .and. (x <= (-5.5d-12)) .or. (.not. (x <= 2.4d+60)) .and. (x <= 8.5d+90) .or. (.not. (x <= 8d+141))) 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 <= -8.2e+162) || (!(x <= -5.675e+131) && ((x <= -6.6e+99) || (!(x <= -1080000000.0) && ((x <= -5.5e-12) || (!(x <= 2.4e+60) && ((x <= 8.5e+90) || !(x <= 8e+141)))))))) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.2e+162) or (not (x <= -5.675e+131) and ((x <= -6.6e+99) or (not (x <= -1080000000.0) and ((x <= -5.5e-12) or (not (x <= 2.4e+60) and ((x <= 8.5e+90) or not (x <= 8e+141))))))): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.2e+162) || (!(x <= -5.675e+131) && ((x <= -6.6e+99) || (!(x <= -1080000000.0) && ((x <= -5.5e-12) || (!(x <= 2.4e+60) && ((x <= 8.5e+90) || !(x <= 8e+141)))))))) 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 <= -8.2e+162) || (~((x <= -5.675e+131)) && ((x <= -6.6e+99) || (~((x <= -1080000000.0)) && ((x <= -5.5e-12) || (~((x <= 2.4e+60)) && ((x <= 8.5e+90) || ~((x <= 8e+141))))))))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.2e+162], And[N[Not[LessEqual[x, -5.675e+131]], $MachinePrecision], Or[LessEqual[x, -6.6e+99], And[N[Not[LessEqual[x, -1080000000.0]], $MachinePrecision], Or[LessEqual[x, -5.5e-12], And[N[Not[LessEqual[x, 2.4e+60]], $MachinePrecision], Or[LessEqual[x, 8.5e+90], N[Not[LessEqual[x, 8e+141]], $MachinePrecision]]]]]]]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+162} \lor \neg \left(x \leq -5.675 \cdot 10^{+131}\right) \land \left(x \leq -6.6 \cdot 10^{+99} \lor \neg \left(x \leq -1080000000\right) \land \left(x \leq -5.5 \cdot 10^{-12} \lor \neg \left(x \leq 2.4 \cdot 10^{+60}\right) \land \left(x \leq 8.5 \cdot 10^{+90} \lor \neg \left(x \leq 8 \cdot 10^{+141}\right)\right)\right)\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -8.1999999999999998e162 or -5.67500000000000026e131 < x < -6.5999999999999998e99 or -1.08e9 < x < -5.5000000000000004e-12 or 2.4e60 < x < 8.5000000000000002e90 or 8.00000000000000014e141 < x Initial program 99.7%
associate--l-99.7%
fma-neg99.7%
distribute-neg-in99.7%
+-commutative99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 95.3%
fma-neg95.3%
Simplified95.3%
Taylor expanded in x around inf 89.9%
if -8.1999999999999998e162 < x < -5.67500000000000026e131 or -6.5999999999999998e99 < x < -1.08e9 or -5.5000000000000004e-12 < x < 2.4e60 or 8.5000000000000002e90 < x < 8.00000000000000014e141Initial program 100.0%
Taylor expanded in x around 0 88.1%
neg-mul-188.1%
Simplified88.1%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.8e-28) (not (<= x 2.5e+58))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e-28) || !(x <= 2.5e+58)) {
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.8d-28)) .or. (.not. (x <= 2.5d+58))) 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.8e-28) || !(x <= 2.5e+58)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.8e-28) or not (x <= 2.5e+58): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.8e-28) || !(x <= 2.5e+58)) 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.8e-28) || ~((x <= 2.5e+58))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.8e-28], N[Not[LessEqual[x, 2.5e+58]], $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.8 \cdot 10^{-28} \lor \neg \left(x \leq 2.5 \cdot 10^{+58}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -5.80000000000000026e-28 or 2.49999999999999993e58 < x Initial program 99.8%
associate--l-99.8%
fma-neg99.8%
distribute-neg-in99.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in z around 0 88.8%
if -5.80000000000000026e-28 < x < 2.49999999999999993e58Initial program 100.0%
Taylor expanded in x around 0 92.7%
neg-mul-192.7%
Simplified92.7%
Final simplification90.9%
(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 64.7%
neg-mul-164.7%
Simplified64.7%
Final simplification64.7%
(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%
associate--l-99.9%
fma-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 38.1%
mul-1-neg38.1%
Simplified38.1%
Final simplification38.1%
herbie shell --seed 2024020
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))