100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -3.55885888884481173 \cdot 10^{195}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right) \cdot n\right) \cdot 100}{i}\\
\mathbf{elif}\;n \le 2.5276530280957779 \cdot 10^{-300}:\\
\;\;\;\;\frac{100}{i} \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot n - 1 \cdot n\right)\\
\mathbf{elif}\;n \le 1.0241992467778217 \cdot 10^{-176}:\\
\;\;\;\;100 \cdot \frac{\left(e^{\left(\log \left(\frac{1}{n}\right) - \log \left(\frac{1}{i}\right)\right) \cdot n} - 1\right) \cdot n}{i}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{100}{i} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}}{\sqrt{\frac{1}{n}}}\right) \cdot \frac{\sqrt[3]{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}}{\sqrt{\frac{1}{n}}}\\
\end{array}double f(double i, double n) {
double r125824 = 100.0;
double r125825 = 1.0;
double r125826 = i;
double r125827 = n;
double r125828 = r125826 / r125827;
double r125829 = r125825 + r125828;
double r125830 = pow(r125829, r125827);
double r125831 = r125830 - r125825;
double r125832 = r125831 / r125828;
double r125833 = r125824 * r125832;
return r125833;
}
double f(double i, double n) {
double r125834 = n;
double r125835 = -3.5588588888448117e+195;
bool r125836 = r125834 <= r125835;
double r125837 = i;
double r125838 = 1.0;
double r125839 = 0.5;
double r125840 = 2.0;
double r125841 = pow(r125837, r125840);
double r125842 = log(r125838);
double r125843 = r125842 * r125834;
double r125844 = fma(r125839, r125841, r125843);
double r125845 = r125841 * r125842;
double r125846 = r125839 * r125845;
double r125847 = r125844 - r125846;
double r125848 = fma(r125837, r125838, r125847);
double r125849 = r125848 * r125834;
double r125850 = 100.0;
double r125851 = r125849 * r125850;
double r125852 = r125851 / r125837;
double r125853 = 2.527653028095778e-300;
bool r125854 = r125834 <= r125853;
double r125855 = r125850 / r125837;
double r125856 = r125837 / r125834;
double r125857 = r125838 + r125856;
double r125858 = pow(r125857, r125834);
double r125859 = r125858 * r125834;
double r125860 = r125838 * r125834;
double r125861 = r125859 - r125860;
double r125862 = r125855 * r125861;
double r125863 = 1.0241992467778217e-176;
bool r125864 = r125834 <= r125863;
double r125865 = 1.0;
double r125866 = r125865 / r125834;
double r125867 = log(r125866);
double r125868 = r125865 / r125837;
double r125869 = log(r125868);
double r125870 = r125867 - r125869;
double r125871 = r125870 * r125834;
double r125872 = exp(r125871);
double r125873 = r125872 - r125838;
double r125874 = r125873 * r125834;
double r125875 = r125874 / r125837;
double r125876 = r125850 * r125875;
double r125877 = cbrt(r125848);
double r125878 = r125877 * r125877;
double r125879 = sqrt(r125866);
double r125880 = r125878 / r125879;
double r125881 = r125855 * r125880;
double r125882 = r125877 / r125879;
double r125883 = r125881 * r125882;
double r125884 = r125864 ? r125876 : r125883;
double r125885 = r125854 ? r125862 : r125884;
double r125886 = r125836 ? r125852 : r125885;
return r125886;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 42.6 |
| Herbie | 24.4 |
if n < -3.5588588888448117e+195Initial program 55.6
rmApplied div-inv55.6
Applied *-un-lft-identity55.6
Applied times-frac55.1
Applied associate-*r*55.1
Simplified55.1
Taylor expanded around 0 24.7
Simplified24.7
rmApplied associate-*l/24.6
Simplified24.6
if -3.5588588888448117e+195 < n < 2.527653028095778e-300Initial program 27.3
rmApplied div-inv27.3
Applied *-un-lft-identity27.3
Applied times-frac27.6
Applied associate-*r*27.7
Simplified27.7
rmApplied div-sub27.7
Simplified30.4
Simplified27.7
if 2.527653028095778e-300 < n < 1.0241992467778217e-176Initial program 41.3
Taylor expanded around inf 20.7
if 1.0241992467778217e-176 < n Initial program 58.8
rmApplied div-inv58.8
Applied *-un-lft-identity58.8
Applied times-frac58.5
Applied associate-*r*58.5
Simplified58.5
Taylor expanded around 0 24.4
Simplified24.4
rmApplied add-sqr-sqrt24.6
Applied add-cube-cbrt25.1
Applied times-frac25.1
Applied associate-*r*21.2
Final simplification24.4
herbie shell --seed 2020089 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
:precision binary64
: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))))