100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.260760569041402 \cdot 10^{+85}:\\
\;\;\;\;\frac{\frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{i}}{\frac{1}{n}} \cdot 100\\
\mathbf{elif}\;n \le -1.901514792923964:\\
\;\;\;\;100 \cdot \frac{\left(i + i \cdot \left(\frac{1}{6} \cdot \left(i \cdot i\right)\right)\right) + i \cdot \left(\frac{1}{2} \cdot i\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 9.072873111493527 \cdot 10^{-149}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\left(i + i \cdot \left(\frac{1}{6} \cdot \left(i \cdot i\right)\right)\right) + i \cdot \left(\frac{1}{2} \cdot i\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r5764952 = 100.0;
double r5764953 = 1.0;
double r5764954 = i;
double r5764955 = n;
double r5764956 = r5764954 / r5764955;
double r5764957 = r5764953 + r5764956;
double r5764958 = pow(r5764957, r5764955);
double r5764959 = r5764958 - r5764953;
double r5764960 = r5764959 / r5764956;
double r5764961 = r5764952 * r5764960;
return r5764961;
}
double f(double i, double n) {
double r5764962 = n;
double r5764963 = -1.260760569041402e+85;
bool r5764964 = r5764962 <= r5764963;
double r5764965 = i;
double r5764966 = r5764965 / r5764962;
double r5764967 = 1.0;
double r5764968 = r5764966 + r5764967;
double r5764969 = pow(r5764968, r5764962);
double r5764970 = r5764969 - r5764967;
double r5764971 = r5764970 / r5764965;
double r5764972 = r5764967 / r5764962;
double r5764973 = r5764971 / r5764972;
double r5764974 = 100.0;
double r5764975 = r5764973 * r5764974;
double r5764976 = -1.901514792923964;
bool r5764977 = r5764962 <= r5764976;
double r5764978 = 0.16666666666666666;
double r5764979 = r5764965 * r5764965;
double r5764980 = r5764978 * r5764979;
double r5764981 = r5764965 * r5764980;
double r5764982 = r5764965 + r5764981;
double r5764983 = 0.5;
double r5764984 = r5764983 * r5764965;
double r5764985 = r5764965 * r5764984;
double r5764986 = r5764982 + r5764985;
double r5764987 = r5764986 / r5764966;
double r5764988 = r5764974 * r5764987;
double r5764989 = 9.072873111493527e-149;
bool r5764990 = r5764962 <= r5764989;
double r5764991 = 0.0;
double r5764992 = r5764990 ? r5764991 : r5764988;
double r5764993 = r5764977 ? r5764988 : r5764992;
double r5764994 = r5764964 ? r5764975 : r5764993;
return r5764994;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.8 |
|---|---|
| Target | 42.4 |
| Herbie | 31.4 |
if n < -1.260760569041402e+85Initial program 47.8
rmApplied div-inv47.8
Applied associate-/r*47.4
if -1.260760569041402e+85 < n < -1.901514792923964 or 9.072873111493527e-149 < n Initial program 53.8
rmApplied add-log-exp53.8
Applied add-log-exp53.9
Applied diff-log53.9
Simplified53.9
Taylor expanded around 0 32.7
Simplified32.7
if -1.901514792923964 < n < 9.072873111493527e-149Initial program 23.8
Taylor expanded around 0 18.3
Final simplification31.4
herbie shell --seed 2019165
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100 (/ (- (exp (* n (if (== (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) 1) (/ i n)))
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))))