
(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 -5e-311) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5d-311)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-311: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-311) tmp = (x * (log(-x) - log(-y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 77.1%
frac-2neg77.1%
log-div99.4%
Applied egg-rr99.4%
if -5.00000000000023e-311 < y Initial program 73.9%
log-div99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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 2e+294) (fma t_0 x (- 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 <= 2e+294) {
tmp = fma(t_0, x, -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 <= 2e+294) tmp = fma(t_0, x, 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, 2e+294], N[(t$95$0 * x + (-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 2 \cdot 10^{+294}:\\
\;\;\;\;\mathsf{fma}\left(t_0, x, -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 4.3%
Taylor expanded in x around 0 43.6%
neg-mul-143.6%
Simplified43.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2.00000000000000013e294Initial program 99.7%
*-commutative99.7%
fma-neg99.8%
Applied egg-rr99.8%
if 2.00000000000000013e294 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 12.5%
Taylor expanded in z around 0 12.5%
log-div56.8%
Applied egg-rr49.1%
Final simplification85.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- z)
(if (<= t_0 2e+294) (- 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 <= 2e+294) {
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 <= 2e+294) {
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 <= 2e+294: 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 <= 2e+294) 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 <= 2e+294) 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, 2e+294], 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 2 \cdot 10^{+294}:\\
\;\;\;\;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 4.3%
Taylor expanded in x around 0 43.6%
neg-mul-143.6%
Simplified43.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 2.00000000000000013e294Initial program 99.7%
if 2.00000000000000013e294 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 12.5%
Taylor expanded in z around 0 12.5%
log-div56.8%
Applied egg-rr49.1%
Final simplification85.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 1e+301) (- t_0 z) (- z)))))
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 <= 1e+301) {
tmp = t_0 - z;
} else {
tmp = -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) {
tmp = -z;
} else if (t_0 <= 1e+301) {
tmp = t_0 - z;
} else {
tmp = -z;
}
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 <= 1e+301: tmp = t_0 - z else: tmp = -z 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 <= 1e+301) tmp = Float64(t_0 - z); else tmp = Float64(-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) tmp = -z; elseif (t_0 <= 1e+301) tmp = t_0 - z; else tmp = -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[LessEqual[t$95$0, (-Infinity)], (-z), If[LessEqual[t$95$0, 1e+301], N[(t$95$0 - z), $MachinePrecision], (-z)]]]
\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 10^{+301}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.00000000000000005e301 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.0%
Taylor expanded in x around 0 42.5%
neg-mul-142.5%
Simplified42.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000005e301Initial program 99.7%
Final simplification85.0%
(FPCore (x y z)
:precision binary64
(if (<= x -6.8e+172)
(* x (- (log (- x)) (log (- y))))
(if (<= x -6.8e-150)
(fma (log (/ x y)) x (- z))
(if (<= x 6.6e-170)
(- z)
(if (<= x 1.65e+164)
(- (- z) (* x (log (/ y x))))
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.8e+172) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -6.8e-150) {
tmp = fma(log((x / y)), x, -z);
} else if (x <= 6.6e-170) {
tmp = -z;
} else if (x <= 1.65e+164) {
tmp = -z - (x * log((y / x)));
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -6.8e+172) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -6.8e-150) tmp = fma(log(Float64(x / y)), x, Float64(-z)); elseif (x <= 6.6e-170) tmp = Float64(-z); elseif (x <= 1.65e+164) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -6.8e+172], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6.8e-150], N[(N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision] * x + (-z)), $MachinePrecision], If[LessEqual[x, 6.6e-170], (-z), If[LessEqual[x, 1.65e+164], N[((-z) - N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+172}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -6.8 \cdot 10^{-150}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(\frac{x}{y}\right), x, -z\right)\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{-170}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+164}:\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -6.7999999999999996e172Initial program 60.5%
Taylor expanded in z around 0 57.3%
frac-2neg60.5%
log-div99.1%
Applied egg-rr95.8%
if -6.7999999999999996e172 < x < -6.79999999999999999e-150Initial program 90.0%
*-commutative90.0%
fma-neg90.0%
Applied egg-rr90.0%
if -6.79999999999999999e-150 < x < 6.60000000000000007e-170Initial program 62.4%
Taylor expanded in x around 0 88.5%
neg-mul-188.5%
Simplified88.5%
if 6.60000000000000007e-170 < x < 1.64999999999999998e164Initial program 83.4%
clear-num46.8%
neg-log48.1%
Applied egg-rr84.6%
if 1.64999999999999998e164 < x Initial program 61.8%
Taylor expanded in z around 0 58.7%
log-div99.3%
Applied egg-rr96.2%
Final simplification89.9%
(FPCore (x y z)
:precision binary64
(if (<= x -3.6e+175)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1e-152)
(fma (log (/ x y)) x (- z))
(if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e+175) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1e-152) {
tmp = fma(log((x / y)), x, -z);
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -3.6e+175) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1e-152) tmp = fma(log(Float64(x / y)), x, Float64(-z)); elseif (x <= -5e-309) 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, -3.6e+175], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-152], N[(N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision] * x + (-z)), $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 -3.6 \cdot 10^{+175}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-152}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(\frac{x}{y}\right), x, -z\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 < -3.60000000000000034e175Initial program 60.5%
Taylor expanded in z around 0 57.3%
frac-2neg60.5%
log-div99.1%
Applied egg-rr95.8%
if -3.60000000000000034e175 < x < -1.00000000000000007e-152Initial program 90.0%
*-commutative90.0%
fma-neg90.0%
Applied egg-rr90.0%
if -1.00000000000000007e-152 < x < -4.9999999999999995e-309Initial program 55.3%
Taylor expanded in x around 0 88.3%
neg-mul-188.3%
Simplified88.3%
if -4.9999999999999995e-309 < x Initial program 73.9%
log-div99.5%
Applied egg-rr99.5%
Final simplification95.1%
(FPCore (x y z)
:precision binary64
(if (<= x -2.15e+175)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.55e-148)
(- (* x (* (log (cbrt (/ x y))) 3.0)) z)
(if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e+175) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.55e-148) {
tmp = (x * (log(cbrt((x / y))) * 3.0)) - z;
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e+175) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.55e-148) {
tmp = (x * (Math.log(Math.cbrt((x / y))) * 3.0)) - z;
} else if (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 <= -2.15e+175) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.55e-148) tmp = Float64(Float64(x * Float64(log(cbrt(Float64(x / y))) * 3.0)) - z); elseif (x <= -5e-309) 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.15e+175], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.55e-148], N[(N[(x * N[(N[Log[N[Power[N[(x / y), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - z), $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 -2.15 \cdot 10^{+175}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-148}:\\
\;\;\;\;x \cdot \left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot 3\right) - z\\
\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 < -2.14999999999999992e175Initial program 60.5%
Taylor expanded in z around 0 57.3%
frac-2neg60.5%
log-div99.1%
Applied egg-rr95.8%
if -2.14999999999999992e175 < x < -1.5500000000000001e-148Initial program 90.0%
add-cube-cbrt90.0%
associate-*l*90.0%
log-prod90.1%
pow290.1%
metadata-eval90.1%
log-pow90.1%
metadata-eval90.1%
Applied egg-rr90.1%
distribute-rgt1-in90.1%
metadata-eval90.1%
*-commutative90.1%
Simplified90.1%
if -1.5500000000000001e-148 < x < -4.9999999999999995e-309Initial program 55.3%
Taylor expanded in x around 0 88.3%
neg-mul-188.3%
Simplified88.3%
if -4.9999999999999995e-309 < x Initial program 73.9%
log-div99.5%
Applied egg-rr99.5%
Final simplification95.1%
(FPCore (x y z)
:precision binary64
(if (<= z -3.5e-9)
(- z)
(if (or (<= z 1.3e-116) (and (not (<= z 5.8e-7)) (<= z 1.9e+61)))
(* x (- (log (/ y x))))
(- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.5e-9) {
tmp = -z;
} else if ((z <= 1.3e-116) || (!(z <= 5.8e-7) && (z <= 1.9e+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 (z <= (-3.5d-9)) then
tmp = -z
else if ((z <= 1.3d-116) .or. (.not. (z <= 5.8d-7)) .and. (z <= 1.9d+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 (z <= -3.5e-9) {
tmp = -z;
} else if ((z <= 1.3e-116) || (!(z <= 5.8e-7) && (z <= 1.9e+61))) {
tmp = x * -Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.5e-9: tmp = -z elif (z <= 1.3e-116) or (not (z <= 5.8e-7) and (z <= 1.9e+61)): tmp = x * -math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.5e-9) tmp = Float64(-z); elseif ((z <= 1.3e-116) || (!(z <= 5.8e-7) && (z <= 1.9e+61))) 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 (z <= -3.5e-9) tmp = -z; elseif ((z <= 1.3e-116) || (~((z <= 5.8e-7)) && (z <= 1.9e+61))) tmp = x * -log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.5e-9], (-z), If[Or[LessEqual[z, 1.3e-116], And[N[Not[LessEqual[z, 5.8e-7]], $MachinePrecision], LessEqual[z, 1.9e+61]]], N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{-9}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-116} \lor \neg \left(z \leq 5.8 \cdot 10^{-7}\right) \land z \leq 1.9 \cdot 10^{+61}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.4999999999999999e-9 or 1.3e-116 < z < 5.7999999999999995e-7 or 1.89999999999999998e61 < z Initial program 72.5%
Taylor expanded in x around 0 73.7%
neg-mul-173.7%
Simplified73.7%
if -3.4999999999999999e-9 < z < 1.3e-116 or 5.7999999999999995e-7 < z < 1.89999999999999998e61Initial program 78.8%
Taylor expanded in z around 0 65.9%
clear-num65.9%
neg-log67.9%
Applied egg-rr67.9%
Final simplification70.9%
(FPCore (x y z)
:precision binary64
(if (<= z -3e-7)
(- z)
(if (or (<= z 1.15e-116) (and (not (<= z 1.45e-5)) (<= z 2.3e+60)))
(* x (log (/ x y)))
(- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3e-7) {
tmp = -z;
} else if ((z <= 1.15e-116) || (!(z <= 1.45e-5) && (z <= 2.3e+60))) {
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 (z <= (-3d-7)) then
tmp = -z
else if ((z <= 1.15d-116) .or. (.not. (z <= 1.45d-5)) .and. (z <= 2.3d+60)) 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 (z <= -3e-7) {
tmp = -z;
} else if ((z <= 1.15e-116) || (!(z <= 1.45e-5) && (z <= 2.3e+60))) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3e-7: tmp = -z elif (z <= 1.15e-116) or (not (z <= 1.45e-5) and (z <= 2.3e+60)): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3e-7) tmp = Float64(-z); elseif ((z <= 1.15e-116) || (!(z <= 1.45e-5) && (z <= 2.3e+60))) 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 (z <= -3e-7) tmp = -z; elseif ((z <= 1.15e-116) || (~((z <= 1.45e-5)) && (z <= 2.3e+60))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3e-7], (-z), If[Or[LessEqual[z, 1.15e-116], And[N[Not[LessEqual[z, 1.45e-5]], $MachinePrecision], LessEqual[z, 2.3e+60]]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-7}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-116} \lor \neg \left(z \leq 1.45 \cdot 10^{-5}\right) \land z \leq 2.3 \cdot 10^{+60}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -2.9999999999999999e-7 or 1.15000000000000001e-116 < z < 1.45e-5 or 2.30000000000000017e60 < z Initial program 72.5%
Taylor expanded in x around 0 73.7%
neg-mul-173.7%
Simplified73.7%
if -2.9999999999999999e-7 < z < 1.15000000000000001e-116 or 1.45e-5 < z < 2.30000000000000017e60Initial program 78.8%
Taylor expanded in z around 0 65.9%
Final simplification70.0%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return 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.6%
Taylor expanded in x around 0 45.6%
neg-mul-145.6%
Simplified45.6%
Final simplification45.6%
(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 2023171
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))