
(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 (* 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 73.9%
add-cube-cbrt73.9%
log-prod73.9%
pow273.9%
Applied egg-rr73.9%
log-pow73.9%
distribute-lft1-in73.9%
metadata-eval73.9%
Simplified73.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 (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+294)))
(- z)
(- (fma x (log (/ y x)) 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 <= 5e+294)) {
tmp = -z;
} else {
tmp = -fma(x, log((y / x)), 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 <= 5e+294)) tmp = Float64(-z); else tmp = Float64(-fma(x, log(Float64(y / x)), z)); end return 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, 5e+294]], $MachinePrecision]], (-z), (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] + 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 5 \cdot 10^{+294}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4.9999999999999999e294 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.6%
remove-double-neg6.6%
sub0-neg6.6%
associate--r-6.6%
neg-sub06.6%
distribute-rgt-neg-in6.6%
neg-sub06.6%
log-div43.6%
associate-+l-43.6%
neg-sub043.6%
+-commutative43.6%
sub-neg43.6%
log-div12.0%
fma-udef12.0%
Simplified12.0%
Taylor expanded in x around 0 45.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.9999999999999999e294Initial program 99.8%
remove-double-neg99.8%
sub0-neg99.8%
associate--r-99.8%
neg-sub099.8%
distribute-rgt-neg-in99.8%
neg-sub099.8%
log-div45.7%
associate-+l-45.7%
neg-sub045.7%
+-commutative45.7%
sub-neg45.7%
log-div99.8%
fma-udef99.8%
Simplified99.8%
Final simplification84.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+294))) (- 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 <= 5e+294)) {
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 <= 5e+294)) {
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 <= 5e+294): 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 <= 5e+294)) 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 <= 5e+294))) 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, 5e+294]], $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 5 \cdot 10^{+294}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4.9999999999999999e294 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.6%
remove-double-neg6.6%
sub0-neg6.6%
associate--r-6.6%
neg-sub06.6%
distribute-rgt-neg-in6.6%
neg-sub06.6%
log-div43.6%
associate-+l-43.6%
neg-sub043.6%
+-commutative43.6%
sub-neg43.6%
log-div12.0%
fma-udef12.0%
Simplified12.0%
Taylor expanded in x around 0 45.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.9999999999999999e294Initial program 99.8%
Final simplification84.7%
(FPCore (x y z)
:precision binary64
(if (<= x -9e+184)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.1e-209)
(- (fma x (log (/ y x)) z))
(if (<= x 5.2e-210)
(- z)
(if (<= x 8.2e+176)
(- (* x (log (/ x y))) z)
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9e+184) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.1e-209) {
tmp = -fma(x, log((y / x)), z);
} else if (x <= 5.2e-210) {
tmp = -z;
} else if (x <= 8.2e+176) {
tmp = (x * log((x / y))) - z;
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -9e+184) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.1e-209) tmp = Float64(-fma(x, log(Float64(y / x)), z)); elseif (x <= 5.2e-210) tmp = Float64(-z); elseif (x <= 8.2e+176) tmp = Float64(Float64(x * log(Float64(x / y))) - z); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -9e+184], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.1e-209], (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] + z), $MachinePrecision]), If[LessEqual[x, 5.2e-210], (-z), If[LessEqual[x, 8.2e+176], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+184}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-209}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-210}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+176}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -9.00000000000000072e184Initial program 53.6%
Taylor expanded in z around 0 53.6%
frac-2neg53.6%
log-div90.3%
Applied egg-rr90.3%
if -9.00000000000000072e184 < x < -2.09999999999999996e-209Initial program 82.1%
remove-double-neg82.1%
sub0-neg82.1%
associate--r-82.1%
neg-sub082.1%
distribute-rgt-neg-in82.1%
neg-sub082.1%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div85.2%
fma-udef85.2%
Simplified85.2%
if -2.09999999999999996e-209 < x < 5.1999999999999997e-210Initial program 44.4%
remove-double-neg44.4%
sub0-neg44.4%
associate--r-44.4%
neg-sub044.4%
distribute-rgt-neg-in44.4%
neg-sub044.4%
log-div40.5%
associate-+l-40.5%
neg-sub040.5%
+-commutative40.5%
sub-neg40.5%
log-div44.4%
fma-udef44.4%
Simplified44.4%
Taylor expanded in x around 0 91.3%
if 5.1999999999999997e-210 < x < 8.1999999999999998e176Initial program 89.6%
if 8.1999999999999998e176 < x Initial program 60.0%
Taylor expanded in z around 0 52.6%
log-div91.7%
Applied egg-rr91.7%
Final simplification88.5%
(FPCore (x y z)
:precision binary64
(if (<= x -9e+180)
(* x (- (log (- x)) (log (- y))))
(if (<= x -4.5e-212)
(- (fma x (log (/ y x)) z))
(if (<= x -2e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9e+180) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -4.5e-212) {
tmp = -fma(x, log((y / x)), z);
} else if (x <= -2e-308) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -9e+180) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -4.5e-212) tmp = Float64(-fma(x, log(Float64(y / x)), z)); elseif (x <= -2e-308) 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, -9e+180], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.5e-212], (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] + z), $MachinePrecision]), If[LessEqual[x, -2e-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 -9 \cdot 10^{+180}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-212}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -8.99999999999999962e180Initial program 53.6%
Taylor expanded in z around 0 53.6%
frac-2neg53.6%
log-div90.3%
Applied egg-rr90.3%
if -8.99999999999999962e180 < x < -4.4999999999999999e-212Initial program 82.1%
remove-double-neg82.1%
sub0-neg82.1%
associate--r-82.1%
neg-sub082.1%
distribute-rgt-neg-in82.1%
neg-sub082.1%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div85.2%
fma-udef85.2%
Simplified85.2%
if -4.4999999999999999e-212 < x < -1.9999999999999998e-308Initial program 55.1%
remove-double-neg55.1%
sub0-neg55.1%
associate--r-55.1%
neg-sub055.1%
distribute-rgt-neg-in55.1%
neg-sub055.1%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div55.1%
fma-udef55.1%
Simplified55.1%
Taylor expanded in x around 0 89.5%
if -1.9999999999999998e-308 < x Initial program 75.1%
log-div46.9%
Applied egg-rr99.6%
Final simplification92.6%
(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 73.0%
frac-2neg39.1%
log-div52.2%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 75.1%
log-div46.9%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -650000000000.0) (not (<= z 125000.0))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -650000000000.0) || !(z <= 125000.0)) {
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 <= (-650000000000.0d0)) .or. (.not. (z <= 125000.0d0))) 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 <= -650000000000.0) || !(z <= 125000.0)) {
tmp = -z;
} else {
tmp = -x * Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -650000000000.0) or not (z <= 125000.0): tmp = -z else: tmp = -x * math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -650000000000.0) || !(z <= 125000.0)) 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 <= -650000000000.0) || ~((z <= 125000.0))) tmp = -z; else tmp = -x * log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -650000000000.0], N[Not[LessEqual[z, 125000.0]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -650000000000 \lor \neg \left(z \leq 125000\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\end{array}
\end{array}
if z < -6.5e11 or 125000 < z Initial program 74.9%
remove-double-neg74.9%
sub0-neg74.9%
associate--r-74.9%
neg-sub074.9%
distribute-rgt-neg-in74.9%
neg-sub074.9%
log-div47.6%
associate-+l-47.6%
neg-sub047.6%
+-commutative47.6%
sub-neg47.6%
log-div75.7%
fma-udef75.7%
Simplified75.7%
Taylor expanded in x around 0 78.0%
if -6.5e11 < z < 125000Initial program 72.9%
remove-double-neg72.9%
sub0-neg72.9%
associate--r-72.9%
neg-sub072.9%
distribute-rgt-neg-in72.9%
neg-sub072.9%
log-div42.5%
associate-+l-42.5%
neg-sub042.5%
+-commutative42.5%
sub-neg42.5%
log-div75.2%
fma-udef75.2%
Simplified75.2%
Taylor expanded in x around inf 33.7%
log-rec33.7%
neg-mul-133.7%
neg-mul-133.7%
sub-neg33.7%
log-div63.9%
Simplified63.9%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1650000000.0) (not (<= z 47000000.0))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1650000000.0) || !(z <= 47000000.0)) {
tmp = -z;
} else {
tmp = x * log((x / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1650000000.0d0)) .or. (.not. (z <= 47000000.0d0))) then
tmp = -z
else
tmp = x * log((x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1650000000.0) || !(z <= 47000000.0)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1650000000.0) or not (z <= 47000000.0): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1650000000.0) || !(z <= 47000000.0)) tmp = Float64(-z); else tmp = Float64(x * log(Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1650000000.0) || ~((z <= 47000000.0))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1650000000.0], N[Not[LessEqual[z, 47000000.0]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1650000000 \lor \neg \left(z \leq 47000000\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.65e9 or 4.7e7 < z Initial program 74.9%
remove-double-neg74.9%
sub0-neg74.9%
associate--r-74.9%
neg-sub074.9%
distribute-rgt-neg-in74.9%
neg-sub074.9%
log-div47.6%
associate-+l-47.6%
neg-sub047.6%
+-commutative47.6%
sub-neg47.6%
log-div75.7%
fma-udef75.7%
Simplified75.7%
Taylor expanded in x around 0 78.0%
if -1.65e9 < z < 4.7e7Initial program 72.9%
Taylor expanded in z around 0 61.6%
Final simplification69.9%
(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 73.9%
remove-double-neg73.9%
sub0-neg73.9%
associate--r-73.9%
neg-sub073.9%
distribute-rgt-neg-in73.9%
neg-sub073.9%
log-div45.1%
associate-+l-45.1%
neg-sub045.1%
+-commutative45.1%
sub-neg45.1%
log-div75.4%
fma-udef75.5%
Simplified75.5%
Taylor expanded in x around 0 50.4%
Final simplification50.4%
(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 2023336
(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))