
(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 (- (* (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 71.6%
add-cube-cbrt71.6%
log-prod71.5%
pow271.5%
Applied egg-rr71.5%
log-pow71.5%
distribute-lft1-in71.5%
metadata-eval71.5%
Simplified71.5%
add071.5%
associate-*r*71.5%
fma-define71.5%
Applied egg-rr71.5%
fma-undefine71.5%
add071.5%
*-commutative71.5%
Simplified71.5%
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 2e+292) (- t_0 z) (- (- z) t_1)))))
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 <= 2e+292) {
tmp = t_0 - z;
} else {
tmp = -z - t_1;
}
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 <= 2e+292) {
tmp = t_0 - z;
} else {
tmp = -z - t_1;
}
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 <= 2e+292: tmp = t_0 - z else: tmp = -z - t_1 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 <= 2e+292) tmp = Float64(t_0 - z); else tmp = Float64(Float64(-z) - t_1); 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 <= 2e+292) tmp = t_0 - z; else tmp = -z - t_1; 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, 2e+292], N[(t$95$0 - z), $MachinePrecision], N[((-z) - t$95$1), $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 2 \cdot 10^{+292}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - t\_1\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 7.1%
add-cube-cbrt7.1%
log-prod7.1%
pow27.1%
Applied egg-rr7.1%
log-pow7.1%
distribute-lft1-in7.1%
metadata-eval7.1%
Simplified7.1%
add-log-exp7.1%
*-commutative7.1%
exp-prod7.1%
*-commutative7.1%
exp-to-pow7.1%
pow37.1%
add-cube-cbrt7.1%
exp-to-pow7.1%
diff-log33.0%
*-commutative33.0%
add-log-exp37.5%
sub-neg37.5%
distribute-rgt-in37.5%
Applied egg-rr37.5%
distribute-rgt-out37.5%
unsub-neg37.5%
log-div7.1%
clear-num7.1%
neg-log9.6%
*-commutative9.6%
neg-log7.1%
clear-num7.1%
log-div37.5%
unsub-neg37.5%
add-log-exp37.5%
sum-log0.9%
add-sqr-sqrt0.0%
sqrt-unprod33.4%
sqr-neg33.4%
sqrt-unprod33.4%
add-sqr-sqrt33.4%
add-exp-log51.4%
Applied egg-rr51.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2e292Initial program 99.8%
if 2e292 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.7%
add-cube-cbrt4.7%
log-prod4.7%
pow24.7%
Applied egg-rr4.7%
log-pow4.7%
distribute-lft1-in4.7%
metadata-eval4.7%
Simplified4.7%
add-log-exp4.7%
*-commutative4.7%
exp-prod4.7%
*-commutative4.7%
exp-to-pow4.7%
pow34.7%
add-cube-cbrt4.7%
exp-to-pow4.7%
diff-log3.1%
*-commutative3.1%
add-log-exp43.1%
sub-neg43.1%
distribute-rgt-in43.0%
Applied egg-rr43.0%
distribute-rgt-out43.1%
unsub-neg43.1%
log-div4.7%
clear-num4.7%
neg-log11.7%
distribute-rgt-neg-out11.7%
distribute-lft-neg-in11.7%
add-sqr-sqrt1.6%
sqrt-unprod4.4%
sqr-neg4.4%
sqrt-unprod2.8%
add-sqr-sqrt4.0%
neg-log1.3%
clear-num1.3%
log-div5.5%
unsub-neg5.5%
add-log-exp5.5%
sum-log0.1%
add-sqr-sqrt0.1%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.0%
Applied egg-rr53.6%
Final simplification85.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+292))) (- 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+292)) {
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+292)) {
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+292): 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+292)) 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+292))) 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+292]], $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^{+292}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 2e292 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.9%
remove-double-neg5.9%
sub-neg5.9%
distribute-neg-in5.9%
sub-neg5.9%
distribute-lft-neg-in5.9%
distribute-lft-neg-in5.9%
distribute-rgt-neg-in5.9%
log-div40.2%
sub-neg40.2%
distribute-neg-in40.2%
remove-double-neg40.2%
+-commutative40.2%
sub-neg40.2%
log-div10.6%
fma-neg10.6%
remove-double-neg10.6%
Simplified10.6%
Taylor expanded in x around 0 48.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2e292Initial program 99.8%
Final simplification84.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+292)))
(- (* 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 <= 2e+292)) {
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 <= 2e+292)) {
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 <= 2e+292): 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 <= 2e+292)) 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 <= 2e+292))) 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, 2e+292]], $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 2 \cdot 10^{+292}\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 2e292 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.9%
add-cube-cbrt5.9%
log-prod5.9%
pow25.9%
Applied egg-rr5.9%
log-pow5.9%
distribute-lft1-in5.9%
metadata-eval5.9%
Simplified5.9%
add-log-exp5.9%
*-commutative5.9%
exp-prod5.9%
*-commutative5.9%
exp-to-pow5.9%
pow35.9%
add-cube-cbrt5.9%
exp-to-pow5.9%
diff-log18.6%
*-commutative18.6%
add-log-exp40.2%
sub-neg40.2%
distribute-rgt-in40.1%
Applied egg-rr40.1%
distribute-rgt-out40.2%
unsub-neg40.2%
log-div5.9%
clear-num5.9%
neg-log10.6%
*-commutative10.6%
neg-log5.9%
clear-num5.9%
log-div40.2%
unsub-neg40.2%
add-log-exp40.2%
sum-log2.0%
add-sqr-sqrt1.5%
sqrt-unprod18.8%
sqr-neg18.8%
sqrt-unprod17.3%
add-sqr-sqrt21.9%
add-exp-log52.4%
Applied egg-rr52.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2e292Initial program 99.8%
Final simplification85.6%
(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 69.9%
remove-double-neg69.9%
sub-neg69.9%
distribute-neg-in69.9%
sub-neg69.9%
distribute-lft-neg-in69.9%
distribute-lft-neg-in69.9%
distribute-rgt-neg-in69.9%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div68.5%
fma-neg68.5%
remove-double-neg68.5%
Simplified68.5%
frac-2neg68.5%
log-div99.6%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 73.8%
clear-num72.9%
log-rec75.2%
Applied egg-rr75.2%
neg-log72.9%
clear-num73.8%
log-div99.5%
unsub-neg99.5%
distribute-rgt-out99.5%
distribute-lft-neg-out99.5%
unsub-neg99.5%
*-commutative99.5%
*-commutative99.5%
Applied egg-rr99.5%
Final simplification99.6%
(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 71.6%
add-cube-cbrt71.6%
log-prod71.5%
pow271.5%
Applied egg-rr71.5%
log-pow71.5%
distribute-lft1-in71.5%
metadata-eval71.5%
Simplified71.5%
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 (<= x -1.52e-158) (- (* 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 <= -1.52e-158) {
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 <= (-1.52d-158)) 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 <= -1.52e-158) {
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 <= -1.52e-158: 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 <= -1.52e-158) 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 <= -1.52e-158) 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, -1.52e-158], 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 -1.52 \cdot 10^{-158}:\\
\;\;\;\;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 < -1.52e-158Initial program 74.1%
if -1.52e-158 < x < -1.9999999999999998e-308Initial program 55.8%
remove-double-neg55.8%
sub-neg55.8%
distribute-neg-in55.8%
sub-neg55.8%
distribute-lft-neg-in55.8%
distribute-lft-neg-in55.8%
distribute-rgt-neg-in55.8%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div52.8%
fma-neg52.8%
remove-double-neg52.8%
Simplified52.8%
Taylor expanded in x around 0 88.9%
if -1.9999999999999998e-308 < x Initial program 73.8%
log-div99.5%
Applied egg-rr99.5%
Final simplification87.2%
(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 69.9%
frac-2neg69.9%
log-div99.6%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 73.8%
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 69.9%
frac-2neg69.9%
log-div99.6%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 73.8%
clear-num72.9%
log-rec75.2%
Applied egg-rr75.2%
neg-log72.9%
clear-num73.8%
log-div99.5%
unsub-neg99.5%
distribute-rgt-out99.5%
distribute-lft-neg-out99.5%
unsub-neg99.5%
*-commutative99.5%
*-commutative99.5%
Applied egg-rr99.5%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.35e-120) (not (<= z 5.8e-69))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e-120) || !(z <= 5.8e-69)) {
tmp = -z;
} else {
tmp = -x * log((y / x));
}
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 <= (-1.35d-120)) .or. (.not. (z <= 5.8d-69))) then
tmp = -z
else
tmp = -x * log((y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e-120) || !(z <= 5.8e-69)) {
tmp = -z;
} else {
tmp = -x * Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.35e-120) or not (z <= 5.8e-69): tmp = -z else: tmp = -x * math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.35e-120) || !(z <= 5.8e-69)) tmp = Float64(-z); else tmp = Float64(Float64(-x) * log(Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.35e-120) || ~((z <= 5.8e-69))) tmp = -z; else tmp = -x * log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.35e-120], N[Not[LessEqual[z, 5.8e-69]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{-120} \lor \neg \left(z \leq 5.8 \cdot 10^{-69}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\end{array}
\end{array}
if z < -1.3499999999999999e-120 or 5.7999999999999997e-69 < z Initial program 73.7%
remove-double-neg73.7%
sub-neg73.7%
distribute-neg-in73.7%
sub-neg73.7%
distribute-lft-neg-in73.7%
distribute-lft-neg-in73.7%
distribute-rgt-neg-in73.7%
log-div43.1%
sub-neg43.1%
distribute-neg-in43.1%
remove-double-neg43.1%
+-commutative43.1%
sub-neg43.1%
log-div72.6%
fma-neg72.6%
remove-double-neg72.6%
Simplified72.6%
Taylor expanded in x around 0 73.0%
if -1.3499999999999999e-120 < z < 5.7999999999999997e-69Initial program 67.3%
remove-double-neg67.3%
sub-neg67.3%
distribute-neg-in67.3%
sub-neg67.3%
distribute-lft-neg-in67.3%
distribute-lft-neg-in67.3%
distribute-rgt-neg-in67.3%
log-div45.6%
sub-neg45.6%
distribute-neg-in45.6%
remove-double-neg45.6%
+-commutative45.6%
sub-neg45.6%
log-div69.2%
fma-neg69.2%
remove-double-neg69.2%
Simplified69.2%
Taylor expanded in x around inf 37.7%
log-rec37.7%
sub-neg37.7%
log-div62.8%
add062.8%
distribute-lft-in62.8%
mul0-rgt62.8%
add062.8%
Simplified62.8%
Final simplification69.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 71.6%
remove-double-neg71.6%
sub-neg71.6%
distribute-neg-in71.6%
sub-neg71.6%
distribute-lft-neg-in71.6%
distribute-lft-neg-in71.6%
distribute-rgt-neg-in71.6%
log-div43.9%
sub-neg43.9%
distribute-neg-in43.9%
remove-double-neg43.9%
+-commutative43.9%
sub-neg43.9%
log-div71.4%
fma-neg71.4%
remove-double-neg71.4%
Simplified71.4%
Taylor expanded in x around 0 53.3%
Final simplification53.3%
(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 2024046
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:alt
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))