
(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 11 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 (- (* (* x (log (/ (cbrt x) (cbrt y)))) 3.0) z))
double code(double x, double y, double z) {
return ((x * log((cbrt(x) / cbrt(y)))) * 3.0) - z;
}
public static double code(double x, double y, double z) {
return ((x * Math.log((Math.cbrt(x) / Math.cbrt(y)))) * 3.0) - z;
}
function code(x, y, z) return Float64(Float64(Float64(x * log(Float64(cbrt(x) / cbrt(y)))) * 3.0) - z) end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) \cdot 3 - z
\end{array}
Initial program 78.3%
add-cbrt-cube52.7%
pow352.7%
Applied egg-rr52.7%
rem-cbrt-cube78.3%
*-un-lft-identity78.3%
metadata-eval78.3%
associate-*r*78.2%
associate-*r*78.2%
*-commutative78.2%
add-log-exp78.2%
exp-to-pow78.2%
pow1/378.2%
cbrt-undiv99.6%
associate-*r*99.6%
*-commutative99.6%
associate-*r*99.6%
cbrt-undiv78.2%
Applied egg-rr78.2%
cbrt-div99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+299))) (- z) (- t_0 z))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e+299)) {
tmp = -z;
} else {
tmp = t_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) || !(t_0 <= 2e+299)) {
tmp = -z;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 2e+299): tmp = -z else: tmp = t_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)) || !(t_0 <= 2e+299)) tmp = Float64(-z); else tmp = Float64(t_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) || ~((t_0 <= 2e+299))) tmp = -z; else tmp = t_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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e+299]], $MachinePrecision]], (-z), N[(t$95$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 \lor \neg \left(t_0 \leq 2 \cdot 10^{+299}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 2.0000000000000001e299 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.6%
remove-double-neg6.6%
sub-neg6.6%
distribute-neg-in6.6%
distribute-rgt-neg-in6.6%
remove-double-neg6.6%
fma-udef6.6%
log-div47.2%
sub-neg47.2%
distribute-neg-in47.2%
remove-double-neg47.2%
+-commutative47.2%
sub-neg47.2%
log-div9.3%
Simplified9.3%
Taylor expanded in x around 0 42.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2.0000000000000001e299Initial program 99.7%
Final simplification86.5%
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (- (fma x (- (log (- y)) (log (- x))) z)) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = -fma(x, (log(-y) - log(-x)), z);
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -5e-310) tmp = Float64(-fma(x, Float64(log(Float64(-y)) - log(Float64(-x))), z)); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], (-N[(x * N[(N[Log[(-y)], $MachinePrecision] - N[Log[(-x)], $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^{-310}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(-y\right) - \log \left(-x\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 77.9%
remove-double-neg77.9%
sub-neg77.9%
distribute-neg-in77.9%
distribute-rgt-neg-in77.9%
remove-double-neg77.9%
fma-udef77.9%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div77.3%
Simplified77.3%
frac-2neg77.3%
log-div99.5%
Applied egg-rr99.5%
if -4.999999999999985e-310 < y Initial program 78.7%
add-cube-cbrt78.7%
log-prod78.6%
pow278.6%
Applied egg-rr78.6%
log-pow78.7%
distribute-lft1-in78.7%
metadata-eval78.7%
Simplified78.7%
pow1/378.5%
log-pow78.6%
Applied egg-rr78.6%
clear-num78.6%
log-rec79.6%
Applied egg-rr79.6%
associate-*r*79.7%
metadata-eval79.7%
*-un-lft-identity79.7%
neg-log78.7%
clear-num78.7%
diff-log99.4%
sub-neg99.4%
distribute-rgt-in99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (- (* x (* (log (/ (cbrt x) (cbrt y))) 3.0)) z))
double code(double x, double y, double z) {
return (x * (log((cbrt(x) / cbrt(y))) * 3.0)) - z;
}
public static double code(double x, double y, double z) {
return (x * (Math.log((Math.cbrt(x) / Math.cbrt(y))) * 3.0)) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(log(Float64(cbrt(x) / cbrt(y))) * 3.0)) - z) end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z
\end{array}
Initial program 78.3%
add-cube-cbrt78.3%
log-prod78.2%
pow278.2%
Applied egg-rr78.2%
log-pow78.2%
distribute-lft1-in78.2%
metadata-eval78.2%
Simplified78.2%
cbrt-div99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(if (<= x -2.05e+201)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2e-147)
(- (* x (log (/ x y))) z)
(if (<= x -5e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.05e+201) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2e-147) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-308) {
tmp = -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 <= (-2.05d+201)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-2d-147)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-308)) then
tmp = -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 <= -2.05e+201) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -2e-147) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.05e+201: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -2e-147: tmp = (x * math.log((x / y))) - z elif x <= -5e-308: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.05e+201) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2e-147) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-308) tmp = Float64(-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 <= -2.05e+201) tmp = x * (log(-x) - log(-y)); elseif (x <= -2e-147) tmp = (x * log((x / y))) - z; elseif (x <= -5e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.05e+201], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2e-147], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-308], (-z), 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 -2.05 \cdot 10^{+201}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-147}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -2.0500000000000001e201Initial program 51.8%
remove-double-neg51.8%
sub-neg51.8%
distribute-neg-in51.8%
distribute-rgt-neg-in51.8%
remove-double-neg51.8%
fma-udef51.8%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div53.0%
Simplified53.0%
frac-2neg53.0%
log-div98.8%
Applied egg-rr98.8%
Taylor expanded in x around inf 0.0%
sub-neg0.0%
distribute-rgt-in0.0%
log-rec0.0%
mul-1-neg0.0%
remove-double-neg0.0%
log-prod96.2%
neg-mul-196.2%
distribute-rgt-in96.6%
sub-neg96.6%
Simplified96.6%
if -2.0500000000000001e201 < x < -1.9999999999999999e-147Initial program 90.4%
if -1.9999999999999999e-147 < x < -4.99999999999999955e-308Initial program 70.2%
remove-double-neg70.2%
sub-neg70.2%
distribute-neg-in70.2%
distribute-rgt-neg-in70.2%
remove-double-neg70.2%
fma-udef70.2%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div70.2%
Simplified70.2%
Taylor expanded in x around 0 90.9%
if -4.99999999999999955e-308 < x Initial program 78.7%
log-div99.4%
Applied egg-rr99.4%
Final simplification95.5%
(FPCore (x y z) :precision binary64 (if (<= x -6.5e-148) (- (* x (log (/ x y))) z) (if (<= x -1e-308) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.5e-148) {
tmp = (x * log((x / y))) - z;
} else if (x <= -1e-308) {
tmp = -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 <= (-6.5d-148)) then
tmp = (x * log((x / y))) - z
else if (x <= (-1d-308)) then
tmp = -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 <= -6.5e-148) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -1e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.5e-148: tmp = (x * math.log((x / y))) - z elif x <= -1e-308: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.5e-148) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -1e-308) tmp = Float64(-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 <= -6.5e-148) tmp = (x * log((x / y))) - z; elseif (x <= -1e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.5e-148], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-308], (-z), 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 -6.5 \cdot 10^{-148}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -6.4999999999999997e-148Initial program 80.9%
if -6.4999999999999997e-148 < x < -9.9999999999999991e-309Initial program 70.2%
remove-double-neg70.2%
sub-neg70.2%
distribute-neg-in70.2%
distribute-rgt-neg-in70.2%
remove-double-neg70.2%
fma-udef70.2%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div70.2%
Simplified70.2%
Taylor expanded in x around 0 90.9%
if -9.9999999999999991e-309 < x Initial program 78.7%
log-div99.4%
Applied egg-rr99.4%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (log(-x) - log(-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-310)) then
tmp = (x * (log(-x) - log(-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-310) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-310: tmp = (x * (math.log(-x) - math.log(-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-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-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-310) tmp = (x * (log(-x) - log(-y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-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 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 77.9%
frac-2neg77.9%
log-div99.5%
Applied egg-rr99.5%
if -4.999999999999985e-310 < y Initial program 78.7%
log-div99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (log(-x) - log(-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-310)) then
tmp = (x * (log(-x) - log(-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-310) {
tmp = (x * (Math.log(-x) - Math.log(-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-310: tmp = (x * (math.log(-x) - math.log(-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-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-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-310) tmp = (x * (log(-x) - log(-y))) - z; else tmp = ((x * log(x)) - (x * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $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^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 77.9%
frac-2neg77.9%
log-div99.5%
Applied egg-rr99.5%
if -4.999999999999985e-310 < y Initial program 78.7%
add-cube-cbrt78.7%
log-prod78.6%
pow278.6%
Applied egg-rr78.6%
log-pow78.7%
distribute-lft1-in78.7%
metadata-eval78.7%
Simplified78.7%
pow1/378.5%
log-pow78.6%
Applied egg-rr78.6%
clear-num78.6%
log-rec79.6%
Applied egg-rr79.6%
associate-*r*79.7%
metadata-eval79.7%
*-un-lft-identity79.7%
neg-log78.7%
clear-num78.7%
diff-log99.4%
sub-neg99.4%
distribute-rgt-in99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e-44) (not (<= x 1e-31))) (* (- x) (log (/ y x))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e-44) || !(x <= 1e-31)) {
tmp = -x * log((y / x));
} 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 ((x <= (-1d-44)) .or. (.not. (x <= 1d-31))) then
tmp = -x * log((y / x))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1e-44) || !(x <= 1e-31)) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1e-44) or not (x <= 1e-31): tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1e-44) || !(x <= 1e-31)) tmp = Float64(Float64(-x) * log(Float64(y / x))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1e-44) || ~((x <= 1e-31))) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e-44], N[Not[LessEqual[x, 1e-31]], $MachinePrecision]], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-44} \lor \neg \left(x \leq 10^{-31}\right):\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -9.99999999999999953e-45 or 1e-31 < x Initial program 78.4%
remove-double-neg78.4%
sub-neg78.4%
distribute-neg-in78.4%
distribute-rgt-neg-in78.4%
remove-double-neg78.4%
fma-udef78.4%
log-div52.3%
sub-neg52.3%
distribute-neg-in52.3%
remove-double-neg52.3%
+-commutative52.3%
sub-neg52.3%
log-div79.5%
Simplified79.5%
Taylor expanded in x around inf 40.8%
log-rec40.8%
neg-mul-140.8%
neg-mul-140.8%
sub-neg40.8%
log-div61.0%
Simplified61.0%
if -9.99999999999999953e-45 < x < 1e-31Initial program 78.2%
remove-double-neg78.2%
sub-neg78.2%
distribute-neg-in78.2%
distribute-rgt-neg-in78.2%
remove-double-neg78.2%
fma-udef78.2%
log-div45.4%
sub-neg45.4%
distribute-neg-in45.4%
remove-double-neg45.4%
+-commutative45.4%
sub-neg45.4%
log-div77.3%
Simplified77.3%
Taylor expanded in x around 0 80.7%
Final simplification69.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.5e-45) (not (<= x 1.45e-31))) (* x (log (/ x y))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e-45) || !(x <= 1.45e-31)) {
tmp = x * log((x / 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 ((x <= (-8.5d-45)) .or. (.not. (x <= 1.45d-31))) then
tmp = x * log((x / y))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e-45) || !(x <= 1.45e-31)) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.5e-45) or not (x <= 1.45e-31): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.5e-45) || !(x <= 1.45e-31)) tmp = Float64(x * log(Float64(x / y))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.5e-45) || ~((x <= 1.45e-31))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.5e-45], N[Not[LessEqual[x, 1.45e-31]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-45} \lor \neg \left(x \leq 1.45 \cdot 10^{-31}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -8.50000000000000041e-45 or 1.45e-31 < x Initial program 78.4%
Taylor expanded in z around 0 60.5%
if -8.50000000000000041e-45 < x < 1.45e-31Initial program 78.2%
remove-double-neg78.2%
sub-neg78.2%
distribute-neg-in78.2%
distribute-rgt-neg-in78.2%
remove-double-neg78.2%
fma-udef78.2%
log-div45.4%
sub-neg45.4%
distribute-neg-in45.4%
remove-double-neg45.4%
+-commutative45.4%
sub-neg45.4%
log-div77.3%
Simplified77.3%
Taylor expanded in x around 0 80.7%
Final simplification69.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 Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 78.3%
remove-double-neg78.3%
sub-neg78.3%
distribute-neg-in78.3%
distribute-rgt-neg-in78.3%
remove-double-neg78.3%
fma-udef78.3%
log-div49.3%
sub-neg49.3%
distribute-neg-in49.3%
remove-double-neg49.3%
+-commutative49.3%
sub-neg49.3%
log-div78.5%
Simplified78.5%
Taylor expanded in x around 0 47.8%
Final simplification47.8%
(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 2024010
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))