
(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.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.8e-41) (not (<= x 3e+34))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e-41) || !(x <= 3e+34)) {
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-41)) .or. (.not. (x <= 3d+34))) 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-41) || !(x <= 3e+34)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.8e-41) or not (x <= 3e+34): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.8e-41) || !(x <= 3e+34)) 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-41) || ~((x <= 3e+34))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.8e-41], N[Not[LessEqual[x, 3e+34]], $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^{-41} \lor \neg \left(x \leq 3 \cdot 10^{+34}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -5.79999999999999955e-41 or 3.00000000000000018e34 < x Initial program 99.7%
Taylor expanded in z around 0 89.8%
if -5.79999999999999955e-41 < x < 3.00000000000000018e34Initial program 100.0%
Taylor expanded in x around 0 93.2%
neg-mul-193.2%
+-commutative93.2%
distribute-neg-in93.2%
sub-neg93.2%
Simplified93.2%
Final simplification91.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -2.85e-40) (- t_0 y) (if (<= x 1.12e-16) (- (- z) y) (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -2.85e-40) {
tmp = t_0 - y;
} else if (x <= 1.12e-16) {
tmp = -z - y;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = x * log(y)
if (x <= (-2.85d-40)) then
tmp = t_0 - y
else if (x <= 1.12d-16) then
tmp = -z - y
else
tmp = t_0 - z
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 <= -2.85e-40) {
tmp = t_0 - y;
} else if (x <= 1.12e-16) {
tmp = -z - y;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if x <= -2.85e-40: tmp = t_0 - y elif x <= 1.12e-16: tmp = -z - y else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (x <= -2.85e-40) tmp = Float64(t_0 - y); elseif (x <= 1.12e-16) tmp = Float64(Float64(-z) - y); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); tmp = 0.0; if (x <= -2.85e-40) tmp = t_0 - y; elseif (x <= 1.12e-16) tmp = -z - y; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.85e-40], N[(t$95$0 - y), $MachinePrecision], If[LessEqual[x, 1.12e-16], N[((-z) - y), $MachinePrecision], N[(t$95$0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;x \leq -2.85 \cdot 10^{-40}:\\
\;\;\;\;t\_0 - y\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-16}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if x < -2.84999999999999992e-40Initial program 99.7%
Taylor expanded in z around 0 90.6%
if -2.84999999999999992e-40 < x < 1.12e-16Initial program 100.0%
Taylor expanded in x around 0 94.8%
neg-mul-194.8%
+-commutative94.8%
distribute-neg-in94.8%
sub-neg94.8%
Simplified94.8%
if 1.12e-16 < x Initial program 99.6%
Taylor expanded in y around 0 89.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -8e+38) (not (<= x 1.8e+35))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8e+38) || !(x <= 1.8e+35)) {
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 <= (-8d+38)) .or. (.not. (x <= 1.8d+35))) 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 <= -8e+38) || !(x <= 1.8e+35)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8e+38) or not (x <= 1.8e+35): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8e+38) || !(x <= 1.8e+35)) 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 <= -8e+38) || ~((x <= 1.8e+35))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8e+38], N[Not[LessEqual[x, 1.8e+35]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{+38} \lor \neg \left(x \leq 1.8 \cdot 10^{+35}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -7.99999999999999982e38 or 1.8e35 < x Initial program 99.6%
Taylor expanded in y around inf 63.1%
associate--r+63.1%
fma-neg63.1%
log-rec63.1%
mul-1-neg63.1%
*-commutative63.1%
associate-/l*63.1%
mul-1-neg63.1%
metadata-eval63.1%
Simplified63.1%
Taylor expanded in x around inf 45.1%
associate-/l*45.0%
Simplified45.0%
Taylor expanded in y around 0 79.1%
if -7.99999999999999982e38 < x < 1.8e35Initial program 100.0%
Taylor expanded in x around 0 91.1%
neg-mul-191.1%
+-commutative91.1%
distribute-neg-in91.1%
sub-neg91.1%
Simplified91.1%
Final simplification85.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.6e+78) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+78) {
tmp = -z;
} else {
tmp = -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 (y <= 1.6d+78) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+78) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.6e+78: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.6e+78) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.6e+78) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.6e+78], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+78}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.59999999999999997e78Initial program 99.8%
Taylor expanded in z around inf 36.3%
neg-mul-136.3%
Simplified36.3%
if 1.59999999999999997e78 < y Initial program 99.9%
Taylor expanded in y around inf 69.6%
neg-mul-169.6%
Simplified69.6%
(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 57.7%
neg-mul-157.7%
+-commutative57.7%
distribute-neg-in57.7%
sub-neg57.7%
Simplified57.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.8%
Taylor expanded in y around inf 32.5%
neg-mul-132.5%
Simplified32.5%
herbie shell --seed 2024100
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))