Average Error: 47.4 → 7.1
Time: 43.0s
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 -7.496666199428134 \cdot 10^{-112}:\\ \;\;\;\;100 \cdot \frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{\frac{i}{n}}\\ \mathbf{elif}\;i \le 7.948478387505878 \cdot 10^{-127}:\\ \;\;\;\;n \cdot \left(\frac{(e^{i} - 1)^*}{i} \cdot 100\right)\\ \mathbf{elif}\;i \le 4.573187613559756 \cdot 10^{+75}:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \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.4
Target46.9
Herbie7.1
\[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 i < -7.496666199428134e-112

    1. Initial program 35.6

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

      \[\leadsto 100 \cdot \frac{\color{blue}{e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)}} - 1}{\frac{i}{n}}\]
    4. Applied expm1-def35.6

      \[\leadsto 100 \cdot \frac{\color{blue}{(e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)} - 1)^*}}{\frac{i}{n}}\]
    5. Simplified1.9

      \[\leadsto 100 \cdot \frac{(e^{\color{blue}{\log_* (1 + \frac{i}{n}) \cdot n}} - 1)^*}{\frac{i}{n}}\]

    if -7.496666199428134e-112 < i < 7.948478387505878e-127

    1. Initial program 59.1

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

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

      \[\leadsto 100 \cdot \frac{\color{blue}{(e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)} - 1)^*}}{\frac{i}{n}}\]
    5. Simplified21.1

      \[\leadsto 100 \cdot \frac{(e^{\color{blue}{\log_* (1 + \frac{i}{n}) \cdot n}} - 1)^*}{\frac{i}{n}}\]
    6. Using strategy rm
    7. Applied associate-/r/22.3

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{i} \cdot n\right)}\]
    8. Applied associate-*r*22.3

      \[\leadsto \color{blue}{\left(100 \cdot \frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{i}\right) \cdot n}\]
    9. Taylor expanded around 0 5.5

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

    if 7.948478387505878e-127 < i < 4.573187613559756e+75

    1. Initial program 50.7

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

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

      \[\leadsto 100 \cdot \frac{\color{blue}{(e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)} - 1)^*}}{\frac{i}{n}}\]
    5. Simplified6.1

      \[\leadsto 100 \cdot \frac{(e^{\color{blue}{\log_* (1 + \frac{i}{n}) \cdot n}} - 1)^*}{\frac{i}{n}}\]
    6. Using strategy rm
    7. Applied associate-/r/6.8

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{i} \cdot n\right)}\]
    8. Applied associate-*r*6.7

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

    if 4.573187613559756e+75 < i

    1. Initial program 33.1

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

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

      \[\leadsto 100 \cdot \frac{\color{blue}{(e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)} - 1)^*}}{\frac{i}{n}}\]
    5. Simplified47.8

      \[\leadsto 100 \cdot \frac{(e^{\color{blue}{\log_* (1 + \frac{i}{n}) \cdot n}} - 1)^*}{\frac{i}{n}}\]
    6. Using strategy rm
    7. Applied associate-*r/47.7

      \[\leadsto \color{blue}{\frac{100 \cdot (e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{\frac{i}{n}}}\]
    8. Taylor expanded around 0 29.2

      \[\leadsto \color{blue}{0}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \le -7.496666199428134 \cdot 10^{-112}:\\ \;\;\;\;100 \cdot \frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{\frac{i}{n}}\\ \mathbf{elif}\;i \le 7.948478387505878 \cdot 10^{-127}:\\ \;\;\;\;n \cdot \left(\frac{(e^{i} - 1)^*}{i} \cdot 100\right)\\ \mathbf{elif}\;i \le 4.573187613559756 \cdot 10^{+75}:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Runtime

Time bar (total: 43.0s)Debug logProfile

herbie shell --seed 2018230 +o rules:numerics
(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))))