
(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 -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 74.9%
Taylor expanded in y around -inf 99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
distribute-frac-neg299.5%
neg-mul-199.5%
log-rec99.5%
sub-neg99.5%
Simplified99.5%
if -4.999999999999985e-310 < y Initial program 76.4%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 4e+301)))
(- (- z) (* x (log (* y x))))
(fma x t_0 (- z)))))
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)) || !(t_1 <= 4e+301)) {
tmp = -z - (x * log((y * x)));
} else {
tmp = fma(x, t_0, -z);
}
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)) || !(t_1 <= 4e+301)) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y * x)))); else tmp = fma(x, t_0, Float64(-z)); 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[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 4e+301]], $MachinePrecision]], N[((-z) - N[(x * N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * t$95$0 + (-z)), $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 \lor \neg \left(t\_1 \leq 4 \cdot 10^{+301}\right):\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4.00000000000000021e301 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.7%
Taylor expanded in x around 0 50.0%
log-rec50.0%
sub-neg50.0%
Simplified50.0%
sub-neg50.0%
distribute-rgt-in49.9%
Applied egg-rr49.9%
+-commutative49.9%
distribute-rgt-out50.0%
neg-sub050.0%
associate--r-50.0%
log-div7.0%
neg-sub07.0%
distribute-rgt-neg-out7.0%
distribute-lft-neg-in7.0%
add-sqr-sqrt1.0%
sqrt-unprod2.9%
sqr-neg2.9%
neg-log1.4%
clear-num1.4%
neg-log1.4%
clear-num1.4%
sqrt-prod0.4%
add-sqr-sqrt1.5%
log-div26.4%
sub-neg26.4%
add-log-exp26.4%
sum-log0.7%
Applied egg-rr54.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.00000000000000021e301Initial program 99.7%
fma-neg99.7%
Simplified99.7%
Final simplification88.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e+301)))
(- (- 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 <= 4e+301)) {
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 <= 4e+301)) {
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 <= 4e+301): 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 <= 4e+301)) 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 <= 4e+301))) 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, 4e+301]], $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 4 \cdot 10^{+301}\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 4.00000000000000021e301 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.7%
Taylor expanded in x around 0 50.0%
log-rec50.0%
sub-neg50.0%
Simplified50.0%
sub-neg50.0%
distribute-rgt-in49.9%
Applied egg-rr49.9%
+-commutative49.9%
distribute-rgt-out50.0%
neg-sub050.0%
associate--r-50.0%
log-div7.0%
neg-sub07.0%
distribute-rgt-neg-out7.0%
distribute-lft-neg-in7.0%
add-sqr-sqrt1.0%
sqrt-unprod2.9%
sqr-neg2.9%
neg-log1.4%
clear-num1.4%
neg-log1.4%
clear-num1.4%
sqrt-prod0.4%
add-sqr-sqrt1.5%
log-div26.4%
sub-neg26.4%
add-log-exp26.4%
sum-log0.7%
Applied egg-rr54.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.00000000000000021e301Initial program 99.7%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e+301))) (- 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 <= 4e+301)) {
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 <= 4e+301)) {
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 <= 4e+301): 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 <= 4e+301)) 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 <= 4e+301))) 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, 4e+301]], $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 4 \cdot 10^{+301}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4.00000000000000021e301 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.7%
Taylor expanded in x around 0 49.6%
mul-1-neg49.6%
Simplified49.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.00000000000000021e301Initial program 99.7%
Final simplification87.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e+301)))
(- (* 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 <= 4e+301)) {
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 <= 4e+301)) {
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 <= 4e+301): 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 <= 4e+301)) 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 <= 4e+301))) 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, 4e+301]], $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 4 \cdot 10^{+301}\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 4.00000000000000021e301 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.7%
Taylor expanded in x around 0 50.0%
log-rec50.0%
sub-neg50.0%
Simplified50.0%
sub-neg50.0%
distribute-rgt-in49.9%
Applied egg-rr49.9%
distribute-rgt-out50.0%
sub-neg50.0%
log-div3.7%
*-commutative3.7%
log-div50.0%
sub-neg50.0%
add-log-exp50.0%
sum-log1.5%
add-sqr-sqrt0.9%
sqrt-unprod27.6%
sqr-neg27.6%
sqrt-unprod26.7%
add-sqr-sqrt27.3%
add-exp-log50.8%
Applied egg-rr50.8%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.00000000000000021e301Initial program 99.7%
Final simplification87.4%
(FPCore (x y z)
:precision binary64
(if (<= x -7.8e+105)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.05e-170)
(- (* x (log (/ x y))) z)
(if (<= x -1e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7.8e+105) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.05e-170) {
tmp = (x * log((x / y))) - z;
} else if (x <= -1e-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 <= (-7.8d+105)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.05d-170)) then
tmp = (x * log((x / y))) - z
else if (x <= (-1d-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 <= -7.8e+105) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.05e-170) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -1e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7.8e+105: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.05e-170: tmp = (x * math.log((x / y))) - z elif x <= -1e-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 <= -7.8e+105) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.05e-170) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -1e-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 <= -7.8e+105) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.05e-170) tmp = (x * log((x / y))) - z; elseif (x <= -1e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7.8e+105], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.05e-170], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-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 -7.8 \cdot 10^{+105}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{-170}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -7.79999999999999957e105Initial program 61.6%
Taylor expanded in y around -inf 99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
distribute-frac-neg299.4%
neg-mul-199.4%
log-rec99.4%
sub-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 83.5%
if -7.79999999999999957e105 < x < -1.05e-170Initial program 94.0%
if -1.05e-170 < x < -1.000000000000002e-309Initial program 62.2%
Taylor expanded in x around 0 92.9%
mul-1-neg92.9%
Simplified92.9%
if -1.000000000000002e-309 < x Initial program 76.4%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
Final simplification94.9%
(FPCore (x y z)
:precision binary64
(if (or (<= x -2e-17)
(and (not (<= x 1.66e-71))
(or (<= x 2.25e-24) (not (<= x 760000000.0)))))
(* x (log (/ x y)))
(- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2e-17) || (!(x <= 1.66e-71) && ((x <= 2.25e-24) || !(x <= 760000000.0)))) {
tmp = x * log((x / y));
} else {
tmp = -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 <= (-2d-17)) .or. (.not. (x <= 1.66d-71)) .and. (x <= 2.25d-24) .or. (.not. (x <= 760000000.0d0))) then
tmp = x * log((x / y))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2e-17) || (!(x <= 1.66e-71) && ((x <= 2.25e-24) || !(x <= 760000000.0)))) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2e-17) or (not (x <= 1.66e-71) and ((x <= 2.25e-24) or not (x <= 760000000.0))): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2e-17) || (!(x <= 1.66e-71) && ((x <= 2.25e-24) || !(x <= 760000000.0)))) tmp = Float64(x * log(Float64(x / y))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2e-17) || (~((x <= 1.66e-71)) && ((x <= 2.25e-24) || ~((x <= 760000000.0))))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2e-17], And[N[Not[LessEqual[x, 1.66e-71]], $MachinePrecision], Or[LessEqual[x, 2.25e-24], N[Not[LessEqual[x, 760000000.0]], $MachinePrecision]]]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-17} \lor \neg \left(x \leq 1.66 \cdot 10^{-71}\right) \land \left(x \leq 2.25 \cdot 10^{-24} \lor \neg \left(x \leq 760000000\right)\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -2.00000000000000014e-17 or 1.6599999999999999e-71 < x < 2.2499999999999999e-24 or 7.6e8 < x Initial program 77.5%
Taylor expanded in z around 0 63.4%
if -2.00000000000000014e-17 < x < 1.6599999999999999e-71 or 2.2499999999999999e-24 < x < 7.6e8Initial program 73.6%
Taylor expanded in x around 0 83.6%
mul-1-neg83.6%
Simplified83.6%
Final simplification72.8%
(FPCore (x y z)
:precision binary64
(if (<= x -1.5e-17)
(* (- x) (log (/ y x)))
(if (or (<= x 1.7e-73) (and (not (<= x 7.5e-24)) (<= x 760000000.0)))
(- z)
(* x (log (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.5e-17) {
tmp = -x * log((y / x));
} else if ((x <= 1.7e-73) || (!(x <= 7.5e-24) && (x <= 760000000.0))) {
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 (x <= (-1.5d-17)) then
tmp = -x * log((y / x))
else if ((x <= 1.7d-73) .or. (.not. (x <= 7.5d-24)) .and. (x <= 760000000.0d0)) 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 (x <= -1.5e-17) {
tmp = -x * Math.log((y / x));
} else if ((x <= 1.7e-73) || (!(x <= 7.5e-24) && (x <= 760000000.0))) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.5e-17: tmp = -x * math.log((y / x)) elif (x <= 1.7e-73) or (not (x <= 7.5e-24) and (x <= 760000000.0)): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.5e-17) tmp = Float64(Float64(-x) * log(Float64(y / x))); elseif ((x <= 1.7e-73) || (!(x <= 7.5e-24) && (x <= 760000000.0))) 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 (x <= -1.5e-17) tmp = -x * log((y / x)); elseif ((x <= 1.7e-73) || (~((x <= 7.5e-24)) && (x <= 760000000.0))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.5e-17], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 1.7e-73], And[N[Not[LessEqual[x, 7.5e-24]], $MachinePrecision], LessEqual[x, 760000000.0]]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-17}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-73} \lor \neg \left(x \leq 7.5 \cdot 10^{-24}\right) \land x \leq 760000000:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -1.50000000000000003e-17Initial program 71.7%
Taylor expanded in z around 0 57.1%
clear-num57.1%
log-div58.7%
metadata-eval58.7%
Applied egg-rr58.7%
neg-sub058.7%
Simplified58.7%
if -1.50000000000000003e-17 < x < 1.7000000000000001e-73 or 7.50000000000000007e-24 < x < 7.6e8Initial program 73.6%
Taylor expanded in x around 0 83.6%
mul-1-neg83.6%
Simplified83.6%
if 1.7000000000000001e-73 < x < 7.50000000000000007e-24 or 7.6e8 < x Initial program 83.7%
Taylor expanded in z around 0 70.1%
Final simplification73.2%
(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.7%
Taylor expanded in x around 0 49.1%
mul-1-neg49.1%
Simplified49.1%
Final simplification49.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 2024079
(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))