
(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 (- (* (* 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 77.3%
log1p-expm1-u45.8%
expm1-udef33.7%
*-commutative33.7%
exp-to-pow33.7%
Applied egg-rr33.7%
pow-to-exp33.7%
*-commutative33.7%
expm1-udef45.8%
log1p-expm1-u77.3%
add-cube-cbrt77.3%
pow377.3%
exp-to-pow77.2%
add-log-exp77.2%
associate-*r*77.2%
Applied egg-rr77.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 (<= t_0 (- INFINITY))
(- z)
(if (<= t_0 1e+288) (- 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 = -z;
} else if (t_0 <= 1e+288) {
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 = -z;
} else if (t_0 <= 1e+288) {
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 = -z elif t_0 <= 1e+288: 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(-z); elseif (t_0 <= 1e+288) 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 = -z; elseif (t_0 <= 1e+288) 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)], (-z), If[LessEqual[t$95$0, 1e+288], 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:\\
\;\;\;\;-z\\
\mathbf{elif}\;t_0 \leq 10^{+288}:\\
\;\;\;\;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 9.1%
remove-double-neg9.1%
sub-neg9.1%
distribute-neg-in9.1%
distribute-rgt-neg-in9.1%
remove-double-neg9.1%
fma-udef9.1%
log-div50.0%
sub-neg50.0%
distribute-neg-in50.0%
remove-double-neg50.0%
+-commutative50.0%
sub-neg50.0%
log-div11.6%
Simplified11.6%
Taylor expanded in x around 0 42.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1e288Initial program 99.6%
if 1e288 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.3%
Taylor expanded in z around 0 5.3%
log-div49.5%
Applied egg-rr49.5%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+288))) (- 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 <= 1e+288)) {
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 <= 1e+288)) {
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 <= 1e+288): 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 <= 1e+288)) 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 <= 1e+288))) 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, 1e+288]], $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 10^{+288}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1e288 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.5%
remove-double-neg7.5%
sub-neg7.5%
distribute-neg-in7.5%
distribute-rgt-neg-in7.5%
remove-double-neg7.5%
fma-udef7.5%
log-div54.7%
sub-neg54.7%
distribute-neg-in54.7%
remove-double-neg54.7%
+-commutative54.7%
sub-neg54.7%
log-div9.6%
Simplified9.6%
Taylor expanded in x around 0 43.2%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1e288Initial program 99.6%
Final simplification86.0%
(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 77.3%
add-cube-cbrt77.3%
log-prod77.2%
pow277.2%
Applied egg-rr77.2%
log-pow77.2%
distribute-lft1-in77.2%
metadata-eval77.2%
Simplified77.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 (- (* (log (/ (cbrt x) (cbrt y))) (* x 3.0)) z))
double code(double x, double y, double z) {
return (log((cbrt(x) / cbrt(y))) * (x * 3.0)) - z;
}
public static double code(double x, double y, double z) {
return (Math.log((Math.cbrt(x) / Math.cbrt(y))) * (x * 3.0)) - z;
}
function code(x, y, z) return Float64(Float64(log(Float64(cbrt(x) / cbrt(y))) * Float64(x * 3.0)) - z) end
code[x_, y_, z_] := N[(N[(N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(x * 3.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot \left(x \cdot 3\right) - z
\end{array}
Initial program 77.3%
log1p-expm1-u45.8%
expm1-udef33.7%
*-commutative33.7%
exp-to-pow33.7%
Applied egg-rr33.7%
pow-to-exp33.7%
*-commutative33.7%
expm1-udef45.8%
log1p-expm1-u77.3%
add-cube-cbrt77.3%
pow377.3%
exp-to-pow77.2%
add-log-exp77.2%
*-commutative77.2%
associate-*r*77.2%
Applied egg-rr77.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 (<= y -4e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (fma x (- (log y) (log x)) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e-310) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = -fma(x, (log(y) - log(x)), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4e-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(-fma(x, Float64(log(y) - log(x)), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-N[(x * N[(N[Log[y], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log y - \log x, z\right)\\
\end{array}
\end{array}
if y < -3.999999999999988e-310Initial program 81.8%
frac-2neg42.1%
log-div51.4%
Applied egg-rr99.5%
if -3.999999999999988e-310 < y Initial program 72.0%
remove-double-neg72.0%
sub-neg72.0%
distribute-neg-in72.0%
distribute-rgt-neg-in72.0%
remove-double-neg72.0%
fma-udef72.0%
log-div99.6%
sub-neg99.6%
distribute-neg-in99.6%
remove-double-neg99.6%
+-commutative99.6%
sub-neg99.6%
log-div71.0%
Simplified71.0%
log-div99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(if (<= x -5.8e+188)
(* x (- (log (- x)) (log (- y))))
(if (<= x -7.5e-187)
(- (* x (log (/ x y))) z)
(if (<= x -2e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.8e+188) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -7.5e-187) {
tmp = (x * log((x / y))) - z;
} else if (x <= -2e-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 <= (-5.8d+188)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-7.5d-187)) then
tmp = (x * log((x / y))) - z
else if (x <= (-2d-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 <= -5.8e+188) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -7.5e-187) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -2e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.8e+188: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -7.5e-187: tmp = (x * math.log((x / y))) - z elif x <= -2e-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 <= -5.8e+188) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -7.5e-187) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -2e-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 <= -5.8e+188) tmp = x * (log(-x) - log(-y)); elseif (x <= -7.5e-187) tmp = (x * log((x / y))) - z; elseif (x <= -2e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.8e+188], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -7.5e-187], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-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 -5.8 \cdot 10^{+188}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -7.5 \cdot 10^{-187}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -5.7999999999999999e188Initial program 62.6%
Taylor expanded in z around 0 54.9%
frac-2neg54.9%
log-div89.3%
Applied egg-rr89.3%
if -5.7999999999999999e188 < x < -7.5000000000000004e-187Initial program 89.9%
if -7.5000000000000004e-187 < x < -1.9999999999999998e-308Initial program 72.7%
remove-double-neg72.7%
sub-neg72.7%
distribute-neg-in72.7%
distribute-rgt-neg-in72.7%
remove-double-neg72.7%
fma-udef72.7%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div72.7%
Simplified72.7%
Taylor expanded in x around 0 95.5%
if -1.9999999999999998e-308 < x Initial program 72.0%
log-div53.8%
Applied egg-rr99.5%
Final simplification94.8%
(FPCore (x y z) :precision binary64 (if (<= y -4e-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 <= -4e-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 <= (-4d-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 <= -4e-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 <= -4e-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 <= -4e-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 <= -4e-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, -4e-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 -4 \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 < -3.999999999999988e-310Initial program 81.8%
frac-2neg42.1%
log-div51.4%
Applied egg-rr99.5%
if -3.999999999999988e-310 < y Initial program 72.0%
log-div53.8%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.8e-20) (not (<= z 5.2e+41))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.8e-20) || !(z <= 5.2e+41)) {
tmp = -z;
} else {
tmp = x * log((x / 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.8d-20)) .or. (.not. (z <= 5.2d+41))) then
tmp = -z
else
tmp = x * log((x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.8e-20) || !(z <= 5.2e+41)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.8e-20) or not (z <= 5.2e+41): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.8e-20) || !(z <= 5.2e+41)) tmp = Float64(-z); else tmp = Float64(x * log(Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.8e-20) || ~((z <= 5.2e+41))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.8e-20], N[Not[LessEqual[z, 5.2e+41]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{-20} \lor \neg \left(z \leq 5.2 \cdot 10^{+41}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -3.7999999999999998e-20 or 5.2000000000000001e41 < z Initial program 77.3%
remove-double-neg77.3%
sub-neg77.3%
distribute-neg-in77.3%
distribute-rgt-neg-in77.3%
remove-double-neg77.3%
fma-udef77.3%
log-div47.5%
sub-neg47.5%
distribute-neg-in47.5%
remove-double-neg47.5%
+-commutative47.5%
sub-neg47.5%
log-div76.5%
Simplified76.5%
Taylor expanded in x around 0 75.4%
if -3.7999999999999998e-20 < z < 5.2000000000000001e41Initial program 77.3%
Taylor expanded in z around 0 65.3%
Final simplification70.3%
(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 77.3%
remove-double-neg77.3%
sub-neg77.3%
distribute-neg-in77.3%
distribute-rgt-neg-in77.3%
remove-double-neg77.3%
fma-udef77.3%
log-div45.9%
sub-neg45.9%
distribute-neg-in45.9%
remove-double-neg45.9%
+-commutative45.9%
sub-neg45.9%
log-div76.8%
Simplified76.8%
Taylor expanded in x around 0 48.4%
Final simplification48.4%
(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 2024013
(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))