100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -6.985621920368718 \cdot 10^{-06}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, -100\right)}{i} \cdot n\\
\mathbf{elif}\;i \le 0.5685613637685243:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{1}{200}, \frac{\frac{i}{n}}{n} - \frac{i}{n}, \frac{\frac{1}{100}}{n}\right)}\\
\mathbf{elif}\;i \le 2.695991510921252 \cdot 10^{+276}:\\
\;\;\;\;\frac{\mathsf{fma}\left(n \cdot n, \left(\log n \cdot \log n\right) \cdot 50, \mathsf{fma}\left(\frac{50}{3} \cdot \left(n \cdot \left(n \cdot n\right)\right), \left(\log i \cdot \log i\right) \cdot \log i, \mathsf{fma}\left(100 \cdot \log i, n, \mathsf{fma}\left(n \cdot n, 50 \cdot \left(\log i \cdot \log i\right), \left(\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log i\right) \cdot \left(\log n \cdot \log n\right)\right) \cdot 50\right)\right) - \mathsf{fma}\left(\frac{100}{3} \cdot \left(n \cdot \left(n \cdot n\right)\right), \log n \cdot \left(\log i \cdot \log i\right), \mathsf{fma}\left(\left(\left(n \cdot n\right) \cdot \log n\right) \cdot \log i, 100, \mathsf{fma}\left(100 \cdot n, \log n, \left(\frac{50}{3} \cdot \left(n \cdot \left(n \cdot n\right)\right)\right) \cdot \mathsf{fma}\left(\log n \cdot \log n, \log n, \log n \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i} \cdot n\\
\end{array}double f(double i, double n) {
double r5248803 = 100.0;
double r5248804 = 1.0;
double r5248805 = i;
double r5248806 = n;
double r5248807 = r5248805 / r5248806;
double r5248808 = r5248804 + r5248807;
double r5248809 = pow(r5248808, r5248806);
double r5248810 = r5248809 - r5248804;
double r5248811 = r5248810 / r5248807;
double r5248812 = r5248803 * r5248811;
return r5248812;
}
double f(double i, double n) {
double r5248813 = i;
double r5248814 = -6.985621920368718e-06;
bool r5248815 = r5248813 <= r5248814;
double r5248816 = 100.0;
double r5248817 = n;
double r5248818 = r5248813 / r5248817;
double r5248819 = log1p(r5248818);
double r5248820 = r5248819 * r5248817;
double r5248821 = exp(r5248820);
double r5248822 = -100.0;
double r5248823 = fma(r5248816, r5248821, r5248822);
double r5248824 = r5248823 / r5248813;
double r5248825 = r5248824 * r5248817;
double r5248826 = 0.5685613637685243;
bool r5248827 = r5248813 <= r5248826;
double r5248828 = 1.0;
double r5248829 = 0.005;
double r5248830 = r5248818 / r5248817;
double r5248831 = r5248830 - r5248818;
double r5248832 = 0.01;
double r5248833 = r5248832 / r5248817;
double r5248834 = fma(r5248829, r5248831, r5248833);
double r5248835 = r5248828 / r5248834;
double r5248836 = 2.695991510921252e+276;
bool r5248837 = r5248813 <= r5248836;
double r5248838 = r5248817 * r5248817;
double r5248839 = log(r5248817);
double r5248840 = r5248839 * r5248839;
double r5248841 = 50.0;
double r5248842 = r5248840 * r5248841;
double r5248843 = 16.666666666666668;
double r5248844 = r5248817 * r5248838;
double r5248845 = r5248843 * r5248844;
double r5248846 = log(r5248813);
double r5248847 = r5248846 * r5248846;
double r5248848 = r5248847 * r5248846;
double r5248849 = r5248816 * r5248846;
double r5248850 = r5248841 * r5248847;
double r5248851 = r5248844 * r5248846;
double r5248852 = r5248851 * r5248840;
double r5248853 = r5248852 * r5248841;
double r5248854 = fma(r5248838, r5248850, r5248853);
double r5248855 = fma(r5248849, r5248817, r5248854);
double r5248856 = 33.333333333333336;
double r5248857 = r5248856 * r5248844;
double r5248858 = r5248839 * r5248847;
double r5248859 = r5248838 * r5248839;
double r5248860 = r5248859 * r5248846;
double r5248861 = r5248816 * r5248817;
double r5248862 = fma(r5248840, r5248839, r5248858);
double r5248863 = r5248845 * r5248862;
double r5248864 = fma(r5248861, r5248839, r5248863);
double r5248865 = fma(r5248860, r5248816, r5248864);
double r5248866 = fma(r5248857, r5248858, r5248865);
double r5248867 = r5248855 - r5248866;
double r5248868 = fma(r5248845, r5248848, r5248867);
double r5248869 = fma(r5248838, r5248842, r5248868);
double r5248870 = r5248869 / r5248818;
double r5248871 = r5248828 + r5248818;
double r5248872 = pow(r5248871, r5248817);
double r5248873 = fma(r5248816, r5248872, r5248822);
double r5248874 = r5248873 / r5248813;
double r5248875 = r5248874 * r5248817;
double r5248876 = r5248837 ? r5248870 : r5248875;
double r5248877 = r5248827 ? r5248835 : r5248876;
double r5248878 = r5248815 ? r5248825 : r5248877;
return r5248878;
}




Bits error versus i




Bits error versus n
| Original | 42.3 |
|---|---|
| Target | 41.9 |
| Herbie | 12.1 |
if i < -6.985621920368718e-06Initial program 28.5
Simplified28.5
rmApplied add-exp-log28.6
Applied pow-exp28.6
Simplified6.3
rmApplied associate-/r/6.8
if -6.985621920368718e-06 < i < 0.5685613637685243Initial program 49.6
Simplified49.6
rmApplied add-exp-log49.6
Applied pow-exp49.6
Simplified48.9
rmApplied clear-num48.9
Taylor expanded around 0 13.8
Simplified13.8
rmApplied clear-num13.8
Simplified12.7
if 0.5685613637685243 < i < 2.695991510921252e+276Initial program 32.7
Simplified32.7
rmApplied add-exp-log49.3
Applied pow-exp49.3
Simplified48.1
Taylor expanded around 0 18.4
Simplified18.4
if 2.695991510921252e+276 < i Initial program 30.6
Simplified30.5
rmApplied associate-/r/30.5
Final simplification12.1
herbie shell --seed 2019164 +o rules:numerics
(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))))