
(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
(if (<= y -4e-310)
(- (* x (- (log (- x)) (log (- y)))) z)
(-
(* x (+ (log (/ (pow (cbrt x) 2.0) (sqrt y))) (log (/ (cbrt x) (sqrt 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((pow(cbrt(x), 2.0) / sqrt(y))) + log((cbrt(x) / sqrt(y))))) - z;
}
return tmp;
}
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((Math.pow(Math.cbrt(x), 2.0) / Math.sqrt(y))) + Math.log((Math.cbrt(x) / Math.sqrt(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(Float64((cbrt(x) ^ 2.0) / sqrt(y))) + log(Float64(cbrt(x) / sqrt(y))))) - 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[(N[(x * N[(N[Log[N[(N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]], $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 \left(\frac{{\left(\sqrt[3]{x}\right)}^{2}}{\sqrt{y}}\right) + \log \left(\frac{\sqrt[3]{x}}{\sqrt{y}}\right)\right) - z\\
\end{array}
\end{array}
if y < -3.999999999999988e-310Initial program 75.5%
Taylor expanded in y around -inf 99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
distribute-frac-neg299.6%
neg-mul-199.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
if -3.999999999999988e-310 < y Initial program 78.4%
add-cube-cbrt78.4%
add-sqr-sqrt78.4%
times-frac78.4%
log-prod99.7%
pow299.7%
Applied egg-rr99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY)))
(- (* x (log (* y x))) 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 <= ((double) INFINITY))) {
tmp = (x * log((y * x))) - 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 <= Double.POSITIVE_INFINITY)) {
tmp = (x * Math.log((y * x))) - 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 <= math.inf): tmp = (x * math.log((y * x))) - 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 <= Inf)) tmp = Float64(Float64(x * log(Float64(y * x))) - 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 <= Inf))) tmp = (x * log((y * x))) - 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, Infinity]], $MachinePrecision]], N[(N[(x * N[Log[N[(y * x), $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 \infty\right):\\
\;\;\;\;x \cdot \log \left(y \cdot x\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 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 4.9%
clear-num4.9%
neg-log4.9%
Applied egg-rr4.9%
*-commutative4.9%
fma-neg4.9%
neg-log4.9%
clear-num4.9%
div-inv4.9%
add-exp-log1.5%
rec-exp1.5%
add-sqr-sqrt0.0%
sqrt-unprod33.7%
sqr-neg33.7%
sqrt-unprod33.7%
add-sqr-sqrt33.7%
add-exp-log48.1%
Applied egg-rr48.1%
fma-undefine48.1%
unsub-neg48.1%
Simplified48.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 85.4%
Final simplification81.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY))) (- 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 <= ((double) INFINITY))) {
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 <= Double.POSITIVE_INFINITY)) {
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 <= math.inf): 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 <= Inf)) 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 <= Inf))) 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, Infinity]], $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 \infty\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 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 4.9%
Taylor expanded in x around 0 46.5%
neg-mul-146.5%
Simplified46.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 85.4%
Final simplification81.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))) (t_1 (log (* y x))))
(if (<= t_0 (- INFINITY))
(- (* x (- t_1)) z)
(if (<= t_0 INFINITY) (- t_0 z) (- (* x t_1) z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double t_1 = log((y * x));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (x * -t_1) - z;
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 - z;
} else {
tmp = (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((y * x));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (x * -t_1) - z;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 - z;
} else {
tmp = (x * t_1) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) t_1 = math.log((y * x)) tmp = 0 if t_0 <= -math.inf: tmp = (x * -t_1) - z elif t_0 <= math.inf: tmp = t_0 - z else: tmp = (x * t_1) - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) t_1 = log(Float64(y * x)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(x * Float64(-t_1)) - z); elseif (t_0 <= Inf) tmp = Float64(t_0 - z); else tmp = Float64(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((y * x)); tmp = 0.0; if (t_0 <= -Inf) tmp = (x * -t_1) - z; elseif (t_0 <= Inf) tmp = t_0 - z; else tmp = (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[(y * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(x * (-t$95$1)), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 - z), $MachinePrecision], N[(N[(x * t$95$1), $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
t_1 := \log \left(y \cdot x\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;x \cdot \left(-t\_1\right) - z\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_1 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 4.9%
clear-num4.9%
neg-log4.9%
Applied egg-rr4.9%
add-exp-log4.9%
add-sqr-sqrt1.5%
sqrt-unprod2.0%
sqr-neg2.0%
sqrt-unprod0.5%
add-sqr-sqrt1.1%
rec-exp1.1%
add-exp-log1.1%
associate-/r/1.1%
add-exp-log0.6%
rec-exp0.6%
add-sqr-sqrt0.0%
sqrt-unprod35.2%
sqr-neg35.2%
sqrt-unprod35.2%
add-sqr-sqrt35.2%
add-exp-log50.6%
Applied egg-rr50.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 85.4%
if +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 76.9%
clear-num75.9%
neg-log76.6%
Applied egg-rr76.6%
*-commutative76.6%
fma-neg76.6%
neg-log75.9%
clear-num76.9%
div-inv76.9%
add-exp-log37.9%
rec-exp37.9%
add-sqr-sqrt20.2%
sqrt-unprod30.0%
sqr-neg30.0%
sqrt-unprod9.8%
add-sqr-sqrt17.8%
add-exp-log39.1%
Applied egg-rr39.1%
fma-undefine39.1%
unsub-neg39.1%
Simplified39.1%
Final simplification81.7%
(FPCore (x y z)
:precision binary64
(if (<= x -3.7e+171)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.8e-163)
(- (* x (log (/ x y))) z)
(if (<= x -4e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.7e+171) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.8e-163) {
tmp = (x * log((x / y))) - z;
} else if (x <= -4e-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 <= (-3.7d+171)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.8d-163)) then
tmp = (x * log((x / y))) - z
else if (x <= (-4d-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 <= -3.7e+171) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.8e-163) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -4e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.7e+171: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.8e-163: tmp = (x * math.log((x / y))) - z elif x <= -4e-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 <= -3.7e+171) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.8e-163) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -4e-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 <= -3.7e+171) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.8e-163) tmp = (x * log((x / y))) - z; elseif (x <= -4e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.7e+171], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.8e-163], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -4e-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 -3.7 \cdot 10^{+171}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-163}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -3.69999999999999998e171Initial program 66.7%
Taylor expanded in z around 0 63.7%
Taylor expanded in y around -inf 90.9%
metadata-eval98.8%
distribute-neg-frac98.8%
distribute-frac-neg298.8%
neg-mul-198.8%
log-rec98.8%
sub-neg98.8%
Simplified90.9%
if -3.69999999999999998e171 < x < -1.7999999999999999e-163Initial program 86.7%
if -1.7999999999999999e-163 < x < -3.9999999999999977e-309Initial program 61.6%
Taylor expanded in x around 0 91.5%
neg-mul-191.5%
Simplified91.5%
if -3.9999999999999977e-309 < x Initial program 78.4%
Taylor expanded in x around 0 99.6%
log-rec99.6%
neg-mul-199.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
(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 75.5%
Taylor expanded in y around -inf 99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
distribute-frac-neg299.6%
neg-mul-199.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
if -3.999999999999988e-310 < y Initial program 78.4%
Taylor expanded in x around 0 99.6%
log-rec99.6%
neg-mul-199.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.1e-56) (not (<= z 1.3e-22))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.1e-56) || !(z <= 1.3e-22)) {
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 <= (-6.1d-56)) .or. (.not. (z <= 1.3d-22))) 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 <= -6.1e-56) || !(z <= 1.3e-22)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.1e-56) or not (z <= 1.3e-22): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.1e-56) || !(z <= 1.3e-22)) 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 <= -6.1e-56) || ~((z <= 1.3e-22))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.1e-56], N[Not[LessEqual[z, 1.3e-22]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.1 \cdot 10^{-56} \lor \neg \left(z \leq 1.3 \cdot 10^{-22}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -6.0999999999999998e-56 or 1.3e-22 < z Initial program 76.5%
Taylor expanded in x around 0 75.2%
neg-mul-175.2%
Simplified75.2%
if -6.0999999999999998e-56 < z < 1.3e-22Initial program 77.5%
Taylor expanded in z around 0 69.2%
Final simplification72.4%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 76.9%
Taylor expanded in x around 0 48.3%
neg-mul-148.3%
Simplified48.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 z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 76.9%
Taylor expanded in x around 0 48.3%
neg-mul-148.3%
Simplified48.3%
neg-sub048.3%
sub-neg48.3%
add-sqr-sqrt20.2%
sqrt-unprod12.9%
sqr-neg12.9%
sqrt-unprod1.5%
add-sqr-sqrt2.5%
Applied egg-rr2.5%
+-lft-identity2.5%
Simplified2.5%
(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 2024138
(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))