100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.3019374668740835:\\
\;\;\;\;100 \cdot \left(\left(n + \frac{1}{2} \cdot \left(i \cdot n\right)\right) + \left(\left(i \cdot i\right) \cdot \frac{1}{6}\right) \cdot n\right)\\
\mathbf{elif}\;n \le 5.021135972250703 \cdot 10^{-197}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\left(n + \frac{1}{2} \cdot \left(i \cdot n\right)\right) + \left(\left(i \cdot i\right) \cdot \frac{1}{6}\right) \cdot n\right)\\
\end{array}double f(double i, double n) {
double r2891950 = 100.0;
double r2891951 = 1.0;
double r2891952 = i;
double r2891953 = n;
double r2891954 = r2891952 / r2891953;
double r2891955 = r2891951 + r2891954;
double r2891956 = pow(r2891955, r2891953);
double r2891957 = r2891956 - r2891951;
double r2891958 = r2891957 / r2891954;
double r2891959 = r2891950 * r2891958;
return r2891959;
}
double f(double i, double n) {
double r2891960 = n;
double r2891961 = -1.3019374668740835;
bool r2891962 = r2891960 <= r2891961;
double r2891963 = 100.0;
double r2891964 = 0.5;
double r2891965 = i;
double r2891966 = r2891965 * r2891960;
double r2891967 = r2891964 * r2891966;
double r2891968 = r2891960 + r2891967;
double r2891969 = r2891965 * r2891965;
double r2891970 = 0.16666666666666666;
double r2891971 = r2891969 * r2891970;
double r2891972 = r2891971 * r2891960;
double r2891973 = r2891968 + r2891972;
double r2891974 = r2891963 * r2891973;
double r2891975 = 5.021135972250703e-197;
bool r2891976 = r2891960 <= r2891975;
double r2891977 = 0.0;
double r2891978 = r2891976 ? r2891977 : r2891974;
double r2891979 = r2891962 ? r2891974 : r2891978;
return r2891979;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.2 |
|---|---|
| Target | 42.2 |
| Herbie | 20.8 |
if n < -1.3019374668740835 or 5.021135972250703e-197 < n Initial program 51.9
rmApplied *-un-lft-identity51.9
Applied add-cube-cbrt52.1
Applied times-frac52.1
Applied associate-/r*52.2
Simplified52.2
Taylor expanded around 0 27.6
Simplified27.6
rmApplied div-inv27.6
Applied *-un-lft-identity27.6
Applied times-frac27.6
Applied times-frac24.6
Taylor expanded around 0 22.7
Simplified22.7
if -1.3019374668740835 < n < 5.021135972250703e-197Initial program 20.7
Taylor expanded around 0 16.4
Final simplification20.8
herbie shell --seed 2019154
(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))))