
(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 78.0%
add-cube-cbrt78.0%
log-prod77.9%
pow277.9%
Applied egg-rr77.9%
log-pow77.9%
distribute-lft1-in77.9%
metadata-eval77.9%
Simplified77.9%
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))
(- z)
(if (<= t_0 INFINITY) (- 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 = -z;
} else if (t_0 <= ((double) INFINITY)) {
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 = -z;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
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 = -z elif t_0 <= math.inf: 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(-z); elseif (t_0 <= Inf) 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 = -z; elseif (t_0 <= Inf) 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)], (-z), If[LessEqual[t$95$0, Infinity], 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:\\
\;\;\;\;-z\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;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 8.1%
remove-double-neg8.1%
sub-neg8.1%
distribute-neg-in8.1%
distribute-rgt-neg-in8.1%
remove-double-neg8.1%
fma-udef8.1%
log-div38.7%
sub-neg38.7%
distribute-neg-in38.7%
remove-double-neg38.7%
+-commutative38.7%
sub-neg38.7%
log-div15.4%
Simplified15.4%
Taylor expanded in x around 0 34.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 87.6%
if +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 78.0%
Taylor expanded in z around 0 40.0%
log-div24.0%
Applied egg-rr24.0%
Final simplification81.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(* x (- (log (- x)) (log (- y))))
(if (<= t_0 INFINITY) (- 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) - log(-y));
} else if (t_0 <= ((double) INFINITY)) {
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) - Math.log(-y));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
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) - math.log(-y)) elif t_0 <= math.inf: 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(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (t_0 <= Inf) 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) - log(-y)); elseif (t_0 <= Inf) 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[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], 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 \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;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 8.1%
Taylor expanded in z around 0 8.1%
frac-2neg8.1%
log-div56.1%
Applied egg-rr56.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 87.6%
if +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 78.0%
Taylor expanded in z around 0 40.0%
log-div24.0%
Applied egg-rr24.0%
Final simplification83.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY))) (- z) (- t_0 z))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= ((double) INFINITY))) {
tmp = -z;
} else {
tmp = t_0 - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= Double.POSITIVE_INFINITY)) {
tmp = -z;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= math.inf): tmp = -z else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= Inf)) tmp = Float64(-z); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= Inf))) tmp = -z; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], (-z), N[(t$95$0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq \infty\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.1%
remove-double-neg8.1%
sub-neg8.1%
distribute-neg-in8.1%
distribute-rgt-neg-in8.1%
remove-double-neg8.1%
fma-udef8.1%
log-div38.7%
sub-neg38.7%
distribute-neg-in38.7%
remove-double-neg38.7%
+-commutative38.7%
sub-neg38.7%
log-div15.4%
Simplified15.4%
Taylor expanded in x around 0 34.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 87.6%
Final simplification81.2%
(FPCore (x y z)
:precision binary64
(if (<= x -2.15e+76)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.85e-167)
(- (* x (log (/ x y))) z)
(if (<= x -5e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e+76) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.85e-167) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-308) {
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 <= (-2.15d+76)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-2.85d-167)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-308)) 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 <= -2.15e+76) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -2.85e-167) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.15e+76: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -2.85e-167: tmp = (x * math.log((x / y))) - z elif x <= -5e-308: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.15e+76) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.85e-167) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-308) 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 <= -2.15e+76) tmp = x * (log(-x) - log(-y)); elseif (x <= -2.85e-167) tmp = (x * log((x / y))) - z; elseif (x <= -5e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.15e+76], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.85e-167], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-308], (-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 -2.15 \cdot 10^{+76}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.85 \cdot 10^{-167}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -2.14999999999999989e76Initial program 67.7%
Taylor expanded in z around 0 65.7%
frac-2neg65.7%
log-div95.5%
Applied egg-rr95.5%
if -2.14999999999999989e76 < x < -2.84999999999999994e-167Initial program 91.3%
if -2.84999999999999994e-167 < x < -4.99999999999999955e-308Initial program 64.8%
remove-double-neg64.8%
sub-neg64.8%
distribute-neg-in64.8%
distribute-rgt-neg-in64.8%
remove-double-neg64.8%
fma-udef64.8%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div64.8%
Simplified64.8%
Taylor expanded in x around 0 88.9%
if -4.99999999999999955e-308 < x Initial program 78.4%
log-div47.6%
Applied egg-rr99.4%
Final simplification95.9%
(FPCore (x y z)
:precision binary64
(if (<= x -8e+109)
(* x (- (log (- x)) (log (- y))))
(if (<= x -9.8e-166)
(- (* x (* 3.0 (log (cbrt (/ x y))))) z)
(if (<= x -1e-311) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8e+109) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -9.8e-166) {
tmp = (x * (3.0 * log(cbrt((x / y))))) - z;
} else if (x <= -1e-311) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (x <= -8e+109) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -9.8e-166) {
tmp = (x * (3.0 * Math.log(Math.cbrt((x / y))))) - z;
} else if (x <= -1e-311) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -8e+109) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -9.8e-166) tmp = Float64(Float64(x * Float64(3.0 * log(cbrt(Float64(x / y))))) - z); elseif (x <= -1e-311) 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, -8e+109], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -9.8e-166], N[(N[(x * N[(3.0 * N[Log[N[Power[N[(x / y), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-311], (-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 -8 \cdot 10^{+109}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -9.8 \cdot 10^{-166}:\\
\;\;\;\;x \cdot \left(3 \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-311}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -7.99999999999999985e109Initial program 65.4%
Taylor expanded in z around 0 65.4%
frac-2neg65.4%
log-div97.3%
Applied egg-rr97.3%
if -7.99999999999999985e109 < x < -9.7999999999999998e-166Initial program 90.5%
add-cube-cbrt90.5%
log-prod90.6%
pow290.6%
Applied egg-rr90.6%
log-pow90.6%
distribute-lft1-in90.6%
metadata-eval90.6%
Simplified90.6%
if -9.7999999999999998e-166 < x < -9.99999999999948e-312Initial program 64.8%
remove-double-neg64.8%
sub-neg64.8%
distribute-neg-in64.8%
distribute-rgt-neg-in64.8%
remove-double-neg64.8%
fma-udef64.8%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div64.8%
Simplified64.8%
Taylor expanded in x around 0 88.9%
if -9.99999999999948e-312 < x Initial program 78.4%
log-div47.6%
Applied egg-rr99.4%
Final simplification95.9%
(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 77.5%
frac-2neg44.3%
log-div58.9%
Applied egg-rr99.4%
if -4.999999999999985e-310 < y Initial program 78.4%
log-div47.6%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.3e+52)
(not
(or (<= x -4.6e-39) (and (not (<= x -9.5e-73)) (<= x 1.32e+84)))))
(* x (log (/ x y)))
(- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.3e+52) || !((x <= -4.6e-39) || (!(x <= -9.5e-73) && (x <= 1.32e+84)))) {
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 <= (-1.3d+52)) .or. (.not. (x <= (-4.6d-39)) .or. (.not. (x <= (-9.5d-73))) .and. (x <= 1.32d+84))) 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 <= -1.3e+52) || !((x <= -4.6e-39) || (!(x <= -9.5e-73) && (x <= 1.32e+84)))) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.3e+52) or not ((x <= -4.6e-39) or (not (x <= -9.5e-73) and (x <= 1.32e+84))): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.3e+52) || !((x <= -4.6e-39) || (!(x <= -9.5e-73) && (x <= 1.32e+84)))) 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 <= -1.3e+52) || ~(((x <= -4.6e-39) || (~((x <= -9.5e-73)) && (x <= 1.32e+84))))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.3e+52], N[Not[Or[LessEqual[x, -4.6e-39], And[N[Not[LessEqual[x, -9.5e-73]], $MachinePrecision], LessEqual[x, 1.32e+84]]]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+52} \lor \neg \left(x \leq -4.6 \cdot 10^{-39} \lor \neg \left(x \leq -9.5 \cdot 10^{-73}\right) \land x \leq 1.32 \cdot 10^{+84}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -1.3e52 or -4.60000000000000016e-39 < x < -9.50000000000000005e-73 or 1.31999999999999994e84 < x Initial program 72.1%
Taylor expanded in z around 0 62.6%
if -1.3e52 < x < -4.60000000000000016e-39 or -9.50000000000000005e-73 < x < 1.31999999999999994e84Initial program 82.5%
remove-double-neg82.5%
sub-neg82.5%
distribute-neg-in82.5%
distribute-rgt-neg-in82.5%
remove-double-neg82.5%
fma-udef82.5%
log-div58.1%
sub-neg58.1%
distribute-neg-in58.1%
remove-double-neg58.1%
+-commutative58.1%
sub-neg58.1%
log-div82.2%
Simplified82.2%
Taylor expanded in x around 0 74.5%
Final simplification69.3%
(FPCore (x y z)
:precision binary64
(if (<= x -1.65e+52)
(* (- x) (log (/ y x)))
(if (or (<= x -5.6e-39) (and (not (<= x -9.5e-73)) (<= x 1.8e+86)))
(- z)
(* x (log (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.65e+52) {
tmp = -x * log((y / x));
} else if ((x <= -5.6e-39) || (!(x <= -9.5e-73) && (x <= 1.8e+86))) {
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.65d+52)) then
tmp = -x * log((y / x))
else if ((x <= (-5.6d-39)) .or. (.not. (x <= (-9.5d-73))) .and. (x <= 1.8d+86)) 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.65e+52) {
tmp = -x * Math.log((y / x));
} else if ((x <= -5.6e-39) || (!(x <= -9.5e-73) && (x <= 1.8e+86))) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.65e+52: tmp = -x * math.log((y / x)) elif (x <= -5.6e-39) or (not (x <= -9.5e-73) and (x <= 1.8e+86)): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.65e+52) tmp = Float64(Float64(-x) * log(Float64(y / x))); elseif ((x <= -5.6e-39) || (!(x <= -9.5e-73) && (x <= 1.8e+86))) 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.65e+52) tmp = -x * log((y / x)); elseif ((x <= -5.6e-39) || (~((x <= -9.5e-73)) && (x <= 1.8e+86))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.65e+52], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -5.6e-39], And[N[Not[LessEqual[x, -9.5e-73]], $MachinePrecision], LessEqual[x, 1.8e+86]]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{+52}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-39} \lor \neg \left(x \leq -9.5 \cdot 10^{-73}\right) \land x \leq 1.8 \cdot 10^{+86}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -1.65e52Initial program 73.2%
remove-double-neg73.2%
sub-neg73.2%
distribute-neg-in73.2%
distribute-rgt-neg-in73.2%
remove-double-neg73.2%
fma-udef73.2%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div75.3%
Simplified75.3%
Taylor expanded in x around inf 0.0%
log-rec0.0%
neg-mul-10.0%
neg-mul-10.0%
sub-neg0.0%
log-div67.6%
Simplified67.6%
if -1.65e52 < x < -5.6000000000000003e-39 or -9.50000000000000005e-73 < x < 1.80000000000000003e86Initial program 82.5%
remove-double-neg82.5%
sub-neg82.5%
distribute-neg-in82.5%
distribute-rgt-neg-in82.5%
remove-double-neg82.5%
fma-udef82.5%
log-div58.1%
sub-neg58.1%
distribute-neg-in58.1%
remove-double-neg58.1%
+-commutative58.1%
sub-neg58.1%
log-div82.2%
Simplified82.2%
Taylor expanded in x around 0 74.5%
if -5.6000000000000003e-39 < x < -9.50000000000000005e-73 or 1.80000000000000003e86 < x Initial program 71.0%
Taylor expanded in z around 0 59.3%
Final simplification69.8%
(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 78.0%
remove-double-neg78.0%
sub-neg78.0%
distribute-neg-in78.0%
distribute-rgt-neg-in78.0%
remove-double-neg78.0%
fma-udef78.0%
log-div50.1%
sub-neg50.1%
distribute-neg-in50.1%
remove-double-neg50.1%
+-commutative50.1%
sub-neg50.1%
log-div78.0%
Simplified78.0%
Taylor expanded in x around 0 47.7%
Final simplification47.7%
(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 2023322
(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))