\[x \cdot \log \left(\frac{x}{y}\right) - z
\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-308}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(\frac{-1}{y}\right), x, x \cdot \log \left(-x\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - \log y\right) \cdot x - z\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
↓
(FPCore (x y z)
:precision binary64
(if (<= y -1e-308)
(- (fma (log (/ -1.0 y)) x (* x (log (- x)))) z)
(- (* (- (log x) (log y)) x) z)))
double code(double x, double y, double z) {
return (x * log((x / y))) - z;
}
↓
double code(double x, double y, double z) {
double tmp;
if (y <= -1e-308) {
tmp = fma(log((-1.0 / y)), x, (x * log(-x))) - z;
} else {
tmp = ((log(x) - log(y)) * x) - z;
}
return tmp;
}
function code(x, y, z)
return Float64(Float64(x * log(Float64(x / y))) - z)
end
↓
function code(x, y, z)
tmp = 0.0
if (y <= -1e-308)
tmp = Float64(fma(log(Float64(-1.0 / y)), x, Float64(x * log(Float64(-x)))) - z);
else
tmp = Float64(Float64(Float64(log(x) - log(y)) * x) - z);
end
return tmp
end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
↓
code[x_, y_, z_] := If[LessEqual[y, -1e-308], N[(N[(N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision] * x + N[(x * N[Log[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] - z), $MachinePrecision]]
x \cdot \log \left(\frac{x}{y}\right) - z
↓
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-308}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(\frac{-1}{y}\right), x, x \cdot \log \left(-x\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - \log y\right) \cdot x - z\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 8.1 |
|---|
| Cost | 20424 |
|---|
\[\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^{+303}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 4.8 |
|---|
| Cost | 13644 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+179}:\\
\;\;\;\;\left(\log \left(\frac{-1}{y}\right) + \log \left(-x\right)\right) \cdot x\\
\mathbf{elif}\;x \leq -5.5 \cdot 10^{-94}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - \log y\right) \cdot x - z\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.3 |
|---|
| Cost | 13572 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-308}:\\
\;\;\;\;\left(\log \left(\frac{-1}{y}\right) + \log \left(-x\right)\right) \cdot x - z\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - \log y\right) \cdot x - z\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 10.8 |
|---|
| Cost | 13516 |
|---|
\[\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{-90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-120}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+193}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - \log y\right) \cdot x\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 6.6 |
|---|
| Cost | 13512 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-95}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - \log y\right) \cdot x - z\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 21.7 |
|---|
| Cost | 7248 |
|---|
\[\begin{array}{l}
t_0 := \log \left(\frac{x}{y}\right) \cdot x\\
\mathbf{if}\;z \leq -2.3 \cdot 10^{-121}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-86}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 32.3 |
|---|
| Cost | 128 |
|---|
\[-z
\]