
(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 -1e-309) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (* 2.0 (log (sqrt x))) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e-309) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = (x * ((2.0 * log(sqrt(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 <= (-1d-309)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = (x * ((2.0d0 * log(sqrt(x))) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1e-309) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = (x * ((2.0 * Math.log(Math.sqrt(x))) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e-309: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = (x * ((2.0 * math.log(math.sqrt(x))) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e-309) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(x * Float64(Float64(2.0 * log(sqrt(x))) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1e-309) tmp = (x * (log(-x) - log(-y))) - z; else tmp = (x * ((2.0 * log(sqrt(x))) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e-309], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[(2.0 * N[Log[N[Sqrt[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-309}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(2 \cdot \log \left(\sqrt{x}\right) - \log y\right) - z\\
\end{array}
\end{array}
if y < -1.000000000000002e-309Initial program 80.3%
Taylor expanded in y around -inf 99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
distribute-frac-neg299.6%
log-rec99.6%
sub-neg99.6%
neg-mul-199.6%
Simplified99.6%
if -1.000000000000002e-309 < y Initial program 72.1%
Taylor expanded in x around 0 99.6%
log-rec99.6%
neg-mul-199.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
add-sqr-sqrt99.6%
log-prod99.6%
Applied egg-rr99.6%
count-299.6%
Simplified99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)) (t_2 (* x (log (* y x)))))
(if (<= t_1 (- INFINITY))
(- t_2 z)
(if (<= t_1 5e+307) (fma x t_0 (- z)) (- (- z) t_2)))))
double code(double x, double y, double z) {
double t_0 = log((x / y));
double t_1 = x * t_0;
double t_2 = x * log((y * x));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2 - z;
} else if (t_1 <= 5e+307) {
tmp = fma(x, t_0, -z);
} else {
tmp = -z - t_2;
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(x / y)) t_1 = Float64(x * t_0) t_2 = Float64(x * log(Float64(y * x))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(t_2 - z); elseif (t_1 <= 5e+307) tmp = fma(x, t_0, Float64(-z)); else tmp = Float64(Float64(-z) - t_2); 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]}, Block[{t$95$2 = N[(x * N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t$95$2 - z), $MachinePrecision], If[LessEqual[t$95$1, 5e+307], N[(x * t$95$0 + (-z)), $MachinePrecision], N[((-z) - t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot t\_0\\
t_2 := x \cdot \log \left(y \cdot x\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2 - z\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - t\_2\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 9.0%
add-cube-cbrt9.0%
associate-/l*9.0%
log-prod80.4%
pow280.4%
Applied egg-rr80.4%
log-div67.5%
associate-+r-67.6%
log-prod67.6%
unpow267.6%
add-cube-cbrt67.6%
sub-neg67.6%
distribute-rgt-in67.6%
Applied egg-rr67.6%
distribute-rgt-out67.6%
sub-neg67.6%
*-commutative67.6%
expm1-log1p-u0.0%
expm1-log1p-u67.6%
sub-neg67.6%
add-sqr-sqrt0.0%
sqrt-unprod50.6%
sqr-neg50.6%
sqrt-unprod50.6%
add-sqr-sqrt50.6%
sum-log64.1%
Applied egg-rr64.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.6%
fma-neg99.6%
Simplified99.6%
if 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.9%
clear-num6.9%
neg-log13.2%
Applied egg-rr13.2%
distribute-rgt-neg-out13.2%
neg-sub013.2%
add-sqr-sqrt0.9%
sqrt-unprod1.4%
sqr-neg1.4%
sqrt-unprod0.5%
add-sqr-sqrt1.6%
neg-log1.6%
clear-num1.6%
diff-log3.3%
add-sqr-sqrt3.3%
add-sqr-sqrt3.3%
sub-neg3.3%
add-sqr-sqrt3.3%
sqrt-unprod3.3%
sqr-neg3.3%
sqrt-unprod0.0%
add-sqr-sqrt7.2%
sum-log51.5%
Applied egg-rr51.5%
neg-sub051.5%
distribute-lft-neg-in51.5%
Simplified51.5%
Final simplification88.9%
(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) (- (- z) t_1)))))
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 = -z - t_1;
}
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 = -z - t_1;
}
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 = -z - t_1 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(Float64(-z) - t_1); 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 = -z - t_1; 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[((-z) - t$95$1), $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(-z\right) - t\_1\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 9.0%
add-cube-cbrt9.0%
associate-/l*9.0%
log-prod80.4%
pow280.4%
Applied egg-rr80.4%
log-div67.5%
associate-+r-67.6%
log-prod67.6%
unpow267.6%
add-cube-cbrt67.6%
sub-neg67.6%
distribute-rgt-in67.6%
Applied egg-rr67.6%
distribute-rgt-out67.6%
sub-neg67.6%
*-commutative67.6%
expm1-log1p-u0.0%
expm1-log1p-u67.6%
sub-neg67.6%
add-sqr-sqrt0.0%
sqrt-unprod50.6%
sqr-neg50.6%
sqrt-unprod50.6%
add-sqr-sqrt50.6%
sum-log64.1%
Applied egg-rr64.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.6%
if 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.9%
clear-num6.9%
neg-log13.2%
Applied egg-rr13.2%
distribute-rgt-neg-out13.2%
neg-sub013.2%
add-sqr-sqrt0.9%
sqrt-unprod1.4%
sqr-neg1.4%
sqrt-unprod0.5%
add-sqr-sqrt1.6%
neg-log1.6%
clear-num1.6%
diff-log3.3%
add-sqr-sqrt3.3%
add-sqr-sqrt3.3%
sub-neg3.3%
add-sqr-sqrt3.3%
sqrt-unprod3.3%
sqr-neg3.3%
sqrt-unprod0.0%
add-sqr-sqrt7.2%
sum-log51.5%
Applied egg-rr51.5%
neg-sub051.5%
distribute-lft-neg-in51.5%
Simplified51.5%
Final simplification88.8%
(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 8.0%
add-cube-cbrt8.0%
associate-/l*8.0%
log-prod78.3%
pow278.3%
Applied egg-rr78.3%
log-div60.4%
associate-+r-60.5%
log-prod60.5%
unpow260.5%
add-cube-cbrt60.5%
sub-neg60.5%
distribute-rgt-in60.5%
Applied egg-rr60.5%
distribute-rgt-out60.5%
sub-neg60.5%
*-commutative60.5%
expm1-log1p-u25.6%
expm1-log1p-u60.5%
sub-neg60.5%
add-sqr-sqrt25.6%
sqrt-unprod51.7%
sqr-neg51.7%
sqrt-unprod26.1%
add-sqr-sqrt29.7%
sum-log57.9%
Applied egg-rr57.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.6%
Final simplification88.8%
(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 8.0%
Taylor expanded in x around 0 53.1%
mul-1-neg53.1%
Simplified53.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.6%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (<= x -1.7e-95) (fma 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 <= -1.7e-95) {
tmp = fma(x, log((x / y)), -z);
} else if (x <= -1e-308) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.7e-95) tmp = fma(x, log(Float64(x / y)), Float64(-z)); elseif (x <= -1e-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, -1.7e-95], N[(x * N[Log[N[(x / y), $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 -1.7 \cdot 10^{-95}:\\
\;\;\;\;\mathsf{fma}\left(x, \log \left(\frac{x}{y}\right), -z\right)\\
\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 < -1.69999999999999997e-95Initial program 88.9%
fma-neg88.9%
Simplified88.9%
if -1.69999999999999997e-95 < x < -9.9999999999999991e-309Initial program 62.2%
Taylor expanded in x around 0 95.1%
mul-1-neg95.1%
Simplified95.1%
if -9.9999999999999991e-309 < x Initial program 72.1%
Taylor expanded in x around 0 99.6%
log-rec99.6%
neg-mul-199.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z) :precision binary64 (if (<= y -1e-309) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e-309) {
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 <= (-1d-309)) 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 <= -1e-309) {
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 <= -1e-309: 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 <= -1e-309) 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 <= -1e-309) 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, -1e-309], 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 -1 \cdot 10^{-309}:\\
\;\;\;\;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.000000000000002e-309Initial program 80.3%
Taylor expanded in y around -inf 99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
distribute-frac-neg299.6%
log-rec99.6%
sub-neg99.6%
neg-mul-199.6%
Simplified99.6%
if -1.000000000000002e-309 < y Initial program 72.1%
Taylor expanded in x around 0 99.6%
log-rec99.6%
neg-mul-199.6%
neg-mul-199.6%
sub-neg99.6%
Simplified99.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.65e-105) (not (<= z 5e-47))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.65e-105) || !(z <= 5e-47)) {
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 <= (-2.65d-105)) .or. (.not. (z <= 5d-47))) 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 <= -2.65e-105) || !(z <= 5e-47)) {
tmp = -z;
} else {
tmp = -x * Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.65e-105) or not (z <= 5e-47): tmp = -z else: tmp = -x * math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.65e-105) || !(z <= 5e-47)) 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 <= -2.65e-105) || ~((z <= 5e-47))) tmp = -z; else tmp = -x * log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.65e-105], N[Not[LessEqual[z, 5e-47]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.65 \cdot 10^{-105} \lor \neg \left(z \leq 5 \cdot 10^{-47}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\end{array}
\end{array}
if z < -2.6500000000000001e-105 or 5.00000000000000011e-47 < z Initial program 76.5%
Taylor expanded in x around 0 73.2%
mul-1-neg73.2%
Simplified73.2%
if -2.6500000000000001e-105 < z < 5.00000000000000011e-47Initial program 75.1%
clear-num74.6%
neg-log76.6%
Applied egg-rr76.6%
Taylor expanded in z around 0 67.9%
associate-*r*67.9%
neg-mul-167.9%
Simplified67.9%
Final simplification71.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.3e-104) (not (<= z 1.28e-46))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.3e-104) || !(z <= 1.28e-46)) {
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 <= (-5.3d-104)) .or. (.not. (z <= 1.28d-46))) 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 <= -5.3e-104) || !(z <= 1.28e-46)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.3e-104) or not (z <= 1.28e-46): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.3e-104) || !(z <= 1.28e-46)) 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 <= -5.3e-104) || ~((z <= 1.28e-46))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.3e-104], N[Not[LessEqual[z, 1.28e-46]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.3 \cdot 10^{-104} \lor \neg \left(z \leq 1.28 \cdot 10^{-46}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -5.30000000000000018e-104 or 1.28e-46 < z Initial program 76.5%
Taylor expanded in x around 0 73.2%
mul-1-neg73.2%
Simplified73.2%
if -5.30000000000000018e-104 < z < 1.28e-46Initial program 75.1%
Taylor expanded in z around 0 66.5%
Final simplification70.6%
(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.0%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
Simplified50.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 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.0%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
Simplified50.9%
neg-sub050.9%
sub-neg50.9%
add-sqr-sqrt21.1%
sqrt-unprod13.6%
sqr-neg13.6%
sqrt-unprod1.3%
add-sqr-sqrt2.3%
Applied egg-rr2.3%
+-lft-identity2.3%
Simplified2.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 2024137
(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))