\[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.4 s
Input Error: 22.2
Output Error: 5.3
Log:
Profile: 🕒
\(\begin{cases} 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} & \text{when } {\left(1 + \frac{i}{n}\right)}^{n} \le 0.0f0 \\ 100 \cdot \frac{(e^{\log_* (1 + \frac{i}{n}) \cdot n} - 1)^*}{\frac{i}{n}} & \text{otherwise} \end{cases}\)

    if (pow (+ 1 (/ i n)) n) < 0.0f0

    1. Started with
      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
      0.3

    if 0.0f0 < (pow (+ 1 (/ i n)) n)

    1. Started with
      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\]
      26.1
    2. Using strategy rm
      26.1
    3. Applied add-exp-log to get
      \[100 \cdot \frac{{\color{red}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \leadsto 100 \cdot \frac{{\color{blue}{\left(e^{\log \left(1 + \frac{i}{n}\right)}\right)}}^{n} - 1}{\frac{i}{n}}\]
      26.1
    4. Applied pow-exp to get
      \[100 \cdot \frac{\color{red}{{\left(e^{\log \left(1 + \frac{i}{n}\right)}\right)}^{n}} - 1}{\frac{i}{n}} \leadsto 100 \cdot \frac{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}{\frac{i}{n}}\]
      26.1
    5. Applied expm1-def to get
      \[100 \cdot \frac{\color{red}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n} - 1}}{\frac{i}{n}} \leadsto 100 \cdot \frac{\color{blue}{(e^{\log \left(1 + \frac{i}{n}\right) \cdot n} - 1)^*}}{\frac{i}{n}}\]
      21.9
    6. Using strategy rm
      21.9
    7. Applied log1p-expm1-u to get
      \[100 \cdot \frac{(e^{\color{red}{\log \left(1 + \frac{i}{n}\right)} \cdot n} - 1)^*}{\frac{i}{n}} \leadsto 100 \cdot \frac{(e^{\color{blue}{\log_* (1 + (e^{\log \left(1 + \frac{i}{n}\right)} - 1)^*)} \cdot n} - 1)^*}{\frac{i}{n}}\]
      21.9
    8. Applied simplify to get
      \[100 \cdot \frac{(e^{\log_* (1 + \color{red}{(e^{\log \left(1 + \frac{i}{n}\right)} - 1)^*}) \cdot n} - 1)^*}{\frac{i}{n}} \leadsto 100 \cdot \frac{(e^{\log_* (1 + \color{blue}{\frac{i}{n}}) \cdot n} - 1)^*}{\frac{i}{n}}\]
      6.2

  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))))