Average Error: 47.3 → 19.2
Time: 2.2m
Precision: 64
Internal Precision: 2880
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le -1.413853159982469 \cdot 10^{+295}:\\ \;\;\;\;\frac{\log \left(e^{{\left(\frac{i}{n} + 1\right)}^{n} - 1}\right)}{\frac{i}{n}} \cdot 100\\ \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le -2.2073205140269853 \cdot 10^{-221}:\\ \;\;\;\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right)\\ \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le 5.85399269516402 \cdot 10^{-256}:\\ \;\;\;\;\log \left(e^{\left(n \cdot 100\right) \cdot \left(1 + i \cdot \frac{1}{2}\right)}\right)\\ \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le 7.657727310247747 \cdot 10^{+33} \lor \left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le 2.9476671514468694 \cdot 10^{+284}:\\ \;\;\;\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n} + 1\right)}^{n} - 1\right)}{\frac{i}{n}}\\ \end{array}\]

Error

Bits error versus i

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original47.3
Target46.5
Herbie19.2
\[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 5 regimes
  2. if (* (* (* (cbrt (+ 1 (* 1/2 i))) 100) (pow (+ 1 (* 1/2 i)) 1/3)) (* (pow (+ 1 (* 1/2 i)) 1/3) n)) < -1.413853159982469e+295

    1. Initial program 16.0

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Using strategy rm
    3. Applied add-log-exp16.0

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

    if -1.413853159982469e+295 < (* (* (* (cbrt (+ 1 (* 1/2 i))) 100) (pow (+ 1 (* 1/2 i)) 1/3)) (* (pow (+ 1 (* 1/2 i)) 1/3) n)) < -2.2073205140269853e-221 or 7.657727310247747e+33 < (* (* (* (cbrt (+ 1 (* 1/2 i))) 100) (pow (+ 1 (* 1/2 i)) 1/3)) (* (pow (+ 1 (* 1/2 i)) 1/3) n)) < 2.9476671514468694e+284

    1. Initial program 58.4

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Taylor expanded around 0 60.7

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

      \[\leadsto \color{blue}{\frac{i \cdot \frac{1}{2} + 1}{\frac{\frac{i}{n}}{100 \cdot i}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity27.3

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\frac{\color{blue}{1 \cdot \frac{i}{n}}}{100 \cdot i}}\]
    6. Applied times-frac27.2

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\color{blue}{\frac{1}{100} \cdot \frac{\frac{i}{n}}{i}}}\]
    7. Applied add-cube-cbrt27.2

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{i \cdot \frac{1}{2} + 1} \cdot \sqrt[3]{i \cdot \frac{1}{2} + 1}\right) \cdot \sqrt[3]{i \cdot \frac{1}{2} + 1}}}{\frac{1}{100} \cdot \frac{\frac{i}{n}}{i}}\]
    8. Applied times-frac27.2

      \[\leadsto \color{blue}{\frac{\sqrt[3]{i \cdot \frac{1}{2} + 1} \cdot \sqrt[3]{i \cdot \frac{1}{2} + 1}}{\frac{1}{100}} \cdot \frac{\sqrt[3]{i \cdot \frac{1}{2} + 1}}{\frac{\frac{i}{n}}{i}}}\]
    9. Applied simplify27.2

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) \cdot \sqrt[3]{1 + \frac{1}{2} \cdot i}\right)} \cdot \frac{\sqrt[3]{i \cdot \frac{1}{2} + 1}}{\frac{\frac{i}{n}}{i}}\]
    10. Applied simplify10.4

      \[\leadsto \left(\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) \cdot \sqrt[3]{1 + \frac{1}{2} \cdot i}\right) \cdot \color{blue}{\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right)}\]
    11. Using strategy rm
    12. Applied pow1/310.4

      \[\leadsto \left(\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) \cdot \color{blue}{{\left(1 + \frac{1}{2} \cdot i\right)}^{\frac{1}{3}}}\right) \cdot \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right)\]
    13. Using strategy rm
    14. Applied pow1/310.4

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

    if -2.2073205140269853e-221 < (* (* (* (cbrt (+ 1 (* 1/2 i))) 100) (pow (+ 1 (* 1/2 i)) 1/3)) (* (pow (+ 1 (* 1/2 i)) 1/3) n)) < 5.85399269516402e-256

    1. Initial program 23.0

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Taylor expanded around 0 25.0

      \[\leadsto 100 \cdot \frac{\color{blue}{\left(\frac{1}{2} \cdot {i}^{2} + \left(1 + i\right)\right)} - 1}{\frac{i}{n}}\]
    3. Applied simplify45.9

      \[\leadsto \color{blue}{\frac{i \cdot \frac{1}{2} + 1}{\frac{\frac{i}{n}}{100 \cdot i}}}\]
    4. Using strategy rm
    5. Applied add-log-exp22.4

      \[\leadsto \color{blue}{\log \left(e^{\frac{i \cdot \frac{1}{2} + 1}{\frac{\frac{i}{n}}{100 \cdot i}}}\right)}\]
    6. Applied simplify22.4

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

    if 5.85399269516402e-256 < (* (* (* (cbrt (+ 1 (* 1/2 i))) 100) (pow (+ 1 (* 1/2 i)) 1/3)) (* (pow (+ 1 (* 1/2 i)) 1/3) n)) < 7.657727310247747e+33

    1. Initial program 53.9

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Taylor expanded around 0 55.5

      \[\leadsto 100 \cdot \frac{\color{blue}{\left(\frac{1}{2} \cdot {i}^{2} + \left(1 + i\right)\right)} - 1}{\frac{i}{n}}\]
    3. Applied simplify19.6

      \[\leadsto \color{blue}{\frac{i \cdot \frac{1}{2} + 1}{\frac{\frac{i}{n}}{100 \cdot i}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity19.6

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\frac{\color{blue}{1 \cdot \frac{i}{n}}}{100 \cdot i}}\]
    6. Applied times-frac19.6

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\color{blue}{\frac{1}{100} \cdot \frac{\frac{i}{n}}{i}}}\]
    7. Applied add-cube-cbrt19.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{i \cdot \frac{1}{2} + 1} \cdot \sqrt[3]{i \cdot \frac{1}{2} + 1}\right) \cdot \sqrt[3]{i \cdot \frac{1}{2} + 1}}}{\frac{1}{100} \cdot \frac{\frac{i}{n}}{i}}\]
    8. Applied times-frac19.5

      \[\leadsto \color{blue}{\frac{\sqrt[3]{i \cdot \frac{1}{2} + 1} \cdot \sqrt[3]{i \cdot \frac{1}{2} + 1}}{\frac{1}{100}} \cdot \frac{\sqrt[3]{i \cdot \frac{1}{2} + 1}}{\frac{\frac{i}{n}}{i}}}\]
    9. Applied simplify19.5

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) \cdot \sqrt[3]{1 + \frac{1}{2} \cdot i}\right)} \cdot \frac{\sqrt[3]{i \cdot \frac{1}{2} + 1}}{\frac{\frac{i}{n}}{i}}\]
    10. Applied simplify27.5

      \[\leadsto \left(\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) \cdot \sqrt[3]{1 + \frac{1}{2} \cdot i}\right) \cdot \color{blue}{\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right)}\]
    11. Using strategy rm
    12. Applied pow1/327.5

      \[\leadsto \left(\left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) \cdot \color{blue}{{\left(1 + \frac{1}{2} \cdot i\right)}^{\frac{1}{3}}}\right) \cdot \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right)\]
    13. Using strategy rm
    14. Applied pow1/327.5

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

    if 2.9476671514468694e+284 < (* (* (* (cbrt (+ 1 (* 1/2 i))) 100) (pow (+ 1 (* 1/2 i)) 1/3)) (* (pow (+ 1 (* 1/2 i)) 1/3) n))

    1. Initial program 29.9

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le -1.413853159982469 \cdot 10^{+295}:\\ \;\;\;\;\frac{\log \left(e^{{\left(\frac{i}{n} + 1\right)}^{n} - 1}\right)}{\frac{i}{n}} \cdot 100\\ \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le -2.2073205140269853 \cdot 10^{-221}:\\ \;\;\;\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right)\\ \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le 5.85399269516402 \cdot 10^{-256}:\\ \;\;\;\;\log \left(e^{\left(n \cdot 100\right) \cdot \left(1 + i \cdot \frac{1}{2}\right)}\right)\\ \mathbf{if}\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le 7.657727310247747 \cdot 10^{+33} \lor \left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right) \le 2.9476671514468694 \cdot 10^{+284}:\\ \;\;\;\;\left(n \cdot {\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}}\right) \cdot \left({\left(1 + i \cdot \frac{1}{2}\right)}^{\frac{1}{3}} \cdot \left(100 \cdot \sqrt[3]{1 + i \cdot \frac{1}{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n} + 1\right)}^{n} - 1\right)}{\frac{i}{n}}\\ \end{array}}\]

Runtime

Time bar (total: 2.2m)Debug logProfile

herbie shell --seed 2018199 
(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))))