
(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 (* 3.0 (log (/ (cbrt x) (cbrt y))))) z))
double code(double x, double y, double z) {
return (x * (3.0 * log((cbrt(x) / cbrt(y))))) - z;
}
public static double code(double x, double y, double z) {
return (x * (3.0 * Math.log((Math.cbrt(x) / Math.cbrt(y))))) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(3.0 * log(Float64(cbrt(x) / cbrt(y))))) - z) end
code[x_, y_, z_] := N[(N[(x * N[(3.0 * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(3 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z
\end{array}
Initial program 74.1%
add-cube-cbrt74.1%
log-prod74.0%
pow274.0%
Applied egg-rr74.0%
log-pow74.0%
distribute-lft1-in74.0%
metadata-eval74.0%
Simplified74.0%
cbrt-div99.6%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+307))) (- z) (- t_0 z))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e+307)) {
tmp = -z;
} else {
tmp = t_0 - 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) || !(t_0 <= 1e+307)) {
tmp = -z;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e+307): tmp = -z else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e+307)) tmp = Float64(-z); else tmp = Float64(t_0 - 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) || ~((t_0 <= 1e+307))) tmp = -z; else tmp = t_0 - 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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+307]], $MachinePrecision]], (-z), N[(t$95$0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{+307}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 9.99999999999999986e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.5%
remove-double-neg5.5%
sub0-neg5.5%
associate--r-5.5%
neg-sub05.5%
distribute-rgt-neg-in5.5%
neg-sub05.5%
log-div44.7%
associate-+l-44.7%
neg-sub044.7%
+-commutative44.7%
sub-neg44.7%
log-div13.2%
fma-udef13.2%
Simplified13.2%
Taylor expanded in x around 0 41.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 9.99999999999999986e306Initial program 99.5%
Final simplification83.9%
(FPCore (x y z)
:precision binary64
(if (<= x -3.3e+164)
(* x (- (log (- x)) (log (- y))))
(if (<= x -5.6e-193)
(- (* x (log (/ x y))) z)
(if (<= x 2.4e-162)
(- z)
(if (<= x 4.5e+150)
(- (fma x (log (/ y x)) z))
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.3e+164) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -5.6e-193) {
tmp = (x * log((x / y))) - z;
} else if (x <= 2.4e-162) {
tmp = -z;
} else if (x <= 4.5e+150) {
tmp = -fma(x, log((y / x)), z);
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -3.3e+164) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -5.6e-193) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= 2.4e-162) tmp = Float64(-z); elseif (x <= 4.5e+150) tmp = Float64(-fma(x, log(Float64(y / x)), z)); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -3.3e+164], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.6e-193], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 2.4e-162], (-z), If[LessEqual[x, 4.5e+150], (-N[(x * N[Log[N[(y / x), $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 -3.3 \cdot 10^{+164}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-193}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-162}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+150}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -3.29999999999999995e164Initial program 44.2%
Taylor expanded in z around 0 40.2%
frac-2neg40.2%
log-div91.0%
Applied egg-rr91.0%
if -3.29999999999999995e164 < x < -5.6000000000000005e-193Initial program 88.7%
if -5.6000000000000005e-193 < x < 2.4000000000000002e-162Initial program 55.9%
remove-double-neg55.9%
sub0-neg55.9%
associate--r-55.9%
neg-sub055.9%
distribute-rgt-neg-in55.9%
neg-sub055.9%
log-div49.9%
associate-+l-49.9%
neg-sub049.9%
+-commutative49.9%
sub-neg49.9%
log-div49.2%
fma-udef49.2%
Simplified49.2%
Taylor expanded in x around 0 91.2%
if 2.4000000000000002e-162 < x < 4.5e150Initial program 90.0%
remove-double-neg90.0%
sub0-neg90.0%
associate--r-90.0%
neg-sub090.0%
distribute-rgt-neg-in90.0%
neg-sub090.0%
log-div99.7%
associate-+l-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
log-div92.7%
fma-udef92.7%
Simplified92.7%
if 4.5e150 < x Initial program 67.8%
Taylor expanded in z around 0 66.5%
log-div97.4%
Applied egg-rr97.4%
Final simplification91.7%
(FPCore (x y z)
:precision binary64
(if (<= x -5.2e+162)
(* x (- (log (- x)) (log (- y))))
(if (<= x -8.5e-193)
(- (* x (log (/ x y))) z)
(if (<= x -1e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.2e+162) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -8.5e-193) {
tmp = (x * log((x / y))) - z;
} else if (x <= -1e-308) {
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 <= (-5.2d+162)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-8.5d-193)) then
tmp = (x * log((x / y))) - z
else if (x <= (-1d-308)) 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 <= -5.2e+162) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -8.5e-193) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -1e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.2e+162: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -8.5e-193: tmp = (x * math.log((x / y))) - z elif x <= -1e-308: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.2e+162) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -8.5e-193) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -1e-308) 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 <= -5.2e+162) tmp = x * (log(-x) - log(-y)); elseif (x <= -8.5e-193) tmp = (x * log((x / y))) - z; elseif (x <= -1e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.2e+162], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -8.5e-193], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-308], (-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 -5.2 \cdot 10^{+162}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-193}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -5.2e162Initial program 44.2%
Taylor expanded in z around 0 40.2%
frac-2neg40.2%
log-div91.0%
Applied egg-rr91.0%
if -5.2e162 < x < -8.50000000000000004e-193Initial program 88.7%
if -8.50000000000000004e-193 < x < -9.9999999999999991e-309Initial program 54.2%
remove-double-neg54.2%
sub0-neg54.2%
associate--r-54.2%
neg-sub054.2%
distribute-rgt-neg-in54.2%
neg-sub054.2%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div50.9%
fma-udef50.9%
Simplified50.9%
Taylor expanded in x around 0 91.7%
if -9.9999999999999991e-309 < x Initial program 76.6%
log-div50.9%
Applied egg-rr99.5%
Final simplification94.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (fma x (log (/ y x)) z))))
(if (<= x -9e-193)
t_0
(if (<= x 2.7e-162)
(- z)
(if (<= x 9.6e+147) t_0 (* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double t_0 = -fma(x, log((y / x)), z);
double tmp;
if (x <= -9e-193) {
tmp = t_0;
} else if (x <= 2.7e-162) {
tmp = -z;
} else if (x <= 9.6e+147) {
tmp = t_0;
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(-fma(x, log(Float64(y / x)), z)) tmp = 0.0 if (x <= -9e-193) tmp = t_0; elseif (x <= 2.7e-162) tmp = Float64(-z); elseif (x <= 9.6e+147) tmp = t_0; else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] + z), $MachinePrecision])}, If[LessEqual[x, -9e-193], t$95$0, If[LessEqual[x, 2.7e-162], (-z), If[LessEqual[x, 9.6e+147], t$95$0, N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{if}\;x \leq -9 \cdot 10^{-193}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-162}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 9.6 \cdot 10^{+147}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -8.9999999999999997e-193 or 2.69999999999999984e-162 < x < 9.60000000000000007e147Initial program 82.3%
remove-double-neg82.3%
sub0-neg82.3%
associate--r-82.3%
neg-sub082.3%
distribute-rgt-neg-in82.3%
neg-sub082.3%
log-div40.9%
associate-+l-40.9%
neg-sub040.9%
+-commutative40.9%
sub-neg40.9%
log-div84.2%
fma-udef84.2%
Simplified84.2%
if -8.9999999999999997e-193 < x < 2.69999999999999984e-162Initial program 55.9%
remove-double-neg55.9%
sub0-neg55.9%
associate--r-55.9%
neg-sub055.9%
distribute-rgt-neg-in55.9%
neg-sub055.9%
log-div49.9%
associate-+l-49.9%
neg-sub049.9%
+-commutative49.9%
sub-neg49.9%
log-div49.2%
fma-udef49.2%
Simplified49.2%
Taylor expanded in x around 0 91.2%
if 9.60000000000000007e147 < x Initial program 67.8%
Taylor expanded in z around 0 66.5%
log-div97.4%
Applied egg-rr97.4%
Final simplification87.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x (log (/ x y))) z)))
(if (<= x -6.2e-192)
t_0
(if (<= x 3.1e-164)
(- z)
(if (<= x 1.46e+153) t_0 (* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double t_0 = (x * log((x / y))) - z;
double tmp;
if (x <= -6.2e-192) {
tmp = t_0;
} else if (x <= 3.1e-164) {
tmp = -z;
} else if (x <= 1.46e+153) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x * log((x / y))) - z
if (x <= (-6.2d-192)) then
tmp = t_0
else if (x <= 3.1d-164) then
tmp = -z
else if (x <= 1.46d+153) then
tmp = t_0
else
tmp = x * (log(x) - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * Math.log((x / y))) - z;
double tmp;
if (x <= -6.2e-192) {
tmp = t_0;
} else if (x <= 3.1e-164) {
tmp = -z;
} else if (x <= 1.46e+153) {
tmp = t_0;
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = (x * math.log((x / y))) - z tmp = 0 if x <= -6.2e-192: tmp = t_0 elif x <= 3.1e-164: tmp = -z elif x <= 1.46e+153: tmp = t_0 else: tmp = x * (math.log(x) - math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(Float64(x * log(Float64(x / y))) - z) tmp = 0.0 if (x <= -6.2e-192) tmp = t_0; elseif (x <= 3.1e-164) tmp = Float64(-z); elseif (x <= 1.46e+153) tmp = t_0; 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))) - z; tmp = 0.0; if (x <= -6.2e-192) tmp = t_0; elseif (x <= 3.1e-164) tmp = -z; elseif (x <= 1.46e+153) tmp = t_0; else tmp = x * (log(x) - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[x, -6.2e-192], t$95$0, If[LessEqual[x, 3.1e-164], (-z), If[LessEqual[x, 1.46e+153], t$95$0, 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) - z\\
\mathbf{if}\;x \leq -6.2 \cdot 10^{-192}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-164}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 1.46 \cdot 10^{+153}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -6.2000000000000001e-192 or 3.1000000000000001e-164 < x < 1.4600000000000001e153Initial program 82.5%
if -6.2000000000000001e-192 < x < 3.1000000000000001e-164Initial program 55.1%
remove-double-neg55.1%
sub0-neg55.1%
associate--r-55.1%
neg-sub055.1%
distribute-rgt-neg-in55.1%
neg-sub055.1%
log-div49.1%
associate-+l-49.1%
neg-sub049.1%
+-commutative49.1%
sub-neg49.1%
log-div50.1%
fma-udef50.1%
Simplified50.1%
Taylor expanded in x around 0 91.0%
if 1.4600000000000001e153 < x Initial program 67.8%
Taylor expanded in z around 0 66.5%
log-div97.4%
Applied egg-rr97.4%
Final simplification86.5%
(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 71.5%
frac-2neg36.7%
log-div51.7%
Applied egg-rr99.5%
if -1.000000000000002e-309 < y Initial program 76.6%
log-div50.9%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.52e-84) (not (<= z 3.7e+23))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.52e-84) || !(z <= 3.7e+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 ((z <= (-1.52d-84)) .or. (.not. (z <= 3.7d+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 ((z <= -1.52e-84) || !(z <= 3.7e+23)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.52e-84) or not (z <= 3.7e+23): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.52e-84) || !(z <= 3.7e+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 ((z <= -1.52e-84) || ~((z <= 3.7e+23))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.52e-84], N[Not[LessEqual[z, 3.7e+23]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.52 \cdot 10^{-84} \lor \neg \left(z \leq 3.7 \cdot 10^{+23}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.5199999999999999e-84 or 3.70000000000000013e23 < z Initial program 75.1%
remove-double-neg75.1%
sub0-neg75.1%
associate--r-75.1%
neg-sub075.1%
distribute-rgt-neg-in75.1%
neg-sub075.1%
log-div56.7%
associate-+l-56.7%
neg-sub056.7%
+-commutative56.7%
sub-neg56.7%
log-div74.7%
fma-udef74.7%
Simplified74.7%
Taylor expanded in x around 0 71.6%
if -1.5199999999999999e-84 < z < 3.70000000000000013e23Initial program 73.1%
Taylor expanded in z around 0 60.1%
Final simplification66.1%
(FPCore (x y z) :precision binary64 (if (<= x -4.2e-41) (* x (- (log (/ y x)))) (if (<= x 3.3e+103) (- z) (* x (log (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.2e-41) {
tmp = x * -log((y / x));
} else if (x <= 3.3e+103) {
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 <= (-4.2d-41)) then
tmp = x * -log((y / x))
else if (x <= 3.3d+103) 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 <= -4.2e-41) {
tmp = x * -Math.log((y / x));
} else if (x <= 3.3e+103) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.2e-41: tmp = x * -math.log((y / x)) elif x <= 3.3e+103: tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.2e-41) tmp = Float64(x * Float64(-log(Float64(y / x)))); elseif (x <= 3.3e+103) 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 <= -4.2e-41) tmp = x * -log((y / x)); elseif (x <= 3.3e+103) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.2e-41], N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[x, 3.3e+103], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{-41}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+103}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -4.20000000000000025e-41Initial program 70.5%
remove-double-neg70.5%
sub0-neg70.5%
associate--r-70.5%
neg-sub070.5%
distribute-rgt-neg-in70.5%
neg-sub070.5%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div75.6%
fma-udef75.6%
Simplified75.6%
Taylor expanded in x around inf 0.0%
log-rec0.0%
neg-mul-10.0%
neg-mul-10.0%
sub-neg0.0%
log-div55.9%
Simplified55.9%
if -4.20000000000000025e-41 < x < 3.30000000000000009e103Initial program 75.8%
remove-double-neg75.8%
sub0-neg75.8%
associate--r-75.8%
neg-sub075.8%
distribute-rgt-neg-in75.8%
neg-sub075.8%
log-div58.9%
associate-+l-58.9%
neg-sub058.9%
+-commutative58.9%
sub-neg58.9%
log-div73.0%
fma-udef73.0%
Simplified73.0%
Taylor expanded in x around 0 72.1%
if 3.30000000000000009e103 < x Initial program 73.7%
Taylor expanded in z around 0 66.8%
Final simplification67.1%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 74.1%
remove-double-neg74.1%
sub0-neg74.1%
associate--r-74.1%
neg-sub074.1%
distribute-rgt-neg-in74.1%
neg-sub074.1%
log-div50.9%
associate-+l-50.9%
neg-sub050.9%
+-commutative50.9%
sub-neg50.9%
log-div73.8%
fma-udef73.8%
Simplified73.8%
Taylor expanded in x around 0 48.8%
Final simplification48.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 2023311
(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))