100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -8.289427775447091 \cdot 10^{-05}:\\
\;\;\;\;n \cdot \frac{\log \left(\sqrt[3]{e^{\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right)}} \cdot \sqrt[3]{e^{\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right)}}\right) + \log \left(\sqrt[3]{e^{\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right)}}\right)}{i}\\
\mathbf{elif}\;i \le 3.8569470324880954 \cdot 10^{-10}:\\
\;\;\;\;\frac{i \cdot \mathsf{fma}\left(i, \left(\mathsf{fma}\left(i, \frac{50}{3}, 50\right)\right), 100\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{\mathsf{fma}\left(50, \left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\log i \cdot \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot n\right)\right), \left(\mathsf{fma}\left(100, \left(\log i \cdot n\right), \left(\left(\left(\left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right) \cdot n\right) \cdot \log i\right) \cdot 50 + 50 \cdot \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right)\right)\right)\right)\right)\right)\right) - \left(\mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \left(\left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right) \cdot n\right)\right), \left(\mathsf{fma}\left(\left(\left(\left(\log n \cdot n\right) \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot \log i\right)\right), \frac{50}{3}, \left(\left(\log n \cdot n\right) \cdot 100\right)\right)\right)\right) + \left(\left(50 \cdot \log i\right) \cdot \left(\left(n \cdot n\right) \cdot \log n\right) + \mathsf{fma}\left(\left(\left(\left(\log n \cdot n\right) \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot \log i\right)\right), \frac{100}{3}, \left(\left(50 \cdot \log i\right) \cdot \left(\left(n \cdot n\right) \cdot \log n\right)\right)\right)\right)\right)}{i}\\
\end{array}double f(double i, double n) {
double r19742756 = 100.0;
double r19742757 = 1.0;
double r19742758 = i;
double r19742759 = n;
double r19742760 = r19742758 / r19742759;
double r19742761 = r19742757 + r19742760;
double r19742762 = pow(r19742761, r19742759);
double r19742763 = r19742762 - r19742757;
double r19742764 = r19742763 / r19742760;
double r19742765 = r19742756 * r19742764;
return r19742765;
}
double f(double i, double n) {
double r19742766 = i;
double r19742767 = -8.289427775447091e-05;
bool r19742768 = r19742766 <= r19742767;
double r19742769 = n;
double r19742770 = 100.0;
double r19742771 = r19742766 / r19742769;
double r19742772 = log1p(r19742771);
double r19742773 = r19742772 * r19742769;
double r19742774 = exp(r19742773);
double r19742775 = -100.0;
double r19742776 = fma(r19742770, r19742774, r19742775);
double r19742777 = exp(r19742776);
double r19742778 = cbrt(r19742777);
double r19742779 = r19742778 * r19742778;
double r19742780 = log(r19742779);
double r19742781 = log(r19742778);
double r19742782 = r19742780 + r19742781;
double r19742783 = r19742782 / r19742766;
double r19742784 = r19742769 * r19742783;
double r19742785 = 3.8569470324880954e-10;
bool r19742786 = r19742766 <= r19742785;
double r19742787 = 16.666666666666668;
double r19742788 = 50.0;
double r19742789 = fma(r19742766, r19742787, r19742788);
double r19742790 = fma(r19742766, r19742789, r19742770);
double r19742791 = r19742766 * r19742790;
double r19742792 = r19742791 / r19742771;
double r19742793 = log(r19742769);
double r19742794 = r19742793 * r19742769;
double r19742795 = r19742794 * r19742794;
double r19742796 = log(r19742766);
double r19742797 = r19742796 * r19742769;
double r19742798 = r19742797 * r19742797;
double r19742799 = r19742798 * r19742769;
double r19742800 = r19742796 * r19742799;
double r19742801 = r19742795 * r19742769;
double r19742802 = r19742801 * r19742796;
double r19742803 = r19742802 * r19742788;
double r19742804 = r19742788 * r19742798;
double r19742805 = r19742803 + r19742804;
double r19742806 = fma(r19742770, r19742797, r19742805);
double r19742807 = fma(r19742787, r19742800, r19742806);
double r19742808 = fma(r19742788, r19742795, r19742807);
double r19742809 = r19742793 * r19742801;
double r19742810 = r19742769 * r19742769;
double r19742811 = r19742794 * r19742810;
double r19742812 = r19742796 * r19742796;
double r19742813 = r19742811 * r19742812;
double r19742814 = r19742794 * r19742770;
double r19742815 = fma(r19742813, r19742787, r19742814);
double r19742816 = fma(r19742787, r19742809, r19742815);
double r19742817 = r19742788 * r19742796;
double r19742818 = r19742810 * r19742793;
double r19742819 = r19742817 * r19742818;
double r19742820 = 33.333333333333336;
double r19742821 = fma(r19742813, r19742820, r19742819);
double r19742822 = r19742819 + r19742821;
double r19742823 = r19742816 + r19742822;
double r19742824 = r19742808 - r19742823;
double r19742825 = r19742824 / r19742766;
double r19742826 = r19742769 * r19742825;
double r19742827 = r19742786 ? r19742792 : r19742826;
double r19742828 = r19742768 ? r19742784 : r19742827;
return r19742828;
}




Bits error versus i




Bits error versus n
| Original | 42.5 |
|---|---|
| Target | 42.3 |
| Herbie | 25.2 |
if i < -8.289427775447091e-05Initial program 28.1
Simplified28.0
rmApplied add-exp-log28.1
Applied pow-exp28.1
Simplified6.0
rmApplied add-log-exp6.0
rmApplied associate-/r/6.5
rmApplied add-cube-cbrt6.5
Applied log-prod6.5
if -8.289427775447091e-05 < i < 3.8569470324880954e-10Initial program 50.2
Simplified50.2
Taylor expanded around 0 32.8
Simplified32.8
if 3.8569470324880954e-10 < i Initial program 32.0
Simplified32.0
rmApplied add-exp-log49.4
Applied pow-exp49.4
Simplified46.9
rmApplied add-log-exp47.9
rmApplied associate-/r/47.9
Taylor expanded around 0 21.2
Simplified21.2
Final simplification25.2
herbie shell --seed 2019121 +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))))