Average Error: 47.2 → 15.2
Time: 1.1m
Precision: 64
Internal Precision: 3392
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;i \le -1.020274055697709 \cdot 10^{-15}:\\ \;\;\;\;\left({\left(\frac{i}{n}\right)}^{n} + -1\right) \cdot \frac{100}{\frac{i}{n}}\\ \mathbf{elif}\;i \le 7.80502775258785 \cdot 10^{+33}:\\ \;\;\;\;100 \cdot n + \left(\left(n \cdot i\right) \cdot e^{\log \left(\sqrt[3]{\frac{50}{3} \cdot i + 50} \cdot \sqrt[3]{\frac{50}{3} \cdot i + 50}\right)}\right) \cdot \sqrt[3]{\frac{50}{3} \cdot i + 50}\\ \mathbf{elif}\;i \le 1.6621105624751792 \cdot 10^{+261}:\\ \;\;\;\;\log \left({\left(e^{n}\right)}^{\left(\left(i \cdot 50 + 100\right) + \frac{50}{3} \cdot \left(i \cdot i\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(\frac{i}{n}\right)}^{n} + -1\right) \cdot \frac{100}{\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.2
Target47.0
Herbie15.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 3 regimes
  2. if i < -1.020274055697709e-15 or 1.6621105624751792e+261 < i

    1. Initial program 29.9

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

      \[\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}}\]
    3. Simplified21.6

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

    if -1.020274055697709e-15 < i < 7.80502775258785e+33

    1. Initial program 57.1

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

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

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

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

      \[\leadsto \color{blue}{\left(i \cdot n\right) \cdot \left(50 + \frac{50}{3} \cdot i\right) + 100 \cdot n}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt10.1

      \[\leadsto \left(i \cdot n\right) \cdot \color{blue}{\left(\left(\sqrt[3]{50 + \frac{50}{3} \cdot i} \cdot \sqrt[3]{50 + \frac{50}{3} \cdot i}\right) \cdot \sqrt[3]{50 + \frac{50}{3} \cdot i}\right)} + 100 \cdot n\]
    8. Applied associate-*r*10.1

      \[\leadsto \color{blue}{\left(\left(i \cdot n\right) \cdot \left(\sqrt[3]{50 + \frac{50}{3} \cdot i} \cdot \sqrt[3]{50 + \frac{50}{3} \cdot i}\right)\right) \cdot \sqrt[3]{50 + \frac{50}{3} \cdot i}} + 100 \cdot n\]
    9. Using strategy rm
    10. Applied add-exp-log10.1

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

    if 7.80502775258785e+33 < i < 1.6621105624751792e+261

    1. Initial program 30.6

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

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

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

      \[\leadsto \color{blue}{\frac{50}{3} \cdot \left({i}^{2} \cdot n\right) + \left(100 \cdot n + 50 \cdot \left(i \cdot n\right)\right)}\]
    5. Simplified62.7

      \[\leadsto \color{blue}{\left(i \cdot n\right) \cdot \left(50 + \frac{50}{3} \cdot i\right) + 100 \cdot n}\]
    6. Using strategy rm
    7. Applied add-log-exp62.7

      \[\leadsto \left(i \cdot n\right) \cdot \left(50 + \frac{50}{3} \cdot i\right) + \color{blue}{\log \left(e^{100 \cdot n}\right)}\]
    8. Applied add-log-exp55.4

      \[\leadsto \color{blue}{\log \left(e^{\left(i \cdot n\right) \cdot \left(50 + \frac{50}{3} \cdot i\right)}\right)} + \log \left(e^{100 \cdot n}\right)\]
    9. Applied sum-log55.4

      \[\leadsto \color{blue}{\log \left(e^{\left(i \cdot n\right) \cdot \left(50 + \frac{50}{3} \cdot i\right)} \cdot e^{100 \cdot n}\right)}\]
    10. Simplified30.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \le -1.020274055697709 \cdot 10^{-15}:\\ \;\;\;\;\left({\left(\frac{i}{n}\right)}^{n} + -1\right) \cdot \frac{100}{\frac{i}{n}}\\ \mathbf{elif}\;i \le 7.80502775258785 \cdot 10^{+33}:\\ \;\;\;\;100 \cdot n + \left(\left(n \cdot i\right) \cdot e^{\log \left(\sqrt[3]{\frac{50}{3} \cdot i + 50} \cdot \sqrt[3]{\frac{50}{3} \cdot i + 50}\right)}\right) \cdot \sqrt[3]{\frac{50}{3} \cdot i + 50}\\ \mathbf{elif}\;i \le 1.6621105624751792 \cdot 10^{+261}:\\ \;\;\;\;\log \left({\left(e^{n}\right)}^{\left(\left(i \cdot 50 + 100\right) + \frac{50}{3} \cdot \left(i \cdot i\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left({\left(\frac{i}{n}\right)}^{n} + -1\right) \cdot \frac{100}{\frac{i}{n}}\\ \end{array}\]

Runtime

Time bar (total: 1.1m)Debug logProfile

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