
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
return (x * log((x / 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((x / y))) - z
end function
public static double code(double x, double y, double z) {
return (x * Math.log((x / y))) - z;
}
def code(x, y, z): return (x * math.log((x / y))) - z
function code(x, y, z) return Float64(Float64(x * log(Float64(x / y))) - z) end
function tmp = code(x, y, z) tmp = (x * log((x / y))) - z; end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
return (x * log((x / 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((x / y))) - z
end function
public static double code(double x, double y, double z) {
return (x * Math.log((x / y))) - z;
}
def code(x, y, z): return (x * math.log((x / y))) - z
function code(x, y, z) return Float64(Float64(x * log(Float64(x / y))) - z) end
function tmp = code(x, y, z) tmp = (x * log((x / y))) - z; end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (if (<= y -5e-311) (- (* x (- (log (- 0.0 x)) (log (- 0.0 y)))) z) (fma (log x) x (- 0.0 (+ z (* x (log y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (log((0.0 - x)) - log((0.0 - y)))) - z;
} else {
tmp = fma(log(x), x, (0.0 - (z + (x * log(y)))));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(log(Float64(0.0 - x)) - log(Float64(0.0 - y)))) - z); else tmp = fma(log(x), x, Float64(0.0 - Float64(z + Float64(x * log(y))))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(N[Log[N[(0.0 - x), $MachinePrecision]], $MachinePrecision] - N[Log[N[(0.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[x], $MachinePrecision] * x + N[(0.0 - N[(z + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(\log \left(0 - x\right) - \log \left(0 - y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log x, x, 0 - \left(z + x \cdot \log y\right)\right)\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 81.9%
frac-2negN/A
log-divN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
neg-sub0N/A
metadata-evalN/A
--lowering--.f64N/A
metadata-evalN/A
log-lowering-log.f64N/A
neg-sub0N/A
metadata-evalN/A
--lowering--.f64N/A
metadata-eval99.3%
Applied egg-rr99.3%
if -5.00000000000023e-311 < y Initial program 77.8%
sub-negN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
neg-sub0N/A
metadata-evalN/A
--lowering--.f64N/A
metadata-eval77.8%
Applied egg-rr77.8%
*-commutativeN/A
diff-logN/A
sub-negN/A
distribute-rgt-outN/A
sub0-negN/A
sub0-negN/A
sub-negN/A
associate--l+N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lft-identityN/A
--lowering--.f64N/A
sub0-negN/A
distribute-lft-neg-outN/A
neg-lowering-neg.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
+-lft-identity99.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- 0.0 z)
(if (<= t_0 4e+282) (- t_0 z) (- (* x (log x)) (* x (log y)))))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 0.0 - z;
} else if (t_0 <= 4e+282) {
tmp = t_0 - z;
} else {
tmp = (x * log(x)) - (x * log(y));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = 0.0 - z;
} else if (t_0 <= 4e+282) {
tmp = t_0 - z;
} else {
tmp = (x * Math.log(x)) - (x * Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if t_0 <= -math.inf: tmp = 0.0 - z elif t_0 <= 4e+282: tmp = t_0 - z else: tmp = (x * math.log(x)) - (x * math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(0.0 - z); elseif (t_0 <= 4e+282) tmp = Float64(t_0 - z); else tmp = Float64(Float64(x * log(x)) - Float64(x * log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (t_0 <= -Inf) tmp = 0.0 - z; elseif (t_0 <= 4e+282) tmp = t_0 - z; else tmp = (x * log(x)) - (x * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(0.0 - z), $MachinePrecision], If[LessEqual[t$95$0, 4e+282], N[(t$95$0 - z), $MachinePrecision], N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log x - x \cdot \log y\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 13.8%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6455.5%
Simplified55.5%
sub0-negN/A
+-lft-identityN/A
neg-lowering-neg.f64N/A
+-lft-identity55.5%
Applied egg-rr55.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.00000000000000013e282Initial program 99.5%
if 4.00000000000000013e282 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 19.6%
Taylor expanded in x around inf
distribute-rgt-inN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
distribute-rgt-inN/A
+-commutativeN/A
*-lowering-*.f64N/A
log-recN/A
unsub-negN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
log-lowering-log.f6454.6%
Simplified54.6%
sub-negN/A
+-commutativeN/A
distribute-rgt-outN/A
accelerator-lowering-fma.f64N/A
sub0-negN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
log-lowering-log.f6454.8%
Applied egg-rr54.8%
+-commutativeN/A
sub0-negN/A
distribute-lft-neg-outN/A
unsub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
remove-double-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
remove-double-negN/A
*-lowering-*.f64N/A
log-lowering-log.f6454.8%
Applied egg-rr54.8%
Final simplification89.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- 0.0 z)
(if (<= t_0 1e+291) (- t_0 z) (* x (- (log x) (log y)))))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 0.0 - z;
} else if (t_0 <= 1e+291) {
tmp = t_0 - z;
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = 0.0 - z;
} else if (t_0 <= 1e+291) {
tmp = t_0 - z;
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if t_0 <= -math.inf: tmp = 0.0 - z elif t_0 <= 1e+291: tmp = t_0 - z else: tmp = x * (math.log(x) - math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(0.0 - z); elseif (t_0 <= 1e+291) tmp = Float64(t_0 - z); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (t_0 <= -Inf) tmp = 0.0 - z; elseif (t_0 <= 1e+291) tmp = t_0 - z; else tmp = x * (log(x) - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(0.0 - z), $MachinePrecision], If[LessEqual[t$95$0, 1e+291], N[(t$95$0 - z), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;t\_0 \leq 10^{+291}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 13.8%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6455.5%
Simplified55.5%
sub0-negN/A
+-lft-identityN/A
neg-lowering-neg.f64N/A
+-lft-identity55.5%
Applied egg-rr55.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 9.9999999999999996e290Initial program 99.5%
if 9.9999999999999996e290 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 11.0%
Taylor expanded in x around inf
distribute-rgt-inN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
distribute-rgt-inN/A
+-commutativeN/A
*-lowering-*.f64N/A
log-recN/A
unsub-negN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
log-lowering-log.f6450.0%
Simplified50.0%
Final simplification88.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- 0.0 z)
(if (<= t_0 1e+291) (- t_0 z) (- 0.0 z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 0.0 - z;
} else if (t_0 <= 1e+291) {
tmp = t_0 - z;
} else {
tmp = 0.0 - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = 0.0 - z;
} else if (t_0 <= 1e+291) {
tmp = t_0 - z;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if t_0 <= -math.inf: tmp = 0.0 - z elif t_0 <= 1e+291: tmp = t_0 - z else: tmp = 0.0 - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(0.0 - z); elseif (t_0 <= 1e+291) tmp = Float64(t_0 - z); else tmp = Float64(0.0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (t_0 <= -Inf) tmp = 0.0 - z; elseif (t_0 <= 1e+291) tmp = t_0 - z; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(0.0 - z), $MachinePrecision], If[LessEqual[t$95$0, 1e+291], N[(t$95$0 - z), $MachinePrecision], N[(0.0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;t\_0 \leq 10^{+291}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 9.9999999999999996e290 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 12.5%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6452.4%
Simplified52.4%
sub0-negN/A
+-lft-identityN/A
neg-lowering-neg.f64N/A
+-lft-identity52.4%
Applied egg-rr52.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 9.9999999999999996e290Initial program 99.5%
Final simplification88.9%
(FPCore (x y z)
:precision binary64
(if (<= x -1.3e+277)
(* x (+ (log (- 0.0 x)) (log (/ -1.0 y))))
(if (<= x -1.75e-114)
(- (* x (log (/ x y))) z)
(if (<= x -1e-307) (- 0.0 z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e+277) {
tmp = x * (log((0.0 - x)) + log((-1.0 / y)));
} else if (x <= -1.75e-114) {
tmp = (x * log((x / y))) - z;
} else if (x <= -1e-307) {
tmp = 0.0 - z;
} else {
tmp = (x * (log(x) - log(y))) - 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 (x <= (-1.3d+277)) then
tmp = x * (log((0.0d0 - x)) + log(((-1.0d0) / y)))
else if (x <= (-1.75d-114)) then
tmp = (x * log((x / y))) - z
else if (x <= (-1d-307)) then
tmp = 0.0d0 - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e+277) {
tmp = x * (Math.log((0.0 - x)) + Math.log((-1.0 / y)));
} else if (x <= -1.75e-114) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -1e-307) {
tmp = 0.0 - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.3e+277: tmp = x * (math.log((0.0 - x)) + math.log((-1.0 / y))) elif x <= -1.75e-114: tmp = (x * math.log((x / y))) - z elif x <= -1e-307: tmp = 0.0 - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.3e+277) tmp = Float64(x * Float64(log(Float64(0.0 - x)) + log(Float64(-1.0 / y)))); elseif (x <= -1.75e-114) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -1e-307) tmp = Float64(0.0 - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.3e+277) tmp = x * (log((0.0 - x)) + log((-1.0 / y))); elseif (x <= -1.75e-114) tmp = (x * log((x / y))) - z; elseif (x <= -1e-307) tmp = 0.0 - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.3e+277], N[(x * N[(N[Log[N[(0.0 - x), $MachinePrecision]], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.75e-114], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-307], N[(0.0 - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+277}:\\
\;\;\;\;x \cdot \left(\log \left(0 - x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-114}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-307}:\\
\;\;\;\;0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.29999999999999994e277Initial program 58.1%
Taylor expanded in x around -inf
*-lowering-*.f64N/A
+-lowering-+.f64N/A
remove-double-negN/A
distribute-frac-neg2N/A
distribute-neg-fracN/A
metadata-evalN/A
log-lowering-log.f64N/A
metadata-evalN/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
remove-double-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
metadata-evalN/A
associate-/r*N/A
remove-double-divN/A
log-lowering-log.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6499.2%
Simplified99.2%
if -1.29999999999999994e277 < x < -1.75e-114Initial program 91.4%
if -1.75e-114 < x < -9.99999999999999909e-308Initial program 68.3%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6487.3%
Simplified87.3%
sub0-negN/A
+-lft-identityN/A
neg-lowering-neg.f64N/A
+-lft-identity87.3%
Applied egg-rr87.3%
if -9.99999999999999909e-308 < x Initial program 77.8%
log-divN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
log-lowering-log.f6499.6%
Applied egg-rr99.6%
Final simplification95.3%
(FPCore (x y z) :precision binary64 (if (<= x -1.75e-114) (- (* x (log (/ x y))) z) (if (<= x -5e-310) (- 0.0 z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.75e-114) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-310) {
tmp = 0.0 - z;
} else {
tmp = (x * (log(x) - log(y))) - 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 (x <= (-1.75d-114)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-310)) then
tmp = 0.0d0 - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.75e-114) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-310) {
tmp = 0.0 - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.75e-114: tmp = (x * math.log((x / y))) - z elif x <= -5e-310: tmp = 0.0 - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.75e-114) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-310) tmp = Float64(0.0 - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.75e-114) tmp = (x * log((x / y))) - z; elseif (x <= -5e-310) tmp = 0.0 - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.75e-114], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-310], N[(0.0 - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-114}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.75e-114Initial program 86.8%
if -1.75e-114 < x < -4.999999999999985e-310Initial program 68.3%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6487.3%
Simplified87.3%
sub0-negN/A
+-lft-identityN/A
neg-lowering-neg.f64N/A
+-lft-identity87.3%
Applied egg-rr87.3%
if -4.999999999999985e-310 < x Initial program 77.8%
log-divN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
log-lowering-log.f6499.6%
Applied egg-rr99.6%
Final simplification93.2%
(FPCore (x y z) :precision binary64 (if (<= y -5e-311) (- (* x (- (log (- 0.0 x)) (log (- 0.0 y)))) z) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (log((0.0 - x)) - log((0.0 - y)))) - z;
} else {
tmp = ((x * log(x)) - (x * log(y))) - 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 (y <= (-5d-311)) then
tmp = (x * (log((0.0d0 - x)) - log((0.0d0 - y)))) - z
else
tmp = ((x * log(x)) - (x * log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (Math.log((0.0 - x)) - Math.log((0.0 - y)))) - z;
} else {
tmp = ((x * Math.log(x)) - (x * Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-311: tmp = (x * (math.log((0.0 - x)) - math.log((0.0 - y)))) - z else: tmp = ((x * math.log(x)) - (x * math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(log(Float64(0.0 - x)) - log(Float64(0.0 - y)))) - z); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-311) tmp = (x * (log((0.0 - x)) - log((0.0 - y)))) - z; else tmp = ((x * log(x)) - (x * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(N[Log[N[(0.0 - x), $MachinePrecision]], $MachinePrecision] - N[Log[N[(0.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(\log \left(0 - x\right) - \log \left(0 - y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 81.9%
frac-2negN/A
log-divN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
neg-sub0N/A
metadata-evalN/A
--lowering--.f64N/A
metadata-evalN/A
log-lowering-log.f64N/A
neg-sub0N/A
metadata-evalN/A
--lowering--.f64N/A
metadata-eval99.3%
Applied egg-rr99.3%
if -5.00000000000023e-311 < y Initial program 77.8%
log-divN/A
sub-negN/A
distribute-rgt-inN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
*-lowering-*.f64N/A
neg-logN/A
log-divN/A
--lowering--.f64N/A
metadata-evalN/A
log-lowering-log.f6499.7%
Applied egg-rr99.7%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y -5e-311) (- (* x (- (log (- 0.0 x)) (log (- 0.0 y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (log((0.0 - x)) - log((0.0 - y)))) - z;
} else {
tmp = (x * (log(x) - log(y))) - 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 (y <= (-5d-311)) then
tmp = (x * (log((0.0d0 - x)) - log((0.0d0 - y)))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (Math.log((0.0 - x)) - Math.log((0.0 - y)))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-311: tmp = (x * (math.log((0.0 - x)) - math.log((0.0 - y)))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(log(Float64(0.0 - x)) - log(Float64(0.0 - y)))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-311) tmp = (x * (log((0.0 - x)) - log((0.0 - y)))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(N[Log[N[(0.0 - x), $MachinePrecision]], $MachinePrecision] - N[Log[N[(0.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(\log \left(0 - x\right) - \log \left(0 - y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 81.9%
frac-2negN/A
log-divN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
neg-sub0N/A
metadata-evalN/A
--lowering--.f64N/A
metadata-evalN/A
log-lowering-log.f64N/A
neg-sub0N/A
metadata-evalN/A
--lowering--.f64N/A
metadata-eval99.3%
Applied egg-rr99.3%
if -5.00000000000023e-311 < y Initial program 77.8%
log-divN/A
--lowering--.f64N/A
log-lowering-log.f64N/A
log-lowering-log.f6499.6%
Applied egg-rr99.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= x -7e+81) t_0 (if (<= x 5.2e+51) (- 0.0 z) t_0))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (x <= -7e+81) {
tmp = t_0;
} else if (x <= 5.2e+51) {
tmp = 0.0 - z;
} 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((x / y))
if (x <= (-7d+81)) then
tmp = t_0
else if (x <= 5.2d+51) then
tmp = 0.0d0 - z
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((x / y));
double tmp;
if (x <= -7e+81) {
tmp = t_0;
} else if (x <= 5.2e+51) {
tmp = 0.0 - z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if x <= -7e+81: tmp = t_0 elif x <= 5.2e+51: tmp = 0.0 - z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (x <= -7e+81) tmp = t_0; elseif (x <= 5.2e+51) tmp = Float64(0.0 - z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (x <= -7e+81) tmp = t_0; elseif (x <= 5.2e+51) tmp = 0.0 - z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7e+81], t$95$0, If[LessEqual[x, 5.2e+51], N[(0.0 - z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;x \leq -7 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+51}:\\
\;\;\;\;0 - z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.0000000000000001e81 or 5.2000000000000002e51 < x Initial program 78.2%
Taylor expanded in z around 0
*-lowering-*.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f6462.6%
Simplified62.6%
if -7.0000000000000001e81 < x < 5.2000000000000002e51Initial program 81.0%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6479.9%
Simplified79.9%
sub0-negN/A
+-lft-identityN/A
neg-lowering-neg.f64N/A
+-lft-identity79.9%
Applied egg-rr79.9%
Final simplification72.5%
(FPCore (x y z) :precision binary64 (- 0.0 z))
double code(double x, double y, double z) {
return 0.0 - z;
}
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
end function
public static double code(double x, double y, double z) {
return 0.0 - z;
}
def code(x, y, z): return 0.0 - z
function code(x, y, z) return Float64(0.0 - z) end
function tmp = code(x, y, z) tmp = 0.0 - z; end
code[x_, y_, z_] := N[(0.0 - z), $MachinePrecision]
\begin{array}{l}
\\
0 - z
\end{array}
Initial program 79.8%
Taylor expanded in x around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f6455.2%
Simplified55.2%
sub0-negN/A
+-lft-identityN/A
neg-lowering-neg.f64N/A
+-lft-identity55.2%
Applied egg-rr55.2%
Final simplification55.2%
(FPCore (x y z) :precision binary64 (if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y < 7.595077799083773e-308) {
tmp = (x * log((x / y))) - z;
} else {
tmp = (x * (log(x) - log(y))) - 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 (y < 7.595077799083773d-308) then
tmp = (x * log((x / y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y < 7.595077799083773e-308) {
tmp = (x * Math.log((x / y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y < 7.595077799083773e-308: tmp = (x * math.log((x / y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y < 7.595077799083773e-308) tmp = Float64(Float64(x * log(Float64(x / y))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y < 7.595077799083773e-308) tmp = (x * log((x / y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[y, 7.595077799083773e-308], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y < 7.595077799083773 \cdot 10^{-308}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
herbie shell --seed 2024191
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< y 7595077799083773/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
(- (* x (log (/ x y))) z))