100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -5.163360055787723405136702348322010579229 \cdot 10^{-11}:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} \cdot 100 - 100}{i} \cdot n\\
\mathbf{elif}\;i \le 6.305809243265488292923253978118289242438 \cdot 10^{-10}:\\
\;\;\;\;\frac{100 \cdot \left(n \cdot \left(\left(\log 1 \cdot \left(n - i \cdot \left(i \cdot 0.5\right)\right) + i \cdot \left(i \cdot 0.5\right)\right) + 1 \cdot i\right)\right)}{i}\\
\mathbf{elif}\;i \le 2.565130334196551364557031790272495063197 \cdot 10^{190}:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} \cdot 100 - 100}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\left(1 \cdot i + \left(1 + n \cdot \log 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r7113982 = 100.0;
double r7113983 = 1.0;
double r7113984 = i;
double r7113985 = n;
double r7113986 = r7113984 / r7113985;
double r7113987 = r7113983 + r7113986;
double r7113988 = pow(r7113987, r7113985);
double r7113989 = r7113988 - r7113983;
double r7113990 = r7113989 / r7113986;
double r7113991 = r7113982 * r7113990;
return r7113991;
}
double f(double i, double n) {
double r7113992 = i;
double r7113993 = -5.1633600557877234e-11;
bool r7113994 = r7113992 <= r7113993;
double r7113995 = 1.0;
double r7113996 = n;
double r7113997 = r7113995 / r7113996;
double r7113998 = r7113997 * r7113992;
double r7113999 = pow(r7113998, r7113996);
double r7114000 = 100.0;
double r7114001 = r7113999 * r7114000;
double r7114002 = r7114001 - r7114000;
double r7114003 = r7114002 / r7113992;
double r7114004 = r7114003 * r7113996;
double r7114005 = 6.305809243265488e-10;
bool r7114006 = r7113992 <= r7114005;
double r7114007 = 1.0;
double r7114008 = log(r7114007);
double r7114009 = 0.5;
double r7114010 = r7113992 * r7114009;
double r7114011 = r7113992 * r7114010;
double r7114012 = r7113996 - r7114011;
double r7114013 = r7114008 * r7114012;
double r7114014 = r7114013 + r7114011;
double r7114015 = r7114007 * r7113992;
double r7114016 = r7114014 + r7114015;
double r7114017 = r7113996 * r7114016;
double r7114018 = r7114000 * r7114017;
double r7114019 = r7114018 / r7113992;
double r7114020 = 2.5651303341965514e+190;
bool r7114021 = r7113992 <= r7114020;
double r7114022 = r7113996 * r7114008;
double r7114023 = r7113995 + r7114022;
double r7114024 = r7114015 + r7114023;
double r7114025 = r7114024 - r7114007;
double r7114026 = r7113992 / r7113996;
double r7114027 = r7114025 / r7114026;
double r7114028 = r7114000 * r7114027;
double r7114029 = r7114021 ? r7114004 : r7114028;
double r7114030 = r7114006 ? r7114019 : r7114029;
double r7114031 = r7113994 ? r7114004 : r7114030;
return r7114031;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.8 |
|---|---|
| Target | 42.7 |
| Herbie | 19.1 |
if i < -5.1633600557877234e-11 or 6.305809243265488e-10 < i < 2.5651303341965514e+190Initial program 29.3
rmApplied associate-/r/29.8
Applied associate-*r*29.8
Taylor expanded around inf 55.4
Simplified23.4
if -5.1633600557877234e-11 < i < 6.305809243265488e-10Initial program 50.7
rmApplied associate-/r/50.4
Applied associate-*r*50.4
Taylor expanded around 0 16.3
Simplified16.3
rmApplied associate-*l*16.3
rmApplied associate-*l/15.3
Applied associate-*r/15.5
if 2.5651303341965514e+190 < i Initial program 33.1
Taylor expanded around 0 33.3
Final simplification19.1
herbie shell --seed 2019200
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))