Average Error: 42.2 → 21.2
Time: 27.6s
Precision: 64
Internal Precision: 128
\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
\[\begin{array}{l} \mathbf{if}\;n \le -2.2020953495892706 \cdot 10^{+82}:\\ \;\;\;\;\left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)}\right) + n\right) \cdot 100\\ \mathbf{elif}\;n \le -1.1970289205805727 \cdot 10^{+28}:\\ \;\;\;\;100 \cdot \left(n \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{i} - \frac{1}{i}\right)\right)\\ \mathbf{elif}\;n \le -660.4789951886963 \lor \neg \left(n \le 3.8746181704323983 \cdot 10^{-106}\right):\\ \;\;\;\;\left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)}\right) + n\right) \cdot 100\\ \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

Original42.2
Target41.6
Herbie21.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 n < -2.2020953495892706e+82 or -1.1970289205805727e+28 < n < -660.4789951886963 or 3.8746181704323983e-106 < n

    1. Initial program 53.7

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

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

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

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

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

    if -2.2020953495892706e+82 < n < -1.1970289205805727e+28

    1. Initial program 32.5

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

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)}\]
    4. Using strategy rm
    5. Applied associate-/r/32.4

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

      \[\leadsto 100 \cdot \left(\color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n} - \frac{1}{i} \cdot n\right)\]
    7. Applied distribute-rgt-out--32.4

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

    if -660.4789951886963 < n < 3.8746181704323983e-106

    1. Initial program 26.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \le -2.2020953495892706 \cdot 10^{+82}:\\ \;\;\;\;\left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)}\right) + n\right) \cdot 100\\ \mathbf{elif}\;n \le -1.1970289205805727 \cdot 10^{+28}:\\ \;\;\;\;100 \cdot \left(n \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{i} - \frac{1}{i}\right)\right)\\ \mathbf{elif}\;n \le -660.4789951886963 \lor \neg \left(n \le 3.8746181704323983 \cdot 10^{-106}\right):\\ \;\;\;\;\left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \left(\sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)} \cdot \sqrt[3]{\left(\frac{1}{6} \cdot i + \frac{1}{2}\right) \cdot \left(i \cdot n\right)}\right) + n\right) \cdot 100\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

herbie shell --seed 2019007 
(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: 26.6s)Debug log

sample395.0ms

Algorithm
intervals

simplify216.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 41.2b

localize25.0ms

Local error

Found 4 expressions with local error:

11.8b
(/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))
7.3b
(pow (+ 1 (/ i n)) n)
1.0b
(- (pow (+ 1 (/ i n)) n) 1)
0.1b
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))

rewrite72.0ms

Algorithm
rewrite-expression-head
Counts
4 → 105
Calls

4 calls. Slowest were:

33.0ms
(/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))
17.0ms
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))
16.0ms
(- (pow (+ 1 (/ i n)) n) 1)

series644.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

202.0ms
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))
190.0ms
(/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))
131.0ms
(- (pow (+ 1 (/ i n)) n) 1)
120.0ms
(pow (+ 1 (/ i n)) n)

simplify3.2s

Counts
97 → 117
Calls

97 calls. Slowest were:

317.0ms
(/ (* (- (exp (* (- (log (/ 1 n)) (log (/ 1 i))) n)) 1) n) i)
288.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)))
228.0ms
(* 100 (/ (* n (- (exp (* n (- (log (/ -1 n)) (log (/ -1 i))))) 1)) i))

prune1.2s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 17.9b

localize13.0ms

Local error

Found 4 expressions with local error:

13.3b
(- (/ (pow (+ 1 (/ i n)) n) (/ i n)) (/ 1 (/ i n)))
7.3b
(pow (+ 1 (/ i n)) n)
0.3b
(/ 1 (/ i n))
0.3b
(/ (pow (+ 1 (/ i n)) n) (/ i n))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 103
Calls

4 calls. Slowest were:

12.0ms
(- (/ (pow (+ 1 (/ i n)) n) (/ i n)) (/ 1 (/ i n)))
7.0ms
(/ (pow (+ 1 (/ i n)) n) (/ i n))
1.0ms
(pow (+ 1 (/ i n)) n)

