
(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 (- (* x (* (log (/ (cbrt x) (cbrt y))) 3.0)) z))
double code(double x, double y, double z) {
return (x * (log((cbrt(x) / cbrt(y))) * 3.0)) - z;
}
public static double code(double x, double y, double z) {
return (x * (Math.log((Math.cbrt(x) / Math.cbrt(y))) * 3.0)) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(log(Float64(cbrt(x) / cbrt(y))) * 3.0)) - z) end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z
\end{array}
Initial program 80.1%
add-cube-cbrt80.1%
log-prod80.0%
pow280.0%
Applied egg-rr80.0%
log-pow80.0%
*-lft-identity80.0%
distribute-rgt-out80.0%
metadata-eval80.0%
Simplified80.0%
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 2e+306) (- t_0 z) (- (* x (log x)) (* 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 <= 2e+306) {
tmp = t_0 - z;
} else {
tmp = (x * log(x)) - (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 <= 2e+306) {
tmp = t_0 - z;
} else {
tmp = (x * Math.log(x)) - (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 <= 2e+306: tmp = t_0 - z else: tmp = (x * math.log(x)) - (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 <= 2e+306) tmp = Float64(t_0 - z); else tmp = Float64(Float64(x * log(x)) - Float64(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 <= 2e+306) tmp = t_0 - z; else tmp = (x * log(x)) - (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, 2e+306], N[(t$95$0 - z), $MachinePrecision], N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * 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 2 \cdot 10^{+306}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log x - x \cdot \log y\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 7.9%
log-div51.6%
sub-neg51.6%
distribute-lft-in51.6%
Applied egg-rr51.6%
distribute-lft-out51.6%
*-commutative51.6%
add-sqr-sqrt0.0%
sqrt-unprod48.5%
sqr-neg48.5%
sqrt-unprod48.5%
add-sqr-sqrt48.5%
log-prod64.0%
Applied egg-rr64.0%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2.00000000000000003e306Initial program 99.3%
if 2.00000000000000003e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.0%
add-cube-cbrt5.0%
log-prod5.0%
pow25.0%
Applied egg-rr5.0%
log-pow5.0%
*-lft-identity5.0%
distribute-rgt-out5.0%
metadata-eval5.0%
Simplified5.0%
Applied egg-rr58.5%
Taylor expanded in z around 0 56.8%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+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 <= 2e+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 <= 2e+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 <= 2e+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 <= 2e+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 <= 2e+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, 2e+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 2 \cdot 10^{+306}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 2.00000000000000003e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.7%
sub-neg6.7%
+-commutative6.7%
neg-sub06.7%
associate-+l-6.7%
sub0-neg6.7%
cancel-sign-sub-inv6.7%
+-commutative6.7%
remove-double-neg6.7%
sub-neg6.7%
distribute-lft-neg-in6.7%
distribute-rgt-neg-in6.7%
log-div54.5%
sub-neg54.5%
distribute-neg-in54.5%
remove-double-neg54.5%
+-commutative54.5%
sub-neg54.5%
log-div8.4%
fma-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 49.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2.00000000000000003e306Initial program 99.3%
Final simplification89.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+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 <= 2e+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 <= 2e+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 <= 2e+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 <= 2e+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 <= 2e+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, 2e+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 2 \cdot 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 2.00000000000000003e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.7%
log-div54.5%
sub-neg54.5%
distribute-lft-in54.5%
Applied egg-rr54.5%
distribute-lft-out54.5%
*-commutative54.5%
add-sqr-sqrt24.4%
sqrt-unprod52.7%
sqr-neg52.7%
sqrt-unprod28.3%
add-sqr-sqrt31.0%
log-prod53.7%
Applied egg-rr53.7%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2.00000000000000003e306Initial program 99.3%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (<= x -1.8e-128) (- (fma x (log (/ y x)) z)) (if (<= x -1e-307) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e-128) {
tmp = -fma(x, log((y / x)), z);
} else if (x <= -1e-307) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.8e-128) tmp = Float64(-fma(x, log(Float64(y / x)), z)); elseif (x <= -1e-307) 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.8e-128], (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] + z), $MachinePrecision]), If[LessEqual[x, -1e-307], (-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.8 \cdot 10^{-128}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-307}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.80000000000000012e-128Initial program 82.6%
sub-neg82.6%
+-commutative82.6%
neg-sub082.6%
associate-+l-82.6%
sub0-neg82.6%
cancel-sign-sub-inv82.6%
+-commutative82.6%
remove-double-neg82.6%
sub-neg82.6%
distribute-lft-neg-in82.6%
distribute-rgt-neg-in82.6%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div83.8%
fma-neg83.8%
remove-double-neg83.8%
Simplified83.8%
if -1.80000000000000012e-128 < x < -9.99999999999999909e-308Initial program 75.5%
sub-neg75.5%
+-commutative75.5%
neg-sub075.5%
associate-+l-75.5%
sub0-neg75.5%
cancel-sign-sub-inv75.5%
+-commutative75.5%
remove-double-neg75.5%
sub-neg75.5%
distribute-lft-neg-in75.5%
distribute-rgt-neg-in75.5%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div68.5%
fma-neg68.5%
remove-double-neg68.5%
Simplified68.5%
Taylor expanded in x around 0 86.3%
if -9.99999999999999909e-308 < x Initial program 79.8%
log-div99.4%
Applied egg-rr99.4%
Final simplification92.7%
(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 80.5%
clear-num78.4%
log-div79.2%
metadata-eval79.2%
frac-2neg79.2%
log-div99.5%
associate--r-99.5%
Applied egg-rr99.5%
+-commutative99.5%
sub0-neg99.5%
sub-neg99.5%
Simplified99.5%
if -3.999999999999988e-310 < y Initial program 79.8%
log-div99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.55e-14) (not (<= z 4.1e-37))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.55e-14) || !(z <= 4.1e-37)) {
tmp = -z;
} else {
tmp = -x * log((y / x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2.55d-14)) .or. (.not. (z <= 4.1d-37))) then
tmp = -z
else
tmp = -x * log((y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.55e-14) || !(z <= 4.1e-37)) {
tmp = -z;
} else {
tmp = -x * Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.55e-14) or not (z <= 4.1e-37): tmp = -z else: tmp = -x * math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.55e-14) || !(z <= 4.1e-37)) tmp = Float64(-z); else tmp = Float64(Float64(-x) * log(Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.55e-14) || ~((z <= 4.1e-37))) tmp = -z; else tmp = -x * log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.55e-14], N[Not[LessEqual[z, 4.1e-37]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.55 \cdot 10^{-14} \lor \neg \left(z \leq 4.1 \cdot 10^{-37}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\end{array}
\end{array}
if z < -2.5499999999999999e-14 or 4.0999999999999998e-37 < z Initial program 79.6%
sub-neg79.6%
+-commutative79.6%
neg-sub079.6%
associate-+l-79.6%
sub0-neg79.6%
cancel-sign-sub-inv79.6%
+-commutative79.6%
remove-double-neg79.6%
sub-neg79.6%
distribute-lft-neg-in79.6%
distribute-rgt-neg-in79.6%
log-div50.7%
sub-neg50.7%
distribute-neg-in50.7%
remove-double-neg50.7%
+-commutative50.7%
sub-neg50.7%
log-div78.3%
fma-neg78.3%
remove-double-neg78.3%
Simplified78.3%
Taylor expanded in x around 0 73.2%
if -2.5499999999999999e-14 < z < 4.0999999999999998e-37Initial program 80.7%
sub-neg80.7%
+-commutative80.7%
neg-sub080.7%
associate-+l-80.7%
sub0-neg80.7%
cancel-sign-sub-inv80.7%
+-commutative80.7%
remove-double-neg80.7%
sub-neg80.7%
distribute-lft-neg-in80.7%
distribute-rgt-neg-in80.7%
log-div59.7%
sub-neg59.7%
distribute-neg-in59.7%
remove-double-neg59.7%
+-commutative59.7%
sub-neg59.7%
log-div80.7%
fma-neg80.7%
remove-double-neg80.7%
Simplified80.7%
Taylor expanded in x around inf 49.3%
distribute-lft-in49.2%
log-rec49.2%
distribute-lft-in49.3%
sub-neg49.3%
log-div72.1%
Simplified72.1%
Final simplification72.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.8e-12) (not (<= z 1.65e-35))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e-12) || !(z <= 1.65e-35)) {
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.8d-12)) .or. (.not. (z <= 1.65d-35))) 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.8e-12) || !(z <= 1.65e-35)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.8e-12) or not (z <= 1.65e-35): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.8e-12) || !(z <= 1.65e-35)) 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.8e-12) || ~((z <= 1.65e-35))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.8e-12], N[Not[LessEqual[z, 1.65e-35]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{-12} \lor \neg \left(z \leq 1.65 \cdot 10^{-35}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.8e-12 or 1.65e-35 < z Initial program 79.6%
sub-neg79.6%
+-commutative79.6%
neg-sub079.6%
associate-+l-79.6%
sub0-neg79.6%
cancel-sign-sub-inv79.6%
+-commutative79.6%
remove-double-neg79.6%
sub-neg79.6%
distribute-lft-neg-in79.6%
distribute-rgt-neg-in79.6%
log-div50.7%
sub-neg50.7%
distribute-neg-in50.7%
remove-double-neg50.7%
+-commutative50.7%
sub-neg50.7%
log-div78.3%
fma-neg78.3%
remove-double-neg78.3%
Simplified78.3%
Taylor expanded in x around 0 73.2%
if -1.8e-12 < z < 1.65e-35Initial program 80.7%
flip--52.7%
clear-num52.7%
*-un-lft-identity52.7%
associate-/l*52.6%
flip--80.4%
fma-neg80.4%
Applied egg-rr80.4%
Taylor expanded in z around 0 72.0%
Final simplification72.7%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 80.1%
sub-neg80.1%
+-commutative80.1%
neg-sub080.1%
associate-+l-80.1%
sub0-neg80.1%
cancel-sign-sub-inv80.1%
+-commutative80.1%
remove-double-neg80.1%
sub-neg80.1%
distribute-lft-neg-in80.1%
distribute-rgt-neg-in80.1%
log-div54.8%
sub-neg54.8%
distribute-neg-in54.8%
remove-double-neg54.8%
+-commutative54.8%
sub-neg54.8%
log-div79.4%
fma-neg79.4%
remove-double-neg79.4%
Simplified79.4%
Taylor expanded in x around 0 47.9%
Final simplification47.9%
(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 2023301
(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))