
(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 (if (<= y -2e-310) (- (* 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 <= -2e-310) {
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 <= -2e-310) {
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 <= -2e-310) 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, -2e-310], 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 -2 \cdot 10^{-310}:\\
\;\;\;\;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 < -1.999999999999994e-310Initial program 76.4%
*-un-lft-identity76.4%
add-cube-cbrt76.4%
times-frac76.4%
log-prod88.8%
pow288.8%
Applied egg-rr88.8%
+-commutative88.8%
log-rec88.8%
unsub-neg88.8%
Simplified88.8%
frac-2neg88.8%
log-div99.4%
Applied egg-rr99.4%
if -1.999999999999994e-310 < y Initial program 75.0%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+303)))
(- (* x (log (* y x))) z)
(fma x t_0 (- z)))))
double code(double x, double y, double z) {
double t_0 = log((x / y));
double t_1 = x * t_0;
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+303)) {
tmp = (x * log((y * x))) - z;
} else {
tmp = fma(x, t_0, -z);
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(x / y)) t_1 = Float64(x * t_0) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+303)) tmp = Float64(Float64(x * log(Float64(y * x))) - z); else tmp = fma(x, t_0, Float64(-z)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+303]], $MachinePrecision]], N[(N[(x * N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x * t$95$0 + (-z)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 2 \cdot 10^{+303}\right):\\
\;\;\;\;x \cdot \log \left(y \cdot x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 2e303 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.3%
*-un-lft-identity6.3%
add-cube-cbrt6.3%
times-frac6.3%
log-prod67.9%
pow267.9%
Applied egg-rr67.9%
+-commutative67.9%
log-rec67.9%
unsub-neg67.9%
Simplified67.9%
diff-log6.3%
associate-/l/6.3%
unpow26.3%
add-cube-cbrt6.3%
expm1-log1p-u6.3%
expm1-log1p-u6.3%
diff-log52.9%
sub-neg52.9%
distribute-rgt-in51.5%
Applied egg-rr51.5%
+-commutative51.5%
distribute-rgt-out52.9%
neg-sub052.9%
associate--r-52.9%
log-div7.5%
neg-sub07.5%
*-commutative7.5%
neg-log6.3%
clear-num6.3%
div-inv6.3%
add-exp-log3.0%
neg-log3.0%
add-sqr-sqrt1.0%
sqrt-unprod27.4%
sqr-neg27.4%
sqrt-unprod26.5%
add-sqr-sqrt33.5%
add-exp-log59.4%
Applied egg-rr59.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2e303Initial program 99.8%
fma-neg99.8%
Simplified99.8%
Final simplification89.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+303)))
(- (* 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 <= 2e+303)) {
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 <= 2e+303)) {
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 <= 2e+303): 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 <= 2e+303)) 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 <= 2e+303))) 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, 2e+303]], $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 2 \cdot 10^{+303}\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 2e303 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.3%
*-un-lft-identity6.3%
add-cube-cbrt6.3%
times-frac6.3%
log-prod67.9%
pow267.9%
Applied egg-rr67.9%
+-commutative67.9%
log-rec67.9%
unsub-neg67.9%
Simplified67.9%
diff-log6.3%
associate-/l/6.3%
unpow26.3%
add-cube-cbrt6.3%
expm1-log1p-u6.3%
expm1-log1p-u6.3%
diff-log52.9%
sub-neg52.9%
distribute-rgt-in51.5%
Applied egg-rr51.5%
+-commutative51.5%
distribute-rgt-out52.9%
neg-sub052.9%
associate--r-52.9%
log-div7.5%
neg-sub07.5%
*-commutative7.5%
neg-log6.3%
clear-num6.3%
div-inv6.3%
add-exp-log3.0%
neg-log3.0%
add-sqr-sqrt1.0%
sqrt-unprod27.4%
sqr-neg27.4%
sqrt-unprod26.5%
add-sqr-sqrt33.5%
add-exp-log59.4%
Applied egg-rr59.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2e303Initial program 99.8%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+303))) (- 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+303)) {
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+303)) {
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+303): 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+303)) 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+303))) 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+303]], $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^{+303}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 2e303 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.3%
Taylor expanded in x around 0 54.6%
mul-1-neg54.6%
Simplified54.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2e303Initial program 99.8%
Final simplification88.2%
(FPCore (x y z)
:precision binary64
(if (<= x -2.5e+114)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.85e-154)
(fma x (log (/ x y)) (- z))
(if (<= x -4e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.5e+114) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.85e-154) {
tmp = fma(x, log((x / y)), -z);
} else if (x <= -4e-308) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.5e+114) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.85e-154) tmp = fma(x, log(Float64(x / y)), Float64(-z)); elseif (x <= -4e-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, -2.5e+114], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.85e-154], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision] + (-z)), $MachinePrecision], If[LessEqual[x, -4e-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.5 \cdot 10^{+114}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.85 \cdot 10^{-154}:\\
\;\;\;\;\mathsf{fma}\left(x, \log \left(\frac{x}{y}\right), -z\right)\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -2.5e114Initial program 70.4%
Taylor expanded in z around 0 64.9%
Taylor expanded in y around -inf 93.7%
metadata-eval99.2%
distribute-neg-frac99.2%
distribute-frac-neg299.2%
log-rec99.2%
sub-neg99.2%
neg-mul-199.2%
Simplified93.7%
if -2.5e114 < x < -2.8499999999999999e-154Initial program 96.1%
fma-neg96.2%
Simplified96.2%
if -2.8499999999999999e-154 < x < -4.00000000000000013e-308Initial program 49.4%
Taylor expanded in x around 0 94.1%
mul-1-neg94.1%
Simplified94.1%
if -4.00000000000000013e-308 < x Initial program 75.0%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z) :precision binary64 (if (<= y -2e-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 <= -2e-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 <= (-2d-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 <= -2e-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 <= -2e-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 <= -2e-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 <= -2e-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, -2e-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 -2 \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 < -1.999999999999994e-310Initial program 76.4%
Taylor expanded in y around -inf 99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
distribute-frac-neg299.4%
log-rec99.4%
sub-neg99.4%
neg-mul-199.4%
Simplified99.4%
if -1.999999999999994e-310 < y Initial program 75.0%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.02e-24)
(and (not (<= x 2.6e-116)) (or (<= x 9.2e+53) (not (<= x 4.7e+157)))))
(* x (log (/ x y)))
(- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.02e-24) || (!(x <= 2.6e-116) && ((x <= 9.2e+53) || !(x <= 4.7e+157)))) {
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.02d-24)) .or. (.not. (x <= 2.6d-116)) .and. (x <= 9.2d+53) .or. (.not. (x <= 4.7d+157))) 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.02e-24) || (!(x <= 2.6e-116) && ((x <= 9.2e+53) || !(x <= 4.7e+157)))) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.02e-24) or (not (x <= 2.6e-116) and ((x <= 9.2e+53) or not (x <= 4.7e+157))): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.02e-24) || (!(x <= 2.6e-116) && ((x <= 9.2e+53) || !(x <= 4.7e+157)))) 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.02e-24) || (~((x <= 2.6e-116)) && ((x <= 9.2e+53) || ~((x <= 4.7e+157))))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.02e-24], And[N[Not[LessEqual[x, 2.6e-116]], $MachinePrecision], Or[LessEqual[x, 9.2e+53], N[Not[LessEqual[x, 4.7e+157]], $MachinePrecision]]]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{-24} \lor \neg \left(x \leq 2.6 \cdot 10^{-116}\right) \land \left(x \leq 9.2 \cdot 10^{+53} \lor \neg \left(x \leq 4.7 \cdot 10^{+157}\right)\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -1.0200000000000001e-24 or 2.6e-116 < x < 9.20000000000000079e53 or 4.7000000000000003e157 < x Initial program 85.2%
Taylor expanded in z around 0 69.1%
if -1.0200000000000001e-24 < x < 2.6e-116 or 9.20000000000000079e53 < x < 4.7000000000000003e157Initial program 68.0%
Taylor expanded in x around 0 76.2%
mul-1-neg76.2%
Simplified76.2%
Final simplification73.0%
(FPCore (x y z)
:precision binary64
(if (<= x -1.3e-24)
(* (- x) (log (/ y x)))
(if (or (<= x 2.9e-116) (and (not (<= x 7.5e+54)) (<= x 4.7e+157)))
(- z)
(* x (log (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e-24) {
tmp = -x * log((y / x));
} else if ((x <= 2.9e-116) || (!(x <= 7.5e+54) && (x <= 4.7e+157))) {
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.3d-24)) then
tmp = -x * log((y / x))
else if ((x <= 2.9d-116) .or. (.not. (x <= 7.5d+54)) .and. (x <= 4.7d+157)) 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.3e-24) {
tmp = -x * Math.log((y / x));
} else if ((x <= 2.9e-116) || (!(x <= 7.5e+54) && (x <= 4.7e+157))) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.3e-24: tmp = -x * math.log((y / x)) elif (x <= 2.9e-116) or (not (x <= 7.5e+54) and (x <= 4.7e+157)): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.3e-24) tmp = Float64(Float64(-x) * log(Float64(y / x))); elseif ((x <= 2.9e-116) || (!(x <= 7.5e+54) && (x <= 4.7e+157))) 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.3e-24) tmp = -x * log((y / x)); elseif ((x <= 2.9e-116) || (~((x <= 7.5e+54)) && (x <= 4.7e+157))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.3e-24], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 2.9e-116], And[N[Not[LessEqual[x, 7.5e+54]], $MachinePrecision], LessEqual[x, 4.7e+157]]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-24}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-116} \lor \neg \left(x \leq 7.5 \cdot 10^{+54}\right) \land x \leq 4.7 \cdot 10^{+157}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -1.3e-24Initial program 81.7%
clear-num81.7%
neg-log83.0%
Applied egg-rr83.0%
Taylor expanded in z around 0 71.2%
associate-*r*71.2%
neg-mul-171.2%
Simplified71.2%
if -1.3e-24 < x < 2.8999999999999998e-116 or 7.50000000000000042e54 < x < 4.7000000000000003e157Initial program 68.0%
Taylor expanded in x around 0 76.2%
mul-1-neg76.2%
Simplified76.2%
if 2.8999999999999998e-116 < x < 7.50000000000000042e54 or 4.7000000000000003e157 < x Initial program 89.2%
Taylor expanded in z around 0 68.1%
Final simplification73.3%
(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.7%
Taylor expanded in x around 0 49.7%
mul-1-neg49.7%
Simplified49.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 75.7%
add-cube-cbrt75.0%
associate-*l*75.0%
fma-neg75.0%
pow275.0%
add-sqr-sqrt37.1%
sqrt-unprod49.1%
sqr-neg49.1%
sqrt-unprod20.4%
add-sqr-sqrt39.3%
Applied egg-rr39.3%
Taylor expanded in x around 0 2.3%
(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 2024146
(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))