?

Average Error: 48.2 → 12.0
Time: 21.6s
Precision: binary64
Cost: 20688

?

\[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
\[\begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -9.5 \cdot 10^{+76}:\\ \;\;\;\;n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{i}\\ \mathbf{elif}\;n \leq -6.3 \cdot 10^{-158}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(n \cdot \left(\log \left(\frac{-1}{n}\right) - \log \left(\frac{-1}{i}\right)\right)\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 1.4 \cdot 10^{-198}:\\ \;\;\;\;\frac{\left(n \cdot 100\right) \cdot \mathsf{fma}\left(-1, \log n, \log i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (i n)
 :precision binary64
 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
   (if (<= n -3.55e+106)
     t_0
     (if (<= n -9.5e+76)
       (* n (/ (+ (* 100.0 (pow (+ 1.0 (/ i n)) n)) -100.0) i))
       (if (<= n -6.3e-158)
         (/ (* 100.0 (expm1 i)) (/ i n))
         (if (<= n -5e-310)
           (/
            (* 100.0 (expm1 (* n (- (log (/ -1.0 n)) (log (/ -1.0 i))))))
            (/ i n))
           (if (<= n 1.4e-198)
             (/ (* (* n 100.0) (fma -1.0 (log n) (log i))) (/ i n))
             (if (<= n 8.2e-26)
               (* 100.0 (/ n (+ 1.0 (* i (+ -0.5 (* i 0.08333333333333333))))))
               t_0))))))))
double code(double i, double n) {
	return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
double code(double i, double n) {
	double t_0 = 100.0 * (n / (i / expm1(i)));
	double tmp;
	if (n <= -3.55e+106) {
		tmp = t_0;
	} else if (n <= -9.5e+76) {
		tmp = n * (((100.0 * pow((1.0 + (i / n)), n)) + -100.0) / i);
	} else if (n <= -6.3e-158) {
		tmp = (100.0 * expm1(i)) / (i / n);
	} else if (n <= -5e-310) {
		tmp = (100.0 * expm1((n * (log((-1.0 / n)) - log((-1.0 / i)))))) / (i / n);
	} else if (n <= 1.4e-198) {
		tmp = ((n * 100.0) * fma(-1.0, log(n), log(i))) / (i / n);
	} else if (n <= 8.2e-26) {
		tmp = 100.0 * (n / (1.0 + (i * (-0.5 + (i * 0.08333333333333333)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(i, n)
	return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n)))
end
function code(i, n)
	t_0 = Float64(100.0 * Float64(n / Float64(i / expm1(i))))
	tmp = 0.0
	if (n <= -3.55e+106)
		tmp = t_0;
	elseif (n <= -9.5e+76)
		tmp = Float64(n * Float64(Float64(Float64(100.0 * (Float64(1.0 + Float64(i / n)) ^ n)) + -100.0) / i));
	elseif (n <= -6.3e-158)
		tmp = Float64(Float64(100.0 * expm1(i)) / Float64(i / n));
	elseif (n <= -5e-310)
		tmp = Float64(Float64(100.0 * expm1(Float64(n * Float64(log(Float64(-1.0 / n)) - log(Float64(-1.0 / i)))))) / Float64(i / n));
	elseif (n <= 1.4e-198)
		tmp = Float64(Float64(Float64(n * 100.0) * fma(-1.0, log(n), log(i))) / Float64(i / n));
	elseif (n <= 8.2e-26)
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * Float64(-0.5 + Float64(i * 0.08333333333333333))))));
	else
		tmp = t_0;
	end
	return tmp
end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -3.55e+106], t$95$0, If[LessEqual[n, -9.5e+76], N[(n * N[(N[(N[(100.0 * N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -6.3e-158], N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -5e-310], N[(N[(100.0 * N[(Exp[N[(n * N[(N[Log[N[(-1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Log[N[(-1.0 / i), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.4e-198], N[(N[(N[(n * 100.0), $MachinePrecision] * N[(-1.0 * N[Log[n], $MachinePrecision] + N[Log[i], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.2e-26], N[(100.0 * N[(n / N[(1.0 + N[(i * N[(-0.5 + N[(i * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\begin{array}{l}
t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;n \leq -9.5 \cdot 10^{+76}:\\
\;\;\;\;n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{i}\\

\mathbf{elif}\;n \leq -6.3 \cdot 10^{-158}:\\
\;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\

\mathbf{elif}\;n \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(n \cdot \left(\log \left(\frac{-1}{n}\right) - \log \left(\frac{-1}{i}\right)\right)\right)}{\frac{i}{n}}\\

\mathbf{elif}\;n \leq 1.4 \cdot 10^{-198}:\\
\;\;\;\;\frac{\left(n \cdot 100\right) \cdot \mathsf{fma}\left(-1, \log n, \log i\right)}{\frac{i}{n}}\\

\mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Target

Original48.2
Target48.1
Herbie12.0
\[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 6 regimes
  2. if n < -3.55000000000000015e106 or 8.1999999999999997e-26 < n

    1. Initial program 56.1

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Simplified55.6

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

      [Start]56.1

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

      associate-/r/ [=>]55.6

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

      *-commutative [=>]55.6

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

      *-rgt-identity [<=]55.6

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

      associate-*l* [=>]55.6

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

      *-lft-identity [=>]55.6

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

      sub-neg [=>]55.6

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

      metadata-eval [=>]55.6

      \[ 100 \cdot \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}}{i}\right) \]
    3. Taylor expanded in n around inf 47.1

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

      \[\leadsto \color{blue}{100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
      Proof

      [Start]47.1

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

      associate-/l* [=>]47.1

      \[ 100 \cdot \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \]

      expm1-def [=>]4.0

      \[ 100 \cdot \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \]

    if -3.55000000000000015e106 < n < -9.5000000000000003e76

    1. Initial program 39.0

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Simplified38.7

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

      [Start]39.0

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

      associate-/r/ [=>]38.7

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

      associate-*r* [=>]38.8

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

      *-lft-identity [<=]38.8

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

      associate-*r* [=>]38.8

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

      *-commutative [=>]38.8

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

      *-commutative [=>]38.8

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

      *-lft-identity [=>]38.8

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

      associate-*r/ [=>]38.7

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

      sub-neg [=>]38.7

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

      distribute-lft-in [=>]38.7

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

      fma-def [=>]38.7

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

      metadata-eval [=>]38.7

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

      metadata-eval [=>]38.7

      \[ n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Applied egg-rr38.7

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

    if -9.5000000000000003e76 < n < -6.30000000000000014e-158

    1. Initial program 43.8

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Simplified43.7

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

      [Start]43.8

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

      associate-*r/ [=>]43.7

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

      sub-neg [=>]43.7

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

      metadata-eval [=>]43.7

      \[ \frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}\right)}{\frac{i}{n}} \]
    3. Taylor expanded in n around inf 51.1

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

      \[\leadsto \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{\frac{i}{n}} \]
      Proof

      [Start]51.1

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

      expm1-def [=>]19.5

      \[ \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{\frac{i}{n}} \]

    if -6.30000000000000014e-158 < n < -4.999999999999985e-310

    1. Initial program 19.7

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Simplified19.7

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

      [Start]19.7

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

      associate-*r/ [=>]19.7

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

      sub-neg [=>]19.7

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

      metadata-eval [=>]19.7

      \[ \frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}\right)}{\frac{i}{n}} \]
    3. Taylor expanded in i around -inf 20.0

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

      \[\leadsto \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(n \cdot \left(\log \left(\frac{-1}{n}\right) - \log \left(\frac{-1}{i}\right)\right)\right)}}{\frac{i}{n}} \]
      Proof

      [Start]20.0

      \[ \frac{100 \cdot \left(e^{n \cdot \left(-1 \cdot \log \left(\frac{-1}{i}\right) + \log \left(-\frac{1}{n}\right)\right)} - 1\right)}{\frac{i}{n}} \]

      expm1-def [=>]13.5

      \[ \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(n \cdot \left(-1 \cdot \log \left(\frac{-1}{i}\right) + \log \left(-\frac{1}{n}\right)\right)\right)}}{\frac{i}{n}} \]

      +-commutative [=>]13.5

      \[ \frac{100 \cdot \mathsf{expm1}\left(n \cdot \color{blue}{\left(\log \left(-\frac{1}{n}\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}\right)}{\frac{i}{n}} \]

      mul-1-neg [=>]13.5

      \[ \frac{100 \cdot \mathsf{expm1}\left(n \cdot \left(\log \left(-\frac{1}{n}\right) + \color{blue}{\left(-\log \left(\frac{-1}{i}\right)\right)}\right)\right)}{\frac{i}{n}} \]

      unsub-neg [=>]13.5

      \[ \frac{100 \cdot \mathsf{expm1}\left(n \cdot \color{blue}{\left(\log \left(-\frac{1}{n}\right) - \log \left(\frac{-1}{i}\right)\right)}\right)}{\frac{i}{n}} \]

      distribute-neg-frac [=>]13.5

      \[ \frac{100 \cdot \mathsf{expm1}\left(n \cdot \left(\log \color{blue}{\left(\frac{-1}{n}\right)} - \log \left(\frac{-1}{i}\right)\right)\right)}{\frac{i}{n}} \]

      metadata-eval [=>]13.5

      \[ \frac{100 \cdot \mathsf{expm1}\left(n \cdot \left(\log \left(\frac{\color{blue}{-1}}{n}\right) - \log \left(\frac{-1}{i}\right)\right)\right)}{\frac{i}{n}} \]

    if -4.999999999999985e-310 < n < 1.4e-198

    1. Initial program 41.2

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Simplified41.2

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

      [Start]41.2

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

      associate-*r/ [=>]41.2

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

      sub-neg [=>]41.2

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

      metadata-eval [=>]41.2

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

      \[\leadsto \frac{\color{blue}{100 \cdot \left(n \cdot \left(-1 \cdot \log n + \log i\right)\right)}}{\frac{i}{n}} \]
    4. Simplified11.8

      \[\leadsto \frac{\color{blue}{\left(100 \cdot n\right) \cdot \mathsf{fma}\left(-1, \log n, \log i\right)}}{\frac{i}{n}} \]
      Proof

      [Start]11.8

      \[ \frac{100 \cdot \left(n \cdot \left(-1 \cdot \log n + \log i\right)\right)}{\frac{i}{n}} \]

      associate-*r* [=>]11.8

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

      fma-def [=>]11.8

      \[ \frac{\left(100 \cdot n\right) \cdot \color{blue}{\mathsf{fma}\left(-1, \log n, \log i\right)}}{\frac{i}{n}} \]

    if 1.4e-198 < n < 8.1999999999999997e-26

    1. Initial program 54.5

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Simplified54.5

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

      [Start]54.5

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

      associate-/r/ [=>]54.5

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

      *-commutative [=>]54.5

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

      *-rgt-identity [<=]54.5

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

      associate-*l* [=>]54.5

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

      *-lft-identity [=>]54.5

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

      sub-neg [=>]54.5

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

      metadata-eval [=>]54.5

      \[ 100 \cdot \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}}{i}\right) \]
    3. Taylor expanded in n around inf 62.0

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

      \[\leadsto \color{blue}{100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
      Proof

      [Start]62.0

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

      associate-/l* [=>]62.0

      \[ 100 \cdot \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \]

      expm1-def [=>]34.9

      \[ 100 \cdot \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \]
    5. Taylor expanded in i around 0 20.1

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

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

      [Start]20.1

      \[ 100 \cdot \frac{n}{1 + \left(0.08333333333333333 \cdot {i}^{2} + -0.5 \cdot i\right)} \]

      +-commutative [=>]20.1

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

      *-commutative [=>]20.1

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

      *-commutative [=>]20.1

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

      unpow2 [=>]20.1

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

      associate-*l* [=>]20.1

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

      distribute-lft-out [=>]20.1

      \[ 100 \cdot \frac{n}{1 + \color{blue}{i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification12.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq -9.5 \cdot 10^{+76}:\\ \;\;\;\;n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{i}\\ \mathbf{elif}\;n \leq -6.3 \cdot 10^{-158}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(n \cdot \left(\log \left(\frac{-1}{n}\right) - \log \left(\frac{-1}{i}\right)\right)\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 1.4 \cdot 10^{-198}:\\ \;\;\;\;\frac{\left(n \cdot 100\right) \cdot \mathsf{fma}\left(-1, \log n, \log i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]

Alternatives

Alternative 1
Error12.1
Cost20688
\[\begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -9.5 \cdot 10^{+76}:\\ \;\;\;\;n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{i}\\ \mathbf{elif}\;n \leq -9 \cdot 10^{-157}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq -5 \cdot 10^{-310}:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \left(\log \left(\frac{-1}{n}\right) - \log \left(\frac{-1}{i}\right)\right)\right)}{i}\right)\\ \mathbf{elif}\;n \leq 2.2 \cdot 10^{-199}:\\ \;\;\;\;\frac{\left(n \cdot 100\right) \cdot \mathsf{fma}\left(-1, \log n, \log i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error12.6
Cost20564
\[\begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -9.5 \cdot 10^{+76}:\\ \;\;\;\;n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{i}\\ \mathbf{elif}\;n \leq -2.6 \cdot 10^{-161}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq -2 \cdot 10^{-308}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{elif}\;n \leq 5.2 \cdot 10^{-199}:\\ \;\;\;\;\frac{\left(n \cdot 100\right) \cdot \mathsf{fma}\left(-1, \log n, \log i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.6
Cost14164
\[\begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -9.5 \cdot 10^{+76}:\\ \;\;\;\;n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{i}\\ \mathbf{elif}\;n \leq -9.5 \cdot 10^{-159}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq -2 \cdot 10^{-309}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{elif}\;n \leq 1.7 \cdot 10^{-199}:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{n \cdot \left(\log i - \log n\right)}{i}\right)\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.9
Cost7560
\[\begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -9.5 \cdot 10^{+76}:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\right)\\ \mathbf{elif}\;n \leq -9.2 \cdot 10^{-159}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 1.1 \cdot 10^{-234}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{elif}\;n \leq 8 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error12.9
Cost7560
\[\begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.55 \cdot 10^{+106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -9 \cdot 10^{+76}:\\ \;\;\;\;n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{i}\\ \mathbf{elif}\;n \leq -2.2 \cdot 10^{-158}:\\ \;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-235}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error11.8
Cost7244
\[\begin{array}{l} t_0 := 100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{if}\;n \leq -2.35 \cdot 10^{-160}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 4.2 \cdot 10^{-235}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error11.8
Cost7244
\[\begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.25 \cdot 10^{-161}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-235}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-26}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error18.5
Cost1352
\[\begin{array}{l} \mathbf{if}\;n \leq -3.25 \cdot 10^{-161}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{-236}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(\frac{n}{-1 + \left(i \cdot i\right) \cdot 0.25} \cdot \left(-1 + i \cdot -0.5\right)\right)\\ \end{array} \]
Alternative 9
Error18.6
Cost1096
\[\begin{array}{l} \mathbf{if}\;n \leq -5.3 \cdot 10^{-161}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 1.35 \cdot 10^{-235}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot \left(-0.5 + i \cdot 0.08333333333333333\right)}\\ \end{array} \]
Alternative 10
Error18.6
Cost968
\[\begin{array}{l} \mathbf{if}\;n \leq -5.4 \cdot 10^{-161}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 2 \cdot 10^{-234}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \mathbf{else}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(-0.005 + i \cdot 0.0008333333333333334\right)}\\ \end{array} \]
Alternative 11
Error19.2
Cost841
\[\begin{array}{l} \mathbf{if}\;n \leq -2.5 \cdot 10^{-161} \lor \neg \left(n \leq 9 \cdot 10^{-240}\right):\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \end{array} \]
Alternative 12
Error20.8
Cost713
\[\begin{array}{l} \mathbf{if}\;i \leq -1.65 \lor \neg \left(i \leq 200000000\right):\\ \;\;\;\;-200 \cdot \frac{n}{i}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
Alternative 13
Error19.3
Cost713
\[\begin{array}{l} \mathbf{if}\;n \leq -2.75 \cdot 10^{-161} \lor \neg \left(n \leq 1.6 \cdot 10^{-234}\right):\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 0}{i}\\ \end{array} \]
Alternative 14
Error21.0
Cost585
\[\begin{array}{l} \mathbf{if}\;i \leq -2 \lor \neg \left(i \leq 5000000\right):\\ \;\;\;\;-200 \cdot \frac{n}{i}\\ \mathbf{else}:\\ \;\;\;\;n \cdot 100\\ \end{array} \]
Alternative 15
Error20.8
Cost448
\[\frac{n}{0.01 + i \cdot -0.005} \]
Alternative 16
Error62.1
Cost192
\[i \cdot -50 \]
Alternative 17
Error27.9
Cost192
\[n \cdot 100 \]

Error

Reproduce?

herbie shell --seed 2023018 
(FPCore (i n)
  :name "Compound Interest"
  :precision binary64

  :herbie-target
  (* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))

  (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))