
(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 (<= x -4e-310) (- (* x (+ (log (pow (cbrt x) 2.0)) (- (log (- (cbrt x))) (log (- y))))) z) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= -4e-310) {
tmp = (x * (log(pow(cbrt(x), 2.0)) + (log(-cbrt(x)) - log(-y)))) - z;
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4e-310) {
tmp = (x * (Math.log(Math.pow(Math.cbrt(x), 2.0)) + (Math.log(-Math.cbrt(x)) - Math.log(-y)))) - z;
} else {
tmp = ((x * Math.log(x)) - (x * Math.log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4e-310) tmp = Float64(Float64(x * Float64(log((cbrt(x) ^ 2.0)) + Float64(log(Float64(-cbrt(x))) - log(Float64(-y))))) - z); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4e-310], N[(N[(x * N[(N[Log[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] + N[(N[Log[(-N[Power[x, 1/3], $MachinePrecision])], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left({\left(\sqrt[3]{x}\right)}^{2}\right) + \left(\log \left(-\sqrt[3]{x}\right) - \log \left(-y\right)\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if x < -3.999999999999988e-310Initial program 67.5%
add-cube-cbrt67.5%
*-un-lft-identity67.5%
times-frac67.5%
log-prod91.6%
pow291.6%
Applied egg-rr91.6%
frac-2neg91.6%
log-div99.6%
Applied egg-rr99.6%
if -3.999999999999988e-310 < x Initial program 81.3%
log-div99.4%
Applied egg-rr99.4%
sub-neg99.4%
distribute-rgt-in99.5%
Applied egg-rr99.5%
Final simplification99.6%
(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 1e+301) (fma t_0 x (- z)) (- z)))))
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 <= 1e+301) {
tmp = fma(t_0, x, -z);
} else {
tmp = -z;
}
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 <= 1e+301) tmp = fma(t_0, x, Float64(-z)); else tmp = Float64(-z); 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, 1e+301], N[(t$95$0 * x + (-z)), $MachinePrecision], (-z)]]]]
\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 10^{+301}:\\
\;\;\;\;\mathsf{fma}\left(t_0, x, -z\right)\\
\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.3%
Taylor expanded in x around 0 38.3%
neg-mul-138.3%
Simplified38.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000005e301Initial program 99.4%
*-commutative99.4%
fma-neg99.4%
Applied egg-rr99.4%
Final simplification82.5%
(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.3%
Taylor expanded in x around 0 38.3%
neg-mul-138.3%
Simplified38.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000005e301Initial program 99.4%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(if (<= x -1.9e+70)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.15e-72)
(- (* x (log (/ x y))) z)
(if (<= x 8.2e-96)
(- z)
(if (<= x 1.9e+215)
(- (- z) (* x (log (/ y x))))
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+70) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.15e-72) {
tmp = (x * log((x / y))) - z;
} else if (x <= 8.2e-96) {
tmp = -z;
} else if (x <= 1.9e+215) {
tmp = -z - (x * log((y / x)));
} else {
tmp = x * (log(x) - log(y));
}
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.9d+70)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-2.15d-72)) then
tmp = (x * log((x / y))) - z
else if (x <= 8.2d-96) then
tmp = -z
else if (x <= 1.9d+215) then
tmp = -z - (x * log((y / x)))
else
tmp = x * (log(x) - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+70) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -2.15e-72) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= 8.2e-96) {
tmp = -z;
} else if (x <= 1.9e+215) {
tmp = -z - (x * Math.log((y / x)));
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.9e+70: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -2.15e-72: tmp = (x * math.log((x / y))) - z elif x <= 8.2e-96: tmp = -z elif x <= 1.9e+215: tmp = -z - (x * math.log((y / x))) else: tmp = x * (math.log(x) - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.9e+70) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.15e-72) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= 8.2e-96) tmp = Float64(-z); elseif (x <= 1.9e+215) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.9e+70) tmp = x * (log(-x) - log(-y)); elseif (x <= -2.15e-72) tmp = (x * log((x / y))) - z; elseif (x <= 8.2e-96) tmp = -z; elseif (x <= 1.9e+215) tmp = -z - (x * log((y / x))); else tmp = x * (log(x) - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.9e+70], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.15e-72], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 8.2e-96], (-z), If[LessEqual[x, 1.9e+215], 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 -1.9 \cdot 10^{+70}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-72}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-96}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+215}:\\
\;\;\;\;\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 < -1.8999999999999999e70Initial program 50.5%
Taylor expanded in z around 0 45.0%
frac-2neg45.0%
log-div84.7%
Applied egg-rr84.7%
if -1.8999999999999999e70 < x < -2.1499999999999999e-72Initial program 95.5%
if -2.1499999999999999e-72 < x < 8.20000000000000048e-96Initial program 70.5%
Taylor expanded in x around 0 85.9%
neg-mul-185.9%
Simplified85.9%
if 8.20000000000000048e-96 < x < 1.89999999999999984e215Initial program 90.1%
clear-num49.7%
neg-log52.5%
Applied egg-rr94.5%
if 1.89999999999999984e215 < x Initial program 67.2%
Taylor expanded in z around 0 67.2%
log-div98.4%
Applied egg-rr98.4%
Final simplification89.8%
(FPCore (x y z)
:precision binary64
(if (<= x -9.3e+64)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.15e-72)
(- (* x (log (/ x y))) z)
(if (<= x -2e-295) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.3e+64) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.15e-72) {
tmp = (x * log((x / y))) - z;
} else if (x <= -2e-295) {
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 <= (-9.3d+64)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-2.15d-72)) then
tmp = (x * log((x / y))) - z
else if (x <= (-2d-295)) 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 <= -9.3e+64) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -2.15e-72) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -2e-295) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9.3e+64: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -2.15e-72: tmp = (x * math.log((x / y))) - z elif x <= -2e-295: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9.3e+64) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.15e-72) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -2e-295) 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 <= -9.3e+64) tmp = x * (log(-x) - log(-y)); elseif (x <= -2.15e-72) tmp = (x * log((x / y))) - z; elseif (x <= -2e-295) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9.3e+64], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.15e-72], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -2e-295], (-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 -9.3 \cdot 10^{+64}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-72}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-295}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -9.2999999999999997e64Initial program 50.5%
Taylor expanded in z around 0 45.0%
frac-2neg45.0%
log-div84.7%
Applied egg-rr84.7%
if -9.2999999999999997e64 < x < -2.1499999999999999e-72Initial program 95.5%
if -2.1499999999999999e-72 < x < -2.00000000000000012e-295Initial program 68.2%
Taylor expanded in x around 0 85.8%
neg-mul-185.8%
Simplified85.8%
if -2.00000000000000012e-295 < x Initial program 81.3%
log-div99.4%
Applied egg-rr99.4%
Final simplification92.8%
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5d-310)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-310: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-310) tmp = (x * (log(-x) - log(-y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 67.5%
frac-2neg31.4%
log-div51.2%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 81.3%
log-div99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= x -4e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= -4e-310) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-4d-310)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = ((x * log(x)) - (x * log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4e-310) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = ((x * Math.log(x)) - (x * Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4e-310: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = ((x * math.log(x)) - (x * math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4e-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4e-310) tmp = (x * (log(-x) - log(-y))) - z; else tmp = ((x * log(x)) - (x * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if x < -3.999999999999988e-310Initial program 67.5%
frac-2neg31.4%
log-div51.2%
Applied egg-rr99.6%
if -3.999999999999988e-310 < x Initial program 81.3%
log-div99.4%
Applied egg-rr99.4%
sub-neg99.4%
distribute-rgt-in99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -6.5e+21) (not (<= x 4.2e-11))) (* (- x) (log (/ y x))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.5e+21) || !(x <= 4.2e-11)) {
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 <= (-6.5d+21)) .or. (.not. (x <= 4.2d-11))) 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 <= -6.5e+21) || !(x <= 4.2e-11)) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.5e+21) or not (x <= 4.2e-11): tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.5e+21) || !(x <= 4.2e-11)) tmp = Float64(Float64(-x) * log(Float64(y / x))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6.5e+21) || ~((x <= 4.2e-11))) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.5e+21], N[Not[LessEqual[x, 4.2e-11]], $MachinePrecision]], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{+21} \lor \neg \left(x \leq 4.2 \cdot 10^{-11}\right):\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -6.5e21 or 4.1999999999999997e-11 < x Initial program 68.3%
Taylor expanded in z around 0 57.1%
clear-num57.1%
neg-log59.9%
Applied egg-rr59.9%
if -6.5e21 < x < 4.1999999999999997e-11Initial program 78.4%
Taylor expanded in x around 0 78.0%
neg-mul-178.0%
Simplified78.0%
Final simplification69.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -6.4e+21) (not (<= x 4.2e-11))) (* x (log (/ x y))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.4e+21) || !(x <= 4.2e-11)) {
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 <= (-6.4d+21)) .or. (.not. (x <= 4.2d-11))) 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 <= -6.4e+21) || !(x <= 4.2e-11)) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.4e+21) or not (x <= 4.2e-11): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.4e+21) || !(x <= 4.2e-11)) 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 <= -6.4e+21) || ~((x <= 4.2e-11))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.4e+21], N[Not[LessEqual[x, 4.2e-11]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{+21} \lor \neg \left(x \leq 4.2 \cdot 10^{-11}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -6.4e21 or 4.1999999999999997e-11 < x Initial program 68.3%
Taylor expanded in z around 0 57.1%
if -6.4e21 < x < 4.1999999999999997e-11Initial program 78.4%
Taylor expanded in x around 0 78.0%
neg-mul-178.0%
Simplified78.0%
Final simplification68.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 73.6%
Taylor expanded in x around 0 48.9%
neg-mul-148.9%
Simplified48.9%
Final simplification48.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 z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 73.6%
flip--45.4%
clear-num45.4%
fma-def45.4%
pow245.4%
Applied egg-rr45.4%
Taylor expanded in x around 0 48.8%
associate-/r/48.9%
metadata-eval48.9%
neg-mul-148.9%
neg-sub048.9%
metadata-eval48.9%
sub-neg48.9%
add-sqr-sqrt21.3%
sqrt-unprod14.3%
sqr-neg14.3%
sqrt-unprod1.2%
add-sqr-sqrt2.3%
metadata-eval2.3%
Applied egg-rr2.3%
+-lft-identity2.3%
Simplified2.3%
Final simplification2.3%
(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 2023200
(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))