
(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 12 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 (- (* x (* (log (/ (cbrt x) (cbrt y))) 3.0)) z))
double code(double x, double y, double z) {
return (x * (log((cbrt(x) / cbrt(y))) * 3.0)) - z;
}
public static double code(double x, double y, double z) {
return (x * (Math.log((Math.cbrt(x) / Math.cbrt(y))) * 3.0)) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(log(Float64(cbrt(x) / cbrt(y))) * 3.0)) - z) end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z
\end{array}
Initial program 74.6%
add-cube-cbrt74.6%
associate-*l*74.6%
log-prod74.6%
pow274.6%
metadata-eval74.6%
log-pow74.6%
metadata-eval74.6%
Applied egg-rr74.6%
distribute-rgt1-in74.6%
metadata-eval74.6%
*-commutative74.6%
Simplified74.6%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (<= t_1 (- INFINITY))
(- z)
(if (<= t_1 1e+265) (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 <= 1e+265) {
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 <= 1e+265) 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, 1e+265], 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 10^{+265}:\\
\;\;\;\;\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.0%
Taylor expanded in x around 0 57.9%
neg-mul-157.9%
Simplified57.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000007e265Initial program 99.5%
*-commutative99.5%
fma-neg99.5%
Applied egg-rr99.5%
if 1.00000000000000007e265 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.7%
add-cube-cbrt8.7%
associate-*l*8.7%
log-prod8.8%
pow28.8%
metadata-eval8.8%
log-pow8.8%
metadata-eval8.8%
Applied egg-rr8.8%
distribute-rgt1-in8.8%
metadata-eval8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in z around 0 8.8%
*-commutative8.8%
unpow1/38.8%
associate-*r*8.8%
unpow1/38.7%
log-pow8.7%
associate-*r*8.7%
metadata-eval8.7%
*-lft-identity8.7%
*-commutative8.7%
Simplified8.7%
log-div52.2%
Applied egg-rr52.2%
Final simplification87.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- z)
(if (<= t_0 1e+265) (- 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 <= 1e+265) {
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 <= 1e+265) {
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 <= 1e+265: 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 <= 1e+265) 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 <= 1e+265) 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, 1e+265], 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 10^{+265}:\\
\;\;\;\;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.0%
Taylor expanded in x around 0 57.9%
neg-mul-157.9%
Simplified57.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000007e265Initial program 99.5%
if 1.00000000000000007e265 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.7%
add-cube-cbrt8.7%
associate-*l*8.7%
log-prod8.8%
pow28.8%
metadata-eval8.8%
log-pow8.8%
metadata-eval8.8%
Applied egg-rr8.8%
distribute-rgt1-in8.8%
metadata-eval8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in z around 0 8.8%
*-commutative8.8%
unpow1/38.8%
associate-*r*8.8%
unpow1/38.7%
log-pow8.7%
associate-*r*8.7%
metadata-eval8.7%
*-lft-identity8.7%
*-commutative8.7%
Simplified8.7%
log-div52.2%
Applied egg-rr52.2%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 4e+269) (- 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 <= 4e+269) {
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 <= 4e+269) {
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 <= 4e+269: 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 <= 4e+269) 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 <= 4e+269) 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, 4e+269], 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 4 \cdot 10^{+269}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4.0000000000000002e269 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.6%
Taylor expanded in x around 0 48.5%
neg-mul-148.5%
Simplified48.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.0000000000000002e269Initial program 99.5%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (if (<= y -1e-310) (fma (- (log (- x)) (log (- y))) x (- z)) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e-310) {
tmp = fma((log(-x) - log(-y)), x, -z);
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1e-310) tmp = fma(Float64(log(Float64(-x)) - log(Float64(-y))), x, Float64(-z)); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1e-310], N[(N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision] * x + (-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 -1 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(-x\right) - \log \left(-y\right), x, -z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -9.999999999999969e-311Initial program 76.8%
*-commutative76.8%
fma-neg76.8%
Applied egg-rr76.8%
frac-2neg41.6%
log-div55.2%
Applied egg-rr99.6%
if -9.999999999999969e-311 < y Initial program 72.6%
log-div50.7%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))))
(if (<= x -3.4e+99)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.4e-186)
(- (* x t_0) z)
(if (<= x 1.6e-139)
(- z)
(if (<= x 1.85e+166) (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 tmp;
if (x <= -3.4e+99) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.4e-186) {
tmp = (x * t_0) - z;
} else if (x <= 1.6e-139) {
tmp = -z;
} else if (x <= 1.85e+166) {
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)) tmp = 0.0 if (x <= -3.4e+99) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.4e-186) tmp = Float64(Float64(x * t_0) - z); elseif (x <= 1.6e-139) tmp = Float64(-z); elseif (x <= 1.85e+166) 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]}, If[LessEqual[x, -3.4e+99], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.4e-186], N[(N[(x * t$95$0), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 1.6e-139], (-z), If[LessEqual[x, 1.85e+166], 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)\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{+99}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-186}:\\
\;\;\;\;x \cdot t_0 - z\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-139}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+166}:\\
\;\;\;\;\mathsf{fma}\left(t_0, x, -z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -3.39999999999999984e99Initial program 67.0%
add-cube-cbrt67.0%
associate-*l*67.0%
log-prod67.0%
pow267.0%
metadata-eval67.0%
log-pow67.0%
metadata-eval67.0%
Applied egg-rr67.0%
distribute-rgt1-in67.0%
metadata-eval67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in z around 0 58.8%
*-commutative58.8%
unpow1/358.7%
associate-*r*58.8%
unpow1/358.8%
log-pow58.7%
associate-*r*58.8%
metadata-eval58.8%
*-lft-identity58.8%
*-commutative58.8%
Simplified58.8%
frac-2neg58.8%
log-div88.4%
Applied egg-rr88.4%
if -3.39999999999999984e99 < x < -1.39999999999999992e-186Initial program 91.0%
if -1.39999999999999992e-186 < x < 1.6e-139Initial program 58.4%
Taylor expanded in x around 0 95.5%
neg-mul-195.5%
Simplified95.5%
if 1.6e-139 < x < 1.85000000000000011e166Initial program 89.2%
*-commutative89.2%
fma-neg89.3%
Applied egg-rr89.3%
if 1.85000000000000011e166 < x Initial program 61.9%
add-cube-cbrt61.8%
associate-*l*61.8%
log-prod61.9%
pow261.9%
metadata-eval61.9%
log-pow61.9%
metadata-eval61.9%
Applied egg-rr61.9%
distribute-rgt1-in61.9%
metadata-eval61.9%
*-commutative61.9%
Simplified61.9%
Taylor expanded in z around 0 55.6%
*-commutative55.6%
unpow1/355.7%
associate-*r*55.7%
unpow1/355.6%
log-pow55.7%
associate-*r*55.7%
metadata-eval55.7%
*-lft-identity55.7%
*-commutative55.7%
Simplified55.7%
log-div90.7%
Applied egg-rr90.7%
Final simplification91.2%
(FPCore (x y z)
:precision binary64
(if (<= x -3e+98)
(* x (- (log (- x)) (log (- y))))
(if (<= x -4.4e-184)
(- (* x (log (/ x y))) z)
(if (<= x -1e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3e+98) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -4.4e-184) {
tmp = (x * log((x / y))) - z;
} else if (x <= -1e-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 <= (-3d+98)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-4.4d-184)) then
tmp = (x * log((x / y))) - z
else if (x <= (-1d-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 <= -3e+98) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -4.4e-184) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -1e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3e+98: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -4.4e-184: tmp = (x * math.log((x / y))) - z elif x <= -1e-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 <= -3e+98) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -4.4e-184) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -1e-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 <= -3e+98) tmp = x * (log(-x) - log(-y)); elseif (x <= -4.4e-184) tmp = (x * log((x / y))) - z; elseif (x <= -1e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3e+98], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.4e-184], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-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 \cdot 10^{+98}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -4.4 \cdot 10^{-184}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -3.0000000000000001e98Initial program 67.0%
add-cube-cbrt67.0%
associate-*l*67.0%
log-prod67.0%
pow267.0%
metadata-eval67.0%
log-pow67.0%
metadata-eval67.0%
Applied egg-rr67.0%
distribute-rgt1-in67.0%
metadata-eval67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in z around 0 58.8%
*-commutative58.8%
unpow1/358.7%
associate-*r*58.8%
unpow1/358.8%
log-pow58.7%
associate-*r*58.8%
metadata-eval58.8%
*-lft-identity58.8%
*-commutative58.8%
Simplified58.8%
frac-2neg58.8%
log-div88.4%
Applied egg-rr88.4%
if -3.0000000000000001e98 < x < -4.39999999999999984e-184Initial program 91.0%
if -4.39999999999999984e-184 < x < -1.000000000000002e-309Initial program 60.4%
Taylor expanded in x around 0 96.0%
neg-mul-196.0%
Simplified96.0%
if -1.000000000000002e-309 < x Initial program 72.6%
log-div50.7%
Applied egg-rr99.5%
Final simplification95.3%
(FPCore (x y z)
:precision binary64
(if (<= x -1.08e+99)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.55e-183)
(- (* x (* 3.0 (log (cbrt (/ x y))))) z)
(if (<= x -1e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.08e+99) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.55e-183) {
tmp = (x * (3.0 * log(cbrt((x / y))))) - z;
} else if (x <= -1e-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 <= -1.08e+99) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.55e-183) {
tmp = (x * (3.0 * Math.log(Math.cbrt((x / y))))) - z;
} else if (x <= -1e-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.08e+99) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.55e-183) tmp = Float64(Float64(x * Float64(3.0 * log(cbrt(Float64(x / y))))) - z); elseif (x <= -1e-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, -1.08e+99], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.55e-183], N[(N[(x * N[(3.0 * N[Log[N[Power[N[(x / y), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-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.08 \cdot 10^{+99}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-183}:\\
\;\;\;\;x \cdot \left(3 \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.08e99Initial program 67.0%
add-cube-cbrt67.0%
associate-*l*67.0%
log-prod67.0%
pow267.0%
metadata-eval67.0%
log-pow67.0%
metadata-eval67.0%
Applied egg-rr67.0%
distribute-rgt1-in67.0%
metadata-eval67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in z around 0 58.8%
*-commutative58.8%
unpow1/358.7%
associate-*r*58.8%
unpow1/358.8%
log-pow58.7%
associate-*r*58.8%
metadata-eval58.8%
*-lft-identity58.8%
*-commutative58.8%
Simplified58.8%
frac-2neg58.8%
log-div88.4%
Applied egg-rr88.4%
if -1.08e99 < x < -1.55e-183Initial program 91.0%
add-cube-cbrt91.0%
associate-*l*91.0%
log-prod91.0%
pow291.0%
metadata-eval91.0%
log-pow91.0%
metadata-eval91.0%
Applied egg-rr91.0%
distribute-rgt1-in91.0%
metadata-eval91.0%
*-commutative91.0%
Simplified91.0%
if -1.55e-183 < x < -1.000000000000002e-309Initial program 60.4%
Taylor expanded in x around 0 96.0%
neg-mul-196.0%
Simplified96.0%
if -1.000000000000002e-309 < x Initial program 72.6%
log-div50.7%
Applied egg-rr99.5%
Final simplification95.3%
(FPCore (x y z) :precision binary64 (if (<= y -1e-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 <= -1e-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 <= (-1d-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 <= -1e-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 <= -1e-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 <= -1e-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 <= -1e-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, -1e-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 -1 \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 < -9.999999999999969e-311Initial program 76.8%
frac-2neg41.6%
log-div55.2%
Applied egg-rr99.5%
if -9.999999999999969e-311 < y Initial program 72.6%
log-div50.7%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -0.29) (not (<= x 1.15e+22))) (* x (log (/ x y))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -0.29) || !(x <= 1.15e+22)) {
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 <= (-0.29d0)) .or. (.not. (x <= 1.15d+22))) 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 <= -0.29) || !(x <= 1.15e+22)) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -0.29) or not (x <= 1.15e+22): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -0.29) || !(x <= 1.15e+22)) 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 <= -0.29) || ~((x <= 1.15e+22))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -0.29], N[Not[LessEqual[x, 1.15e+22]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.29 \lor \neg \left(x \leq 1.15 \cdot 10^{+22}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -0.28999999999999998 or 1.1500000000000001e22 < x Initial program 76.4%
add-cube-cbrt76.4%
associate-*l*76.4%
log-prod76.4%
pow276.4%
metadata-eval76.4%
log-pow76.4%
metadata-eval76.4%
Applied egg-rr76.4%
distribute-rgt1-in76.4%
metadata-eval76.4%
*-commutative76.4%
Simplified76.4%
Taylor expanded in z around 0 61.1%
*-commutative61.1%
unpow1/361.1%
associate-*r*61.3%
unpow1/361.2%
log-pow61.1%
associate-*r*61.3%
metadata-eval61.3%
*-lft-identity61.3%
*-commutative61.3%
Simplified61.3%
if -0.28999999999999998 < x < 1.1500000000000001e22Initial program 72.9%
Taylor expanded in x around 0 78.1%
neg-mul-178.1%
Simplified78.1%
Final simplification69.7%
(FPCore (x y z) :precision binary64 (if (<= x -0.0045) (* (- x) (log (/ y x))) (if (<= x 4.5e+23) (- z) (* x (log (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.0045) {
tmp = -x * log((y / x));
} else if (x <= 4.5e+23) {
tmp = -z;
} else {
tmp = x * log((x / 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 <= (-0.0045d0)) then
tmp = -x * log((y / x))
else if (x <= 4.5d+23) then
tmp = -z
else
tmp = x * log((x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -0.0045) {
tmp = -x * Math.log((y / x));
} else if (x <= 4.5e+23) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.0045: tmp = -x * math.log((y / x)) elif x <= 4.5e+23: tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.0045) tmp = Float64(Float64(-x) * log(Float64(y / x))); elseif (x <= 4.5e+23) tmp = Float64(-z); else tmp = Float64(x * log(Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.0045) tmp = -x * log((y / x)); elseif (x <= 4.5e+23) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.0045], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.5e+23], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0045:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+23}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -0.00449999999999999966Initial program 76.5%
add-cube-cbrt76.5%
associate-*l*76.5%
log-prod76.5%
pow276.5%
metadata-eval76.5%
log-pow76.5%
metadata-eval76.5%
Applied egg-rr76.5%
distribute-rgt1-in76.5%
metadata-eval76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in z around 0 62.7%
*-commutative62.7%
unpow1/362.7%
associate-*r*62.9%
unpow1/362.9%
log-pow62.8%
associate-*r*62.9%
metadata-eval62.9%
*-lft-identity62.9%
*-commutative62.9%
Simplified62.9%
clear-num62.9%
neg-log64.7%
Applied egg-rr64.7%
if -0.00449999999999999966 < x < 4.49999999999999979e23Initial program 72.9%
Taylor expanded in x around 0 78.1%
neg-mul-178.1%
Simplified78.1%
if 4.49999999999999979e23 < x Initial program 76.3%
add-cube-cbrt76.3%
associate-*l*76.3%
log-prod76.3%
pow276.3%
metadata-eval76.3%
log-pow76.3%
metadata-eval76.3%
Applied egg-rr76.3%
distribute-rgt1-in76.3%
metadata-eval76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in z around 0 59.1%
*-commutative59.1%
unpow1/359.3%
associate-*r*59.4%
unpow1/359.2%
log-pow59.2%
associate-*r*59.4%
metadata-eval59.4%
*-lft-identity59.4%
*-commutative59.4%
Simplified59.4%
Final simplification70.2%
(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 74.6%
Taylor expanded in x around 0 47.9%
neg-mul-147.9%
Simplified47.9%
Final simplification47.9%
(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 2023290
(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))