
(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 9 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 82.3%
add-log-exp30.3%
*-commutative30.3%
exp-to-pow30.4%
Applied egg-rr30.4%
add-cube-cbrt30.4%
pow330.4%
exp-to-pow30.4%
exp-prod30.3%
*-commutative30.3%
add-log-exp82.2%
associate-*r*82.2%
Applied egg-rr82.2%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))) (t_1 (* x (log (* x y)))))
(if (<= t_0 (- INFINITY))
(- t_1 z)
(if (<= t_0 1e+306) (- t_0 z) (- (fabs t_1) z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double t_1 = x * log((x * y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1 - z;
} else if (t_0 <= 1e+306) {
tmp = t_0 - z;
} else {
tmp = fabs(t_1) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double t_1 = x * Math.log((x * y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1 - z;
} else if (t_0 <= 1e+306) {
tmp = t_0 - z;
} else {
tmp = Math.abs(t_1) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) t_1 = x * math.log((x * y)) tmp = 0 if t_0 <= -math.inf: tmp = t_1 - z elif t_0 <= 1e+306: tmp = t_0 - z else: tmp = math.fabs(t_1) - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) t_1 = Float64(x * log(Float64(x * y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(t_1 - z); elseif (t_0 <= 1e+306) tmp = Float64(t_0 - z); else tmp = Float64(abs(t_1) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); t_1 = x * log((x * y)); tmp = 0.0; if (t_0 <= -Inf) tmp = t_1 - z; elseif (t_0 <= 1e+306) tmp = t_0 - z; else tmp = abs(t_1) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(t$95$1 - z), $MachinePrecision], If[LessEqual[t$95$0, 1e+306], N[(t$95$0 - z), $MachinePrecision], N[(N[Abs[t$95$1], $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot \log \left(x \cdot y\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1 - z\\
\mathbf{elif}\;t_0 \leq 10^{+306}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;\left|t_1\right| - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 5.4%
add-cube-cbrt5.4%
log-prod5.4%
pow25.4%
Applied egg-rr5.4%
log-pow5.4%
distribute-lft1-in5.4%
metadata-eval5.4%
*-commutative5.4%
Simplified5.4%
add-log-exp5.4%
*-commutative5.4%
exp-prod5.4%
exp-to-pow5.4%
pow35.4%
add-cube-cbrt5.4%
log-pow5.4%
frac-2neg5.4%
diff-log74.7%
sub-neg74.7%
distribute-rgt-in74.6%
add-sqr-sqrt74.7%
sqrt-unprod28.6%
sqr-neg28.6%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr25.0%
distribute-rgt-out25.0%
sub-neg25.0%
*-commutative25.0%
sub-neg25.0%
add-sqr-sqrt0.0%
sqrt-unprod25.0%
sqr-neg25.0%
sqrt-unprod25.0%
add-sqr-sqrt25.0%
sum-log43.0%
Applied egg-rr43.0%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000002e306Initial program 99.8%
if 1.00000000000000002e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.6%
log-div36.9%
Applied egg-rr36.9%
Applied egg-rr46.4%
unpow246.4%
rem-sqrt-square50.5%
Simplified50.5%
Final simplification90.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))) (t_1 (log (* x y))))
(if (<= t_0 (- INFINITY))
(- (* x (fabs t_1)) z)
(if (<= t_0 1e+306) (- t_0 z) (- (fabs (* x t_1)) z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double t_1 = log((x * y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (x * fabs(t_1)) - z;
} else if (t_0 <= 1e+306) {
tmp = t_0 - z;
} else {
tmp = fabs((x * t_1)) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double t_1 = Math.log((x * y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (x * Math.abs(t_1)) - z;
} else if (t_0 <= 1e+306) {
tmp = t_0 - z;
} else {
tmp = Math.abs((x * t_1)) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) t_1 = math.log((x * y)) tmp = 0 if t_0 <= -math.inf: tmp = (x * math.fabs(t_1)) - z elif t_0 <= 1e+306: tmp = t_0 - z else: tmp = math.fabs((x * t_1)) - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) t_1 = log(Float64(x * y)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(x * abs(t_1)) - z); elseif (t_0 <= 1e+306) tmp = Float64(t_0 - z); else tmp = Float64(abs(Float64(x * t_1)) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); t_1 = log((x * y)); tmp = 0.0; if (t_0 <= -Inf) tmp = (x * abs(t_1)) - z; elseif (t_0 <= 1e+306) tmp = t_0 - z; else tmp = abs((x * t_1)) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(x * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, 1e+306], N[(t$95$0 - z), $MachinePrecision], N[(N[Abs[N[(x * t$95$1), $MachinePrecision]], $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
t_1 := \log \left(x \cdot y\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x \cdot \left|t_1\right| - z\\
\mathbf{elif}\;t_0 \leq 10^{+306}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot t_1\right| - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 5.4%
add-cube-cbrt5.4%
log-prod5.4%
pow25.4%
Applied egg-rr5.4%
log-pow5.4%
distribute-lft1-in5.4%
metadata-eval5.4%
*-commutative5.4%
Simplified5.4%
cbrt-div99.6%
div-inv99.6%
Applied egg-rr99.5%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.5%
add-sqr-sqrt74.3%
sqrt-unprod99.5%
pow299.5%
add-log-exp5.1%
cbrt-div5.1%
exp-to-pow5.1%
pow35.1%
add-cube-cbrt5.1%
diff-log25.0%
Applied egg-rr46.4%
unpow246.4%
rem-sqrt-square46.4%
Simplified46.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000002e306Initial program 99.8%
if 1.00000000000000002e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.6%
log-div36.9%
Applied egg-rr36.9%
Applied egg-rr46.4%
unpow246.4%
rem-sqrt-square50.5%
Simplified50.5%
Final simplification90.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+306)))
(- (* x (log (* x y))) 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+306)) {
tmp = (x * log((x * y))) - 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+306)) {
tmp = (x * Math.log((x * y))) - 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+306): tmp = (x * math.log((x * y))) - 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+306)) tmp = Float64(Float64(x * log(Float64(x * y))) - 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+306))) tmp = (x * log((x * y))) - 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+306]], $MachinePrecision]], N[(N[(x * N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], 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^{+306}\right):\\
\;\;\;\;x \cdot \log \left(x \cdot y\right) - z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.00000000000000002e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.4%
add-cube-cbrt4.4%
log-prod4.4%
pow24.4%
Applied egg-rr4.4%
log-pow4.4%
distribute-lft1-in4.4%
metadata-eval4.4%
*-commutative4.4%
Simplified4.4%
add-log-exp4.4%
*-commutative4.4%
exp-prod4.4%
exp-to-pow4.4%
pow34.4%
add-cube-cbrt4.4%
log-pow4.4%
frac-2neg4.4%
diff-log67.9%
sub-neg67.9%
distribute-rgt-in67.9%
add-sqr-sqrt67.9%
sqrt-unprod21.3%
sqr-neg21.3%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr31.9%
distribute-rgt-out31.8%
sub-neg31.8%
*-commutative31.8%
sub-neg31.8%
add-sqr-sqrt21.1%
sqrt-unprod31.8%
sqr-neg31.8%
sqrt-unprod10.6%
add-sqr-sqrt12.1%
sum-log44.1%
Applied egg-rr44.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000002e306Initial program 99.8%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 INFINITY) (- t_0 z) (- z)))))
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 <= ((double) INFINITY)) {
tmp = t_0 - z;
} else {
tmp = -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 = -z;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 - z;
} else {
tmp = -z;
}
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 <= math.inf: tmp = t_0 - z else: tmp = -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(-z); elseif (t_0 <= Inf) tmp = Float64(t_0 - z); else tmp = Float64(-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 = -z; elseif (t_0 <= Inf) tmp = t_0 - z; else tmp = -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)], (-z), If[LessEqual[t$95$0, Infinity], N[(t$95$0 - z), $MachinePrecision], (-z)]]]
\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 \infty:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.4%
add-log-exp5.4%
*-commutative5.4%
exp-to-pow5.4%
Applied egg-rr5.4%
Taylor expanded in x around 0 36.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 88.8%
Final simplification84.7%
(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 82.3%
add-cube-cbrt82.3%
log-prod82.2%
pow282.2%
Applied egg-rr82.2%
log-pow82.2%
distribute-lft1-in82.2%
metadata-eval82.2%
*-commutative82.2%
Simplified82.2%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(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 79.0%
frac-2neg79.0%
log-div99.6%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 86.7%
log-div99.5%
Applied egg-rr99.5%
Final simplification99.6%
(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 79.0%
frac-2neg79.0%
log-div99.6%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 86.7%
log-div99.5%
Applied egg-rr99.5%
sub-neg99.5%
distribute-rgt-out99.6%
distribute-lft-neg-out99.6%
unsub-neg99.6%
*-commutative99.6%
*-commutative99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 82.3%
add-log-exp30.3%
*-commutative30.3%
exp-to-pow30.4%
Applied egg-rr30.4%
Taylor expanded in x around 0 46.9%
Final simplification46.9%
(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 2023199
(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))