Average Error: 47.1 → 16.8
Time: 2.3m
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) = -\infty:\\ \;\;\;\;100 \cdot \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 \left(n \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)\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.3656908641368595 \cdot 10^{-236}:\\ \;\;\;\;\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.667160863126875 \cdot 10^{-191}:\\ \;\;\;\;100 \cdot \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 \left(n \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)\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.0098637413681323 \cdot 10^{+82}:\\ \;\;\;\;\frac{100 + \left(100 \cdot i\right) \cdot \frac{1}{2}}{\frac{\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 5.5864212954745974 \cdot 10^{+305}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;100 \cdot \left(\left(\sqrt[3]{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \cdot \sqrt[3]{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}}\right) \cdot \sqrt[3]{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}}\right)\\ \end{array}\]

Error

Bits error versus i

Bits error versus n

Target

Original47.1
Target46.7
Herbie16.8
\[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 (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < -inf.0 or -1.3656908641368595e-236 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < 1.667160863126875e-191

    1. Initial program 20.6

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

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

      \[\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-frac20.6

      \[\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 simplify20.6

      \[\leadsto 100 \cdot \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 \color{blue}{\left(n \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)}\right)\]

    if -inf.0 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < -1.3656908641368595e-236 or 1.0098637413681323e+82 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < 5.5864212954745974e+305

    1. Initial program 57.7

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

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

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

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

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

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

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

      \[\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.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.667160863126875e-191 < (* (exp (+ (log (* (cbrt (+ 1 (* 1/2 i))) 100)) (log (cbrt (+ 1 (* 1/2 i)))))) (* (cbrt (+ 1 (* 1/2 i))) n)) < 1.0098637413681323e+82

    1. Initial program 56.9

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

      \[\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-identity17.2

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

      \[\leadsto \frac{i \cdot \frac{1}{2} + 1}{\color{blue}{\frac{1}{100} \cdot \frac{\frac{i}{n}}{i}}}\]
    7. Applied associate-/r*17.1

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

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

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

    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 add-cube-cbrt28.2

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

Runtime

Time bar (total: 2.3m)Debug logProfile

herbie shell --seed '#(1072840222 1305617769 1692503039 1353360431 4178980589 1488672652)' 
(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))))