series506.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

194.0ms
(/ (pow (+ 1 (/ i n)) n) (/ i n))
169.0ms
(- (/ (pow (+ 1 (/ i n)) n) (/ i n)) (/ 1 (/ i n)))
133.0ms
(pow (+ 1 (/ i n)) n)
10.0ms
(/ 1 (/ i n))

simplify2.3s

Counts
103 → 115
Calls

103 calls. Slowest were:

336.0ms
(/ (* (- (exp (* (- (log (/ 1 n)) (log (/ 1 i))) n)) 1) n) i)
211.0ms
(/ (* (exp (* (- (log (/ 1 n)) (log (/ 1 i))) n)) n) i)
177.0ms
(/ (* n (- (exp (* n (- (log (/ -1 n)) (log (/ -1 i))))) 1)) i)

prune970.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 6.3b

localize32.0ms

Local error

Found 3 expressions with local error:

0.4b
(* 1/6 i)
0.1b
(* (* i n) (+ (* 1/6 i) 1/2))
0.1b
(* 100 (+ n (* (* i n) (+ (* 1/6 i) 1/2))))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 42
Calls

3 calls. Slowest were:

9.0ms
(* (* i n) (+ (* 1/6 i) 1/2))
1.0ms
(* 100 (+ n (* (* i n) (+ (* 1/6 i) 1/2))))
0.0ms
(* 1/6 i)

series78.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

46.0ms
(* 100 (+ n (* (* i n) (+ (* 1/6 i) 1/2))))
25.0ms
(* (* i n) (+ (* 1/6 i) 1/2))
7.0ms
(* 1/6 i)

simplify2.4s

Counts
26 → 51
Calls

26 calls. Slowest were:

391.0ms
(- n (* (* i n) (+ (* 1/6 i) 1/2)))
253.0ms
(* 100 (* (* i n) (+ (* 1/6 i) 1/2)))
232.0ms
(* (* (* i n) (+ (* 1/6 i) 1/2)) 100)

prune479.0ms

Pruning

17 alts after pruning (17 fresh and 0 done)

Merged error: 6.3b

localize30.0ms

Local error

Found 4 expressions with local error:

19.1b
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
19.1b
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
19.1b
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
0.4b
(* 1/6 i)

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 41
Calls

4 calls. Slowest were:

6.0ms
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
6.0ms
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
5.0ms
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))

series255.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

101.0ms
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
80.0ms
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
67.0ms
(cbrt (* (* i n) (+ (* 1/6 i) 1/2)))
7.0ms
(* 1/6 i)

simplify3.3s

Counts
21 → 53
Calls

21 calls. Slowest were:

529.0ms
(cbrt (* (* i n) (+ (pow (* 1/6 i) 3) (pow 1/2 3))))
299.0ms
(- (+ (exp (* 1/3 (- (log -1/6) (+ (* 2 (log (/ -1 i))) (log (/ -1 n)))))) (/ (exp (* 1/3 (- (log -1/6) (+ (* 2 (log (/ -1 i))) (log (/ -1 n)))))) i)) (/ (exp (* 1/3 (- (log -1/6) (+ (* 2 (log (/ -1 i))) (log (/ -1 n)))))) (pow i 2)))
296.0ms
(- (+ (exp (* 1/3 (- (log -1/6) (+ (* 2 (log (/ -1 i))) (log (/ -1 n)))))) (/ (exp (* 1/3 (- (log -1/6) (+ (* 2 (log (/ -1 i))) (log (/ -1 n)))))) i)) (/ (exp (* 1/3 (- (log -1/6) (+ (* 2 (log (/ -1 i))) (log (/ -1 n)))))) (pow i 2)))

prune641.0ms

Pruning

17 alts after pruning (16 fresh and 1 done)

Merged error: 6.3b

regimes559.0ms

Accuracy

48.5% (13.1b remaining)

Error of 21.2b against oracle of 8.1b and baseline of 33.5b

bsearch633.0ms

end0.0ms

sample8.5s

Algorithm
intervals