
(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 8 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 -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 74.7%
Taylor expanded in y around -inf 99.4%
neg-mul-199.4%
metadata-eval99.4%
distribute-neg-frac99.4%
distribute-frac-neg299.4%
log-rec99.4%
sub-neg99.4%
Simplified99.4%
if -1.999999999999994e-310 < y Initial program 77.1%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+221)))
(- (- z) (* x (log (* y x))))
(- 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 <= 5e+221)) {
tmp = -z - (x * log((y * x)));
} 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 <= 5e+221)) {
tmp = -z - (x * Math.log((y * x)));
} 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 <= 5e+221): tmp = -z - (x * math.log((y * x))) 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 <= 5e+221)) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y * x)))); 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 <= 5e+221))) tmp = -z - (x * log((y * x))); 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, 5e+221]], $MachinePrecision]], N[((-z) - N[(x * N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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 5 \cdot 10^{+221}\right):\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.0000000000000002e221 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 12.9%
Taylor expanded in z around inf 10.2%
sub-neg10.2%
associate-/l*10.2%
metadata-eval10.2%
Simplified10.2%
clear-num12.9%
log-div16.6%
metadata-eval16.6%
Applied egg-rr13.9%
neg-sub016.6%
Simplified13.9%
distribute-frac-neg13.9%
distribute-frac-neg213.9%
div-inv13.9%
Applied egg-rr47.0%
Taylor expanded in z around 0 47.6%
distribute-lft-out47.6%
Simplified47.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.0000000000000002e221Initial program 99.5%
Final simplification85.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (* y x))) (t_1 (* x (log (/ x y)))))
(if (<= t_1 (- INFINITY))
(* z (+ (/ x (/ z t_0)) -1.0))
(if (<= t_1 5e+221) (- t_1 z) (- (- z) (* x t_0))))))
double code(double x, double y, double z) {
double t_0 = log((y * x));
double t_1 = x * log((x / y));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = z * ((x / (z / t_0)) + -1.0);
} else if (t_1 <= 5e+221) {
tmp = t_1 - z;
} else {
tmp = -z - (x * t_0);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.log((y * x));
double t_1 = x * Math.log((x / y));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = z * ((x / (z / t_0)) + -1.0);
} else if (t_1 <= 5e+221) {
tmp = t_1 - z;
} else {
tmp = -z - (x * t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.log((y * x)) t_1 = x * math.log((x / y)) tmp = 0 if t_1 <= -math.inf: tmp = z * ((x / (z / t_0)) + -1.0) elif t_1 <= 5e+221: tmp = t_1 - z else: tmp = -z - (x * t_0) return tmp
function code(x, y, z) t_0 = log(Float64(y * x)) t_1 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(z * Float64(Float64(x / Float64(z / t_0)) + -1.0)); elseif (t_1 <= 5e+221) tmp = Float64(t_1 - z); else tmp = Float64(Float64(-z) - Float64(x * t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = log((y * x)); t_1 = x * log((x / y)); tmp = 0.0; if (t_1 <= -Inf) tmp = z * ((x / (z / t_0)) + -1.0); elseif (t_1 <= 5e+221) tmp = t_1 - z; else tmp = -z - (x * t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(z * N[(N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+221], N[(t$95$1 - z), $MachinePrecision], N[((-z) - N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(y \cdot x\right)\\
t_1 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;z \cdot \left(\frac{x}{\frac{z}{t\_0}} + -1\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+221}:\\
\;\;\;\;t\_1 - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - x \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 11.4%
Taylor expanded in z around inf 11.4%
sub-neg11.4%
associate-/l*11.4%
metadata-eval11.4%
Simplified11.4%
clear-num11.4%
associate-/r/11.4%
Applied egg-rr11.4%
*-commutative11.4%
clear-num11.4%
neg-log12.6%
div-inv12.6%
clear-num12.6%
un-div-inv12.6%
neg-log11.4%
clear-num11.4%
log-div37.9%
sub-neg37.9%
add-log-exp37.9%
sum-log1.2%
add-sqr-sqrt0.0%
sqrt-unprod37.9%
sqr-neg37.9%
sqrt-unprod37.9%
add-sqr-sqrt37.9%
add-exp-log50.4%
Applied egg-rr50.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.0000000000000002e221Initial program 99.5%
if 5.0000000000000002e221 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 13.9%
Taylor expanded in z around inf 9.4%
sub-neg9.4%
associate-/l*9.4%
metadata-eval9.4%
Simplified9.4%
clear-num13.9%
log-div19.4%
metadata-eval19.4%
Applied egg-rr14.9%
neg-sub019.4%
Simplified14.9%
distribute-frac-neg14.9%
distribute-frac-neg214.9%
div-inv14.9%
Applied egg-rr47.4%
Taylor expanded in z around 0 48.0%
distribute-lft-out48.0%
Simplified48.0%
Final simplification85.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+244))) (- 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+244)) {
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+244)) {
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+244): 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+244)) 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+244))) 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+244]], $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^{+244}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.00000000000000007e244 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 11.6%
Taylor expanded in x around 0 45.0%
neg-mul-145.0%
Simplified45.0%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000007e244Initial program 99.5%
Final simplification84.8%
(FPCore (x y z)
:precision binary64
(if (<= x -1.9e+144)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.8e-197)
(- (* x (log (/ x y))) z)
(if (<= x 3.9e-222)
(- z)
(if (<= x 2.3e+219)
(- (- z) (* x (log (/ y x))))
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+144) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.8e-197) {
tmp = (x * log((x / y))) - z;
} else if (x <= 3.9e-222) {
tmp = -z;
} else if (x <= 2.3e+219) {
tmp = -z - (x * log((y / x)));
} else {
tmp = x * (log(x) - log(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 (x <= (-1.9d+144)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-2.8d-197)) then
tmp = (x * log((x / y))) - z
else if (x <= 3.9d-222) then
tmp = -z
else if (x <= 2.3d+219) then
tmp = -z - (x * log((y / x)))
else
tmp = x * (log(x) - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+144) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -2.8e-197) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= 3.9e-222) {
tmp = -z;
} else if (x <= 2.3e+219) {
tmp = -z - (x * Math.log((y / x)));
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.9e+144: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -2.8e-197: tmp = (x * math.log((x / y))) - z elif x <= 3.9e-222: tmp = -z elif x <= 2.3e+219: tmp = -z - (x * math.log((y / x))) else: tmp = x * (math.log(x) - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.9e+144) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.8e-197) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= 3.9e-222) tmp = Float64(-z); elseif (x <= 2.3e+219) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.9e+144) tmp = x * (log(-x) - log(-y)); elseif (x <= -2.8e-197) tmp = (x * log((x / y))) - z; elseif (x <= 3.9e-222) tmp = -z; elseif (x <= 2.3e+219) tmp = -z - (x * log((y / x))); else tmp = x * (log(x) - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.9e+144], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.8e-197], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 3.9e-222], (-z), If[LessEqual[x, 2.3e+219], N[((-z) - N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+144}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-197}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-222}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+219}:\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -1.90000000000000013e144Initial program 69.3%
Taylor expanded in z around 0 62.2%
Taylor expanded in y around -inf 90.7%
neg-mul-198.6%
metadata-eval98.6%
distribute-neg-frac98.6%
distribute-frac-neg298.6%
log-rec98.6%
sub-neg98.6%
Simplified90.7%
if -1.90000000000000013e144 < x < -2.8000000000000002e-197Initial program 88.0%
if -2.8000000000000002e-197 < x < 3.9000000000000001e-222Initial program 52.2%
Taylor expanded in x around 0 93.2%
neg-mul-193.2%
Simplified93.2%
if 3.9000000000000001e-222 < x < 2.3000000000000001e219Initial program 87.7%
clear-num87.0%
log-div89.5%
metadata-eval89.5%
Applied egg-rr89.5%
neg-sub089.5%
Simplified89.5%
if 2.3000000000000001e219 < x Initial program 39.1%
Taylor expanded in z around 0 39.1%
Taylor expanded in x around 0 98.8%
log-rec98.8%
sub-neg98.8%
Simplified98.8%
Final simplification90.5%
(FPCore (x y z)
:precision binary64
(if (<= x -1.3e+139)
(* x (- (log (- x)) (log (- y))))
(if (<= x -9.8e-197)
(- (* x (log (/ x y))) z)
(if (<= x 1e-294) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e+139) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -9.8e-197) {
tmp = (x * log((x / y))) - z;
} else if (x <= 1e-294) {
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.3d+139)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-9.8d-197)) then
tmp = (x * log((x / y))) - z
else if (x <= 1d-294) 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.3e+139) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -9.8e-197) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= 1e-294) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.3e+139: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -9.8e-197: tmp = (x * math.log((x / y))) - z elif x <= 1e-294: 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.3e+139) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -9.8e-197) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= 1e-294) 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.3e+139) tmp = x * (log(-x) - log(-y)); elseif (x <= -9.8e-197) tmp = (x * log((x / y))) - z; elseif (x <= 1e-294) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.3e+139], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -9.8e-197], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 1e-294], (-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.3 \cdot 10^{+139}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -9.8 \cdot 10^{-197}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq 10^{-294}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.30000000000000011e139Initial program 69.3%
Taylor expanded in z around 0 62.2%
Taylor expanded in y around -inf 90.7%
neg-mul-198.6%
metadata-eval98.6%
distribute-neg-frac98.6%
distribute-frac-neg298.6%
log-rec98.6%
sub-neg98.6%
Simplified90.7%
if -1.30000000000000011e139 < x < -9.8000000000000004e-197Initial program 88.0%
if -9.8000000000000004e-197 < x < 1.00000000000000002e-294Initial program 47.9%
Taylor expanded in x around 0 93.0%
neg-mul-193.0%
Simplified93.0%
if 1.00000000000000002e-294 < x Initial program 78.2%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z)
:precision binary64
(if (or (<= z -1.4e+84)
(not (or (<= z -8.5e+23) (and (not (<= z -1.2e-47)) (<= z 0.78)))))
(- z)
(* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.4e+84) || !((z <= -8.5e+23) || (!(z <= -1.2e-47) && (z <= 0.78)))) {
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 <= (-1.4d+84)) .or. (.not. (z <= (-8.5d+23)) .or. (.not. (z <= (-1.2d-47))) .and. (z <= 0.78d0))) 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 <= -1.4e+84) || !((z <= -8.5e+23) || (!(z <= -1.2e-47) && (z <= 0.78)))) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.4e+84) or not ((z <= -8.5e+23) or (not (z <= -1.2e-47) and (z <= 0.78))): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.4e+84) || !((z <= -8.5e+23) || (!(z <= -1.2e-47) && (z <= 0.78)))) 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 <= -1.4e+84) || ~(((z <= -8.5e+23) || (~((z <= -1.2e-47)) && (z <= 0.78))))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.4e+84], N[Not[Or[LessEqual[z, -8.5e+23], And[N[Not[LessEqual[z, -1.2e-47]], $MachinePrecision], LessEqual[z, 0.78]]]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+84} \lor \neg \left(z \leq -8.5 \cdot 10^{+23} \lor \neg \left(z \leq -1.2 \cdot 10^{-47}\right) \land z \leq 0.78\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.39999999999999991e84 or -8.5000000000000001e23 < z < -1.2e-47 or 0.78000000000000003 < z Initial program 77.4%
Taylor expanded in x around 0 79.1%
neg-mul-179.1%
Simplified79.1%
if -1.39999999999999991e84 < z < -8.5000000000000001e23 or -1.2e-47 < z < 0.78000000000000003Initial program 74.6%
Taylor expanded in z around 0 61.6%
Final simplification69.1%
(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 75.8%
Taylor expanded in x around 0 47.3%
neg-mul-147.3%
Simplified47.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 2024107
(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))