\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\]
↓
\[x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
\]
(FPCore (x y z t)
:precision binary64
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
↓
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* y (expm1 z))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
↓
double code(double x, double y, double z, double t) {
return x - (log1p((y * expm1(z))) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
↓
public static double code(double x, double y, double z, double t) {
return x - (Math.log1p((y * Math.expm1(z))) / t);
}
def code(x, y, z, t):
return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
↓
def code(x, y, z, t):
return x - (math.log1p((y * math.expm1(z))) / t)
function code(x, y, z, t)
return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t))
end
↓
function code(x, y, z, t)
return Float64(x - Float64(log1p(Float64(y * expm1(z))) / t))
end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
↓
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
Alternatives
| Alternative 1 |
|---|
| Error | 8.08% |
|---|
| Cost | 7240 |
|---|
\[\begin{array}{l}
t_1 := \mathsf{log1p}\left(y \cdot z\right)\\
\mathbf{if}\;y \leq -220000000000:\\
\;\;\;\;x - \frac{t_1}{t}\\
\mathbf{elif}\;y \leq 5000:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \frac{-1}{t}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 8.09% |
|---|
| Cost | 7240 |
|---|
\[\begin{array}{l}
t_1 := \mathsf{log1p}\left(y \cdot z\right)\\
\mathbf{if}\;y \leq -205000000000:\\
\;\;\;\;x + \frac{-1}{\frac{t}{t_1}}\\
\mathbf{elif}\;y \leq 5000:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \frac{-1}{t}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 8.1% |
|---|
| Cost | 7113 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \leq -220000000000 \lor \neg \left(y \leq 0.1\right):\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 13.33% |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \leq -1.66 \cdot 10^{+167}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+267}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 18.46% |
|---|
| Cost | 1220 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \leq -5.3 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{y}{\frac{t}{z \cdot z}} \cdot -0.5 - \frac{y}{\frac{t}{z}}\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 30.84% |
|---|
| Cost | 648 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-119}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-245}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 21.66% |
|---|
| Cost | 580 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \leq -5.3 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 18.51% |
|---|
| Cost | 580 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{-20}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 28.87% |
|---|
| Cost | 64 |
|---|
\[x
\]