\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\]
↓
\[\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t_1 \leq 10000:\\
\;\;\;\;100 \cdot \left(\frac{\frac{i}{n} \cdot t_0 - \frac{i}{n}}{\frac{i}{n}} \cdot \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\left(1 + n\right) + -1\right)\\
\end{array}
\]
(FPCore (i n)
:precision binary64
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
↓
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 0.0)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 10000.0)
(* 100.0 (* (/ (- (* (/ i n) t_0) (/ i n)) (/ i n)) (/ n i)))
(* 100.0 (+ (+ 1.0 n) -1.0))))))double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
↓
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= 10000.0) {
tmp = 100.0 * (((((i / n) * t_0) - (i / n)) / (i / n)) * (n / i));
} else {
tmp = 100.0 * ((1.0 + n) + -1.0);
}
return tmp;
}
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
↓
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (Math.expm1((n * Math.log1p((i / n)))) / (i / n));
} else if (t_1 <= 10000.0) {
tmp = 100.0 * (((((i / n) * t_0) - (i / n)) / (i / n)) * (n / i));
} else {
tmp = 100.0 * ((1.0 + n) + -1.0);
}
return tmp;
}
def code(i, n):
return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
↓
def code(i, n):
t_0 = math.pow((1.0 + (i / n)), n)
t_1 = (t_0 + -1.0) / (i / n)
tmp = 0
if t_1 <= 0.0:
tmp = 100.0 * (math.expm1((n * math.log1p((i / n)))) / (i / n))
elif t_1 <= 10000.0:
tmp = 100.0 * (((((i / n) * t_0) - (i / n)) / (i / n)) * (n / i))
else:
tmp = 100.0 * ((1.0 + n) + -1.0)
return tmp
function code(i, n)
return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n)))
end
↓
function code(i, n)
t_0 = Float64(1.0 + Float64(i / n)) ^ n
t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n))
tmp = 0.0
if (t_1 <= 0.0)
tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n)));
elseif (t_1 <= 10000.0)
tmp = Float64(100.0 * Float64(Float64(Float64(Float64(Float64(i / n) * t_0) - Float64(i / n)) / Float64(i / n)) * Float64(n / i)));
else
tmp = Float64(100.0 * Float64(Float64(1.0 + n) + -1.0));
end
return tmp
end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 10000.0], N[(100.0 * N[(N[(N[(N[(N[(i / n), $MachinePrecision] * t$95$0), $MachinePrecision] - N[(i / n), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision] * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(1.0 + n), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
↓
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t_1 \leq 10000:\\
\;\;\;\;100 \cdot \left(\frac{\frac{i}{n} \cdot t_0 - \frac{i}{n}}{\frac{i}{n}} \cdot \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\left(1 + n\right) + -1\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 13.6 |
|---|
| Cost | 13768 |
|---|
\[\begin{array}{l}
\mathbf{if}\;i \leq 1.8 \cdot 10^{-39}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{elif}\;i \leq 1.35 \cdot 10^{+86}:\\
\;\;\;\;100 \cdot \left(\frac{n}{i} \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)\right)\\
\mathbf{elif}\;i \leq 3.8 \cdot 10^{+261}:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{100}{\frac{1}{n}}}{1 + i \cdot -0.5}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 13.7 |
|---|
| Cost | 7692 |
|---|
\[\begin{array}{l}
\mathbf{if}\;i \leq 1.8 \cdot 10^{-39}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{elif}\;i \leq 1.45 \cdot 10^{+81}:\\
\;\;\;\;100 \cdot \left(\log \left(\frac{i}{n}\right) \cdot \frac{n \cdot n}{i}\right)\\
\mathbf{elif}\;i \leq 3.65 \cdot 10^{+261}:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{100}{\frac{1}{n}}}{1 + i \cdot -0.5}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 14.0 |
|---|
| Cost | 7368 |
|---|
\[\begin{array}{l}
\mathbf{if}\;i \leq 1.8 \cdot 10^{-39}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{elif}\;i \leq 4.4 \cdot 10^{+155}:\\
\;\;\;\;100 \cdot \left(\log \left(\frac{i}{n}\right) \cdot \frac{n \cdot n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{100}{\frac{1}{n}}}{1 + i \cdot -0.5}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 13.5 |
|---|
| Cost | 7244 |
|---|
\[\begin{array}{l}
t_0 := n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{if}\;n \leq -3.1 \cdot 10^{-133}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 3.15 \cdot 10^{-282}:\\
\;\;\;\;100 \cdot \left(\left(1 + n\right) + -1\right)\\
\mathbf{elif}\;n \leq 2.15 \cdot 10^{-20}:\\
\;\;\;\;\frac{100 \cdot \left(\frac{1}{i + 2} \cdot \left(i \cdot 2\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 20.7 |
|---|
| Cost | 969 |
|---|
\[\begin{array}{l}
\mathbf{if}\;n \leq -3.1 \cdot 10^{-133} \lor \neg \left(n \leq 2.3 \cdot 10^{-280}\right):\\
\;\;\;\;\frac{\frac{100}{\frac{1}{n}}}{1 + i \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\left(1 + n\right) + -1\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 24.2 |
|---|
| Cost | 713 |
|---|
\[\begin{array}{l}
\mathbf{if}\;i \leq -2.9 \cdot 10^{+141} \lor \neg \left(i \leq 10^{+54}\right):\\
\;\;\;\;100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 19.8 |
|---|
| Cost | 713 |
|---|
\[\begin{array}{l}
\mathbf{if}\;i \leq -1.5 \cdot 10^{-40} \lor \neg \left(i \leq 7.2 \cdot 10^{-52}\right):\\
\;\;\;\;100 \cdot \left(\left(1 + n\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 28.8 |
|---|
| Cost | 192 |
|---|
\[n \cdot 100
\]