Average Error: 42.6 → 19.4
Time: 30.0s
Precision: 64
Internal Precision: 128
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;i \le -12.035440265493026:\\ \;\;\;\;100 \cdot \frac{{\left(\frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\ \mathbf{elif}\;i \le -6.979401657817147 \cdot 10^{-276}:\\ \;\;\;\;\frac{n \cdot \left(100 \cdot \left(\left(i \cdot \frac{1}{6} + \frac{1}{2}\right) \cdot \left(i \cdot i\right) + i\right)\right)}{i}\\ \mathbf{elif}\;i \le 9.950093919193757 \cdot 10^{-43}:\\ \;\;\;\;\left(n \cdot i\right) \cdot \left(\frac{50}{3} \cdot i + 50\right) + 100 \cdot n\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{i}\right)\\ \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

Original42.6
Target42.1
Herbie19.4
\[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 < -12.035440265493026

    1. Initial program 27.9

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

      \[\leadsto 100 \cdot \color{blue}{\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. Simplified18.4

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

    if -12.035440265493026 < i < -6.979401657817147e-276

    1. Initial program 51.1

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

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

      \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n}\]
    5. Taylor expanded around 0 16.5

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

      \[\leadsto \left(100 \cdot \frac{\color{blue}{i + \left(i \cdot i\right) \cdot \left(\frac{1}{6} \cdot i + \frac{1}{2}\right)}}{i}\right) \cdot n\]
    7. Using strategy rm
    8. Applied associate-*r/16.6

      \[\leadsto \color{blue}{\frac{100 \cdot \left(i + \left(i \cdot i\right) \cdot \left(\frac{1}{6} \cdot i + \frac{1}{2}\right)\right)}{i}} \cdot n\]
    9. Applied associate-*l/15.2

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

    if -6.979401657817147e-276 < i < 9.950093919193757e-43

    1. Initial program 49.9

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

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

      \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n}\]
    5. Taylor expanded around 0 15.6

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

      \[\leadsto \left(100 \cdot \frac{\color{blue}{i + \left(i \cdot i\right) \cdot \left(\frac{1}{6} \cdot i + \frac{1}{2}\right)}}{i}\right) \cdot n\]
    7. Taylor expanded around -inf 15.6

      \[\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)}\]
    8. Simplified15.6

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

    if 9.950093919193757e-43 < i

    1. Initial program 35.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \le -12.035440265493026:\\ \;\;\;\;100 \cdot \frac{{\left(\frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\ \mathbf{elif}\;i \le -6.979401657817147 \cdot 10^{-276}:\\ \;\;\;\;\frac{n \cdot \left(100 \cdot \left(\left(i \cdot \frac{1}{6} + \frac{1}{2}\right) \cdot \left(i \cdot i\right) + i\right)\right)}{i}\\ \mathbf{elif}\;i \le 9.950093919193757 \cdot 10^{-43}:\\ \;\;\;\;\left(n \cdot i\right) \cdot \left(\frac{50}{3} \cdot i + 50\right) + 100 \cdot n\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{i}\right)\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 28.8s)Debug log

sample379.0ms

Algorithm
intervals

simplify193.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

193.0ms
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 40.4b

localize31.0ms

Local error

Found 4 expressions with local error:

10.9b
(/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))
4.9b
(pow (+ 1 (/ i n)) n)
2.2b
(- (pow (+ 1 (/ i n)) n) 1)
0.1b
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))

rewrite42.0ms

Algorithm
rewrite-expression-head
Counts
4 → 105
Calls

4 calls. Slowest were:

22.0ms
(/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))
9.0ms
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))
8.0ms
(- (pow (+ 1 (/ i n)) n) 1)

series678.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

239.0ms
(/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))
212.0ms
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))
133.0ms
(- (pow (+ 1 (/ i n)) n) 1)
93.0ms
(pow (+ 1 (/ i n)) n)

simplify3.6s

Counts
97 → 117
Calls

97 calls. Slowest were:

435.0ms
(/ (* (- (exp (* (- (log (/ 1 n)) (log (/ 1 i))) n)) 1) n) i)
316.0ms
(* 100 (/ (* n (- (exp (* n (- (log (/ -1 n)) (log (/ -1 i))))) 1)) i))
309.0ms
(/ (* (* (- (pow (+ 1 (/ i n)) n) 1) (- (pow (+ 1 (/ i n)) n) 1)) (- (pow (+ 1 (/ i n)) n) 1)) (* (* (/ i n) (/ i n)) (/ i n)))

prune1.1s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 18.7b

