\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\]
↓
\[\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right) - t
\]
(FPCore (x y z t)
:precision binary64
(- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
↓
(FPCore (x y z t)
:precision binary64
(- (fma x (log y) (* z (log1p (- y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - y)))) - t;
}
↓
double code(double x, double y, double z, double t) {
return fma(x, log(y), (z * log1p(-y))) - t;
}
function code(x, y, z, t)
return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t)
end
↓
function code(x, y, z, t)
return Float64(fma(x, log(y), Float64(z * log1p(Float64(-y)))) - t)
end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
↓
code[x_, y_, z_, t_] := N[(N[(x * N[Log[y], $MachinePrecision] + N[(z * N[Log[1 + (-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
↓
\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right) - t
Alternatives
| Alternative 1 |
|---|
| Error | 15.8 |
|---|
| Cost | 7386 |
|---|
\[\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -3.25 \cdot 10^{+184}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{+168}:\\
\;\;\;\;-t\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{+30} \lor \neg \left(x \leq 3.05 \cdot 10^{-88}\right) \land \left(x \leq 3.7 \cdot 10^{-76} \lor \neg \left(x \leq 1500000000000\right)\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right) - t\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 6.1 |
|---|
| Cost | 7049 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-74} \lor \neg \left(x \leq 1.06 \cdot 10^{-92}\right):\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 6.3 |
|---|
| Cost | 6985 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.32 \cdot 10^{-73} \lor \neg \left(x \leq 1.08 \cdot 10^{-88}\right):\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right) - t\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.5 |
|---|
| Cost | 6976 |
|---|
\[x \cdot \log y - \left(t + y \cdot z\right)
\]
| Alternative 5 |
|---|
| Error | 32.7 |
|---|
| Cost | 520 |
|---|
\[\begin{array}{l}
\mathbf{if}\;t \leq -1.6 \cdot 10^{-126}:\\
\;\;\;\;-t\\
\mathbf{elif}\;t \leq 4.8 \cdot 10^{-95}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 27.4 |
|---|
| Cost | 384 |
|---|
\[y \cdot \left(-z\right) - t
\]
| Alternative 7 |
|---|
| Error | 36.4 |
|---|
| Cost | 128 |
|---|
\[-t
\]