\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
Test:
Compound Interest
Bits:
128 bits
Bits error versus i
Bits error versus n
Time: 13.0 s
Input Error: 23.2
Output Error: 5.7
Log:
Profile: 🕒
\(\begin{cases} 100 \cdot \frac{\log \left(e^{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)}{\frac{i}{n}} & \text{when } i \le -8.4597405f-09 \\ \left(i \cdot 50 + 100\right) \cdot n & \text{when } i \le 0.15324226f0 \\ 100 \cdot \left(\frac{\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} + 1}{i} \cdot \frac{\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{1}{n}}\right) & \text{otherwise} \end{cases}\)

    if i < -8.4597405f-09

    1. Started with
      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
      12.8
    2. Using strategy rm
      12.8
    3. Applied add-log-exp to get
      \[100 \cdot \frac{\color{red}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \leadsto 100 \cdot \frac{\color{blue}{\log \left(e^{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)}}{\frac{i}{n}}\]
      12.8

    if -8.4597405f-09 < i < 0.15324226f0

    1. Started with
      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
      29.7
    2. Applied taylor to get
      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \leadsto 100 \cdot \frac{\left(\frac{1}{2} \cdot {i}^2 + \left(1 + i\right)\right) - 1}{\frac{i}{n}}\]
      27.7
    3. Taylor expanded around 0 to get
      \[100 \cdot \frac{\color{red}{\left(\frac{1}{2} \cdot {i}^2 + \left(1 + i\right)\right)} - 1}{\frac{i}{n}} \leadsto 100 \cdot \frac{\color{blue}{\left(\frac{1}{2} \cdot {i}^2 + \left(1 + i\right)\right)} - 1}{\frac{i}{n}}\]
      27.7
    4. Applied simplify to get
      \[\color{red}{100 \cdot \frac{\left(\frac{1}{2} \cdot {i}^2 + \left(1 + i\right)\right) - 1}{\frac{i}{n}}} \leadsto \color{blue}{\left(\frac{1}{2} \cdot i + 1\right) \cdot \frac{i \cdot 100}{\frac{i}{n}}}\]
      6.0
    5. Applied taylor to get
      \[\left(\frac{1}{2} \cdot i + 1\right) \cdot \frac{i \cdot 100}{\frac{i}{n}} \leadsto 100 \cdot n + 50 \cdot \left(n \cdot i\right)\]
      0.0
    6. Taylor expanded around 0 to get
      \[\color{red}{100 \cdot n + 50 \cdot \left(n \cdot i\right)} \leadsto \color{blue}{100 \cdot n + 50 \cdot \left(n \cdot i\right)}\]
      0.0
    7. Applied simplify to get
      \[\color{red}{100 \cdot n + 50 \cdot \left(n \cdot i\right)} \leadsto \color{blue}{\left(i \cdot 50 + 100\right) \cdot n}\]
      0.0

    if 0.15324226f0 < i

    1. Started with
      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
      15.9
    2. Using strategy rm
      15.9
    3. Applied div-inv to get
      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\color{red}{\frac{i}{n}}} \leadsto 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\color{blue}{i \cdot \frac{1}{n}}}\]
      16.0
    4. Applied add-sqr-sqrt to get
      \[100 \cdot \frac{\color{red}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{i \cdot \frac{1}{n}} \leadsto 100 \cdot \frac{\color{blue}{{\left(\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}}\right)}^2} - 1}{i \cdot \frac{1}{n}}\]
      16.1
    5. Applied difference-of-sqr-1 to get
      \[100 \cdot \frac{\color{red}{{\left(\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}}\right)}^2 - 1}}{i \cdot \frac{1}{n}} \leadsto 100 \cdot \frac{\color{blue}{\left(\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} + 1\right) \cdot \left(\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} - 1\right)}}{i \cdot \frac{1}{n}}\]
      16.1
    6. Applied times-frac to get
      \[100 \cdot \color{red}{\frac{\left(\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} + 1\right) \cdot \left(\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} - 1\right)}{i \cdot \frac{1}{n}}} \leadsto 100 \cdot \color{blue}{\left(\frac{\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} + 1}{i} \cdot \frac{\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{1}{n}}\right)}\]
      16.1

  1. Removed slow pow expressions

Original test:


(lambda ((i default) (n default))
  #:name "Compound Interest"
  (* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n)))
  #:target
  (* 100 (/ (- (exp (* n (if (= (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) 1) (/ i n))))