
(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 (- (* 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 78.3%
add-cube-cbrt78.3%
associate-*l*78.3%
log-prod78.2%
pow278.2%
metadata-eval78.2%
log-pow78.2%
metadata-eval78.2%
Applied egg-rr78.2%
distribute-rgt1-in78.2%
metadata-eval78.2%
*-commutative78.2%
Simplified78.2%
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 2e+305) (fma t_0 x (- z)) (* x (- (log x) (log y)))))))
double code(double x, double y, double z) {
double t_0 = log((x / y));
double t_1 = x * t_0;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -z;
} else if (t_1 <= 2e+305) {
tmp = fma(t_0, x, -z);
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(x / y)) t_1 = Float64(x * t_0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-z); elseif (t_1 <= 2e+305) tmp = fma(t_0, x, Float64(-z)); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-z), If[LessEqual[t$95$1, 2e+305], N[(t$95$0 * x + (-z)), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot t_0\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-z\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;\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 5.2%
Taylor expanded in x around 0 46.3%
neg-mul-146.3%
Simplified46.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.9999999999999999e305Initial program 99.8%
*-commutative99.8%
fma-neg99.8%
Applied egg-rr99.8%
if 1.9999999999999999e305 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.7%
Taylor expanded in z around 0 7.7%
log-div48.6%
Applied egg-rr48.6%
Final simplification87.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(- z)
(if (<= t_0 2e+305) (- t_0 z) (* x (- (log x) (log y)))))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = -z;
} else if (t_0 <= 2e+305) {
tmp = t_0 - z;
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = -z;
} else if (t_0 <= 2e+305) {
tmp = t_0 - z;
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if t_0 <= -math.inf: tmp = -z elif t_0 <= 2e+305: tmp = t_0 - z else: tmp = x * (math.log(x) - math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(-z); elseif (t_0 <= 2e+305) tmp = Float64(t_0 - z); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (t_0 <= -Inf) tmp = -z; elseif (t_0 <= 2e+305) tmp = t_0 - z; else tmp = x * (log(x) - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], (-z), If[LessEqual[t$95$0, 2e+305], N[(t$95$0 - z), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;-z\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;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 5.2%
Taylor expanded in x around 0 46.3%
neg-mul-146.3%
Simplified46.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.9999999999999999e305Initial program 99.8%
if 1.9999999999999999e305 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.7%
Taylor expanded in z around 0 7.7%
log-div48.6%
Applied egg-rr48.6%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 2e+305) (- 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+305) {
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+305) {
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+305: 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+305) 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+305) 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+305], 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^{+305}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.9999999999999999e305 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.5%
Taylor expanded in x around 0 44.4%
neg-mul-144.4%
Simplified44.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.9999999999999999e305Initial program 99.8%
Final simplification87.0%
(FPCore (x y z)
:precision binary64
(if (<= x -4.7e+141)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.36e-149)
(- (* x (log (/ x y))) z)
(if (<= x 7.8e-146)
(- z)
(if (<= x 1.55e+232)
(- (* (- x) (log (/ y x))) z)
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.7e+141) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.36e-149) {
tmp = (x * log((x / y))) - z;
} else if (x <= 7.8e-146) {
tmp = -z;
} else if (x <= 1.55e+232) {
tmp = (-x * log((y / x))) - z;
} 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 <= (-4.7d+141)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.36d-149)) then
tmp = (x * log((x / y))) - z
else if (x <= 7.8d-146) then
tmp = -z
else if (x <= 1.55d+232) then
tmp = (-x * log((y / x))) - z
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 <= -4.7e+141) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.36e-149) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= 7.8e-146) {
tmp = -z;
} else if (x <= 1.55e+232) {
tmp = (-x * Math.log((y / x))) - z;
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.7e+141: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.36e-149: tmp = (x * math.log((x / y))) - z elif x <= 7.8e-146: tmp = -z elif x <= 1.55e+232: tmp = (-x * math.log((y / x))) - z else: tmp = x * (math.log(x) - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.7e+141) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.36e-149) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= 7.8e-146) tmp = Float64(-z); elseif (x <= 1.55e+232) tmp = Float64(Float64(Float64(-x) * log(Float64(y / x))) - z); 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 <= -4.7e+141) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.36e-149) tmp = (x * log((x / y))) - z; elseif (x <= 7.8e-146) tmp = -z; elseif (x <= 1.55e+232) tmp = (-x * log((y / x))) - z; else tmp = x * (log(x) - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.7e+141], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.36e-149], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 7.8e-146], (-z), If[LessEqual[x, 1.55e+232], N[(N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7 \cdot 10^{+141}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.36 \cdot 10^{-149}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-146}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+232}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -4.69999999999999979e141Initial program 53.4%
Taylor expanded in z around 0 47.1%
frac-2neg47.1%
log-div89.8%
Applied egg-rr89.8%
if -4.69999999999999979e141 < x < -1.36e-149Initial program 96.0%
if -1.36e-149 < x < 7.80000000000000005e-146Initial program 70.0%
Taylor expanded in x around 0 90.5%
neg-mul-190.5%
Simplified90.5%
if 7.80000000000000005e-146 < x < 1.54999999999999992e232Initial program 88.1%
clear-num45.6%
neg-log46.7%
Applied egg-rr89.2%
if 1.54999999999999992e232 < x Initial program 57.1%
Taylor expanded in z around 0 53.7%
log-div95.2%
Applied egg-rr95.2%
Final simplification91.4%
(FPCore (x y z)
:precision binary64
(if (<= x -4.1e+139)
(* x (- (log (- x)) (log (- y))))
(if (<= x -5.6e-149)
(- (* x (log (/ x y))) z)
(if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.1e+139) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -5.6e-149) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-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 <= (-4.1d+139)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-5.6d-149)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-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 <= -4.1e+139) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -5.6e-149) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.1e+139: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -5.6e-149: tmp = (x * math.log((x / y))) - z elif x <= -5e-309: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.1e+139) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -5.6e-149) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-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 <= -4.1e+139) tmp = x * (log(-x) - log(-y)); elseif (x <= -5.6e-149) tmp = (x * log((x / y))) - z; elseif (x <= -5e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.1e+139], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.6e-149], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-309], (-z), N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{+139}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-149}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -4.1000000000000002e139Initial program 53.4%
Taylor expanded in z around 0 47.1%
frac-2neg47.1%
log-div89.8%
Applied egg-rr89.8%
if -4.1000000000000002e139 < x < -5.5999999999999997e-149Initial program 96.0%
if -5.5999999999999997e-149 < x < -4.9999999999999995e-309Initial program 69.9%
Taylor expanded in x around 0 91.4%
neg-mul-191.4%
Simplified91.4%
if -4.9999999999999995e-309 < x Initial program 79.7%
log-div47.4%
Applied egg-rr99.4%
Final simplification96.3%
(FPCore (x y z) :precision binary64 (if (<= y -1e-309) (- (* 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-309) {
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-309)) 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-309) {
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-309: 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-309) 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-309) 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-309], 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^{-309}:\\
\;\;\;\;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 < -1.000000000000002e-309Initial program 76.7%
frac-2neg30.6%
log-div42.5%
Applied egg-rr99.6%
if -1.000000000000002e-309 < y Initial program 79.7%
log-div47.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= z -3.5e-29) (- z) (if (<= z 8.6e-84) (* (- x) (log (/ y x))) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.5e-29) {
tmp = -z;
} else if (z <= 8.6e-84) {
tmp = -x * log((y / x));
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.5d-29)) then
tmp = -z
else if (z <= 8.6d-84) then
tmp = -x * log((y / x))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.5e-29) {
tmp = -z;
} else if (z <= 8.6e-84) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.5e-29: tmp = -z elif z <= 8.6e-84: tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.5e-29) tmp = Float64(-z); elseif (z <= 8.6e-84) 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 <= -3.5e-29) tmp = -z; elseif (z <= 8.6e-84) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.5e-29], (-z), If[LessEqual[z, 8.6e-84], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{-29}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 8.6 \cdot 10^{-84}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.4999999999999997e-29 or 8.6000000000000007e-84 < z Initial program 80.7%
Taylor expanded in x around 0 77.3%
neg-mul-177.3%
Simplified77.3%
if -3.4999999999999997e-29 < z < 8.6000000000000007e-84Initial program 74.3%
Taylor expanded in z around 0 62.3%
clear-num62.2%
neg-log62.9%
Applied egg-rr62.9%
Final simplification71.8%
(FPCore (x y z) :precision binary64 (if (<= z -3e-29) (- z) (if (<= z 2.7e-84) (* x (log (/ x y))) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3e-29) {
tmp = -z;
} else if (z <= 2.7e-84) {
tmp = x * log((x / y));
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3d-29)) then
tmp = -z
else if (z <= 2.7d-84) then
tmp = x * log((x / y))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3e-29) {
tmp = -z;
} else if (z <= 2.7e-84) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3e-29: tmp = -z elif z <= 2.7e-84: tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3e-29) tmp = Float64(-z); elseif (z <= 2.7e-84) tmp = Float64(x * log(Float64(x / y))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3e-29) tmp = -z; elseif (z <= 2.7e-84) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3e-29], (-z), If[LessEqual[z, 2.7e-84], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-29}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{-84}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.0000000000000003e-29 or 2.6999999999999999e-84 < z Initial program 80.7%
Taylor expanded in x around 0 77.3%
neg-mul-177.3%
Simplified77.3%
if -3.0000000000000003e-29 < z < 2.6999999999999999e-84Initial program 74.3%
Taylor expanded in z around 0 62.3%
Final simplification71.5%
(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 78.3%
Taylor expanded in x around 0 55.8%
neg-mul-155.8%
Simplified55.8%
Final simplification55.8%
(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 2023268
(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))