Average Error: 43.3 → 19.0
Time: 26.4s
Precision: 64
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;i \le -2072.084458567275305540533736348152160645:\\ \;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} - 1}{\frac{i}{n}} \cdot 100\\ \mathbf{elif}\;i \le 3.107272117925894111483480369189253739367 \cdot 10^{-249}:\\ \;\;\;\;\frac{1}{\frac{\frac{i}{i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1}}{100}} \cdot n\\ \mathbf{elif}\;i \le 5.594879277814152504998655712764588088248 \cdot 10^{-6}:\\ \;\;\;\;\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \left(\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left({\left(\frac{i}{n} + 1\right)}^{\left(n \cdot 2\right)} - 1 \cdot 1\right) \cdot 100}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}}{i} \cdot n\\ \end{array}\]
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\begin{array}{l}
\mathbf{if}\;i \le -2072.084458567275305540533736348152160645:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} - 1}{\frac{i}{n}} \cdot 100\\

\mathbf{elif}\;i \le 3.107272117925894111483480369189253739367 \cdot 10^{-249}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1}}{100}} \cdot n\\

\mathbf{elif}\;i \le 5.594879277814152504998655712764588088248 \cdot 10^{-6}:\\
\;\;\;\;\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \left(\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left({\left(\frac{i}{n} + 1\right)}^{\left(n \cdot 2\right)} - 1 \cdot 1\right) \cdot 100}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}}{i} \cdot n\\

\end{array}
double f(double i, double n) {
        double r113843 = 100.0;
        double r113844 = 1.0;
        double r113845 = i;
        double r113846 = n;
        double r113847 = r113845 / r113846;
        double r113848 = r113844 + r113847;
        double r113849 = pow(r113848, r113846);
        double r113850 = r113849 - r113844;
        double r113851 = r113850 / r113847;
        double r113852 = r113843 * r113851;
        return r113852;
}

double f(double i, double n) {
        double r113853 = i;
        double r113854 = -2072.0844585672753;
        bool r113855 = r113853 <= r113854;
        double r113856 = 1.0;
        double r113857 = n;
        double r113858 = r113856 / r113857;
        double r113859 = r113858 * r113853;
        double r113860 = pow(r113859, r113857);
        double r113861 = 1.0;
        double r113862 = r113860 - r113861;
        double r113863 = r113853 / r113857;
        double r113864 = r113862 / r113863;
        double r113865 = 100.0;
        double r113866 = r113864 * r113865;
        double r113867 = 3.107272117925894e-249;
        bool r113868 = r113853 <= r113867;
        double r113869 = 0.5;
        double r113870 = r113853 * r113869;
        double r113871 = r113870 + r113861;
        double r113872 = r113853 * r113871;
        double r113873 = r113853 * r113853;
        double r113874 = r113869 * r113873;
        double r113875 = r113874 - r113857;
        double r113876 = log(r113861);
        double r113877 = r113875 * r113876;
        double r113878 = r113872 - r113877;
        double r113879 = r113853 / r113878;
        double r113880 = r113879 / r113865;
        double r113881 = r113856 / r113880;
        double r113882 = r113881 * r113857;
        double r113883 = 5.5948792778141525e-06;
        bool r113884 = r113853 <= r113883;
        double r113885 = r113857 * r113878;
        double r113886 = r113853 / r113865;
        double r113887 = r113885 / r113886;
        double r113888 = cbrt(r113887);
        double r113889 = r113888 * r113888;
        double r113890 = r113888 * r113889;
        double r113891 = r113863 + r113861;
        double r113892 = 2.0;
        double r113893 = r113857 * r113892;
        double r113894 = pow(r113891, r113893);
        double r113895 = r113861 * r113861;
        double r113896 = r113894 - r113895;
        double r113897 = r113896 * r113865;
        double r113898 = pow(r113891, r113857);
        double r113899 = r113898 + r113861;
        double r113900 = r113897 / r113899;
        double r113901 = r113900 / r113853;
        double r113902 = r113901 * r113857;
        double r113903 = r113884 ? r113890 : r113902;
        double r113904 = r113868 ? r113882 : r113903;
        double r113905 = r113855 ? r113866 : r113904;
        return r113905;
}

Error

