
(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
(let* ((t_0 (log (- y))) (t_1 (log (- x))))
(if (<= y -5e-310)
(-
(*
x
(/
(- (pow t_1 3.0) (pow t_0 3.0))
(+ (pow t_1 2.0) (+ (pow t_0 2.0) (* t_1 t_0)))))
z)
(- (fma (- (log y)) x (* x (log x))) z))))
double code(double x, double y, double z) {
double t_0 = log(-y);
double t_1 = log(-x);
double tmp;
if (y <= -5e-310) {
tmp = (x * ((pow(t_1, 3.0) - pow(t_0, 3.0)) / (pow(t_1, 2.0) + (pow(t_0, 2.0) + (t_1 * t_0))))) - z;
} else {
tmp = fma(-log(y), x, (x * log(x))) - z;
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(-y)) t_1 = log(Float64(-x)) tmp = 0.0 if (y <= -5e-310) tmp = Float64(Float64(x * Float64(Float64((t_1 ^ 3.0) - (t_0 ^ 3.0)) / Float64((t_1 ^ 2.0) + Float64((t_0 ^ 2.0) + Float64(t_1 * t_0))))) - z); else tmp = Float64(fma(Float64(-log(y)), x, Float64(x * log(x))) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[(-y)], $MachinePrecision]}, Block[{t$95$1 = N[Log[(-x)], $MachinePrecision]}, If[LessEqual[y, -5e-310], N[(N[(x * N[(N[(N[Power[t$95$1, 3.0], $MachinePrecision] - N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[t$95$1, 2.0], $MachinePrecision] + N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[((-N[Log[y], $MachinePrecision]) * x + N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(-y\right)\\
t_1 := \log \left(-x\right)\\
\mathbf{if}\;y \leq -5 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \frac{{t\_1}^{3} - {t\_0}^{3}}{{t\_1}^{2} + \left({t\_0}^{2} + t\_1 \cdot t\_0\right)} - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\log y, x, x \cdot \log x\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 76.4%
lift-log.f64N/A
lift-/.f64N/A
frac-2negN/A
log-divN/A
flip3--N/A
lower-/.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-log.f64N/A
lower-neg.f64N/A
lower-pow.f64N/A
lower-log.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites99.2%
if -4.999999999999985e-310 < y Initial program 74.5%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6478.2
Applied rewrites78.2%
lift-*.f64N/A
lift-neg.f64N/A
neg-sub0N/A
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lift-log.f64N/A
lift-log.f64N/A
associate--r-N/A
neg-sub0N/A
lift-neg.f64N/A
distribute-rgt-outN/A
lift-*.f64N/A
lower-fma.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- z)
(if (<= t_0 5e+296) (- (* x (log (/ (/ 1.0 y) (/ 1.0 x)))) 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 <= 5e+296) {
tmp = (x * log(((1.0 / y) / (1.0 / x)))) - 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 <= 5e+296) {
tmp = (x * Math.log(((1.0 / y) / (1.0 / x)))) - 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 <= 5e+296: tmp = (x * math.log(((1.0 / y) / (1.0 / x)))) - 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 <= 5e+296) tmp = Float64(Float64(x * log(Float64(Float64(1.0 / y) / Float64(1.0 / x)))) - 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 <= 5e+296) tmp = (x * log(((1.0 / y) / (1.0 / x)))) - 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, 5e+296], N[(N[(x * N[Log[N[(N[(1.0 / y), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 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 5 \cdot 10^{+296}:\\
\;\;\;\;x \cdot \log \left(\frac{\frac{1}{y}}{\frac{1}{x}}\right) - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.0000000000000001e296 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.2%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6452.0
Applied rewrites52.0%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.0000000000000001e296Initial program 99.8%
lift-/.f64N/A
clear-numN/A
div-invN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 5e+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 <= 5e+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 <= 5e+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 <= 5e+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 <= 5e+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 <= 5e+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, 5e+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 5 \cdot 10^{+296}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.0000000000000001e296 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.2%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6452.0
Applied rewrites52.0%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.0000000000000001e296Initial program 99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (log (- x)) (log (- y)))))
(if (<= x -3.5e+167)
(* x t_0)
(if (<= x -2e-310)
(* z (fma t_0 (/ x z) -1.0))
(- (fma (- (log y)) x (* x (log x))) z)))))
double code(double x, double y, double z) {
double t_0 = log(-x) - log(-y);
double tmp;
if (x <= -3.5e+167) {
tmp = x * t_0;
} else if (x <= -2e-310) {
tmp = z * fma(t_0, (x / z), -1.0);
} else {
tmp = fma(-log(y), x, (x * log(x))) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(log(Float64(-x)) - log(Float64(-y))) tmp = 0.0 if (x <= -3.5e+167) tmp = Float64(x * t_0); elseif (x <= -2e-310) tmp = Float64(z * fma(t_0, Float64(x / z), -1.0)); else tmp = Float64(fma(Float64(-log(y)), x, Float64(x * log(x))) - 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, -3.5e+167], N[(x * t$95$0), $MachinePrecision], If[LessEqual[x, -2e-310], N[(z * N[(t$95$0 * N[(x / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[((-N[Log[y], $MachinePrecision]) * x + N[(x * N[Log[x], $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 -3.5 \cdot 10^{+167}:\\
\;\;\;\;x \cdot t\_0\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;z \cdot \mathsf{fma}\left(t\_0, \frac{x}{z}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\log y, x, x \cdot \log x\right) - z\\
\end{array}
\end{array}
if x < -3.49999999999999987e167Initial program 62.9%
Taylor expanded in x around inf
distribute-rgt-inN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
distribute-rgt-inN/A
+-commutativeN/A
lower-*.f64N/A
log-recN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f640.0
Applied rewrites0.0%
Applied rewrites94.0%
if -3.49999999999999987e167 < x < -1.999999999999994e-310Initial program 80.4%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6460.2
Applied rewrites60.2%
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-/.f6479.3
Applied rewrites79.3%
Applied rewrites97.8%
if -1.999999999999994e-310 < x Initial program 74.5%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6478.2
Applied rewrites78.2%
lift-*.f64N/A
lift-neg.f64N/A
neg-sub0N/A
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lift-log.f64N/A
lift-log.f64N/A
associate--r-N/A
neg-sub0N/A
lift-neg.f64N/A
distribute-rgt-outN/A
lift-*.f64N/A
lower-fma.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(if (<= x -7.2e+165)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.5e-173)
(- (* (- x) (log (/ y x))) z)
(if (<= x -2e-304) (- z) (- (fma (- (log y)) x (* x (log x))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7.2e+165) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.5e-173) {
tmp = (-x * log((y / x))) - z;
} else if (x <= -2e-304) {
tmp = -z;
} else {
tmp = fma(-log(y), x, (x * log(x))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -7.2e+165) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.5e-173) tmp = Float64(Float64(Float64(-x) * log(Float64(y / x))) - z); elseif (x <= -2e-304) tmp = Float64(-z); else tmp = Float64(fma(Float64(-log(y)), x, Float64(x * log(x))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -7.2e+165], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.5e-173], N[(N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-304], (-z), N[(N[((-N[Log[y], $MachinePrecision]) * x + N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{+165}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-173}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-304}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\log y, x, x \cdot \log x\right) - z\\
\end{array}
\end{array}
if x < -7.1999999999999996e165Initial program 62.9%
Taylor expanded in x around inf
distribute-rgt-inN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
distribute-rgt-inN/A
+-commutativeN/A
lower-*.f64N/A
log-recN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f640.0
Applied rewrites0.0%
Applied rewrites94.0%
if -7.1999999999999996e165 < x < -1.5000000000000001e-173Initial program 91.7%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6492.5
Applied rewrites92.5%
if -1.5000000000000001e-173 < x < -1.99999999999999994e-304Initial program 50.8%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6496.8
Applied rewrites96.8%
if -1.99999999999999994e-304 < x Initial program 74.5%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6478.2
Applied rewrites78.2%
lift-*.f64N/A
lift-neg.f64N/A
neg-sub0N/A
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lift-log.f64N/A
lift-log.f64N/A
associate--r-N/A
neg-sub0N/A
lift-neg.f64N/A
distribute-rgt-outN/A
lift-*.f64N/A
lower-fma.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Final simplification96.6%
(FPCore (x y z)
:precision binary64
(if (<= x -7.2e+165)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.5e-173)
(- (* (- x) (log (/ y x))) z)
(if (<= x -2e-304) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7.2e+165) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.5e-173) {
tmp = (-x * log((y / x))) - z;
} else if (x <= -2e-304) {
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 <= (-7.2d+165)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.5d-173)) then
tmp = (-x * log((y / x))) - z
else if (x <= (-2d-304)) 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 <= -7.2e+165) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.5e-173) {
tmp = (-x * Math.log((y / x))) - z;
} else if (x <= -2e-304) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7.2e+165: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.5e-173: tmp = (-x * math.log((y / x))) - z elif x <= -2e-304: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7.2e+165) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.5e-173) tmp = Float64(Float64(Float64(-x) * log(Float64(y / x))) - z); elseif (x <= -2e-304) 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 <= -7.2e+165) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.5e-173) tmp = (-x * log((y / x))) - z; elseif (x <= -2e-304) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7.2e+165], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.5e-173], N[(N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-304], (-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 -7.2 \cdot 10^{+165}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-173}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-304}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -7.1999999999999996e165Initial program 62.9%
Taylor expanded in x around inf
distribute-rgt-inN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
distribute-rgt-inN/A
+-commutativeN/A
lower-*.f64N/A
log-recN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f640.0
Applied rewrites0.0%
Applied rewrites94.0%
if -7.1999999999999996e165 < x < -1.5000000000000001e-173Initial program 91.7%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6492.5
Applied rewrites92.5%
if -1.5000000000000001e-173 < x < -1.99999999999999994e-304Initial program 50.8%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6496.8
Applied rewrites96.8%
if -1.99999999999999994e-304 < x Initial program 74.5%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
Final simplification96.6%
(FPCore (x y z) :precision binary64 (if (<= x -1.5e-173) (- (* (- x) (log (/ y x))) z) (if (<= x -2e-304) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.5e-173) {
tmp = (-x * log((y / x))) - z;
} else if (x <= -2e-304) {
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.5d-173)) then
tmp = (-x * log((y / x))) - z
else if (x <= (-2d-304)) 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.5e-173) {
tmp = (-x * Math.log((y / x))) - z;
} else if (x <= -2e-304) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.5e-173: tmp = (-x * math.log((y / x))) - z elif x <= -2e-304: 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.5e-173) tmp = Float64(Float64(Float64(-x) * log(Float64(y / x))) - z); elseif (x <= -2e-304) 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.5e-173) tmp = (-x * log((y / x))) - z; elseif (x <= -2e-304) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.5e-173], N[(N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-304], (-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.5 \cdot 10^{-173}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-304}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.5000000000000001e-173Initial program 83.4%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6483.9
Applied rewrites83.9%
if -1.5000000000000001e-173 < x < -1.99999999999999994e-304Initial program 50.8%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6496.8
Applied rewrites96.8%
if -1.99999999999999994e-304 < x Initial program 74.5%
lift-log.f64N/A
lift-/.f64N/A
log-divN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
Final simplification93.0%
(FPCore (x y z) :precision binary64 (if (<= z -2.9e+26) (- z) (if (<= z 3.2e-62) (* (- x) (log (/ y x))) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.9e+26) {
tmp = -z;
} else if (z <= 3.2e-62) {
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.9d+26)) then
tmp = -z
else if (z <= 3.2d-62) 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.9e+26) {
tmp = -z;
} else if (z <= 3.2e-62) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.9e+26: tmp = -z elif z <= 3.2e-62: tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.9e+26) tmp = Float64(-z); elseif (z <= 3.2e-62) 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.9e+26) tmp = -z; elseif (z <= 3.2e-62) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.9e+26], (-z), If[LessEqual[z, 3.2e-62], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{+26}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-62}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -2.9e26 or 3.20000000000000021e-62 < z Initial program 73.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6476.7
Applied rewrites76.7%
if -2.9e26 < z < 3.20000000000000021e-62Initial program 77.8%
lift-log.f64N/A
lift-/.f64N/A
clear-numN/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-/.f6480.6
Applied rewrites80.6%
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.f6467.7
Applied rewrites67.7%
Final simplification72.6%
(FPCore (x y z) :precision binary64 (if (<= z -2.9e+26) (- z) (if (<= z 3.2e-62) (* x (log (/ x y))) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.9e+26) {
tmp = -z;
} else if (z <= 3.2e-62) {
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.9d+26)) then
tmp = -z
else if (z <= 3.2d-62) 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.9e+26) {
tmp = -z;
} else if (z <= 3.2e-62) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.9e+26: tmp = -z elif z <= 3.2e-62: tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.9e+26) tmp = Float64(-z); elseif (z <= 3.2e-62) 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.9e+26) tmp = -z; elseif (z <= 3.2e-62) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.9e+26], (-z), If[LessEqual[z, 3.2e-62], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{+26}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-62}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -2.9e26 or 3.20000000000000021e-62 < z Initial program 73.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6476.7
Applied rewrites76.7%
if -2.9e26 < z < 3.20000000000000021e-62Initial program 77.8%
Taylor expanded in z around 0
lower-*.f64N/A
lower-log.f64N/A
lower-/.f6464.9
Applied rewrites64.9%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return 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.5%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6450.4
Applied rewrites50.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 2024222
(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))