Average Error: 47.5 → 18.5
Time: 2.2m
Precision: 64
Internal Precision: 3392
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;e^{\log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) + \log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i}\right)} \cdot \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right) \le -1.3570284883755644 \cdot 10^{-192}:\\ \;\;\;\;\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}\;e^{\log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) + \log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i}\right)} \cdot \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right) \le 1.6918520627528846 \cdot 10^{-280}:\\ \;\;\;\;\left(100 \cdot \frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1} \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i}\right) \cdot \frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{1}{n}}\\ \mathbf{if}\;e^{\log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) + \log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i}\right)} \cdot \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right) \le 2.184763415670238 \cdot 10^{+37}:\\ \;\;\;\;\frac{\sqrt{i \cdot \frac{1}{2} + 1}}{\frac{\sqrt[3]{\frac{i}{n}} \cdot \sqrt[3]{\frac{i}{n}}}{100}} \cdot \frac{\sqrt{i \cdot \frac{1}{2} + 1}}{\frac{\sqrt[3]{\frac{i}{n}}}{i}}\\ \mathbf{if}\;e^{\log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot 100\right) + \log \left(\sqrt[3]{1 + \frac{1}{2} \cdot i}\right)} \cdot \left(\sqrt[3]{1 + \frac{1}{2} \cdot i} \cdot n\right) \le 6.075228628301184 \cdot 10^{+306}:\\ \;\;\;\;\frac{i \cdot \frac{1}{2} + 1}{\frac{1}{n \cdot 100}}\\ \mathbf{else}:\\ \;\;\;\;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}}\\ \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
Target47.0
Herbie18.5
\[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 (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < -1.3570284883755644e-192

    1. Initial program 54.3

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

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

      \[\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-identity28.9

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

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

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

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

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

      \[\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 -1.3570284883755644e-192 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < 1.6918520627528846e-280

    1. Initial program 22.7

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

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

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

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

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

    if 1.6918520627528846e-280 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < 2.184763415670238e+37

    1. Initial program 52.5

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

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

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

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\color{blue}{\frac{\sqrt[3]{\frac{i}{n}} \cdot \sqrt[3]{\frac{i}{n}}}{100} \cdot \frac{\sqrt[3]{\frac{i}{n}}}{i}}}\]
    7. Applied add-sqr-sqrt21.8

      \[\leadsto \frac{\color{blue}{\sqrt{i \cdot \frac{1}{2} + 1} \cdot \sqrt{i \cdot \frac{1}{2} + 1}}}{\frac{\sqrt[3]{\frac{i}{n}} \cdot \sqrt[3]{\frac{i}{n}}}{100} \cdot \frac{\sqrt[3]{\frac{i}{n}}}{i}}\]
    8. Applied times-frac21.8

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

    if 2.184763415670238e+37 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < 6.075228628301184e+306

    1. Initial program 59.2

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

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

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

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

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\frac{1}{\color{blue}{n \cdot 100}}}\]

    if 6.075228628301184e+306 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n))

    1. Initial program 28.8

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

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

      \[\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}}\]
  3. Recombined 5 regimes into one program.

Runtime

Time bar (total: 2.2m)Debug logProfile

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