Bits error versus i

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original43.3
Target43.1
Herbie19.0
\[100 \cdot \frac{e^{n \cdot \begin{array}{l} \mathbf{if}\;1 + \frac{i}{n} = 1:\\ \;\;\;\;\frac{i}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{i}{n} \cdot \log \left(1 + \frac{i}{n}\right)}{\left(\frac{i}{n} + 1\right) - 1}\\ \end{array}} - 1}{\frac{i}{n}}\]

Derivation

  1. Split input into 4 regimes
  2. if i < -2072.0844585672753

    1. Initial program 27.9

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Using strategy rm
    3. Applied associate-/r/28.5

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)}\]
    4. Applied associate-*r*28.5

      \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n}\]
    5. Simplified28.4

      \[\leadsto \color{blue}{\frac{\left({\left(\frac{i}{n} + 1\right)}^{n} - 1\right) \cdot 100}{i}} \cdot n\]
    6. Taylor expanded around inf 64.0

      \[\leadsto \color{blue}{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}}\]
    7. Simplified19.4

      \[\leadsto \color{blue}{\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} - 1}{\frac{i}{n}} \cdot 100}\]

    if -2072.0844585672753 < i < 3.107272117925894e-249

    1. Initial program 51.5

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Using strategy rm
    3. Applied associate-/r/51.1

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)}\]
    4. Applied associate-*r*51.1

      \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n}\]
    5. Simplified51.1

      \[\leadsto \color{blue}{\frac{\left({\left(\frac{i}{n} + 1\right)}^{n} - 1\right) \cdot 100}{i}} \cdot n\]
    6. Taylor expanded around 0 16.2

      \[\leadsto \frac{\color{blue}{\left(\left(\log 1 \cdot n + \left(1 \cdot i + 0.5 \cdot {i}^{2}\right)\right) - 0.5 \cdot \left(\log 1 \cdot {i}^{2}\right)\right)} \cdot 100}{i} \cdot n\]
    7. Simplified16.2

      \[\leadsto \frac{\color{blue}{\left(\left(\left(\left(i \cdot i\right) \cdot 0.5 + 1 \cdot i\right) - 0.5 \cdot \left(\left(i \cdot i\right) \cdot \log 1\right)\right) + n \cdot \log 1\right)} \cdot 100}{i} \cdot n\]
    8. Using strategy rm
    9. Applied clear-num16.2

      \[\leadsto \color{blue}{\frac{1}{\frac{i}{\left(\left(\left(\left(i \cdot i\right) \cdot 0.5 + 1 \cdot i\right) - 0.5 \cdot \left(\left(i \cdot i\right) \cdot \log 1\right)\right) + n \cdot \log 1\right) \cdot 100}}} \cdot n\]
    10. Simplified16.1

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{i}{i \cdot \left(1 + 0.5 \cdot i\right) - \log 1 \cdot \left(\left(i \cdot i\right) \cdot 0.5 - n\right)}}{100}}} \cdot n\]

    if 3.107272117925894e-249 < i < 5.5948792778141525e-06

    1. Initial program 50.4

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Using strategy rm
    3. Applied associate-/r/50.2

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)}\]
    4. Applied associate-*r*50.2

      \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n}\]
    5. Simplified50.2

      \[\leadsto \color{blue}{\frac{\left({\left(\frac{i}{n} + 1\right)}^{n} - 1\right) \cdot 100}{i}} \cdot n\]
    6. Taylor expanded around 0 17.6

      \[\leadsto \frac{\color{blue}{\left(\left(\log 1 \cdot n + \left(1 \cdot i + 0.5 \cdot {i}^{2}\right)\right) - 0.5 \cdot \left(\log 1 \cdot {i}^{2}\right)\right)} \cdot 100}{i} \cdot n\]
    7. Simplified17.6

      \[\leadsto \frac{\color{blue}{\left(\left(\left(\left(i \cdot i\right) \cdot 0.5 + 1 \cdot i\right) - 0.5 \cdot \left(\left(i \cdot i\right) \cdot \log 1\right)\right) + n \cdot \log 1\right)} \cdot 100}{i} \cdot n\]
    8. Using strategy rm
    9. Applied add-cube-cbrt18.4

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{\left(\left(\left(\left(i \cdot i\right) \cdot 0.5 + 1 \cdot i\right) - 0.5 \cdot \left(\left(i \cdot i\right) \cdot \log 1\right)\right) + n \cdot \log 1\right) \cdot 100}{i} \cdot n} \cdot \sqrt[3]{\frac{\left(\left(\left(\left(i \cdot i\right) \cdot 0.5 + 1 \cdot i\right) - 0.5 \cdot \left(\left(i \cdot i\right) \cdot \log 1\right)\right) + n \cdot \log 1\right) \cdot 100}{i} \cdot n}\right) \cdot \sqrt[3]{\frac{\left(\left(\left(\left(i \cdot i\right) \cdot 0.5 + 1 \cdot i\right) - 0.5 \cdot \left(\left(i \cdot i\right) \cdot \log 1\right)\right) + n \cdot \log 1\right) \cdot 100}{i} \cdot n}}\]
    10. Simplified15.4

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{\left(i \cdot \left(1 + 0.5 \cdot i\right) - \log 1 \cdot \left(\left(i \cdot i\right) \cdot 0.5 - n\right)\right) \cdot n}{\frac{i}{100}}} \cdot \sqrt[3]{\frac{\left(i \cdot \left(1 + 0.5 \cdot i\right) - \log 1 \cdot \left(\left(i \cdot i\right) \cdot 0.5 - n\right)\right) \cdot n}{\frac{i}{100}}}\right)} \cdot \sqrt[3]{\frac{\left(\left(\left(\left(i \cdot i\right) \cdot 0.5 + 1 \cdot i\right) - 0.5 \cdot \left(\left(i \cdot i\right) \cdot \log 1\right)\right) + n \cdot \log 1\right) \cdot 100}{i} \cdot n}\]
    11. Simplified15.5

      \[\leadsto \left(\sqrt[3]{\frac{\left(i \cdot \left(1 + 0.5 \cdot i\right) - \log 1 \cdot \left(\left(i \cdot i\right) \cdot 0.5 - n\right)\right) \cdot n}{\frac{i}{100}}} \cdot \sqrt[3]{\frac{\left(i \cdot \left(1 + 0.5 \cdot i\right) - \log 1 \cdot \left(\left(i \cdot i\right) \cdot 0.5 - n\right)\right) \cdot n}{\frac{i}{100}}}\right) \cdot \color{blue}{\sqrt[3]{\frac{\left(i \cdot \left(1 + 0.5 \cdot i\right) - \log 1 \cdot \left(\left(i \cdot i\right) \cdot 0.5 - n\right)\right) \cdot n}{\frac{i}{100}}}}\]

    if 5.5948792778141525e-06 < i

    1. Initial program 32.7

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Using strategy rm
    3. Applied associate-/r/32.7

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)}\]
    4. Applied associate-*r*32.7

      \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n}\]
    5. Simplified32.7

      \[\leadsto \color{blue}{\frac{\left({\left(\frac{i}{n} + 1\right)}^{n} - 1\right) \cdot 100}{i}} \cdot n\]
    6. Using strategy rm
    7. Applied flip--32.7

      \[\leadsto \frac{\color{blue}{\frac{{\left(\frac{i}{n} + 1\right)}^{n} \cdot {\left(\frac{i}{n} + 1\right)}^{n} - 1 \cdot 1}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}} \cdot 100}{i} \cdot n\]
    8. Applied associate-*l/32.7

      \[\leadsto \frac{\color{blue}{\frac{\left({\left(\frac{i}{n} + 1\right)}^{n} \cdot {\left(\frac{i}{n} + 1\right)}^{n} - 1 \cdot 1\right) \cdot 100}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}}}{i} \cdot n\]
    9. Simplified32.7

      \[\leadsto \frac{\frac{\color{blue}{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{\left(n \cdot 2\right)} - 1 \cdot 1\right)}}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}}{i} \cdot n\]
  3. Recombined 4 regimes into one program.
  4. Final simplification19.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \le -2072.084458567275305540533736348152160645:\\ \;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} - 1}{\frac{i}{n}} \cdot 100\\ \mathbf{elif}\;i \le 3.107272117925894111483480369189253739367 \cdot 10^{-249}:\\ \;\;\;\;\frac{1}{\frac{\frac{i}{i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1}}{100}} \cdot n\\ \mathbf{elif}\;i \le 5.594879277814152504998655712764588088248 \cdot 10^{-6}:\\ \;\;\;\;\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \left(\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left({\left(\frac{i}{n} + 1\right)}^{\left(n \cdot 2\right)} - 1 \cdot 1\right) \cdot 100}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}}{i} \cdot n\\ \end{array}\]

Reproduce

herbie shell --seed 2019196 
(FPCore (i n)
  :name "Compound Interest"

  :herbie-target
  (* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))

  (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))