
(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-310) (fma (+ (log (/ -1.0 y)) (log (- x))) (/ 1.0 (/ 1.0 x)) (- z)) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e-310) {
tmp = fma((log((-1.0 / y)) + log(-x)), (1.0 / (1.0 / x)), -z);
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1e-310) tmp = fma(Float64(log(Float64(-1.0 / y)) + log(Float64(-x))), Float64(1.0 / Float64(1.0 / x)), Float64(-z)); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1e-310], N[(N[(N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision] + N[Log[(-x)], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 / x), $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 -1 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(\frac{-1}{y}\right) + \log \left(-x\right), \frac{1}{\frac{1}{x}}, -z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -9.999999999999969e-311Initial program 75.5%
lift--.f64N/A
sub-negN/A
unpow1N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
lower-fma.f64N/A
lower-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lower-/.f64N/A
lower-neg.f6475.5
Applied rewrites75.5%
Taylor expanded in y around -inf
+-commutativeN/A
lower-+.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6499.5
Applied rewrites99.5%
if -9.999999999999969e-311 < y Initial program 79.9%
lift-*.f64N/A
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
sub-negN/A
distribute-rgt-inN/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 2e+296) (- 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 <= 2e+296) {
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 <= 2e+296) {
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 <= 2e+296: 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 <= 2e+296) 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 <= 2e+296) 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, 2e+296], 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 2 \cdot 10^{+296}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.99999999999999996e296 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.2%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6453.7
Applied rewrites53.7%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.99999999999999996e296Initial program 99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (log (- x)) (log (- y)))))
(if (<= x -7.2e+144)
(* x t_0)
(if (<= x -5e-310)
(* z (fma t_0 (/ x z) -1.0))
(- (- (* x (log x)) (* x (log y))) z)))))
double code(double x, double y, double z) {
double t_0 = log(-x) - log(-y);
double tmp;
if (x <= -7.2e+144) {
tmp = x * t_0;
} else if (x <= -5e-310) {
tmp = z * fma(t_0, (x / z), -1.0);
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(log(Float64(-x)) - log(Float64(-y))) tmp = 0.0 if (x <= -7.2e+144) tmp = Float64(x * t_0); elseif (x <= -5e-310) tmp = Float64(z * fma(t_0, Float64(x / z), -1.0)); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.2e+144], N[(x * t$95$0), $MachinePrecision], If[LessEqual[x, -5e-310], N[(z * N[(t$95$0 * N[(x / z), $MachinePrecision] + -1.0), $MachinePrecision]), $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}
t_0 := \log \left(-x\right) - \log \left(-y\right)\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{+144}:\\
\;\;\;\;x \cdot t\_0\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;z \cdot \mathsf{fma}\left(t\_0, \frac{x}{z}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if x < -7.1999999999999995e144Initial program 74.5%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-+.f64N/A
remove-double-negN/A
distribute-frac-neg2N/A
distribute-neg-fracN/A
metadata-evalN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-neg.f64N/A
mul-1-negN/A
log-recN/A
metadata-evalN/A
associate-/r*N/A
remove-double-divN/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6490.0
Applied rewrites90.0%
if -7.1999999999999995e144 < x < -4.999999999999985e-310Initial program 75.8%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6475.7
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6475.7
Applied rewrites75.7%
Taylor expanded in z around inf
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-/.f6471.9
Applied rewrites71.9%
Applied rewrites94.9%
if -4.999999999999985e-310 < x Initial program 79.9%
lift-*.f64N/A
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
sub-negN/A
distribute-rgt-inN/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
Final simplification96.7%
(FPCore (x y z)
:precision binary64
(if (<= x -8.2e+89)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.65e-107)
(- (* x (log (/ x y))) z)
(if (<= x -2e-309) (- z) (- (- (* x (log x)) (* x (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.2e+89) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.65e-107) {
tmp = (x * log((x / y))) - z;
} else if (x <= -2e-309) {
tmp = -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 (x <= (-8.2d+89)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.65d-107)) then
tmp = (x * log((x / y))) - z
else if (x <= (-2d-309)) then
tmp = -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 (x <= -8.2e+89) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.65e-107) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -2e-309) {
tmp = -z;
} else {
tmp = ((x * Math.log(x)) - (x * Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -8.2e+89: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.65e-107: tmp = (x * math.log((x / y))) - z elif x <= -2e-309: tmp = -z else: tmp = ((x * math.log(x)) - (x * math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -8.2e+89) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.65e-107) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -2e-309) tmp = Float64(-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 (x <= -8.2e+89) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.65e-107) tmp = (x * log((x / y))) - z; elseif (x <= -2e-309) tmp = -z; else tmp = ((x * log(x)) - (x * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8.2e+89], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.65e-107], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-309], (-z), 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}\;x \leq -8.2 \cdot 10^{+89}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-107}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if x < -8.1999999999999997e89Initial program 69.7%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-+.f64N/A
remove-double-negN/A
distribute-frac-neg2N/A
distribute-neg-fracN/A
metadata-evalN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-neg.f64N/A
mul-1-negN/A
log-recN/A
metadata-evalN/A
associate-/r*N/A
remove-double-divN/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6481.9
Applied rewrites81.9%
if -8.1999999999999997e89 < x < -1.65000000000000002e-107Initial program 91.1%
if -1.65000000000000002e-107 < x < -1.9999999999999988e-309Initial program 66.1%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6488.4
Applied rewrites88.4%
if -1.9999999999999988e-309 < x Initial program 79.9%
lift-*.f64N/A
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
sub-negN/A
distribute-rgt-inN/A
lower-+.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
Final simplification93.4%
(FPCore (x y z)
:precision binary64
(if (<= x -8.2e+89)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.65e-107)
(- (* x (log (/ x y))) z)
(if (<= x -2e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.2e+89) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.65e-107) {
tmp = (x * log((x / y))) - z;
} else if (x <= -2e-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.2d+89)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.65d-107)) then
tmp = (x * log((x / y))) - z
else if (x <= (-2d-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.2e+89) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.65e-107) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -2e-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.2e+89: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.65e-107: tmp = (x * math.log((x / y))) - z elif x <= -2e-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.2e+89) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.65e-107) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -2e-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.2e+89) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.65e-107) tmp = (x * log((x / y))) - z; elseif (x <= -2e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8.2e+89], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.65e-107], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-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.2 \cdot 10^{+89}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-107}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -8.1999999999999997e89Initial program 69.7%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-+.f64N/A
remove-double-negN/A
distribute-frac-neg2N/A
distribute-neg-fracN/A
metadata-evalN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-neg.f64N/A
mul-1-negN/A
log-recN/A
metadata-evalN/A
associate-/r*N/A
remove-double-divN/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6481.9
Applied rewrites81.9%
if -8.1999999999999997e89 < x < -1.65000000000000002e-107Initial program 91.1%
if -1.65000000000000002e-107 < x < -1.9999999999999988e-309Initial program 66.1%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6488.4
Applied rewrites88.4%
if -1.9999999999999988e-309 < x Initial program 79.9%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f6499.5
Applied rewrites99.5%
Final simplification93.4%
(FPCore (x y z) :precision binary64 (if (<= x -1.65e-107) (- (* x (log (/ x y))) z) (if (<= x -2e-309) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.65e-107) {
tmp = (x * log((x / y))) - z;
} else if (x <= -2e-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 <= (-1.65d-107)) then
tmp = (x * log((x / y))) - z
else if (x <= (-2d-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 <= -1.65e-107) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -2e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.65e-107: tmp = (x * math.log((x / y))) - z elif x <= -2e-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 <= -1.65e-107) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -2e-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 <= -1.65e-107) tmp = (x * log((x / y))) - z; elseif (x <= -2e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.65e-107], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-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 -1.65 \cdot 10^{-107}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.65000000000000002e-107Initial program 81.3%
if -1.65000000000000002e-107 < x < -1.9999999999999988e-309Initial program 66.1%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6488.4
Applied rewrites88.4%
if -1.9999999999999988e-309 < x Initial program 79.9%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f6499.5
Applied rewrites99.5%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e-124) (- z) (if (<= z 8e-46) (* (- x) (log (/ y x))) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e-124) {
tmp = -z;
} else if (z <= 8e-46) {
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 <= (-2.1d-124)) then
tmp = -z
else if (z <= 8d-46) 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 <= -2.1e-124) {
tmp = -z;
} else if (z <= 8e-46) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e-124: tmp = -z elif z <= 8e-46: tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e-124) tmp = Float64(-z); elseif (z <= 8e-46) 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 (z <= -2.1e-124) tmp = -z; elseif (z <= 8e-46) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e-124], (-z), If[LessEqual[z, 8e-46], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{-124}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-46}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -2.1000000000000001e-124 or 8.00000000000000018e-46 < z Initial program 76.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6478.8
Applied rewrites78.8%
if -2.1000000000000001e-124 < z < 8.00000000000000018e-46Initial program 79.0%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
Taylor expanded in z around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6465.5
Applied rewrites65.5%
Final simplification73.9%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e-124) (- z) (if (<= z 8e-46) (* x (log (/ x y))) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e-124) {
tmp = -z;
} else if (z <= 8e-46) {
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 <= (-2.1d-124)) then
tmp = -z
else if (z <= 8d-46) 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 <= -2.1e-124) {
tmp = -z;
} else if (z <= 8e-46) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e-124: tmp = -z elif z <= 8e-46: tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e-124) tmp = Float64(-z); elseif (z <= 8e-46) 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 <= -2.1e-124) tmp = -z; elseif (z <= 8e-46) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e-124], (-z), If[LessEqual[z, 8e-46], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{-124}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-46}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -2.1000000000000001e-124 or 8.00000000000000018e-46 < z Initial program 76.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6478.8
Applied rewrites78.8%
if -2.1000000000000001e-124 < z < 8.00000000000000018e-46Initial program 79.0%
Taylor expanded in z around 0
lower-*.f64N/A
lower-log.f64N/A
lower-/.f6464.1
Applied rewrites64.1%
(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 77.7%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6458.4
Applied rewrites58.4%
(FPCore (x y z) :precision binary64 0.0)
double code(double x, double y, double z) {
return 0.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.0d0
end function
public static double code(double x, double y, double z) {
return 0.0;
}
def code(x, y, z): return 0.0
function code(x, y, z) return 0.0 end
function tmp = code(x, y, z) tmp = 0.0; end
code[x_, y_, z_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 77.7%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
log-prodN/A
lower-+.f64N/A
lower-log.f64N/A
clear-numN/A
lift-/.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-log.f64N/A
clear-numN/A
lift-/.f64N/A
inv-powN/A
pow-powN/A
lower-pow.f64N/A
metadata-evalN/A
metadata-eval77.7
Applied rewrites77.7%
Taylor expanded in z around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.4
Applied rewrites33.4%
Applied rewrites2.7%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 77.7%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6477.5
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6477.5
Applied rewrites77.5%
lift-/.f64N/A
lift-/.f64N/A
remove-double-div77.7
lift-fma.f64N/A
lift-neg.f64N/A
Applied rewrites2.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 2024233
(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))