
(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-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (- (* x (log x)) (* 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)) - (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)) - (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)) - (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)) - (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(Float64(x * log(x)) - Float64(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)) - (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[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * 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}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 82.1%
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 -4.999999999999985e-310 < y Initial program 74.8%
Taylor expanded in y around -inf 0.0%
metadata-eval0.0%
distribute-neg-frac0.0%
distribute-frac-neg20.0%
neg-mul-10.0%
log-rec0.0%
sub-neg0.0%
Simplified0.0%
sub-neg0.0%
distribute-rgt-in0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod53.7%
sqr-neg53.7%
sqrt-unprod99.6%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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+277) (- 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+277) {
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+277) {
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+277: 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+277) 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+277) 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+277], 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^{+277}:\\
\;\;\;\;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 7.4%
add-cube-cbrt7.4%
associate-/l*7.4%
log-prod79.0%
pow279.0%
Applied egg-rr79.0%
sum-log7.4%
associate-*r/7.4%
unpow27.4%
add-cube-cbrt7.4%
add-cbrt-cube7.4%
unpow37.4%
add-sqr-sqrt6.0%
sqrt-unprod6.7%
pow26.7%
Applied egg-rr57.0%
unpow257.0%
rem-sqrt-square57.0%
Simplified57.0%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.99999999999999982e277Initial program 99.8%
if 4.99999999999999982e277 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.7%
Taylor expanded in y around -inf 32.1%
metadata-eval32.1%
distribute-neg-frac32.1%
distribute-frac-neg232.1%
neg-mul-132.1%
log-rec32.1%
sub-neg32.1%
Simplified32.1%
sub-neg32.1%
distribute-rgt-in32.1%
add-sqr-sqrt32.1%
sqrt-unprod0.5%
sqr-neg0.5%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod24.1%
sqr-neg24.1%
sqrt-unprod67.7%
add-sqr-sqrt67.7%
Applied egg-rr67.7%
distribute-rgt-out67.6%
sub-neg67.6%
add-cube-cbrt67.6%
unpow267.6%
log-prod67.5%
associate-+r-67.5%
log-div54.9%
add-sqr-sqrt54.9%
sqrt-unprod28.0%
pow228.0%
Applied egg-rr45.4%
unpow245.4%
rem-sqrt-square59.1%
Simplified59.1%
Final simplification90.0%
(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+277) (- 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+277) {
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+277) {
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+277: 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+277) 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+277) 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+277], 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^{+277}:\\
\;\;\;\;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 7.4%
Taylor expanded in y around -inf 43.7%
metadata-eval43.7%
distribute-neg-frac43.7%
distribute-frac-neg243.7%
neg-mul-143.7%
log-rec43.7%
sub-neg43.7%
Simplified43.7%
sub-neg43.7%
distribute-rgt-in43.7%
add-sqr-sqrt43.7%
sqrt-unprod14.8%
sqr-neg14.8%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod22.8%
sqr-neg22.8%
sqrt-unprod56.2%
add-sqr-sqrt56.2%
Applied egg-rr56.2%
distribute-rgt-out56.1%
sub-neg56.1%
log-div7.4%
add-cbrt-cube7.4%
unpow37.4%
*-commutative7.4%
Applied egg-rr55.8%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.99999999999999982e277Initial program 99.8%
if 4.99999999999999982e277 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.7%
Taylor expanded in y around -inf 32.1%
metadata-eval32.1%
distribute-neg-frac32.1%
distribute-frac-neg232.1%
neg-mul-132.1%
log-rec32.1%
sub-neg32.1%
Simplified32.1%
sub-neg32.1%
distribute-rgt-in32.1%
add-sqr-sqrt32.1%
sqrt-unprod0.5%
sqr-neg0.5%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod24.1%
sqr-neg24.1%
sqrt-unprod67.7%
add-sqr-sqrt67.7%
Applied egg-rr67.7%
distribute-rgt-out67.6%
sub-neg67.6%
add-cube-cbrt67.6%
unpow267.6%
log-prod67.5%
associate-+r-67.5%
log-div54.9%
add-sqr-sqrt54.9%
sqrt-unprod28.0%
pow228.0%
Applied egg-rr45.4%
unpow245.4%
rem-sqrt-square59.1%
Simplified59.1%
Final simplification89.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+277)))
(- (* 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+277)) {
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+277)) {
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+277): 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+277)) 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+277))) 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+277]], $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^{+277}\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 4.99999999999999982e277 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.5%
Taylor expanded in y around -inf 38.3%
metadata-eval38.3%
distribute-neg-frac38.3%
distribute-frac-neg238.3%
neg-mul-138.3%
log-rec38.3%
sub-neg38.3%
Simplified38.3%
sub-neg38.3%
distribute-rgt-in38.3%
add-sqr-sqrt38.3%
sqrt-unprod8.1%
sqr-neg8.1%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod23.4%
sqr-neg23.4%
sqrt-unprod61.6%
add-sqr-sqrt61.6%
Applied egg-rr61.6%
distribute-rgt-out61.5%
sub-neg61.5%
log-div7.5%
add-cbrt-cube7.5%
unpow37.5%
*-commutative7.5%
Applied egg-rr55.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.99999999999999982e277Initial program 99.8%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+277))) (- 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+277)) {
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+277)) {
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+277): 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+277)) 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+277))) 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+277]], $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^{+277}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4.99999999999999982e277 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.5%
Taylor expanded in x around 0 49.5%
neg-mul-149.5%
Simplified49.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.99999999999999982e277Initial program 99.8%
Final simplification88.0%
(FPCore (x y z)
:precision binary64
(if (<= x -1.55e+125)
(* x (- (log (- x)) (log (- y))))
(if (<= x -4.6e-166)
(- (* (- x) (log (/ y x))) z)
(if (<= x -5e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.55e+125) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -4.6e-166) {
tmp = (-x * log((y / x))) - z;
} else if (x <= -5e-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 <= (-1.55d+125)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-4.6d-166)) then
tmp = (-x * log((y / x))) - z
else if (x <= (-5d-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 <= -1.55e+125) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -4.6e-166) {
tmp = (-x * Math.log((y / x))) - z;
} else if (x <= -5e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.55e+125: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -4.6e-166: tmp = (-x * math.log((y / x))) - z elif x <= -5e-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 <= -1.55e+125) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -4.6e-166) tmp = Float64(Float64(Float64(-x) * log(Float64(y / x))) - z); elseif (x <= -5e-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 <= -1.55e+125) tmp = x * (log(-x) - log(-y)); elseif (x <= -4.6e-166) tmp = (-x * log((y / x))) - z; elseif (x <= -5e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.55e+125], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.6e-166], N[(N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-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.55 \cdot 10^{+125}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{-166}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.55e125Initial program 63.8%
Taylor expanded in z around 0 58.0%
Taylor expanded in y around -inf 88.3%
metadata-eval99.1%
distribute-neg-frac99.1%
distribute-frac-neg299.1%
neg-mul-199.1%
log-rec99.1%
sub-neg99.1%
Simplified88.3%
if -1.55e125 < x < -4.59999999999999997e-166Initial program 98.1%
clear-num98.1%
neg-log99.8%
Applied egg-rr99.8%
if -4.59999999999999997e-166 < x < -4.99999999999999955e-308Initial program 71.4%
Taylor expanded in x around 0 91.9%
neg-mul-191.9%
Simplified91.9%
if -4.99999999999999955e-308 < x Initial program 74.8%
Taylor expanded in x around 0 99.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
Final simplification97.3%
(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 82.1%
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 -4.999999999999985e-310 < y Initial program 74.8%
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 -410.0) (not (<= x 2.8e-61))) (* (- x) (log (/ y x))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -410.0) || !(x <= 2.8e-61)) {
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 <= (-410.0d0)) .or. (.not. (x <= 2.8d-61))) 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 <= -410.0) || !(x <= 2.8e-61)) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -410.0) or not (x <= 2.8e-61): tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -410.0) || !(x <= 2.8e-61)) tmp = Float64(Float64(-x) * log(Float64(y / x))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -410.0) || ~((x <= 2.8e-61))) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -410.0], N[Not[LessEqual[x, 2.8e-61]], $MachinePrecision]], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -410 \lor \neg \left(x \leq 2.8 \cdot 10^{-61}\right):\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -410 or 2.8000000000000001e-61 < x Initial program 78.1%
Taylor expanded in z around 0 59.4%
clear-num76.7%
neg-log78.7%
Applied egg-rr60.0%
if -410 < x < 2.8000000000000001e-61Initial program 78.2%
Taylor expanded in x around 0 81.4%
neg-mul-181.4%
Simplified81.4%
Final simplification69.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -24.0) (not (<= x 1.75e-61))) (* x (log (/ x y))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -24.0) || !(x <= 1.75e-61)) {
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 <= (-24.0d0)) .or. (.not. (x <= 1.75d-61))) 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 <= -24.0) || !(x <= 1.75e-61)) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -24.0) or not (x <= 1.75e-61): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -24.0) || !(x <= 1.75e-61)) 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 <= -24.0) || ~((x <= 1.75e-61))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -24.0], N[Not[LessEqual[x, 1.75e-61]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -24 \lor \neg \left(x \leq 1.75 \cdot 10^{-61}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -24 or 1.7500000000000002e-61 < x Initial program 78.1%
Taylor expanded in z around 0 59.4%
if -24 < x < 1.7500000000000002e-61Initial program 78.2%
Taylor expanded in x around 0 81.4%
neg-mul-181.4%
Simplified81.4%
Final simplification69.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 78.2%
Taylor expanded in x around 0 51.4%
neg-mul-151.4%
Simplified51.4%
(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 78.2%
Taylor expanded in x around 0 51.4%
neg-mul-151.4%
Simplified51.4%
neg-sub051.4%
sub-neg51.4%
add-sqr-sqrt22.5%
sqrt-unprod12.8%
sqr-neg12.8%
sqrt-unprod1.3%
add-sqr-sqrt2.4%
Applied egg-rr2.4%
+-lft-identity2.4%
Simplified2.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 2024135
(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))