
(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 12 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(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 80.2%
add-cube-cbrt80.2%
pow380.2%
Applied egg-rr80.2%
pow-to-exp80.2%
rem-log-exp80.2%
Applied egg-rr80.2%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (<= t_1 (- INFINITY))
(* x (- (log (- x)) (log (- y))))
(if (<= t_1 4e+288) (fma x t_0 (- z)) (* x (- (log x) (log y)))))))
double code(double x, double y, double z) {
double t_0 = log((x / y));
double t_1 = x * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x * (log(-x) - log(-y));
} else if (t_1 <= 4e+288) {
tmp = fma(x, t_0, -z);
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(x / y)) t_1 = Float64(x * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (t_1 <= 4e+288) tmp = fma(x, t_0, Float64(-z)); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+288], N[(x * 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 := \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+288}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\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 4.5%
Taylor expanded in z around 0 4.5%
Taylor expanded in y around -inf 47.6%
metadata-eval47.6%
distribute-neg-frac47.6%
distribute-frac-neg247.6%
log-rec47.6%
sub-neg47.6%
neg-mul-147.6%
Simplified47.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4e288Initial program 99.8%
fmm-def99.8%
Simplified99.8%
if 4e288 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.5%
add-sqr-sqrt8.5%
pow28.5%
Applied egg-rr8.5%
Taylor expanded in x around inf 52.6%
log-rec52.6%
distribute-rgt-in52.6%
mul-1-neg52.6%
log-rec52.6%
remove-double-neg52.6%
distribute-rgt-in52.6%
+-commutative52.6%
sub-neg52.6%
Simplified52.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (<= t_1 (- INFINITY))
(- (* x (log (* x y))) z)
(if (<= t_1 4e+288) (fma x t_0 (- z)) (* x (- (log x) (log y)))))))
double code(double x, double y, double z) {
double t_0 = log((x / y));
double t_1 = x * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (x * log((x * y))) - z;
} else if (t_1 <= 4e+288) {
tmp = fma(x, t_0, -z);
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(x / y)) t_1 = Float64(x * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(x * log(Float64(x * y))) - z); elseif (t_1 <= 4e+288) tmp = fma(x, t_0, Float64(-z)); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(x * N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$1, 4e+288], N[(x * 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 := \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;x \cdot \log \left(x \cdot y\right) - z\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+288}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\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 4.5%
add-cube-cbrt4.5%
associate-/l*4.5%
log-prod68.9%
pow268.9%
Applied egg-rr68.9%
log-div52.1%
associate-+r-52.1%
log-prod52.1%
unpow252.1%
add-cube-cbrt52.1%
log-div4.5%
frac-2neg4.5%
diff-log47.6%
sub-neg47.6%
distribute-rgt-in47.4%
add-sqr-sqrt47.4%
sqrt-unprod7.4%
sqr-neg7.4%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr52.0%
distribute-rgt-out52.1%
sub-neg52.1%
log-div4.5%
*-commutative4.5%
log-div52.1%
sub-neg52.1%
add-log-exp52.1%
sum-log1.2%
add-sqr-sqrt0.0%
sqrt-unprod38.7%
sqr-neg38.7%
sqrt-unprod38.7%
add-sqr-sqrt38.7%
add-exp-log43.1%
Applied egg-rr43.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4e288Initial program 99.8%
fmm-def99.8%
Simplified99.8%
if 4e288 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.5%
add-sqr-sqrt8.5%
pow28.5%
Applied egg-rr8.5%
Taylor expanded in x around inf 52.6%
log-rec52.6%
distribute-rgt-in52.6%
mul-1-neg52.6%
log-rec52.6%
remove-double-neg52.6%
distribute-rgt-in52.6%
+-commutative52.6%
sub-neg52.6%
Simplified52.6%
Final simplification89.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- (* x (log (* x y))) z)
(if (<= t_0 4e+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 = (x * log((x * y))) - z;
} else if (t_0 <= 4e+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 = (x * Math.log((x * y))) - z;
} else if (t_0 <= 4e+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 = (x * math.log((x * y))) - z elif t_0 <= 4e+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(Float64(x * log(Float64(x * y))) - z); elseif (t_0 <= 4e+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 = (x * log((x * y))) - z; elseif (t_0 <= 4e+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)], N[(N[(x * N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, 4e+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:\\
\;\;\;\;x \cdot \log \left(x \cdot y\right) - z\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 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 4.5%
add-cube-cbrt4.5%
associate-/l*4.5%
log-prod68.9%
pow268.9%
Applied egg-rr68.9%
log-div52.1%
associate-+r-52.1%
log-prod52.1%
unpow252.1%
add-cube-cbrt52.1%
log-div4.5%
frac-2neg4.5%
diff-log47.6%
sub-neg47.6%
distribute-rgt-in47.4%
add-sqr-sqrt47.4%
sqrt-unprod7.4%
sqr-neg7.4%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr52.0%
distribute-rgt-out52.1%
sub-neg52.1%
log-div4.5%
*-commutative4.5%
log-div52.1%
sub-neg52.1%
add-log-exp52.1%
sum-log1.2%
add-sqr-sqrt0.0%
sqrt-unprod38.7%
sqr-neg38.7%
sqrt-unprod38.7%
add-sqr-sqrt38.7%
add-exp-log43.1%
Applied egg-rr43.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4e288Initial program 99.8%
if 4e288 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.5%
add-sqr-sqrt8.5%
pow28.5%
Applied egg-rr8.5%
Taylor expanded in x around inf 52.6%
log-rec52.6%
distribute-rgt-in52.6%
mul-1-neg52.6%
log-rec52.6%
remove-double-neg52.6%
distribute-rgt-in52.6%
+-commutative52.6%
sub-neg52.6%
Simplified52.6%
Final simplification89.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+302)))
(- (* 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+302)) {
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+302)) {
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+302): 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+302)) 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+302))) 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+302]], $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^{+302}\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.0000000000000001e302 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.1%
add-cube-cbrt5.1%
associate-/l*5.1%
log-prod65.0%
pow265.0%
Applied egg-rr65.0%
log-div56.4%
associate-+r-56.4%
log-prod56.4%
unpow256.4%
add-cube-cbrt56.4%
log-div5.1%
frac-2neg5.1%
diff-log43.3%
sub-neg43.3%
distribute-rgt-in43.2%
add-sqr-sqrt43.2%
sqrt-unprod11.2%
sqr-neg11.2%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr56.4%
distribute-rgt-out56.4%
sub-neg56.4%
log-div5.1%
*-commutative5.1%
log-div56.4%
sub-neg56.4%
add-log-exp56.4%
sum-log2.9%
add-sqr-sqrt2.3%
sqrt-unprod19.1%
sqr-neg19.1%
sqrt-unprod16.8%
add-sqr-sqrt23.1%
add-exp-log40.6%
Applied egg-rr40.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.0000000000000001e302Initial program 99.8%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+302))) (- 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+302)) {
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+302)) {
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+302): 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+302)) 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+302))) 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+302]], $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^{+302}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.0000000000000001e302 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.1%
Taylor expanded in x around 0 37.8%
mul-1-neg37.8%
Simplified37.8%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.0000000000000001e302Initial program 99.8%
Final simplification87.0%
(FPCore (x y z)
:precision binary64
(if (<= x -1.9e+159)
(* x (- (log (- x)) (log (- y))))
(if (<= x -4.5e-68)
(- (* x (log (/ x y))) z)
(if (<= x -2e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+159) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -4.5e-68) {
tmp = (x * log((x / y))) - z;
} else if (x <= -2e-309) {
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.9d+159)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-4.5d-68)) then
tmp = (x * log((x / y))) - z
else if (x <= (-2d-309)) 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.9e+159) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -4.5e-68) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -2e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.9e+159: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -4.5e-68: tmp = (x * math.log((x / y))) - z elif x <= -2e-309: 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.9e+159) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -4.5e-68) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -2e-309) 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.9e+159) tmp = x * (log(-x) - log(-y)); elseif (x <= -4.5e-68) tmp = (x * log((x / y))) - z; elseif (x <= -2e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.9e+159], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.5e-68], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-309], (-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.9 \cdot 10^{+159}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-68}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.89999999999999983e159Initial program 65.5%
Taylor expanded in z around 0 56.3%
Taylor expanded in y around -inf 89.8%
metadata-eval98.9%
distribute-neg-frac98.9%
distribute-frac-neg298.9%
log-rec98.9%
sub-neg98.9%
neg-mul-198.9%
Simplified89.8%
if -1.89999999999999983e159 < x < -4.49999999999999999e-68Initial program 97.4%
if -4.49999999999999999e-68 < x < -1.9999999999999988e-309Initial program 78.1%
Taylor expanded in x around 0 89.1%
mul-1-neg89.1%
Simplified89.1%
if -1.9999999999999988e-309 < x Initial program 78.8%
Taylor expanded in x around 0 99.7%
log-rec99.7%
sub-neg99.7%
Simplified99.7%
(FPCore (x y z) :precision binary64 (if (<= y -2e-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 <= -2e-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 <= (-2d-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 <= -2e-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 <= -2e-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 <= -2e-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 <= -2e-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, -2e-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 -2 \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 < -1.999999999999994e-310Initial program 81.8%
Taylor expanded in y around -inf 99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
distribute-frac-neg299.5%
log-rec99.5%
sub-neg99.5%
neg-mul-199.5%
Simplified99.5%
if -1.999999999999994e-310 < y Initial program 78.8%
Taylor expanded in x around 0 99.7%
log-rec99.7%
sub-neg99.7%
Simplified99.7%
(FPCore (x y z) :precision binary64 (if (<= x -21000000000000.0) (* x (log (/ x y))) (if (<= x 3.2e-39) (- z) (* x (- (log (/ y x)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -21000000000000.0) {
tmp = x * log((x / y));
} else if (x <= 3.2e-39) {
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 (x <= (-21000000000000.0d0)) then
tmp = x * log((x / y))
else if (x <= 3.2d-39) 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 (x <= -21000000000000.0) {
tmp = x * Math.log((x / y));
} else if (x <= 3.2e-39) {
tmp = -z;
} else {
tmp = x * -Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -21000000000000.0: tmp = x * math.log((x / y)) elif x <= 3.2e-39: tmp = -z else: tmp = x * -math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -21000000000000.0) tmp = Float64(x * log(Float64(x / y))); elseif (x <= 3.2e-39) tmp = Float64(-z); else tmp = Float64(x * Float64(-log(Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -21000000000000.0) tmp = x * log((x / y)); elseif (x <= 3.2e-39) tmp = -z; else tmp = x * -log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -21000000000000.0], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.2e-39], (-z), N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -21000000000000:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-39}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\end{array}
\end{array}
if x < -2.1e13Initial program 80.8%
Taylor expanded in z around 0 69.1%
if -2.1e13 < x < 3.1999999999999998e-39Initial program 82.0%
Taylor expanded in x around 0 81.8%
mul-1-neg81.8%
Simplified81.8%
if 3.1999999999999998e-39 < x Initial program 76.5%
Taylor expanded in z around 0 53.5%
clear-num53.5%
neg-log56.0%
Applied egg-rr56.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.2e-54) (not (<= z 5.5e-46))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.2e-54) || !(z <= 5.5e-46)) {
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 <= (-9.2d-54)) .or. (.not. (z <= 5.5d-46))) 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 <= -9.2e-54) || !(z <= 5.5e-46)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.2e-54) or not (z <= 5.5e-46): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.2e-54) || !(z <= 5.5e-46)) 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 <= -9.2e-54) || ~((z <= 5.5e-46))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.2e-54], N[Not[LessEqual[z, 5.5e-46]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \cdot 10^{-54} \lor \neg \left(z \leq 5.5 \cdot 10^{-46}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -9.1999999999999996e-54 or 5.49999999999999983e-46 < z Initial program 80.7%
Taylor expanded in x around 0 74.6%
mul-1-neg74.6%
Simplified74.6%
if -9.1999999999999996e-54 < z < 5.49999999999999983e-46Initial program 79.5%
Taylor expanded in z around 0 66.5%
Final simplification71.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 80.2%
Taylor expanded in x around 0 51.9%
mul-1-neg51.9%
Simplified51.9%
(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 z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 80.2%
Taylor expanded in x around 0 51.9%
mul-1-neg51.9%
Simplified51.9%
neg-sub051.9%
sub-neg51.9%
add-sqr-sqrt25.4%
sqrt-unprod15.0%
sqr-neg15.0%
sqrt-unprod1.1%
add-sqr-sqrt2.1%
Applied egg-rr2.1%
+-lft-identity2.1%
Simplified2.1%
(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 2024163
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< y 7595077799083773/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
(- (* x (log (/ x y))) z))