
(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 10 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 (* 3.0 (log (/ (cbrt x) (cbrt y))))) z))
double code(double x, double y, double z) {
return (x * (3.0 * log((cbrt(x) / cbrt(y))))) - z;
}
public static double code(double x, double y, double z) {
return (x * (3.0 * Math.log((Math.cbrt(x) / Math.cbrt(y))))) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(3.0 * log(Float64(cbrt(x) / cbrt(y))))) - z) end
code[x_, y_, z_] := N[(N[(x * N[(3.0 * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(3 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z
\end{array}
Initial program 74.5%
add-cube-cbrt74.5%
log-prod74.5%
pow274.5%
Applied egg-rr74.5%
log-pow74.5%
distribute-lft1-in74.5%
metadata-eval74.5%
Simplified74.5%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- (* x (log (* x y))) z)
(if (<= t_0 4e+273) (- 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+273) {
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+273) {
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+273: 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+273) 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+273) 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+273], 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^{+273}:\\
\;\;\;\;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.8%
add-cube-cbrt4.8%
log-prod4.8%
pow24.8%
Applied egg-rr4.8%
log-pow4.8%
distribute-lft1-in4.8%
metadata-eval4.8%
Simplified4.8%
*-commutative4.8%
add-log-exp4.8%
exp-to-pow4.8%
pow34.8%
add-cube-cbrt4.8%
frac-2neg4.8%
diff-log56.9%
sub-neg56.9%
distribute-rgt-in56.9%
add-sqr-sqrt56.9%
sqrt-unprod19.8%
sqr-neg19.8%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr42.9%
distribute-rgt-out42.9%
sub-neg42.9%
log-div4.8%
*-commutative4.8%
log-div42.9%
sub-neg42.9%
add-log-exp42.9%
sum-log1.3%
add-sqr-sqrt0.0%
sqrt-unprod39.6%
sqr-neg39.6%
sqrt-unprod39.6%
add-sqr-sqrt39.6%
add-exp-log58.9%
Applied egg-rr58.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 3.99999999999999978e273Initial program 99.6%
if 3.99999999999999978e273 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 15.6%
Taylor expanded in z around 0 15.6%
log-div55.4%
Applied egg-rr55.4%
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+306))) (- 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+306)) {
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+306)) {
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+306): 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+306)) 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+306))) 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+306]], $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^{+306}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.00000000000000002e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.5%
remove-double-neg6.5%
sub-neg6.5%
distribute-neg-in6.5%
sub-neg6.5%
distribute-rgt-neg-in6.5%
fma-neg6.5%
log-div56.5%
sub-neg56.5%
distribute-neg-in56.5%
remove-double-neg56.5%
+-commutative56.5%
sub-neg56.5%
log-div13.5%
remove-double-neg13.5%
Simplified13.5%
Taylor expanded in x around 0 46.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000002e306Initial program 99.6%
Final simplification85.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+306)))
(- (* 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+306)) {
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+306)) {
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+306): 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+306)) 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+306))) 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+306]], $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^{+306}\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.00000000000000002e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.5%
add-cube-cbrt6.5%
log-prod6.5%
pow26.5%
Applied egg-rr6.5%
log-pow6.5%
distribute-lft1-in6.5%
metadata-eval6.5%
Simplified6.5%
*-commutative6.5%
add-log-exp6.5%
exp-to-pow6.5%
pow36.5%
add-cube-cbrt6.5%
frac-2neg6.5%
diff-log43.3%
sub-neg43.3%
distribute-rgt-in43.3%
add-sqr-sqrt43.3%
sqrt-unprod17.5%
sqr-neg17.5%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr56.5%
distribute-rgt-out56.5%
sub-neg56.5%
log-div6.5%
*-commutative6.5%
log-div56.5%
sub-neg56.5%
add-log-exp56.5%
sum-log4.2%
add-sqr-sqrt3.6%
sqrt-unprod23.6%
sqr-neg23.6%
sqrt-unprod20.1%
add-sqr-sqrt32.3%
add-exp-log50.9%
Applied egg-rr50.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000002e306Initial program 99.6%
Final simplification86.5%
(FPCore (x y z)
:precision binary64
(if (<= x -1.5e+215)
(* x (- (log (- x)) (log (- y))))
(if (<= x -9e-175)
(- (fma x (log (/ y x)) z))
(if (<= x -5e-310) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.5e+215) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -9e-175) {
tmp = -fma(x, log((y / x)), z);
} else if (x <= -5e-310) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.5e+215) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -9e-175) tmp = Float64(-fma(x, log(Float64(y / x)), z)); elseif (x <= -5e-310) tmp = Float64(-z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.5e+215], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -9e-175], (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] + z), $MachinePrecision]), If[LessEqual[x, -5e-310], (-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.5 \cdot 10^{+215}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-175}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.5e215Initial program 58.9%
Taylor expanded in z around 0 52.1%
frac-2neg52.1%
log-div88.4%
Applied egg-rr88.4%
if -1.5e215 < x < -8.99999999999999996e-175Initial program 84.6%
remove-double-neg84.6%
sub-neg84.6%
distribute-neg-in84.6%
sub-neg84.6%
distribute-rgt-neg-in84.6%
fma-neg84.6%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div87.3%
remove-double-neg87.3%
Simplified87.3%
if -8.99999999999999996e-175 < x < -4.999999999999985e-310Initial program 78.2%
remove-double-neg78.2%
sub-neg78.2%
distribute-neg-in78.2%
sub-neg78.2%
distribute-rgt-neg-in78.2%
fma-neg78.2%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div78.2%
remove-double-neg78.2%
Simplified78.2%
Taylor expanded in x around 0 98.6%
if -4.999999999999985e-310 < x Initial program 70.4%
log-div45.5%
Applied egg-rr99.6%
Final simplification94.4%
(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 78.3%
frac-2neg42.0%
log-div55.1%
Applied egg-rr99.4%
if -1.999999999999994e-310 < y Initial program 70.4%
log-div45.5%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(if (or (<= z -3.6e-25)
(not
(or (<= z -3.9e-97) (and (not (<= z -2.2e-126)) (<= z 2.6e-34)))))
(- z)
(* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.6e-25) || !((z <= -3.9e-97) || (!(z <= -2.2e-126) && (z <= 2.6e-34)))) {
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 <= (-3.6d-25)) .or. (.not. (z <= (-3.9d-97)) .or. (.not. (z <= (-2.2d-126))) .and. (z <= 2.6d-34))) 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 <= -3.6e-25) || !((z <= -3.9e-97) || (!(z <= -2.2e-126) && (z <= 2.6e-34)))) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.6e-25) or not ((z <= -3.9e-97) or (not (z <= -2.2e-126) and (z <= 2.6e-34))): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.6e-25) || !((z <= -3.9e-97) || (!(z <= -2.2e-126) && (z <= 2.6e-34)))) 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 <= -3.6e-25) || ~(((z <= -3.9e-97) || (~((z <= -2.2e-126)) && (z <= 2.6e-34))))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.6e-25], N[Not[Or[LessEqual[z, -3.9e-97], And[N[Not[LessEqual[z, -2.2e-126]], $MachinePrecision], LessEqual[z, 2.6e-34]]]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{-25} \lor \neg \left(z \leq -3.9 \cdot 10^{-97} \lor \neg \left(z \leq -2.2 \cdot 10^{-126}\right) \land z \leq 2.6 \cdot 10^{-34}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -3.5999999999999999e-25 or -3.8999999999999998e-97 < z < -2.20000000000000014e-126 or 2.5999999999999999e-34 < z Initial program 69.5%
remove-double-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
sub-neg69.5%
distribute-rgt-neg-in69.5%
fma-neg69.5%
log-div52.3%
sub-neg52.3%
distribute-neg-in52.3%
remove-double-neg52.3%
+-commutative52.3%
sub-neg52.3%
log-div72.7%
remove-double-neg72.7%
Simplified72.7%
Taylor expanded in x around 0 74.2%
if -3.5999999999999999e-25 < z < -3.8999999999999998e-97 or -2.20000000000000014e-126 < z < 2.5999999999999999e-34Initial program 80.6%
Taylor expanded in z around 0 65.1%
Final simplification70.1%
(FPCore (x y z)
:precision binary64
(if (<= z -2e-24)
(- z)
(if (<= z -4e-97)
(* (- x) (log (/ y x)))
(if (or (<= z -1.12e-125) (not (<= z 9.5e-28)))
(- z)
(* x (log (/ x y)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e-24) {
tmp = -z;
} else if (z <= -4e-97) {
tmp = -x * log((y / x));
} else if ((z <= -1.12e-125) || !(z <= 9.5e-28)) {
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 <= (-2d-24)) then
tmp = -z
else if (z <= (-4d-97)) then
tmp = -x * log((y / x))
else if ((z <= (-1.12d-125)) .or. (.not. (z <= 9.5d-28))) 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 <= -2e-24) {
tmp = -z;
} else if (z <= -4e-97) {
tmp = -x * Math.log((y / x));
} else if ((z <= -1.12e-125) || !(z <= 9.5e-28)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e-24: tmp = -z elif z <= -4e-97: tmp = -x * math.log((y / x)) elif (z <= -1.12e-125) or not (z <= 9.5e-28): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e-24) tmp = Float64(-z); elseif (z <= -4e-97) tmp = Float64(Float64(-x) * log(Float64(y / x))); elseif ((z <= -1.12e-125) || !(z <= 9.5e-28)) 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 <= -2e-24) tmp = -z; elseif (z <= -4e-97) tmp = -x * log((y / x)); elseif ((z <= -1.12e-125) || ~((z <= 9.5e-28))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e-24], (-z), If[LessEqual[z, -4e-97], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -1.12e-125], N[Not[LessEqual[z, 9.5e-28]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-24}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -4 \cdot 10^{-97}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;z \leq -1.12 \cdot 10^{-125} \lor \neg \left(z \leq 9.5 \cdot 10^{-28}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.99999999999999985e-24 or -4.00000000000000014e-97 < z < -1.11999999999999997e-125 or 9.50000000000000001e-28 < z Initial program 69.5%
remove-double-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
sub-neg69.5%
distribute-rgt-neg-in69.5%
fma-neg69.5%
log-div52.3%
sub-neg52.3%
distribute-neg-in52.3%
remove-double-neg52.3%
+-commutative52.3%
sub-neg52.3%
log-div72.7%
remove-double-neg72.7%
Simplified72.7%
Taylor expanded in x around 0 74.2%
if -1.99999999999999985e-24 < z < -4.00000000000000014e-97Initial program 90.9%
remove-double-neg90.9%
sub-neg90.9%
distribute-neg-in90.9%
sub-neg90.9%
distribute-rgt-neg-in90.9%
fma-neg90.9%
log-div27.1%
sub-neg27.1%
distribute-neg-in27.1%
remove-double-neg27.1%
+-commutative27.1%
sub-neg27.1%
log-div94.2%
remove-double-neg94.2%
Simplified94.2%
Taylor expanded in x around inf 18.3%
log-rec18.3%
sub-neg18.3%
log-div85.2%
Simplified85.2%
if -1.11999999999999997e-125 < z < 9.50000000000000001e-28Initial program 79.5%
Taylor expanded in z around 0 63.3%
Final simplification70.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 74.5%
remove-double-neg74.5%
sub-neg74.5%
distribute-neg-in74.5%
sub-neg74.5%
distribute-rgt-neg-in74.5%
fma-neg74.5%
log-div48.3%
sub-neg48.3%
distribute-neg-in48.3%
remove-double-neg48.3%
+-commutative48.3%
sub-neg48.3%
log-div75.7%
remove-double-neg75.7%
Simplified75.7%
Taylor expanded in x around 0 49.6%
Final simplification49.6%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 74.5%
add-cube-cbrt74.5%
log-prod74.5%
pow274.5%
Applied egg-rr74.5%
log-pow74.5%
distribute-lft1-in74.5%
metadata-eval74.5%
Simplified74.5%
fma-neg74.4%
*-commutative74.4%
add-log-exp74.4%
exp-to-pow74.5%
pow374.5%
add-cube-cbrt74.5%
fma-neg74.5%
rem-cube-cbrt73.0%
sqr-pow33.0%
pow-prod-down33.5%
Applied egg-rr9.5%
log-pow21.2%
Simplified21.2%
Taylor expanded in x around 0 2.1%
Final simplification2.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 2024039
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))