
(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 (- 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 77.1%
Taylor expanded in y around -inf 99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
distribute-frac-neg299.5%
log-rec99.5%
sub-neg99.5%
neg-mul-199.5%
Simplified99.5%
if -1.999999999999994e-310 < y Initial program 74.0%
Taylor expanded in x around 0 99.7%
log-rec99.7%
neg-mul-199.7%
neg-mul-199.7%
sub-neg99.7%
Simplified99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (<= t_1 (- INFINITY))
(- z)
(if (<= t_1 5e+253) (fma x t_0 (- z)) (* x (- (log x) (log y)))))))
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)) {
tmp = -z;
} else if (t_1 <= 5e+253) {
tmp = fma(x, t_0, -z);
} else {
tmp = x * (log(x) - log(y));
}
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)) tmp = Float64(-z); elseif (t_1 <= 5e+253) tmp = fma(x, t_0, Float64(-z)); else tmp = Float64(x * Float64(log(x) - log(y))); 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[LessEqual[t$95$1, (-Infinity)], (-z), If[LessEqual[t$95$1, 5e+253], N[(x * t$95$0 + (-z)), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $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:\\
\;\;\;\;-z\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+253}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 9.1%
Taylor expanded in x around 0 48.7%
mul-1-neg48.7%
Simplified48.7%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.9999999999999997e253Initial program 99.8%
fma-neg99.8%
Simplified99.8%
if 4.9999999999999997e253 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 14.7%
add-cube-cbrt14.5%
pow314.5%
Applied egg-rr14.5%
Taylor expanded in x around inf 64.9%
log-rec64.9%
mul-1-neg64.9%
log-rec64.9%
remove-double-div64.9%
+-commutative64.9%
sub-neg64.9%
Simplified64.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- z)
(if (<= t_0 5e+253) (- t_0 z) (* x (- (log x) (log y)))))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = -z;
} else if (t_0 <= 5e+253) {
tmp = t_0 - z;
} else {
tmp = x * (log(x) - log(y));
}
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) {
tmp = -z;
} else if (t_0 <= 5e+253) {
tmp = t_0 - z;
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if t_0 <= -math.inf: tmp = -z elif t_0 <= 5e+253: tmp = t_0 - z else: tmp = x * (math.log(x) - math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(-z); elseif (t_0 <= 5e+253) tmp = Float64(t_0 - z); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (t_0 <= -Inf) tmp = -z; elseif (t_0 <= 5e+253) tmp = t_0 - z; else tmp = x * (log(x) - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], (-z), If[LessEqual[t$95$0, 5e+253], N[(t$95$0 - z), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;-z\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+253}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 9.1%
Taylor expanded in x around 0 48.7%
mul-1-neg48.7%
Simplified48.7%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.9999999999999997e253Initial program 99.8%
if 4.9999999999999997e253 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 14.7%
add-cube-cbrt14.5%
pow314.5%
Applied egg-rr14.5%
Taylor expanded in x around inf 64.9%
log-rec64.9%
mul-1-neg64.9%
log-rec64.9%
remove-double-div64.9%
+-commutative64.9%
sub-neg64.9%
Simplified64.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+289))) (- 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+289)) {
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+289)) {
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+289): 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+289)) 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+289))) 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+289]], $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^{+289}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 2.0000000000000001e289 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.7%
Taylor expanded in x around 0 45.3%
mul-1-neg45.3%
Simplified45.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2.0000000000000001e289Initial program 99.8%
Final simplification85.3%
(FPCore (x y z)
:precision binary64
(if (<= x -1.75e+196)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.3e-98)
(- (- z) (* x (log (/ y x))))
(if (<= x 3.5e-140)
(- z)
(if (<= x 8.2e+139)
(fma x (log (/ x y)) (- z))
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.75e+196) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.3e-98) {
tmp = -z - (x * log((y / x)));
} else if (x <= 3.5e-140) {
tmp = -z;
} else if (x <= 8.2e+139) {
tmp = fma(x, log((x / y)), -z);
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.75e+196) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.3e-98) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); elseif (x <= 3.5e-140) tmp = Float64(-z); elseif (x <= 8.2e+139) tmp = fma(x, log(Float64(x / y)), Float64(-z)); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.75e+196], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.3e-98], N[((-z) - N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.5e-140], (-z), If[LessEqual[x, 8.2e+139], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision] + (-z)), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{+196}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-98}:\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-140}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(x, \log \left(\frac{x}{y}\right), -z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -1.7499999999999999e196Initial program 60.6%
Taylor expanded in z around 0 57.1%
Taylor expanded in y around -inf 91.7%
metadata-eval99.0%
distribute-neg-frac99.0%
distribute-frac-neg299.0%
log-rec99.0%
sub-neg99.0%
neg-mul-199.0%
Simplified91.7%
if -1.7499999999999999e196 < x < -2.30000000000000001e-98Initial program 87.9%
clear-num87.9%
neg-log91.4%
Applied egg-rr91.4%
if -2.30000000000000001e-98 < x < 3.4999999999999998e-140Initial program 63.0%
Taylor expanded in x around 0 87.3%
mul-1-neg87.3%
Simplified87.3%
if 3.4999999999999998e-140 < x < 8.2000000000000004e139Initial program 92.8%
fma-neg92.8%
Simplified92.8%
if 8.2000000000000004e139 < x Initial program 57.5%
add-cube-cbrt56.7%
pow356.6%
Applied egg-rr56.6%
Taylor expanded in x around inf 96.7%
log-rec96.7%
mul-1-neg96.7%
log-rec96.7%
remove-double-div96.7%
+-commutative96.7%
sub-neg96.7%
Simplified96.7%
Final simplification91.5%
(FPCore (x y z)
:precision binary64
(if (<= x -8.5e+195)
(* x (- (log (- x)) (log (- y))))
(if (<= x -3e-98)
(- (- z) (* x (log (/ y x))))
(if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.5e+195) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -3e-98) {
tmp = -z - (x * log((y / x)));
} else if (x <= -5e-309) {
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 <= (-8.5d+195)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-3d-98)) then
tmp = -z - (x * log((y / x)))
else if (x <= (-5d-309)) 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 <= -8.5e+195) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -3e-98) {
tmp = -z - (x * Math.log((y / x)));
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -8.5e+195: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -3e-98: tmp = -z - (x * math.log((y / x))) elif x <= -5e-309: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -8.5e+195) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -3e-98) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); elseif (x <= -5e-309) 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 <= -8.5e+195) tmp = x * (log(-x) - log(-y)); elseif (x <= -3e-98) tmp = -z - (x * log((y / x))); elseif (x <= -5e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8.5e+195], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3e-98], N[((-z) - N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-309], (-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 -8.5 \cdot 10^{+195}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-98}:\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -8.5e195Initial program 60.6%
Taylor expanded in z around 0 57.1%
Taylor expanded in y around -inf 91.7%
metadata-eval99.0%
distribute-neg-frac99.0%
distribute-frac-neg299.0%
log-rec99.0%
sub-neg99.0%
neg-mul-199.0%
Simplified91.7%
if -8.5e195 < x < -3e-98Initial program 87.9%
clear-num87.9%
neg-log91.4%
Applied egg-rr91.4%
if -3e-98 < x < -4.9999999999999995e-309Initial program 71.3%
Taylor expanded in x around 0 89.6%
mul-1-neg89.6%
Simplified89.6%
if -4.9999999999999995e-309 < x Initial program 74.0%
Taylor expanded in x around 0 99.7%
log-rec99.7%
neg-mul-199.7%
neg-mul-199.7%
sub-neg99.7%
Simplified99.7%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.3e+36) (not (<= x 1.22e+59))) (* x (- (log (/ y x)))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.3e+36) || !(x <= 1.22e+59)) {
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 <= (-4.3d+36)) .or. (.not. (x <= 1.22d+59))) 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 <= -4.3e+36) || !(x <= 1.22e+59)) {
tmp = x * -Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.3e+36) or not (x <= 1.22e+59): tmp = x * -math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.3e+36) || !(x <= 1.22e+59)) 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 <= -4.3e+36) || ~((x <= 1.22e+59))) tmp = x * -log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.3e+36], N[Not[LessEqual[x, 1.22e+59]], $MachinePrecision]], N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.3 \cdot 10^{+36} \lor \neg \left(x \leq 1.22 \cdot 10^{+59}\right):\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -4.30000000000000005e36 or 1.22e59 < x Initial program 70.2%
clear-num70.2%
neg-log74.1%
Applied egg-rr74.1%
Taylor expanded in z around 0 61.5%
associate-*r*61.5%
neg-mul-161.5%
Simplified61.5%
if -4.30000000000000005e36 < x < 1.22e59Initial program 79.2%
Taylor expanded in x around 0 76.1%
mul-1-neg76.1%
Simplified76.1%
Final simplification69.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e+34) (not (<= x 5.4e+57))) (* x (log (/ x y))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e+34) || !(x <= 5.4e+57)) {
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 <= (-1d+34)) .or. (.not. (x <= 5.4d+57))) 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 <= -1e+34) || !(x <= 5.4e+57)) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1e+34) or not (x <= 5.4e+57): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1e+34) || !(x <= 5.4e+57)) 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 <= -1e+34) || ~((x <= 5.4e+57))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e+34], N[Not[LessEqual[x, 5.4e+57]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+34} \lor \neg \left(x \leq 5.4 \cdot 10^{+57}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -9.99999999999999946e33 or 5.3999999999999997e57 < x Initial program 70.2%
Taylor expanded in z around 0 58.5%
if -9.99999999999999946e33 < x < 5.3999999999999997e57Initial program 79.2%
Taylor expanded in x around 0 76.1%
mul-1-neg76.1%
Simplified76.1%
Final simplification68.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 75.3%
Taylor expanded in x around 0 50.3%
mul-1-neg50.3%
Simplified50.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 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.3%
Taylor expanded in x around 0 50.3%
mul-1-neg50.3%
Simplified50.3%
neg-sub050.3%
sub-neg50.3%
add-sqr-sqrt26.1%
sqrt-unprod15.7%
sqr-neg15.7%
sqrt-unprod1.2%
add-sqr-sqrt2.1%
Applied egg-rr2.1%
+-lft-identity2.1%
Simplified2.1%
(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 2024141
(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))