Average Error: 46.9 → 14.7
Time: 48.8s
Precision: 64
Internal Precision: 3136
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;i \le -48.698076754147564 \lor \neg \left(i \le 14006630.041316262\right):\\ \;\;\;\;\left({\left(\frac{i}{n}\right)}^{n} + -1\right) \cdot \frac{100}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot n + \left(\left(n \cdot i\right) \cdot {\left(\left(\frac{50}{3} \cdot i + 50\right) \cdot \left(\frac{50}{3} \cdot i + 50\right)\right)}^{\frac{1}{3}}\right) \cdot \sqrt[3]{\frac{50}{3} \cdot i + 50}\\ \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

Original46.9
Target46.7
Herbie14.7
\[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 2 regimes
  2. if i < -48.698076754147564 or 14006630.041316262 < i

    1. Initial program 28.9

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

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

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

    if -48.698076754147564 < i < 14006630.041316262

    1. Initial program 57.5

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

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

      \[\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 -inf 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 pow1/310.1

      \[\leadsto \left(\left(i \cdot n\right) \cdot \left(\sqrt[3]{50 + \frac{50}{3} \cdot i} \cdot \color{blue}{{\left(50 + \frac{50}{3} \cdot i\right)}^{\frac{1}{3}}}\right)\right) \cdot \sqrt[3]{50 + \frac{50}{3} \cdot i} + 100 \cdot n\]
    11. Applied pow1/310.1

      \[\leadsto \left(\left(i \cdot n\right) \cdot \left(\color{blue}{{\left(50 + \frac{50}{3} \cdot i\right)}^{\frac{1}{3}}} \cdot {\left(50 + \frac{50}{3} \cdot i\right)}^{\frac{1}{3}}\right)\right) \cdot \sqrt[3]{50 + \frac{50}{3} \cdot i} + 100 \cdot n\]
    12. Applied pow-prod-down10.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \le -48.698076754147564 \lor \neg \left(i \le 14006630.041316262\right):\\ \;\;\;\;\left({\left(\frac{i}{n}\right)}^{n} + -1\right) \cdot \frac{100}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot n + \left(\left(n \cdot i\right) \cdot {\left(\left(\frac{50}{3} \cdot i + 50\right) \cdot \left(\frac{50}{3} \cdot i + 50\right)\right)}^{\frac{1}{3}}\right) \cdot \sqrt[3]{\frac{50}{3} \cdot i + 50}\\ \end{array}\]

Runtime

Time bar (total: 48.8s)Debug logProfile

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