
(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 11 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 76.7%
add-cube-cbrt76.6%
log-prod76.6%
pow276.6%
Applied egg-rr76.6%
log-pow76.6%
distribute-lft1-in76.6%
metadata-eval76.6%
Simplified76.6%
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 2e+291) (- 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 <= 2e+291) {
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 <= 2e+291) {
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 <= 2e+291: 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 <= 2e+291) 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 <= 2e+291) 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, 2e+291], 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 2 \cdot 10^{+291}:\\
\;\;\;\;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 3.7%
remove-double-neg3.7%
sub-neg3.7%
distribute-neg-in3.7%
distribute-rgt-neg-in3.7%
remove-double-neg3.7%
fma-udef3.7%
log-div57.8%
sub-neg57.8%
distribute-neg-in57.8%
remove-double-neg57.8%
+-commutative57.8%
sub-neg57.8%
log-div6.9%
Simplified6.9%
Taylor expanded in x around 0 55.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.9999999999999999e291Initial program 99.8%
if 1.9999999999999999e291 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 12.3%
remove-double-neg12.3%
sub-neg12.3%
distribute-neg-in12.3%
distribute-rgt-neg-in12.3%
remove-double-neg12.3%
fma-udef12.3%
log-div57.5%
sub-neg57.5%
distribute-neg-in57.5%
remove-double-neg57.5%
+-commutative57.5%
sub-neg57.5%
log-div17.1%
Simplified17.1%
Taylor expanded in x around inf 52.6%
log-rec52.6%
neg-mul-152.6%
neg-mul-152.6%
sub-neg52.6%
log-div13.3%
Simplified13.3%
log-div52.6%
Applied egg-rr52.6%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+291))) (- 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+291)) {
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+291)) {
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+291): 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+291)) 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+291))) 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+291]], $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^{+291}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.9999999999999999e291 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.2%
remove-double-neg7.2%
sub-neg7.2%
distribute-neg-in7.2%
distribute-rgt-neg-in7.2%
remove-double-neg7.2%
fma-udef7.2%
log-div57.7%
sub-neg57.7%
distribute-neg-in57.7%
remove-double-neg57.7%
+-commutative57.7%
sub-neg57.7%
log-div11.1%
Simplified11.1%
Taylor expanded in x around 0 48.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.9999999999999999e291Initial program 99.8%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (<= x -5e-312) (- (* x (- (log (- x)) (log (- y)))) z) (- (fma x (- (log y) (log x)) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5e-312) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = -fma(x, (log(y) - log(x)), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -5e-312) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(-fma(x, Float64(log(y) - log(x)), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -5e-312], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-N[(x * N[(N[Log[y], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-312}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log y - \log x, z\right)\\
\end{array}
\end{array}
if x < -5.0000000000022e-312Initial program 77.0%
frac-2neg77.0%
log-div99.4%
Applied egg-rr99.4%
if -5.0000000000022e-312 < x Initial program 76.4%
remove-double-neg76.4%
sub-neg76.4%
distribute-neg-in76.4%
distribute-rgt-neg-in76.4%
remove-double-neg76.4%
fma-udef76.4%
log-div99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
log-div76.6%
Simplified76.6%
log-div42.8%
Applied egg-rr99.7%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(if (<= x -2.25e+179)
(* x (- (log (- x)) (log (- y))))
(if (<= x -5e-312)
(- (fma x (log (/ y x)) z))
(- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.25e+179) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -5e-312) {
tmp = -fma(x, log((y / x)), z);
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.25e+179) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -5e-312) tmp = Float64(-fma(x, log(Float64(y / x)), z)); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2.25e+179], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-312], (-N[(x * N[Log[N[(y / x), $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}\;x \leq -2.25 \cdot 10^{+179}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-312}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -2.2500000000000001e179Initial program 61.5%
remove-double-neg61.5%
sub-neg61.5%
distribute-neg-in61.5%
distribute-rgt-neg-in61.5%
remove-double-neg61.5%
fma-udef61.5%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div67.0%
Simplified67.0%
Taylor expanded in x around inf 0.0%
log-rec0.0%
neg-mul-10.0%
neg-mul-10.0%
sub-neg0.0%
log-div57.1%
Simplified57.1%
frac-2neg57.1%
log-div88.0%
Applied egg-rr88.0%
if -2.2500000000000001e179 < x < -5.0000000000022e-312Initial program 80.7%
remove-double-neg80.7%
sub-neg80.7%
distribute-neg-in80.7%
distribute-rgt-neg-in80.7%
remove-double-neg80.7%
fma-udef80.8%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div80.8%
Simplified80.8%
if -5.0000000000022e-312 < x Initial program 76.4%
log-div99.7%
Applied egg-rr99.7%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (<= x -5e-312) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= -5e-312) {
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 (x <= (-5d-312)) 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 (x <= -5e-312) {
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 x <= -5e-312: 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 (x <= -5e-312) 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 (x <= -5e-312) 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[x, -5e-312], 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}\;x \leq -5 \cdot 10^{-312}:\\
\;\;\;\;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 x < -5.0000000000022e-312Initial program 77.0%
frac-2neg77.0%
log-div99.4%
Applied egg-rr99.4%
if -5.0000000000022e-312 < x Initial program 76.4%
log-div99.7%
Applied egg-rr99.7%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (<= y 4.8e-299) (- (fma x (log (/ y x)) z)) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e-299) {
tmp = -fma(x, log((y / x)), z);
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 4.8e-299) tmp = Float64(-fma(x, log(Float64(y / x)), z)); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 4.8e-299], (-N[(x * N[Log[N[(y / x), $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.8 \cdot 10^{-299}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < 4.80000000000000039e-299Initial program 77.2%
remove-double-neg77.2%
sub-neg77.2%
distribute-neg-in77.2%
distribute-rgt-neg-in77.2%
remove-double-neg77.2%
fma-udef77.2%
log-div0.9%
sub-neg0.9%
distribute-neg-in0.9%
remove-double-neg0.9%
+-commutative0.9%
sub-neg0.9%
log-div78.3%
Simplified78.3%
if 4.80000000000000039e-299 < y Initial program 76.2%
log-div99.7%
Applied egg-rr99.7%
Final simplification90.2%
(FPCore (x y z)
:precision binary64
(if (or (<= z -5.3e+58)
(and (not (<= z -1.66e+16)) (or (<= z -4.8e-69) (not (<= z 1e-12)))))
(- z)
(* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.3e+58) || (!(z <= -1.66e+16) && ((z <= -4.8e-69) || !(z <= 1e-12)))) {
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 <= (-5.3d+58)) .or. (.not. (z <= (-1.66d+16))) .and. (z <= (-4.8d-69)) .or. (.not. (z <= 1d-12))) 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 <= -5.3e+58) || (!(z <= -1.66e+16) && ((z <= -4.8e-69) || !(z <= 1e-12)))) {
tmp = -z;
} else {
tmp = -x * Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.3e+58) or (not (z <= -1.66e+16) and ((z <= -4.8e-69) or not (z <= 1e-12))): tmp = -z else: tmp = -x * math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.3e+58) || (!(z <= -1.66e+16) && ((z <= -4.8e-69) || !(z <= 1e-12)))) 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 <= -5.3e+58) || (~((z <= -1.66e+16)) && ((z <= -4.8e-69) || ~((z <= 1e-12))))) tmp = -z; else tmp = -x * log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.3e+58], And[N[Not[LessEqual[z, -1.66e+16]], $MachinePrecision], Or[LessEqual[z, -4.8e-69], N[Not[LessEqual[z, 1e-12]], $MachinePrecision]]]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.3 \cdot 10^{+58} \lor \neg \left(z \leq -1.66 \cdot 10^{+16}\right) \land \left(z \leq -4.8 \cdot 10^{-69} \lor \neg \left(z \leq 10^{-12}\right)\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\end{array}
\end{array}
if z < -5.3000000000000006e58 or -1.66e16 < z < -4.8000000000000002e-69 or 9.9999999999999998e-13 < z Initial program 81.0%
remove-double-neg81.0%
sub-neg81.0%
distribute-neg-in81.0%
distribute-rgt-neg-in81.0%
remove-double-neg81.0%
fma-udef81.1%
log-div59.8%
sub-neg59.8%
distribute-neg-in59.8%
remove-double-neg59.8%
+-commutative59.8%
sub-neg59.8%
log-div81.2%
Simplified81.2%
Taylor expanded in x around 0 80.8%
if -5.3000000000000006e58 < z < -1.66e16 or -4.8000000000000002e-69 < z < 9.9999999999999998e-13Initial program 71.2%
remove-double-neg71.2%
sub-neg71.2%
distribute-neg-in71.2%
distribute-rgt-neg-in71.2%
remove-double-neg71.2%
fma-udef71.2%
log-div50.6%
sub-neg50.6%
distribute-neg-in50.6%
remove-double-neg50.6%
+-commutative50.6%
sub-neg50.6%
log-div72.3%
Simplified72.3%
Taylor expanded in x around inf 41.6%
log-rec41.6%
neg-mul-141.6%
neg-mul-141.6%
sub-neg41.6%
log-div64.5%
Simplified64.5%
Final simplification73.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.75e-71) (not (<= z 3.2e-14))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.75e-71) || !(z <= 3.2e-14)) {
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.75d-71)) .or. (.not. (z <= 3.2d-14))) 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.75e-71) || !(z <= 3.2e-14)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.75e-71) or not (z <= 3.2e-14): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.75e-71) || !(z <= 3.2e-14)) 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.75e-71) || ~((z <= 3.2e-14))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.75e-71], N[Not[LessEqual[z, 3.2e-14]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{-71} \lor \neg \left(z \leq 3.2 \cdot 10^{-14}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.75e-71 or 3.2000000000000002e-14 < z Initial program 78.9%
remove-double-neg78.9%
sub-neg78.9%
distribute-neg-in78.9%
distribute-rgt-neg-in78.9%
remove-double-neg78.9%
fma-udef78.9%
log-div58.0%
sub-neg58.0%
distribute-neg-in58.0%
remove-double-neg58.0%
+-commutative58.0%
sub-neg58.0%
log-div79.9%
Simplified79.9%
Taylor expanded in x around 0 76.6%
if -1.75e-71 < z < 3.2000000000000002e-14Initial program 73.4%
Taylor expanded in z around 0 65.0%
Final simplification71.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 76.7%
remove-double-neg76.7%
sub-neg76.7%
distribute-neg-in76.7%
distribute-rgt-neg-in76.7%
remove-double-neg76.7%
fma-udef76.7%
log-div55.7%
sub-neg55.7%
distribute-neg-in55.7%
remove-double-neg55.7%
+-commutative55.7%
sub-neg55.7%
log-div77.2%
Simplified77.2%
Taylor expanded in x around 0 52.7%
Final simplification52.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 z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 76.7%
clear-num76.3%
log-rec77.2%
Applied egg-rr77.2%
fma-neg77.2%
neg-log76.3%
clear-num76.7%
add-cube-cbrt76.6%
pow376.6%
exp-to-pow76.6%
add-log-exp76.6%
*-commutative76.6%
fma-def76.6%
associate-*r*76.6%
add-sqr-sqrt37.4%
sqrt-unprod44.6%
sqr-neg44.6%
sqrt-unprod20.6%
add-sqr-sqrt35.8%
fma-def35.8%
Applied egg-rr35.8%
Taylor expanded in x around 0 2.2%
Final simplification2.2%
(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 2024019
(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))