localize38.0ms

Local error

Found 4 expressions with local error:

10.9b
(/ (- (sqrt (pow (+ 1 (/ i n)) n)) 1) (/ i n))
4.9b
(pow (+ (/ i n) 1) n)
4.9b
(pow (+ 1 (/ i n)) n)
1.9b
(- (sqrt (pow (+ 1 (/ i n)) n)) 1)

rewrite73.0ms

Algorithm
rewrite-expression-head
Counts
4 → 90
Calls

4 calls. Slowest were:

40.0ms
(/ (- (sqrt (pow (+ 1 (/ i n)) n)) 1) (/ i n))
21.0ms
(- (sqrt (pow (+ 1 (/ i n)) n)) 1)
8.0ms
(pow (+ (/ i n) 1) n)

series806.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

325.0ms
(/ (- (sqrt (pow (+ 1 (/ i n)) n)) 1) (/ i n))
204.0ms
(- (sqrt (pow (+ 1 (/ i n)) n)) 1)
148.0ms
(pow (+ 1 (/ i n)) n)
128.0ms
(pow (+ (/ i n) 1) n)

simplify3.3s

Counts
87 → 102
Calls

87 calls. Slowest were:

525.0ms
(exp (* (- (log (/ 1 n)) (log (/ 1 i))) n))
329.0ms
(/ (* (* (- (sqrt (pow (+ 1 (/ i n)) n)) 1) (- (sqrt (pow (+ 1 (/ i n)) n)) 1)) (- (sqrt (pow (+ 1 (/ i n)) n)) 1)) (* (* (/ i n) (/ i n)) (/ i n)))
296.0ms
(/ (* (- (sqrt (exp (* (- (log (/ 1 n)) (log (/ 1 i))) n))) 1) n) i)

prune1.6s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 18.7b

localize21.0ms

Local error

Found 4 expressions with local error:

4.9b
(pow (+ 1 (/ i n)) n)
2.2b
(- (pow (+ 1 (/ i n)) n) 1)
0.1b
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) i))
0.0b
(* (* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) i)) n)

rewrite59.0ms

Algorithm
rewrite-expression-head
Counts
4 → 49
Calls

4 calls. Slowest were:

20.0ms
(* (* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) i)) n)
18.0ms
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) i))
17.0ms
(- (pow (+ 1 (/ i n)) n) 1)

series603.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

225.0ms
(* (* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) i)) n)
160.0ms
(- (pow (+ 1 (/ i n)) n) 1)
116.0ms
(pow (+ 1 (/ i n)) n)
102.0ms
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) i))

simplify1.9s

Counts
24 → 61
Calls

24 calls. Slowest were:

299.0ms
(* -1 (/ (- 100 (* 100 (exp (* n (- (log (/ -1 n)) (log (/ -1 i))))))) i))
245.0ms
(/ (- (* 100 (exp (* (- (log (/ 1 n)) (log (/ 1 i))) n))) 100) i)
241.0ms
(* 100 (/ (* n (- (exp (* n (- (log (/ -1 n)) (log (/ -1 i))))) 1)) i))

prune594.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 8.1b

localize47.0ms

Local error

Found 4 expressions with local error:

3.0b
(/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i)
2.7b
(* (* 100 (/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i)) n)
0.3b
(* 1/6 i)
0.1b
(* 100 (/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i))

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
4 → 46
Calls

4 calls. Slowest were:

18.0ms
(/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i)
4.0ms
(* (* 100 (/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i)) n)
1.0ms
(* 100 (/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i))

series92.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

37.0ms
(* (* 100 (/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i)) n)
28.0ms
(* 100 (/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i))
20.0ms
(/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i)
7.0ms
(* 1/6 i)

simplify1.4s

Counts
21 → 58
Calls

21 calls. Slowest were:

203.0ms
(* (* 100 (+ i (* (* i i) (+ (* 1/6 i) 1/2)))) n)
170.0ms
(* (cbrt (+ i (* (* i i) (+ (* 1/6 i) 1/2)))) (cbrt (+ i (* (* i i) (+ (* 1/6 i) 1/2)))))
120.0ms
(sqrt (/ (+ i (* (* i i) (+ (* 1/6 i) 1/2))) i))

prune492.0ms

Pruning

15 alts after pruning (14 fresh and 1 done)

Merged error: 8.0b

regimes399.0ms

Accuracy

55.2% (11.0b remaining)

Error of 19.4b against oracle of 8.4b and baseline of 33.0b

bsearch779.0ms

end0.0ms

sample10.6s

Algorithm
intervals