Average Error: 47.5 → 17.3
Time: 6.9m
Precision: 64
Internal Precision: 3392
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;1 + \frac{1}{2} \cdot i \le -3.5964007201178633 \cdot 10^{+21}:\\ \;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot {\left(1 + \frac{i}{n}\right)}^{n} - 1}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\ \mathbf{if}\;1 + \frac{1}{2} \cdot i \le 1.00000000000054:\\ \;\;\;\;\left(\left(100 + \frac{100}{3} \cdot i\right) - \frac{25}{9} \cdot {i}^{2}\right) \cdot \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right)\\ \mathbf{if}\;1 + \frac{1}{2} \cdot i \le 2.3039825294862687 \cdot 10^{+153}:\\ \;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot {\left(1 + \frac{i}{n}\right)}^{n} - 1}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{i \cdot \frac{1}{2} + 1}{e^{\log \left(\frac{i}{n}\right) - \log \left(100 \cdot i\right)}}\\ \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.5
Target46.9
Herbie17.3
\[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 3 regimes
  2. if (+ 1 (* 1/2 i)) < -3.5964007201178633e+21 or 1.00000000000054 < (+ 1 (* 1/2 i)) < 2.3039825294862687e+153

    1. Initial program 28.3

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

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

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

    if -3.5964007201178633e+21 < (+ 1 (* 1/2 i)) < 1.00000000000054

    1. Initial program 57.3

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
    2. Taylor expanded around 0 57.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 simplify26.4

      \[\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-identity26.4

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

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

      \[\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-frac26.3

      \[\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 simplify26.3

      \[\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.8

      \[\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. Taylor expanded around 0 10.7

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

    if 2.3039825294862687e+153 < (+ 1 (* 1/2 i))

    1. Initial program 32.3

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

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

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

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\frac{\frac{i}{n}}{\color{blue}{e^{\log \left(100 \cdot i\right)}}}}\]
    6. Applied add-exp-log34.7

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

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

Runtime

Time bar (total: 6.9m)Debug logProfile

herbie shell --seed '#(1072967564 1937075727 894099792 790700740 1036514779 1027793188)' 
(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))))