
(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 (if (<= y -5e-311) (- (* x (- (- (log (- x)) (log (- (cbrt y)))) (log (pow (cbrt y) 2.0)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * ((log(-x) - log(-cbrt(y))) - log(pow(cbrt(y), 2.0)))) - z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * ((Math.log(-x) - Math.log(-Math.cbrt(y))) - Math.log(Math.pow(Math.cbrt(y), 2.0)))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(Float64(log(Float64(-x)) - log(Float64(-cbrt(y)))) - log((cbrt(y) ^ 2.0)))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-N[Power[y, 1/3], $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[Log[N[Power[N[Power[y, 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $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^{-311}:\\
\;\;\;\;x \cdot \left(\left(\log \left(-x\right) - \log \left(-\sqrt[3]{y}\right)\right) - \log \left({\left(\sqrt[3]{y}\right)}^{2}\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 73.6%
*-un-lft-identity73.6%
add-cube-cbrt73.6%
times-frac73.6%
log-prod94.4%
pow294.4%
Applied egg-rr94.4%
+-commutative94.4%
log-rec94.4%
unsub-neg94.4%
Simplified94.4%
frac-2neg94.4%
log-div99.6%
Applied egg-rr99.6%
if -5.00000000000023e-311 < y Initial program 76.5%
Taylor expanded in x around 0 99.5%
log-rec99.5%
sub-neg99.5%
Simplified99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))) (t_1 (log (* y x))))
(if (<= t_0 (- INFINITY))
(- (* x (fabs t_1)) z)
(if (<= t_0 5e+307) (- t_0 z) (- (fabs (* x t_1)) z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double t_1 = log((y * x));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (x * fabs(t_1)) - z;
} else if (t_0 <= 5e+307) {
tmp = t_0 - z;
} else {
tmp = fabs((x * t_1)) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double t_1 = Math.log((y * x));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (x * Math.abs(t_1)) - z;
} else if (t_0 <= 5e+307) {
tmp = t_0 - z;
} else {
tmp = Math.abs((x * t_1)) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) t_1 = math.log((y * x)) tmp = 0 if t_0 <= -math.inf: tmp = (x * math.fabs(t_1)) - z elif t_0 <= 5e+307: tmp = t_0 - z else: tmp = math.fabs((x * t_1)) - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) t_1 = log(Float64(y * x)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(x * abs(t_1)) - z); elseif (t_0 <= 5e+307) tmp = Float64(t_0 - z); else tmp = Float64(abs(Float64(x * t_1)) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); t_1 = log((y * x)); tmp = 0.0; if (t_0 <= -Inf) tmp = (x * abs(t_1)) - z; elseif (t_0 <= 5e+307) tmp = t_0 - z; else tmp = abs((x * t_1)) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(x * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, 5e+307], N[(t$95$0 - z), $MachinePrecision], N[(N[Abs[N[(x * t$95$1), $MachinePrecision]], $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
t_1 := \log \left(y \cdot x\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;x \cdot \left|t\_1\right| - z\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot t\_1\right| - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 4.2%
add-cbrt-cube4.2%
pow34.2%
Applied egg-rr4.2%
rem-cbrt-cube4.2%
add-sqr-sqrt3.3%
sqrt-unprod4.5%
pow24.5%
log-div42.1%
sub-neg42.1%
add-log-exp42.1%
sum-log1.2%
add-sqr-sqrt0.0%
sqrt-unprod42.2%
sqr-neg42.2%
sqrt-unprod42.2%
add-sqr-sqrt42.2%
add-exp-log58.1%
Applied egg-rr58.1%
unpow258.1%
rem-sqrt-square58.1%
Simplified58.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.8%
if 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.8%
add-cbrt-cube3.8%
pow33.8%
Applied egg-rr3.8%
rem-square-sqrt3.8%
sqrt-unprod3.8%
pow23.8%
rem-cbrt-cube3.8%
log-div14.7%
sub-neg14.7%
add-log-exp14.7%
sum-log2.6%
add-sqr-sqrt2.6%
sqrt-unprod2.6%
sqr-neg2.6%
sqrt-unprod0.0%
add-sqr-sqrt7.3%
add-exp-log49.8%
Applied egg-rr49.8%
unpow249.8%
rem-sqrt-square56.1%
Simplified56.1%
Final simplification88.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))) (t_1 (* x (log (* y x)))))
(if (<= t_0 (- INFINITY))
(- t_1 z)
(if (<= t_0 5e+307) (- t_0 z) (- (fabs t_1) z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double t_1 = x * log((y * x));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1 - z;
} else if (t_0 <= 5e+307) {
tmp = t_0 - z;
} else {
tmp = fabs(t_1) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double t_1 = x * Math.log((y * x));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1 - z;
} else if (t_0 <= 5e+307) {
tmp = t_0 - z;
} else {
tmp = Math.abs(t_1) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) t_1 = x * math.log((y * x)) tmp = 0 if t_0 <= -math.inf: tmp = t_1 - z elif t_0 <= 5e+307: tmp = t_0 - z else: tmp = math.fabs(t_1) - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) t_1 = Float64(x * log(Float64(y * x))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(t_1 - z); elseif (t_0 <= 5e+307) tmp = Float64(t_0 - z); else tmp = Float64(abs(t_1) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); t_1 = x * log((y * x)); tmp = 0.0; if (t_0 <= -Inf) tmp = t_1 - z; elseif (t_0 <= 5e+307) tmp = t_0 - z; else tmp = abs(t_1) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(t$95$1 - z), $MachinePrecision], If[LessEqual[t$95$0, 5e+307], N[(t$95$0 - z), $MachinePrecision], N[(N[Abs[t$95$1], $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot \log \left(y \cdot x\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1 - z\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1\right| - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 4.2%
*-un-lft-identity4.2%
add-cube-cbrt4.2%
times-frac4.2%
log-prod80.4%
pow280.4%
Applied egg-rr80.4%
+-commutative80.4%
log-rec80.4%
unsub-neg80.4%
Simplified80.4%
diff-log4.2%
associate-/l/4.2%
unpow24.2%
add-cube-cbrt4.2%
diff-log50.0%
sub-neg50.0%
distribute-rgt-in50.0%
Applied egg-rr50.0%
distribute-rgt-out50.0%
sub-neg50.0%
log-div4.2%
*-commutative4.2%
log-div50.0%
sub-neg50.0%
add-log-exp50.0%
sum-log0.9%
add-sqr-sqrt0.0%
sqrt-unprod42.2%
sqr-neg42.2%
sqrt-unprod42.2%
add-sqr-sqrt42.2%
add-exp-log56.2%
Applied egg-rr56.2%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.8%
if 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.8%
add-cbrt-cube3.8%
pow33.8%
Applied egg-rr3.8%
rem-square-sqrt3.8%
sqrt-unprod3.8%
pow23.8%
rem-cbrt-cube3.8%
log-div14.7%
sub-neg14.7%
add-log-exp14.7%
sum-log2.6%
add-sqr-sqrt2.6%
sqrt-unprod2.6%
sqr-neg2.6%
sqrt-unprod0.0%
add-sqr-sqrt7.3%
add-exp-log49.8%
Applied egg-rr49.8%
unpow249.8%
rem-sqrt-square56.1%
Simplified56.1%
Final simplification88.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+307)))
(- (* x (log (* y x))) 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+307)) {
tmp = (x * log((y * x))) - 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+307)) {
tmp = (x * Math.log((y * x))) - 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+307): tmp = (x * math.log((y * x))) - 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+307)) tmp = Float64(Float64(x * log(Float64(y * x))) - 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+307))) tmp = (x * log((y * x))) - 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+307]], $MachinePrecision]], N[(N[(x * N[Log[N[(y * x), $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 5 \cdot 10^{+307}\right):\\
\;\;\;\;x \cdot \log \left(y \cdot x\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.0%
*-un-lft-identity4.0%
add-cube-cbrt4.0%
times-frac4.0%
log-prod78.4%
pow278.4%
Applied egg-rr78.4%
+-commutative78.4%
log-rec78.4%
unsub-neg78.4%
Simplified78.4%
diff-log4.0%
associate-/l/4.0%
unpow24.0%
add-cube-cbrt4.0%
diff-log48.4%
sub-neg48.4%
distribute-rgt-in48.5%
Applied egg-rr48.5%
distribute-rgt-out48.4%
sub-neg48.4%
log-div4.0%
*-commutative4.0%
log-div48.4%
sub-neg48.4%
add-log-exp48.4%
sum-log1.7%
add-sqr-sqrt1.2%
sqrt-unprod23.0%
sqr-neg23.0%
sqrt-unprod21.7%
add-sqr-sqrt25.9%
add-exp-log53.1%
Applied egg-rr53.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.8%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+307))) (- 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+307)) {
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+307)) {
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+307): 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+307)) 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+307))) 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+307]], $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^{+307}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.0%
Taylor expanded in x around 0 50.3%
neg-mul-150.3%
Simplified50.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.8%
Final simplification87.0%
(FPCore (x y z)
:precision binary64
(if (<= x -3.4e+137)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.12e-154)
(- (* x (log (/ x y))) z)
(if (<= x -1e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.4e+137) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.12e-154) {
tmp = (x * log((x / y))) - z;
} else if (x <= -1e-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 <= (-3.4d+137)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.12d-154)) then
tmp = (x * log((x / y))) - z
else if (x <= (-1d-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 <= -3.4e+137) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.12e-154) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -1e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.4e+137: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.12e-154: tmp = (x * math.log((x / y))) - z elif x <= -1e-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 <= -3.4e+137) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.12e-154) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -1e-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 <= -3.4e+137) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.12e-154) tmp = (x * log((x / y))) - z; elseif (x <= -1e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.4e+137], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.12e-154], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-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 -3.4 \cdot 10^{+137}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.12 \cdot 10^{-154}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -3.39999999999999986e137Initial program 61.0%
Taylor expanded in z around 0 52.7%
Taylor expanded in y around -inf 88.2%
metadata-eval99.3%
distribute-neg-frac99.3%
distribute-frac-neg299.3%
neg-mul-199.3%
log-rec99.3%
sub-neg99.3%
Simplified88.2%
if -3.39999999999999986e137 < x < -1.12e-154Initial program 89.6%
if -1.12e-154 < x < -9.9999999999999991e-309Initial program 57.6%
Taylor expanded in x around 0 93.7%
neg-mul-193.7%
Simplified93.7%
if -9.9999999999999991e-309 < x Initial program 76.5%
Taylor expanded in x around 0 99.5%
log-rec99.5%
sub-neg99.5%
Simplified99.5%
(FPCore (x y z) :precision binary64 (if (<= y -5e-311) (- (* 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-311) {
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-311)) 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-311) {
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-311: 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-311) 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-311) 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-311], 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^{-311}:\\
\;\;\;\;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 < -5.00000000000023e-311Initial program 73.6%
Taylor expanded in y around -inf 99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
distribute-frac-neg299.6%
neg-mul-199.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
if -5.00000000000023e-311 < y Initial program 76.5%
Taylor expanded in x around 0 99.5%
log-rec99.5%
sub-neg99.5%
Simplified99.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.4e+33) (not (<= x 7.5))) (* x (- (log (/ y x)))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.4e+33) || !(x <= 7.5)) {
tmp = x * -log((y / x));
} 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 <= (-2.4d+33)) .or. (.not. (x <= 7.5d0))) then
tmp = x * -log((y / x))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.4e+33) || !(x <= 7.5)) {
tmp = x * -Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.4e+33) or not (x <= 7.5): tmp = x * -math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.4e+33) || !(x <= 7.5)) tmp = Float64(x * Float64(-log(Float64(y / x)))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.4e+33) || ~((x <= 7.5))) tmp = x * -log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.4e+33], N[Not[LessEqual[x, 7.5]], $MachinePrecision]], N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+33} \lor \neg \left(x \leq 7.5\right):\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -2.4e33 or 7.5 < x Initial program 76.1%
clear-num76.1%
neg-log77.2%
Applied egg-rr77.2%
Taylor expanded in z around 0 60.5%
associate-*r*60.5%
neg-mul-160.5%
Simplified60.5%
if -2.4e33 < x < 7.5Initial program 74.0%
Taylor expanded in x around 0 75.3%
neg-mul-175.3%
Simplified75.3%
Final simplification68.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.8e+27) (not (<= x 370000.0))) (* x (log (/ x y))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.8e+27) || !(x <= 370000.0)) {
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 <= (-2.8d+27)) .or. (.not. (x <= 370000.0d0))) 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 <= -2.8e+27) || !(x <= 370000.0)) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.8e+27) or not (x <= 370000.0): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.8e+27) || !(x <= 370000.0)) 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 <= -2.8e+27) || ~((x <= 370000.0))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.8e+27], N[Not[LessEqual[x, 370000.0]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{+27} \lor \neg \left(x \leq 370000\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -2.7999999999999999e27 or 3.7e5 < x Initial program 76.1%
Taylor expanded in z around 0 59.5%
if -2.7999999999999999e27 < x < 3.7e5Initial program 74.0%
Taylor expanded in x around 0 75.3%
neg-mul-175.3%
Simplified75.3%
Final simplification67.5%
(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 75.1%
Taylor expanded in x around 0 49.0%
neg-mul-149.0%
Simplified49.0%
(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 75.1%
Taylor expanded in x around 0 49.0%
neg-mul-149.0%
Simplified49.0%
neg-sub049.0%
sub-neg49.0%
add-sqr-sqrt27.6%
sqrt-unprod17.3%
sqr-neg17.3%
sqrt-unprod1.0%
add-sqr-sqrt2.2%
Applied egg-rr2.2%
+-lft-identity2.2%
Simplified2.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 2024180
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< y 7595077799083773/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
(- (* x (log (/ x y))) z))