Compound Interest

Percentage Accurate: 28.3% → 98.5%
Time: 22.9s
Alternatives: 20
Speedup: 38.0×

Specification

?
\[\begin{array}{l} \\ 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \end{array} \]
(FPCore (i n)
 :precision binary64
 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
	return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
	return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n):
	return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n)
	return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n)))
end
function tmp = code(i, n)
	tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n));
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]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 20 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 28.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \end{array} \]
(FPCore (i n)
 :precision binary64
 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
	return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
	return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n):
	return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n)
	return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n)))
end
function tmp = code(i, n)
	tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n));
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]
\begin{array}{l}

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

Alternative 1: 98.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\ t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\ t_2 := n \cdot \frac{\mathsf{fma}\left(100, t_0, -100\right)}{i}\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (pow (+ 1.0 (/ i n)) n))
        (t_1 (/ (+ t_0 -1.0) (/ i n)))
        (t_2 (* n (/ (fma 100.0 t_0 -100.0) i))))
   (if (<= t_1 -4e-16)
     t_2
     (if (<= t_1 0.0)
       (* (/ (expm1 (* n (log1p (/ i n)))) i) (* n 100.0))
       (if (<= t_1 INFINITY) t_2 (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
double code(double i, double n) {
	double t_0 = pow((1.0 + (i / n)), n);
	double t_1 = (t_0 + -1.0) / (i / n);
	double t_2 = n * (fma(100.0, t_0, -100.0) / i);
	double tmp;
	if (t_1 <= -4e-16) {
		tmp = t_2;
	} else if (t_1 <= 0.0) {
		tmp = (expm1((n * log1p((i / n)))) / i) * (n * 100.0);
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = t_2;
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
function code(i, n)
	t_0 = Float64(1.0 + Float64(i / n)) ^ n
	t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n))
	t_2 = Float64(n * Float64(fma(100.0, t_0, -100.0) / i))
	tmp = 0.0
	if (t_1 <= -4e-16)
		tmp = t_2;
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i) * Float64(n * 100.0));
	elseif (t_1 <= Inf)
		tmp = t_2;
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(n * N[(N[(100.0 * t$95$0 + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-16], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$2, N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
t_2 := n \cdot \frac{\mathsf{fma}\left(100, t_0, -100\right)}{i}\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-16}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -3.9999999999999999e-16 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0

    1. Initial program 99.6%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/99.8%

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

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative99.7%

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

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg99.9%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in99.9%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. fma-def99.9%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, 100 \cdot \left(-1\right)\right)}}{i} \]
      8. metadata-eval99.9%

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

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

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

    if -3.9999999999999999e-16 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0

    1. Initial program 27.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative27.1%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg26.5%

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

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

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. metadata-eval26.5%

        \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      7. sub-neg26.5%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i} \cdot \left(n \cdot 100\right) \]
      8. associate-*l/26.5%

        \[\leadsto \color{blue}{\frac{\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right) \cdot \left(n \cdot 100\right)}{i}} \]
      9. associate-/l*27.1%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n \cdot 100}}} \]
      10. add-exp-log27.1%

        \[\leadsto \frac{\color{blue}{e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)}} - 1}{\frac{i}{n \cdot 100}} \]
      11. expm1-def27.1%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)\right)}}{\frac{i}{n \cdot 100}} \]
      12. log-pow35.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}{\frac{i}{n \cdot 100}} \]
      13. log1p-udef98.5%

        \[\leadsto \frac{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right)}{\frac{i}{n \cdot 100}} \]
    3. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n \cdot 100}}} \]
    4. Step-by-step derivation
      1. associate-/r/98.2%

        \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)} \]
    5. Simplified98.2%

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative1.9%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*1.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def81.9%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified81.9%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified99.9%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -4 \cdot 10^{-16}:\\ \;\;\;\;n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 2: 84.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\ t_1 := t_0 \cdot 100\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{-218}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \mathbf{elif}\;t_0 \leq \infty:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))) (t_1 (* t_0 100.0)))
   (if (<= t_0 -1e-218)
     t_1
     (if (<= t_0 0.0)
       (* (* n 100.0) (/ (expm1 i) i))
       (if (<= t_0 INFINITY) t_1 (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
double code(double i, double n) {
	double t_0 = (pow((1.0 + (i / n)), n) + -1.0) / (i / n);
	double t_1 = t_0 * 100.0;
	double tmp;
	if (t_0 <= -1e-218) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = (n * 100.0) * (expm1(i) / i);
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = (Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n);
	double t_1 = t_0 * 100.0;
	double tmp;
	if (t_0 <= -1e-218) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = (n * 100.0) * (Math.expm1(i) / i);
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	t_0 = (math.pow((1.0 + (i / n)), n) + -1.0) / (i / n)
	t_1 = t_0 * 100.0
	tmp = 0
	if t_0 <= -1e-218:
		tmp = t_1
	elif t_0 <= 0.0:
		tmp = (n * 100.0) * (math.expm1(i) / i)
	elif t_0 <= math.inf:
		tmp = t_1
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	t_0 = Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n))
	t_1 = Float64(t_0 * 100.0)
	tmp = 0.0
	if (t_0 <= -1e-218)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i));
	elseif (t_0 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * 100.0), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-218], t$95$1, If[LessEqual[t$95$0, 0.0], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$1, N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
t_1 := t_0 \cdot 100\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-218}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -1e-218 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0

    1. Initial program 99.0%

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

    if -1e-218 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0

    1. Initial program 21.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative21.9%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*21.2%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg21.2%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval21.2%

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

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

      \[\leadsto \color{blue}{\frac{e^{i} - 1}{i}} \cdot \left(n \cdot 100\right) \]
    5. Step-by-step derivation
      1. expm1-def81.6%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(i\right)}}{i} \cdot \left(n \cdot 100\right) \]
    6. Simplified81.6%

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative1.9%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*1.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def81.9%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified81.9%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified99.9%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -1 \cdot 10^{-218}:\\ \;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \cdot 100\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \cdot 100\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 3: 84.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(1 + \frac{i}{n}\right)}^{n} + -1\\ t_1 := \frac{t_0}{\frac{i}{n}}\\ t_2 := \left(n \cdot 100\right) \cdot \frac{t_0}{i}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-169}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (+ (pow (+ 1.0 (/ i n)) n) -1.0))
        (t_1 (/ t_0 (/ i n)))
        (t_2 (* (* n 100.0) (/ t_0 i))))
   (if (<= t_1 -1e-169)
     t_2
     (if (<= t_1 0.0)
       (* 100.0 (/ n (/ i (expm1 i))))
       (if (<= t_1 INFINITY) t_2 (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
double code(double i, double n) {
	double t_0 = pow((1.0 + (i / n)), n) + -1.0;
	double t_1 = t_0 / (i / n);
	double t_2 = (n * 100.0) * (t_0 / i);
	double tmp;
	if (t_1 <= -1e-169) {
		tmp = t_2;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n / (i / expm1(i)));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = t_2;
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = Math.pow((1.0 + (i / n)), n) + -1.0;
	double t_1 = t_0 / (i / n);
	double t_2 = (n * 100.0) * (t_0 / i);
	double tmp;
	if (t_1 <= -1e-169) {
		tmp = t_2;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n / (i / Math.expm1(i)));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_2;
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	t_0 = math.pow((1.0 + (i / n)), n) + -1.0
	t_1 = t_0 / (i / n)
	t_2 = (n * 100.0) * (t_0 / i)
	tmp = 0
	if t_1 <= -1e-169:
		tmp = t_2
	elif t_1 <= 0.0:
		tmp = 100.0 * (n / (i / math.expm1(i)))
	elif t_1 <= math.inf:
		tmp = t_2
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	t_0 = Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0)
	t_1 = Float64(t_0 / Float64(i / n))
	t_2 = Float64(Float64(n * 100.0) * Float64(t_0 / i))
	tmp = 0.0
	if (t_1 <= -1e-169)
		tmp = t_2;
	elseif (t_1 <= 0.0)
		tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i))));
	elseif (t_1 <= Inf)
		tmp = t_2;
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(n * 100.0), $MachinePrecision] * N[(t$95$0 / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-169], t$95$2, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$2, N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n} + -1\\
t_1 := \frac{t_0}{\frac{i}{n}}\\
t_2 := \left(n \cdot 100\right) \cdot \frac{t_0}{i}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-169}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -1.00000000000000002e-169 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0

    1. Initial program 98.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative98.9%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*99.2%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg99.2%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval99.2%

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

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

    if -1.00000000000000002e-169 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0

    1. Initial program 23.8%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative37.7%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*37.7%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def82.1%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified82.1%

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative1.9%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*1.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def81.9%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified81.9%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified99.9%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -1 \cdot 10^{-169}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 4: 84.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\ t_1 := t_0 + -1\\ t_2 := \frac{t_1}{\frac{i}{n}}\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{-169}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(\frac{t_0}{i} + \frac{-1}{i}\right)\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{t_1}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (+ t_0 -1.0)) (t_2 (/ t_1 (/ i n))))
   (if (<= t_2 -1e-169)
     (* (* n 100.0) (+ (/ t_0 i) (/ -1.0 i)))
     (if (<= t_2 0.0)
       (* 100.0 (/ n (/ i (expm1 i))))
       (if (<= t_2 INFINITY)
         (* (* n 100.0) (/ t_1 i))
         (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
double code(double i, double n) {
	double t_0 = pow((1.0 + (i / n)), n);
	double t_1 = t_0 + -1.0;
	double t_2 = t_1 / (i / n);
	double tmp;
	if (t_2 <= -1e-169) {
		tmp = (n * 100.0) * ((t_0 / i) + (-1.0 / i));
	} else if (t_2 <= 0.0) {
		tmp = 100.0 * (n / (i / expm1(i)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = (n * 100.0) * (t_1 / i);
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = Math.pow((1.0 + (i / n)), n);
	double t_1 = t_0 + -1.0;
	double t_2 = t_1 / (i / n);
	double tmp;
	if (t_2 <= -1e-169) {
		tmp = (n * 100.0) * ((t_0 / i) + (-1.0 / i));
	} else if (t_2 <= 0.0) {
		tmp = 100.0 * (n / (i / Math.expm1(i)));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = (n * 100.0) * (t_1 / i);
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	t_0 = math.pow((1.0 + (i / n)), n)
	t_1 = t_0 + -1.0
	t_2 = t_1 / (i / n)
	tmp = 0
	if t_2 <= -1e-169:
		tmp = (n * 100.0) * ((t_0 / i) + (-1.0 / i))
	elif t_2 <= 0.0:
		tmp = 100.0 * (n / (i / math.expm1(i)))
	elif t_2 <= math.inf:
		tmp = (n * 100.0) * (t_1 / i)
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	t_0 = Float64(1.0 + Float64(i / n)) ^ n
	t_1 = Float64(t_0 + -1.0)
	t_2 = Float64(t_1 / Float64(i / n))
	tmp = 0.0
	if (t_2 <= -1e-169)
		tmp = Float64(Float64(n * 100.0) * Float64(Float64(t_0 / i) + Float64(-1.0 / i)));
	elseif (t_2 <= 0.0)
		tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i))));
	elseif (t_2 <= Inf)
		tmp = Float64(Float64(n * 100.0) * Float64(t_1 / i));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + -1.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-169], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(t$95$0 / i), $MachinePrecision] + N[(-1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(n * 100.0), $MachinePrecision] * N[(t$95$1 / i), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := t_0 + -1\\
t_2 := \frac{t_1}{\frac{i}{n}}\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{-169}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(\frac{t_0}{i} + \frac{-1}{i}\right)\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{t_1}{i}\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -1.00000000000000002e-169

    1. Initial program 97.8%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative97.8%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*98.2%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg98.2%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval98.2%

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

      \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
    4. Step-by-step derivation
      1. metadata-eval98.2%

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

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i} \cdot \left(n \cdot 100\right) \]
      3. div-sub99.0%

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} - \frac{1}{i}\right)} \cdot \left(n \cdot 100\right) \]
    5. Applied egg-rr99.0%

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

    if -1.00000000000000002e-169 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0

    1. Initial program 23.8%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative37.7%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*37.7%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def82.1%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified82.1%

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

    if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0

    1. Initial program 99.6%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative99.6%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*99.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg99.8%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval99.8%

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

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative1.9%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*1.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def81.9%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified81.9%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified99.9%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification88.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -1 \cdot 10^{-169}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} + \frac{-1}{i}\right)\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 5: 97.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(1 + \frac{i}{n}\right)}^{n} + -1\\ t_1 := \frac{t_0}{\frac{i}{n}}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_1 \cdot 100\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n}{\frac{i}{100}}\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{t_0}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (+ (pow (+ 1.0 (/ i n)) n) -1.0)) (t_1 (/ t_0 (/ i n))))
   (if (<= t_1 (- INFINITY))
     (* t_1 100.0)
     (if (<= t_1 0.0)
       (* (expm1 (* n (log1p (/ i n)))) (/ n (/ i 100.0)))
       (if (<= t_1 INFINITY)
         (* (* n 100.0) (/ t_0 i))
         (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
double code(double i, double n) {
	double t_0 = pow((1.0 + (i / n)), n) + -1.0;
	double t_1 = t_0 / (i / n);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = expm1((n * log1p((i / n)))) * (n / (i / 100.0));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = (n * 100.0) * (t_0 / i);
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = Math.pow((1.0 + (i / n)), n) + -1.0;
	double t_1 = t_0 / (i / n);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = Math.expm1((n * Math.log1p((i / n)))) * (n / (i / 100.0));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = (n * 100.0) * (t_0 / i);
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	t_0 = math.pow((1.0 + (i / n)), n) + -1.0
	t_1 = t_0 / (i / n)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = t_1 * 100.0
	elif t_1 <= 0.0:
		tmp = math.expm1((n * math.log1p((i / n)))) * (n / (i / 100.0))
	elif t_1 <= math.inf:
		tmp = (n * 100.0) * (t_0 / i)
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	t_0 = Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0)
	t_1 = Float64(t_0 / Float64(i / n))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(t_1 * 100.0);
	elseif (t_1 <= 0.0)
		tmp = Float64(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(n / Float64(i / 100.0)));
	elseif (t_1 <= Inf)
		tmp = Float64(Float64(n * 100.0) * Float64(t_0 / i));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(n / N[(i / 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(n * 100.0), $MachinePrecision] * N[(t$95$0 / i), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n} + -1\\
t_1 := \frac{t_0}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_1 \cdot 100\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n}{\frac{i}{100}}\\

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{t_0}{i}\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -inf.0

    1. Initial program 100.0%

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

    if -inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0

    1. Initial program 28.3%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative28.3%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg27.8%

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval27.8%

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

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. metadata-eval27.7%

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

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i} \cdot \left(n \cdot 100\right) \]
      8. associate-*l/27.7%

        \[\leadsto \color{blue}{\frac{\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right) \cdot \left(n \cdot 100\right)}{i}} \]
      9. associate-/l*28.3%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n \cdot 100}}} \]
      10. add-exp-log28.3%

        \[\leadsto \frac{\color{blue}{e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)}} - 1}{\frac{i}{n \cdot 100}} \]
      11. expm1-def28.3%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)\right)}}{\frac{i}{n \cdot 100}} \]
      12. log-pow36.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}{\frac{i}{n \cdot 100}} \]
      13. log1p-udef98.5%

        \[\leadsto \frac{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right)}{\frac{i}{n \cdot 100}} \]
    3. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n \cdot 100}}} \]
    4. Step-by-step derivation
      1. associate-/r/98.2%

        \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)} \]
    5. Simplified98.2%

      \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u77.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\right)\right)} \]
      2. expm1-udef44.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\right)} - 1} \]
      3. div-inv44.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{1}{i}\right)} \cdot \left(n \cdot 100\right)\right)} - 1 \]
      4. associate-*l*43.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \left(\frac{1}{i} \cdot \left(n \cdot 100\right)\right)}\right)} - 1 \]
      5. associate-*l/43.9%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \color{blue}{\frac{1 \cdot \left(n \cdot 100\right)}{i}}\right)} - 1 \]
      6. *-un-lft-identity43.9%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{\color{blue}{n \cdot 100}}{i}\right)} - 1 \]
    7. Applied egg-rr43.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n \cdot 100}{i}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def77.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n \cdot 100}{i}\right)\right)} \]
      2. expm1-log1p97.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n \cdot 100}{i}} \]
      3. *-commutative97.0%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{i} \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)} \]
      4. associate-/l*96.8%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{100}}} \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \]
    9. Simplified96.8%

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

    if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0

    1. Initial program 99.6%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative99.6%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*99.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg99.8%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval99.8%

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

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative1.9%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*1.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def81.9%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified81.9%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified99.9%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification97.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -\infty:\\ \;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \cdot 100\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n}{\frac{i}{100}}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 6: 98.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\ t_1 := t_0 + -1\\ t_2 := \frac{t_1}{\frac{i}{n}}\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{-16}:\\ \;\;\;\;100 \cdot \left(\left(\frac{n}{i} - \frac{n}{i}\right) + \left(n \cdot \frac{t_0}{i} - \frac{n}{i}\right)\right)\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{t_1}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (+ t_0 -1.0)) (t_2 (/ t_1 (/ i n))))
   (if (<= t_2 -4e-16)
     (* 100.0 (+ (- (/ n i) (/ n i)) (- (* n (/ t_0 i)) (/ n i))))
     (if (<= t_2 0.0)
       (* (/ (expm1 (* n (log1p (/ i n)))) i) (* n 100.0))
       (if (<= t_2 INFINITY)
         (* (* n 100.0) (/ t_1 i))
         (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
double code(double i, double n) {
	double t_0 = pow((1.0 + (i / n)), n);
	double t_1 = t_0 + -1.0;
	double t_2 = t_1 / (i / n);
	double tmp;
	if (t_2 <= -4e-16) {
		tmp = 100.0 * (((n / i) - (n / i)) + ((n * (t_0 / i)) - (n / i)));
	} else if (t_2 <= 0.0) {
		tmp = (expm1((n * log1p((i / n)))) / i) * (n * 100.0);
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = (n * 100.0) * (t_1 / i);
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = Math.pow((1.0 + (i / n)), n);
	double t_1 = t_0 + -1.0;
	double t_2 = t_1 / (i / n);
	double tmp;
	if (t_2 <= -4e-16) {
		tmp = 100.0 * (((n / i) - (n / i)) + ((n * (t_0 / i)) - (n / i)));
	} else if (t_2 <= 0.0) {
		tmp = (Math.expm1((n * Math.log1p((i / n)))) / i) * (n * 100.0);
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = (n * 100.0) * (t_1 / i);
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	t_0 = math.pow((1.0 + (i / n)), n)
	t_1 = t_0 + -1.0
	t_2 = t_1 / (i / n)
	tmp = 0
	if t_2 <= -4e-16:
		tmp = 100.0 * (((n / i) - (n / i)) + ((n * (t_0 / i)) - (n / i)))
	elif t_2 <= 0.0:
		tmp = (math.expm1((n * math.log1p((i / n)))) / i) * (n * 100.0)
	elif t_2 <= math.inf:
		tmp = (n * 100.0) * (t_1 / i)
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	t_0 = Float64(1.0 + Float64(i / n)) ^ n
	t_1 = Float64(t_0 + -1.0)
	t_2 = Float64(t_1 / Float64(i / n))
	tmp = 0.0
	if (t_2 <= -4e-16)
		tmp = Float64(100.0 * Float64(Float64(Float64(n / i) - Float64(n / i)) + Float64(Float64(n * Float64(t_0 / i)) - Float64(n / i))));
	elseif (t_2 <= 0.0)
		tmp = Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i) * Float64(n * 100.0));
	elseif (t_2 <= Inf)
		tmp = Float64(Float64(n * 100.0) * Float64(t_1 / i));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + -1.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-16], N[(100.0 * N[(N[(N[(n / i), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision] + N[(N[(n * N[(t$95$0 / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(n * 100.0), $MachinePrecision] * N[(t$95$1 / i), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := t_0 + -1\\
t_2 := \frac{t_1}{\frac{i}{n}}\\
\mathbf{if}\;t_2 \leq -4 \cdot 10^{-16}:\\
\;\;\;\;100 \cdot \left(\left(\frac{n}{i} - \frac{n}{i}\right) + \left(n \cdot \frac{t_0}{i} - \frac{n}{i}\right)\right)\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{t_1}{i}\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -3.9999999999999999e-16

    1. Initial program 99.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. div-sub99.7%

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

        \[\leadsto 100 \cdot \left(\color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n} - \frac{1}{\frac{i}{n}}\right) \]
      3. *-un-lft-identity99.7%

        \[\leadsto 100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n - \color{blue}{1 \cdot \frac{1}{\frac{i}{n}}}\right) \]
      4. clear-num99.8%

        \[\leadsto 100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n - 1 \cdot \color{blue}{\frac{n}{i}}\right) \]
      5. prod-diff99.8%

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

      \[\leadsto 100 \cdot \color{blue}{\left(\mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right) + \mathsf{fma}\left(-\frac{n}{i}, 1, \frac{n}{i} \cdot 1\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative99.8%

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

        \[\leadsto 100 \cdot \left(\color{blue}{\left(\left(-\frac{n}{i}\right) \cdot 1 + \frac{n}{i} \cdot 1\right)} + \mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right)\right) \]
      3. *-rgt-identity99.8%

        \[\leadsto 100 \cdot \left(\left(\color{blue}{\left(-\frac{n}{i}\right)} + \frac{n}{i} \cdot 1\right) + \mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right)\right) \]
      4. distribute-neg-frac99.8%

        \[\leadsto 100 \cdot \left(\left(\color{blue}{\frac{-n}{i}} + \frac{n}{i} \cdot 1\right) + \mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right)\right) \]
      5. *-rgt-identity99.8%

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

        \[\leadsto 100 \cdot \left(\left(\frac{-n}{i} + \frac{n}{i}\right) + \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n + \left(-\frac{n}{i} \cdot 1\right)\right)}\right) \]
      7. *-rgt-identity99.8%

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

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

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

    if -3.9999999999999999e-16 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0

    1. Initial program 27.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative27.1%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg26.5%

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

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

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. metadata-eval26.5%

        \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      7. sub-neg26.5%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i} \cdot \left(n \cdot 100\right) \]
      8. associate-*l/26.5%

        \[\leadsto \color{blue}{\frac{\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right) \cdot \left(n \cdot 100\right)}{i}} \]
      9. associate-/l*27.1%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n \cdot 100}}} \]
      10. add-exp-log27.1%

        \[\leadsto \frac{\color{blue}{e^{\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)}} - 1}{\frac{i}{n \cdot 100}} \]
      11. expm1-def27.1%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)\right)}}{\frac{i}{n \cdot 100}} \]
      12. log-pow35.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}{\frac{i}{n \cdot 100}} \]
      13. log1p-udef98.5%

        \[\leadsto \frac{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right)}{\frac{i}{n \cdot 100}} \]
    3. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n \cdot 100}}} \]
    4. Step-by-step derivation
      1. associate-/r/98.2%

        \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)} \]
    5. Simplified98.2%

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

    if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0

    1. Initial program 99.6%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative99.6%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*99.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg99.8%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval99.8%

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

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative1.9%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*1.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def81.9%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified81.9%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified99.9%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification98.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -4 \cdot 10^{-16}:\\ \;\;\;\;100 \cdot \left(\left(\frac{n}{i} - \frac{n}{i}\right) + \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} - \frac{n}{i}\right)\right)\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 7: 86.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{100}{i} \cdot \left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\ t_1 := i \cdot \left(0.5 - \frac{0.5}{n}\right)\\ \mathbf{if}\;i \leq -1.15 \cdot 10^{-122}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;i \leq 8.4 \cdot 10^{-125}:\\ \;\;\;\;n \cdot \frac{1}{\frac{100 + -100 \cdot t_1}{10000 - {\left(100 \cdot t_1\right)}^{2}}}\\ \mathbf{elif}\;i \leq 7 \cdot 10^{+238}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(\left(\frac{n}{i} - \frac{n}{i}\right) + \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} - \frac{n}{i}\right)\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* (/ 100.0 i) (* n (expm1 (* n (log1p (/ i n)))))))
        (t_1 (* i (- 0.5 (/ 0.5 n)))))
   (if (<= i -1.15e-122)
     t_0
     (if (<= i 8.4e-125)
       (*
        n
        (/
         1.0
         (/ (+ 100.0 (* -100.0 t_1)) (- 10000.0 (pow (* 100.0 t_1) 2.0)))))
       (if (<= i 7e+238)
         t_0
         (*
          100.0
          (+
           (- (/ n i) (/ n i))
           (- (* n (/ (pow (+ 1.0 (/ i n)) n) i)) (/ n i)))))))))
double code(double i, double n) {
	double t_0 = (100.0 / i) * (n * expm1((n * log1p((i / n)))));
	double t_1 = i * (0.5 - (0.5 / n));
	double tmp;
	if (i <= -1.15e-122) {
		tmp = t_0;
	} else if (i <= 8.4e-125) {
		tmp = n * (1.0 / ((100.0 + (-100.0 * t_1)) / (10000.0 - pow((100.0 * t_1), 2.0))));
	} else if (i <= 7e+238) {
		tmp = t_0;
	} else {
		tmp = 100.0 * (((n / i) - (n / i)) + ((n * (pow((1.0 + (i / n)), n) / i)) - (n / i)));
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = (100.0 / i) * (n * Math.expm1((n * Math.log1p((i / n)))));
	double t_1 = i * (0.5 - (0.5 / n));
	double tmp;
	if (i <= -1.15e-122) {
		tmp = t_0;
	} else if (i <= 8.4e-125) {
		tmp = n * (1.0 / ((100.0 + (-100.0 * t_1)) / (10000.0 - Math.pow((100.0 * t_1), 2.0))));
	} else if (i <= 7e+238) {
		tmp = t_0;
	} else {
		tmp = 100.0 * (((n / i) - (n / i)) + ((n * (Math.pow((1.0 + (i / n)), n) / i)) - (n / i)));
	}
	return tmp;
}
def code(i, n):
	t_0 = (100.0 / i) * (n * math.expm1((n * math.log1p((i / n)))))
	t_1 = i * (0.5 - (0.5 / n))
	tmp = 0
	if i <= -1.15e-122:
		tmp = t_0
	elif i <= 8.4e-125:
		tmp = n * (1.0 / ((100.0 + (-100.0 * t_1)) / (10000.0 - math.pow((100.0 * t_1), 2.0))))
	elif i <= 7e+238:
		tmp = t_0
	else:
		tmp = 100.0 * (((n / i) - (n / i)) + ((n * (math.pow((1.0 + (i / n)), n) / i)) - (n / i)))
	return tmp
function code(i, n)
	t_0 = Float64(Float64(100.0 / i) * Float64(n * expm1(Float64(n * log1p(Float64(i / n))))))
	t_1 = Float64(i * Float64(0.5 - Float64(0.5 / n)))
	tmp = 0.0
	if (i <= -1.15e-122)
		tmp = t_0;
	elseif (i <= 8.4e-125)
		tmp = Float64(n * Float64(1.0 / Float64(Float64(100.0 + Float64(-100.0 * t_1)) / Float64(10000.0 - (Float64(100.0 * t_1) ^ 2.0)))));
	elseif (i <= 7e+238)
		tmp = t_0;
	else
		tmp = Float64(100.0 * Float64(Float64(Float64(n / i) - Float64(n / i)) + Float64(Float64(n * Float64((Float64(1.0 + Float64(i / n)) ^ n) / i)) - Float64(n / i))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[(N[(100.0 / i), $MachinePrecision] * N[(n * N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(i * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -1.15e-122], t$95$0, If[LessEqual[i, 8.4e-125], N[(n * N[(1.0 / N[(N[(100.0 + N[(-100.0 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(10000.0 - N[Power[N[(100.0 * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 7e+238], t$95$0, N[(100.0 * N[(N[(N[(n / i), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision] + N[(N[(n * N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{100}{i} \cdot \left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\
t_1 := i \cdot \left(0.5 - \frac{0.5}{n}\right)\\
\mathbf{if}\;i \leq -1.15 \cdot 10^{-122}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;i \leq 8.4 \cdot 10^{-125}:\\
\;\;\;\;n \cdot \frac{1}{\frac{100 + -100 \cdot t_1}{10000 - {\left(100 \cdot t_1\right)}^{2}}}\\

\mathbf{elif}\;i \leq 7 \cdot 10^{+238}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\left(\frac{n}{i} - \frac{n}{i}\right) + \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} - \frac{n}{i}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -1.15000000000000003e-122 or 8.3999999999999999e-125 < i < 7.00000000000000005e238

    1. Initial program 42.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. clear-num42.1%

        \[\leadsto 100 \cdot \color{blue}{\frac{1}{\frac{\frac{i}{n}}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      2. un-div-inv42.1%

        \[\leadsto \color{blue}{\frac{100}{\frac{\frac{i}{n}}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      3. associate-/l/42.2%

        \[\leadsto \frac{100}{\color{blue}{\frac{i}{\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right) \cdot n}}} \]
      4. add-exp-log42.2%

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

        \[\leadsto \frac{100}{\frac{i}{\color{blue}{\mathsf{expm1}\left(\log \left({\left(1 + \frac{i}{n}\right)}^{n}\right)\right)} \cdot n}} \]
      6. log-pow43.9%

        \[\leadsto \frac{100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right) \cdot n}} \]
      7. log1p-udef89.2%

        \[\leadsto \frac{100}{\frac{i}{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right) \cdot n}} \]
    3. Applied egg-rr89.2%

      \[\leadsto \color{blue}{\frac{100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot n}}} \]
    4. Step-by-step derivation
      1. /-rgt-identity89.2%

        \[\leadsto \frac{100}{\frac{i}{\color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{1}} \cdot n}} \]
      2. associate-/r/89.2%

        \[\leadsto \frac{100}{\frac{i}{\color{blue}{\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{1}{n}}}}} \]
      3. associate-/r/89.3%

        \[\leadsto \color{blue}{\frac{100}{i} \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{1}{n}}} \]
      4. associate-/r/89.3%

        \[\leadsto \frac{100}{i} \cdot \color{blue}{\left(\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{1} \cdot n\right)} \]
      5. /-rgt-identity89.3%

        \[\leadsto \frac{100}{i} \cdot \left(\color{blue}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)} \cdot n\right) \]
      6. *-commutative89.3%

        \[\leadsto \frac{100}{i} \cdot \color{blue}{\left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)} \]
    5. Simplified89.3%

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

    if -1.15000000000000003e-122 < i < 8.3999999999999999e-125

    1. Initial program 4.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/5.8%

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

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative5.8%

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

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg5.8%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in5.8%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. fma-def5.8%

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

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, 100 \cdot \color{blue}{-1}\right)}{i} \]
      9. metadata-eval5.8%

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

      \[\leadsto \color{blue}{n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}} \]
    4. Taylor expanded in i around 0 95.3%

      \[\leadsto n \cdot \color{blue}{\left(100 + 100 \cdot \left(i \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*r/95.3%

        \[\leadsto n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right)\right) \]
      2. metadata-eval95.3%

        \[\leadsto n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right)\right) \]
    6. Simplified95.3%

      \[\leadsto n \cdot \color{blue}{\left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)} \]
    7. Step-by-step derivation
      1. flip-+95.3%

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot 100 - \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right) \cdot \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)}{100 - 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}} \]
      2. clear-num95.3%

        \[\leadsto n \cdot \color{blue}{\frac{1}{\frac{100 - 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}{100 \cdot 100 - \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right) \cdot \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)}}} \]
      3. cancel-sign-sub-inv95.3%

        \[\leadsto n \cdot \frac{1}{\frac{\color{blue}{100 + \left(-100\right) \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}}{100 \cdot 100 - \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right) \cdot \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)}} \]
      4. metadata-eval95.3%

        \[\leadsto n \cdot \frac{1}{\frac{100 + \color{blue}{-100} \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}{100 \cdot 100 - \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right) \cdot \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)}} \]
      5. metadata-eval95.3%

        \[\leadsto n \cdot \frac{1}{\frac{100 + -100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}{\color{blue}{10000} - \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right) \cdot \left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)}} \]
      6. pow295.3%

        \[\leadsto n \cdot \frac{1}{\frac{100 + -100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}{10000 - \color{blue}{{\left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)}^{2}}}} \]
    8. Applied egg-rr95.3%

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

    if 7.00000000000000005e238 < i

    1. Initial program 72.0%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. div-sub72.0%

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

        \[\leadsto 100 \cdot \left(\color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n} - \frac{1}{\frac{i}{n}}\right) \]
      3. *-un-lft-identity72.4%

        \[\leadsto 100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n - \color{blue}{1 \cdot \frac{1}{\frac{i}{n}}}\right) \]
      4. clear-num72.6%

        \[\leadsto 100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n - 1 \cdot \color{blue}{\frac{n}{i}}\right) \]
      5. prod-diff72.6%

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

      \[\leadsto 100 \cdot \color{blue}{\left(\mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right) + \mathsf{fma}\left(-\frac{n}{i}, 1, \frac{n}{i} \cdot 1\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative72.6%

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

        \[\leadsto 100 \cdot \left(\color{blue}{\left(\left(-\frac{n}{i}\right) \cdot 1 + \frac{n}{i} \cdot 1\right)} + \mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right)\right) \]
      3. *-rgt-identity72.6%

        \[\leadsto 100 \cdot \left(\left(\color{blue}{\left(-\frac{n}{i}\right)} + \frac{n}{i} \cdot 1\right) + \mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right)\right) \]
      4. distribute-neg-frac72.6%

        \[\leadsto 100 \cdot \left(\left(\color{blue}{\frac{-n}{i}} + \frac{n}{i} \cdot 1\right) + \mathsf{fma}\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i}, n, -\frac{n}{i} \cdot 1\right)\right) \]
      5. *-rgt-identity72.6%

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

        \[\leadsto 100 \cdot \left(\left(\frac{-n}{i} + \frac{n}{i}\right) + \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n + \left(-\frac{n}{i} \cdot 1\right)\right)}\right) \]
      7. *-rgt-identity72.6%

        \[\leadsto 100 \cdot \left(\left(\frac{-n}{i} + \frac{n}{i}\right) + \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} \cdot n + \left(-\color{blue}{\frac{n}{i}}\right)\right)\right) \]
      8. unsub-neg72.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -1.15 \cdot 10^{-122}:\\ \;\;\;\;\frac{100}{i} \cdot \left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\ \mathbf{elif}\;i \leq 8.4 \cdot 10^{-125}:\\ \;\;\;\;n \cdot \frac{1}{\frac{100 + -100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}{10000 - {\left(100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)}^{2}}}\\ \mathbf{elif}\;i \leq 7 \cdot 10^{+238}:\\ \;\;\;\;\frac{100}{i} \cdot \left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(\left(\frac{n}{i} - \frac{n}{i}\right) + \left(n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n}}{i} - \frac{n}{i}\right)\right)\\ \end{array} \]

Alternative 8: 81.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -4.4 \cdot 10^{-244}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-235}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.35 \cdot 10^{-59}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
   (if (<= n -4.4e-244)
     t_0
     (if (<= n 4.5e-235)
       (* (* n 100.0) (/ 0.0 i))
       (if (<= n 2.35e-59) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) t_0)))))
double code(double i, double n) {
	double t_0 = 100.0 * (n / (i / expm1(i)));
	double tmp;
	if (n <= -4.4e-244) {
		tmp = t_0;
	} else if (n <= 4.5e-235) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 2.35e-59) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = 100.0 * (n / (i / Math.expm1(i)));
	double tmp;
	if (n <= -4.4e-244) {
		tmp = t_0;
	} else if (n <= 4.5e-235) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 2.35e-59) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(i, n):
	t_0 = 100.0 * (n / (i / math.expm1(i)))
	tmp = 0
	if n <= -4.4e-244:
		tmp = t_0
	elif n <= 4.5e-235:
		tmp = (n * 100.0) * (0.0 / i)
	elif n <= 2.35e-59:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	else:
		tmp = t_0
	return tmp
function code(i, n)
	t_0 = Float64(100.0 * Float64(n / Float64(i / expm1(i))))
	tmp = 0.0
	if (n <= -4.4e-244)
		tmp = t_0;
	elseif (n <= 4.5e-235)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (n <= 2.35e-59)
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	else
		tmp = t_0;
	end
	return tmp
end
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, -4.4e-244], t$95$0, If[LessEqual[n, 4.5e-235], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.35e-59], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{if}\;n \leq -4.4 \cdot 10^{-244}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;n \leq 4.5 \cdot 10^{-235}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\

\mathbf{elif}\;n \leq 2.35 \cdot 10^{-59}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -4.39999999999999969e-244 or 2.35e-59 < n

    1. Initial program 31.8%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative37.6%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*37.5%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def85.2%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified85.2%

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

    if -4.39999999999999969e-244 < n < 4.4999999999999998e-235

    1. Initial program 55.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative55.4%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*55.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg55.8%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval55.8%

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

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

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

    if 4.4999999999999998e-235 < n < 2.35e-59

    1. Initial program 14.8%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative4.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*4.0%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def53.5%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified53.5%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative72.6%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified72.6%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.4 \cdot 10^{-244}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-235}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.35 \cdot 10^{-59}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]

Alternative 9: 81.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2.6 \cdot 10^{-248}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 7.4 \cdot 10^{-235}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.35 \cdot 10^{-59}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -2.6e-248)
   (* 100.0 (/ n (/ i (expm1 i))))
   (if (<= n 7.4e-235)
     (* (* n 100.0) (/ 0.0 i))
     (if (<= n 2.35e-59)
       (* 100.0 (/ n (+ 1.0 (* i -0.5))))
       (* (* n 100.0) (/ (expm1 i) i))))))
double code(double i, double n) {
	double tmp;
	if (n <= -2.6e-248) {
		tmp = 100.0 * (n / (i / expm1(i)));
	} else if (n <= 7.4e-235) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 2.35e-59) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else {
		tmp = (n * 100.0) * (expm1(i) / i);
	}
	return tmp;
}
public static double code(double i, double n) {
	double tmp;
	if (n <= -2.6e-248) {
		tmp = 100.0 * (n / (i / Math.expm1(i)));
	} else if (n <= 7.4e-235) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 2.35e-59) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else {
		tmp = (n * 100.0) * (Math.expm1(i) / i);
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -2.6e-248:
		tmp = 100.0 * (n / (i / math.expm1(i)))
	elif n <= 7.4e-235:
		tmp = (n * 100.0) * (0.0 / i)
	elif n <= 2.35e-59:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	else:
		tmp = (n * 100.0) * (math.expm1(i) / i)
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -2.6e-248)
		tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i))));
	elseif (n <= 7.4e-235)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (n <= 2.35e-59)
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	else
		tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i));
	end
	return tmp
end
code[i_, n_] := If[LessEqual[n, -2.6e-248], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.4e-235], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.35e-59], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.6 \cdot 10^{-248}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\

\mathbf{elif}\;n \leq 7.4 \cdot 10^{-235}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\

\mathbf{elif}\;n \leq 2.35 \cdot 10^{-59}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -2.60000000000000007e-248

    1. Initial program 38.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative32.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*32.0%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def79.2%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified79.2%

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

    if -2.60000000000000007e-248 < n < 7.4000000000000002e-235

    1. Initial program 55.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative55.4%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*55.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg55.8%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval55.8%

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

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

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

    if 7.4000000000000002e-235 < n < 2.35e-59

    1. Initial program 14.8%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative4.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*4.0%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def53.5%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified53.5%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative72.6%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified72.6%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]

    if 2.35e-59 < n

    1. Initial program 22.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative22.4%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*22.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg22.8%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval22.8%

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

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

      \[\leadsto \color{blue}{\frac{e^{i} - 1}{i}} \cdot \left(n \cdot 100\right) \]
    5. Step-by-step derivation
      1. expm1-def94.0%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(i\right)}}{i} \cdot \left(n \cdot 100\right) \]
    6. Simplified94.0%

      \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(i\right)}{i}} \cdot \left(n \cdot 100\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification83.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.6 \cdot 10^{-248}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 7.4 \cdot 10^{-235}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.35 \cdot 10^{-59}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \]

Alternative 10: 59.8% accurate, 5.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -0.0146:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;i \leq 2.45 \cdot 10^{+188}:\\ \;\;\;\;n \cdot 100 + 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 + 0.5 \cdot \frac{-1}{n}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -0.0146)
   (* (* n 100.0) (/ 0.0 i))
   (if (<= i 2.45e+188)
     (+ (* n 100.0) (* 100.0 (* i (* n (+ 0.5 (* 0.5 (/ -1.0 n)))))))
     (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))
double code(double i, double n) {
	double tmp;
	if (i <= -0.0146) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (i <= 2.45e+188) {
		tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))));
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (i <= (-0.0146d0)) then
        tmp = (n * 100.0d0) * (0.0d0 / i)
    else if (i <= 2.45d+188) then
        tmp = (n * 100.0d0) + (100.0d0 * (i * (n * (0.5d0 + (0.5d0 * ((-1.0d0) / n))))))
    else
        tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (i <= -0.0146) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (i <= 2.45e+188) {
		tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))));
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= -0.0146:
		tmp = (n * 100.0) * (0.0 / i)
	elif i <= 2.45e+188:
		tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))))
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= -0.0146)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (i <= 2.45e+188)
		tmp = Float64(Float64(n * 100.0) + Float64(100.0 * Float64(i * Float64(n * Float64(0.5 + Float64(0.5 * Float64(-1.0 / n)))))));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= -0.0146)
		tmp = (n * 100.0) * (0.0 / i);
	elseif (i <= 2.45e+188)
		tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))));
	else
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, -0.0146], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.45e+188], N[(N[(n * 100.0), $MachinePrecision] + N[(100.0 * N[(i * N[(n * N[(0.5 + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq -0.0146:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\

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

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -0.0146000000000000001

    1. Initial program 72.2%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative72.2%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*70.5%

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

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

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

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

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

    if -0.0146000000000000001 < i < 2.45e188

    1. Initial program 14.1%

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

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

    if 2.45e188 < i

    1. Initial program 66.4%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative20.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*20.0%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def20.0%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified20.0%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative38.6%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified38.6%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -0.0146:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;i \leq 2.45 \cdot 10^{+188}:\\ \;\;\;\;n \cdot 100 + 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 + 0.5 \cdot \frac{-1}{n}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 11: 59.8% accurate, 6.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -0.0146:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;i \leq 2.45 \cdot 10^{+188}:\\ \;\;\;\;n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -0.0146)
   (* (* n 100.0) (/ 0.0 i))
   (if (<= i 2.45e+188)
     (* n (+ 100.0 (* 100.0 (* i (- 0.5 (/ 0.5 n))))))
     (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))
double code(double i, double n) {
	double tmp;
	if (i <= -0.0146) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (i <= 2.45e+188) {
		tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n)))));
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (i <= (-0.0146d0)) then
        tmp = (n * 100.0d0) * (0.0d0 / i)
    else if (i <= 2.45d+188) then
        tmp = n * (100.0d0 + (100.0d0 * (i * (0.5d0 - (0.5d0 / n)))))
    else
        tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (i <= -0.0146) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (i <= 2.45e+188) {
		tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n)))));
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= -0.0146:
		tmp = (n * 100.0) * (0.0 / i)
	elif i <= 2.45e+188:
		tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n)))))
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= -0.0146)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (i <= 2.45e+188)
		tmp = Float64(n * Float64(100.0 + Float64(100.0 * Float64(i * Float64(0.5 - Float64(0.5 / n))))));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= -0.0146)
		tmp = (n * 100.0) * (0.0 / i);
	elseif (i <= 2.45e+188)
		tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n)))));
	else
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, -0.0146], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.45e+188], N[(n * N[(100.0 + N[(100.0 * N[(i * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq -0.0146:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\

\mathbf{elif}\;i \leq 2.45 \cdot 10^{+188}:\\
\;\;\;\;n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -0.0146000000000000001

    1. Initial program 72.2%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative72.2%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*70.5%

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

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

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

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

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

    if -0.0146000000000000001 < i < 2.45e188

    1. Initial program 14.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/14.6%

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

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative14.6%

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

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg14.6%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in14.6%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. fma-def14.6%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, 100 \cdot \left(-1\right)\right)}}{i} \]
      8. metadata-eval14.6%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, 100 \cdot \color{blue}{-1}\right)}{i} \]
      9. metadata-eval14.6%

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

      \[\leadsto \color{blue}{n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}} \]
    4. Taylor expanded in i around 0 77.2%

      \[\leadsto n \cdot \color{blue}{\left(100 + 100 \cdot \left(i \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right)\right) \]
      2. metadata-eval77.2%

        \[\leadsto n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right)\right) \]
    6. Simplified77.2%

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

    if 2.45e188 < i

    1. Initial program 66.4%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative20.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*20.0%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def20.0%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified20.0%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative38.6%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified38.6%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -0.0146:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;i \leq 2.45 \cdot 10^{+188}:\\ \;\;\;\;n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 12: 60.2% accurate, 8.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 8 \cdot 10^{-191} \lor \neg \left(i \leq 2.45 \cdot 10^{+188}\right):\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (or (<= i 8e-191) (not (<= i 2.45e+188)))
   (* 100.0 (/ n (+ 1.0 (* i -0.5))))
   (/ (* -100.0 (* i n)) (- i))))
double code(double i, double n) {
	double tmp;
	if ((i <= 8e-191) || !(i <= 2.45e+188)) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else {
		tmp = (-100.0 * (i * n)) / -i;
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((i <= 8d-191) .or. (.not. (i <= 2.45d+188))) then
        tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
    else
        tmp = ((-100.0d0) * (i * n)) / -i
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if ((i <= 8e-191) || !(i <= 2.45e+188)) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else {
		tmp = (-100.0 * (i * n)) / -i;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if (i <= 8e-191) or not (i <= 2.45e+188):
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	else:
		tmp = (-100.0 * (i * n)) / -i
	return tmp
function code(i, n)
	tmp = 0.0
	if ((i <= 8e-191) || !(i <= 2.45e+188))
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	else
		tmp = Float64(Float64(-100.0 * Float64(i * n)) / Float64(-i));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if ((i <= 8e-191) || ~((i <= 2.45e+188)))
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	else
		tmp = (-100.0 * (i * n)) / -i;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[Or[LessEqual[i, 8e-191], N[Not[LessEqual[i, 2.45e+188]], $MachinePrecision]], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / (-i)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 8 \cdot 10^{-191} \lor \neg \left(i \leq 2.45 \cdot 10^{+188}\right):\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < 8.0000000000000002e-191 or 2.45e188 < i

    1. Initial program 34.9%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative30.8%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*30.8%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def76.8%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified76.8%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative65.6%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified65.6%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]

    if 8.0000000000000002e-191 < i < 2.45e188

    1. Initial program 23.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative23.7%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg23.9%

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval23.9%

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

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. *-commutative23.8%

        \[\leadsto \color{blue}{\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}} \]
      7. frac-2neg23.8%

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

        \[\leadsto \left(n \cdot 100\right) \cdot \frac{-\left({\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}\right)}{-i} \]
      9. sub-neg23.8%

        \[\leadsto \left(n \cdot 100\right) \cdot \frac{-\color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}{-i} \]
      10. associate-*r/23.8%

        \[\leadsto \color{blue}{\frac{\left(n \cdot 100\right) \cdot \left(-\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)\right)}{-i}} \]
    3. Applied egg-rr87.6%

      \[\leadsto \color{blue}{\frac{\left(n \cdot 100\right) \cdot \left(-\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)}{-i}} \]
    4. Taylor expanded in i around 0 61.5%

      \[\leadsto \frac{\color{blue}{-100 \cdot \left(i \cdot n\right)}}{-i} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 8 \cdot 10^{-191} \lor \neg \left(i \leq 2.45 \cdot 10^{+188}\right):\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\ \end{array} \]

Alternative 13: 59.9% accurate, 8.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -0.0146:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;i \leq 2 \cdot 10^{+188}:\\ \;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -0.0146)
   (* (* n 100.0) (/ 0.0 i))
   (if (<= i 2e+188)
     (* 100.0 (* n (+ 1.0 (* i 0.5))))
     (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))
double code(double i, double n) {
	double tmp;
	if (i <= -0.0146) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (i <= 2e+188) {
		tmp = 100.0 * (n * (1.0 + (i * 0.5)));
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (i <= (-0.0146d0)) then
        tmp = (n * 100.0d0) * (0.0d0 / i)
    else if (i <= 2d+188) then
        tmp = 100.0d0 * (n * (1.0d0 + (i * 0.5d0)))
    else
        tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (i <= -0.0146) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (i <= 2e+188) {
		tmp = 100.0 * (n * (1.0 + (i * 0.5)));
	} else {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= -0.0146:
		tmp = (n * 100.0) * (0.0 / i)
	elif i <= 2e+188:
		tmp = 100.0 * (n * (1.0 + (i * 0.5)))
	else:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= -0.0146)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (i <= 2e+188)
		tmp = Float64(100.0 * Float64(n * Float64(1.0 + Float64(i * 0.5))));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= -0.0146)
		tmp = (n * 100.0) * (0.0 / i);
	elseif (i <= 2e+188)
		tmp = 100.0 * (n * (1.0 + (i * 0.5)));
	else
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, -0.0146], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2e+188], N[(100.0 * N[(n * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq -0.0146:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\

\mathbf{elif}\;i \leq 2 \cdot 10^{+188}:\\
\;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot 0.5\right)\right)\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -0.0146000000000000001

    1. Initial program 72.2%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative72.2%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*70.5%

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

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

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

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

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

    if -0.0146000000000000001 < i < 2e188

    1. Initial program 14.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative14.1%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*14.5%

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

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

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

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

      \[\leadsto \color{blue}{\left(1 + i \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)} \cdot \left(n \cdot 100\right) \]
    5. Step-by-step derivation
      1. associate-*r/77.2%

        \[\leadsto \left(1 + i \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \cdot \left(n \cdot 100\right) \]
      2. metadata-eval77.2%

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

      \[\leadsto \color{blue}{\left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \cdot \left(n \cdot 100\right) \]
    7. Taylor expanded in n around inf 77.2%

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

    if 2e188 < i

    1. Initial program 66.4%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative20.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*20.0%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def20.0%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified20.0%

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

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative38.6%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified38.6%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -0.0146:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;i \leq 2 \cdot 10^{+188}:\\ \;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 14: 61.7% accurate, 9.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1.1 \cdot 10^{+16}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq 1.85 \cdot 10^{+27}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -1.1e+16)
   (* n (+ 100.0 (* i 50.0)))
   (if (<= n 1.85e+27) (* 100.0 (/ i (/ i n))) (/ (* -100.0 (* i n)) (- i)))))
double code(double i, double n) {
	double tmp;
	if (n <= -1.1e+16) {
		tmp = n * (100.0 + (i * 50.0));
	} else if (n <= 1.85e+27) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (-100.0 * (i * n)) / -i;
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-1.1d+16)) then
        tmp = n * (100.0d0 + (i * 50.0d0))
    else if (n <= 1.85d+27) then
        tmp = 100.0d0 * (i / (i / n))
    else
        tmp = ((-100.0d0) * (i * n)) / -i
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= -1.1e+16) {
		tmp = n * (100.0 + (i * 50.0));
	} else if (n <= 1.85e+27) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (-100.0 * (i * n)) / -i;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -1.1e+16:
		tmp = n * (100.0 + (i * 50.0))
	elif n <= 1.85e+27:
		tmp = 100.0 * (i / (i / n))
	else:
		tmp = (-100.0 * (i * n)) / -i
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -1.1e+16)
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	elseif (n <= 1.85e+27)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	else
		tmp = Float64(Float64(-100.0 * Float64(i * n)) / Float64(-i));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= -1.1e+16)
		tmp = n * (100.0 + (i * 50.0));
	elseif (n <= 1.85e+27)
		tmp = 100.0 * (i / (i / n));
	else
		tmp = (-100.0 * (i * n)) / -i;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -1.1e+16], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.85e+27], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / (-i)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.1 \cdot 10^{+16}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\

\mathbf{elif}\;n \leq 1.85 \cdot 10^{+27}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -1.1e16

    1. Initial program 32.8%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative30.6%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*30.6%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def84.7%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified84.7%

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

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]
    6. Step-by-step derivation
      1. associate-*r*61.6%

        \[\leadsto \color{blue}{\left(50 \cdot i\right) \cdot n} + 100 \cdot n \]
      2. distribute-rgt-out61.6%

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
    7. Simplified61.6%

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

    if -1.1e16 < n < 1.85000000000000001e27

    1. Initial program 39.8%

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

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]

    if 1.85000000000000001e27 < n

    1. Initial program 18.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative18.7%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg19.2%

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval19.2%

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

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

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

        \[\leadsto \left(n \cdot 100\right) \cdot \color{blue}{\frac{-\left({\left(1 + \frac{i}{n}\right)}^{n} + -1\right)}{-i}} \]
      8. metadata-eval19.2%

        \[\leadsto \left(n \cdot 100\right) \cdot \frac{-\left({\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}\right)}{-i} \]
      9. sub-neg19.2%

        \[\leadsto \left(n \cdot 100\right) \cdot \frac{-\color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}{-i} \]
      10. associate-*r/19.2%

        \[\leadsto \color{blue}{\frac{\left(n \cdot 100\right) \cdot \left(-\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)\right)}{-i}} \]
    3. Applied egg-rr68.9%

      \[\leadsto \color{blue}{\frac{\left(n \cdot 100\right) \cdot \left(-\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)}{-i}} \]
    4. Taylor expanded in i around 0 64.1%

      \[\leadsto \frac{\color{blue}{-100 \cdot \left(i \cdot n\right)}}{-i} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification63.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.1 \cdot 10^{+16}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq 1.85 \cdot 10^{+27}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\ \end{array} \]

Alternative 15: 61.7% accurate, 9.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -3.6 \cdot 10^{+15}:\\ \;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot 0.5\right)\right)\\ \mathbf{elif}\;n \leq 2.1 \cdot 10^{+27}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -3.6e+15)
   (* 100.0 (* n (+ 1.0 (* i 0.5))))
   (if (<= n 2.1e+27) (* 100.0 (/ i (/ i n))) (/ (* -100.0 (* i n)) (- i)))))
double code(double i, double n) {
	double tmp;
	if (n <= -3.6e+15) {
		tmp = 100.0 * (n * (1.0 + (i * 0.5)));
	} else if (n <= 2.1e+27) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (-100.0 * (i * n)) / -i;
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-3.6d+15)) then
        tmp = 100.0d0 * (n * (1.0d0 + (i * 0.5d0)))
    else if (n <= 2.1d+27) then
        tmp = 100.0d0 * (i / (i / n))
    else
        tmp = ((-100.0d0) * (i * n)) / -i
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= -3.6e+15) {
		tmp = 100.0 * (n * (1.0 + (i * 0.5)));
	} else if (n <= 2.1e+27) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (-100.0 * (i * n)) / -i;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -3.6e+15:
		tmp = 100.0 * (n * (1.0 + (i * 0.5)))
	elif n <= 2.1e+27:
		tmp = 100.0 * (i / (i / n))
	else:
		tmp = (-100.0 * (i * n)) / -i
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -3.6e+15)
		tmp = Float64(100.0 * Float64(n * Float64(1.0 + Float64(i * 0.5))));
	elseif (n <= 2.1e+27)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	else
		tmp = Float64(Float64(-100.0 * Float64(i * n)) / Float64(-i));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= -3.6e+15)
		tmp = 100.0 * (n * (1.0 + (i * 0.5)));
	elseif (n <= 2.1e+27)
		tmp = 100.0 * (i / (i / n));
	else
		tmp = (-100.0 * (i * n)) / -i;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -3.6e+15], N[(100.0 * N[(n * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.1e+27], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / (-i)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.6 \cdot 10^{+15}:\\
\;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot 0.5\right)\right)\\

\mathbf{elif}\;n \leq 2.1 \cdot 10^{+27}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -3.6e15

    1. Initial program 32.8%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative32.8%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*33.3%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg33.3%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval33.3%

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

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

      \[\leadsto \color{blue}{\left(1 + i \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)} \cdot \left(n \cdot 100\right) \]
    5. Step-by-step derivation
      1. associate-*r/61.6%

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

        \[\leadsto \left(1 + i \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \cdot \left(n \cdot 100\right) \]
    6. Simplified61.6%

      \[\leadsto \color{blue}{\left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \cdot \left(n \cdot 100\right) \]
    7. Taylor expanded in n around inf 61.6%

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

    if -3.6e15 < n < 2.09999999999999995e27

    1. Initial program 39.8%

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

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]

    if 2.09999999999999995e27 < n

    1. Initial program 18.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative18.7%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg19.2%

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval19.2%

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

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

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

        \[\leadsto \left(n \cdot 100\right) \cdot \color{blue}{\frac{-\left({\left(1 + \frac{i}{n}\right)}^{n} + -1\right)}{-i}} \]
      8. metadata-eval19.2%

        \[\leadsto \left(n \cdot 100\right) \cdot \frac{-\left({\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}\right)}{-i} \]
      9. sub-neg19.2%

        \[\leadsto \left(n \cdot 100\right) \cdot \frac{-\color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}{-i} \]
      10. associate-*r/19.2%

        \[\leadsto \color{blue}{\frac{\left(n \cdot 100\right) \cdot \left(-\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)\right)}{-i}} \]
    3. Applied egg-rr68.9%

      \[\leadsto \color{blue}{\frac{\left(n \cdot 100\right) \cdot \left(-\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)}{-i}} \]
    4. Taylor expanded in i around 0 64.1%

      \[\leadsto \frac{\color{blue}{-100 \cdot \left(i \cdot n\right)}}{-i} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification63.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.6 \cdot 10^{+15}:\\ \;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot 0.5\right)\right)\\ \mathbf{elif}\;n \leq 2.1 \cdot 10^{+27}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-100 \cdot \left(i \cdot n\right)}{-i}\\ \end{array} \]

Alternative 16: 62.2% accurate, 10.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1.65 \cdot 10^{+16} \lor \neg \left(n \leq 1.88 \cdot 10^{-59}\right):\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (or (<= n -1.65e+16) (not (<= n 1.88e-59)))
   (* n (+ 100.0 (* i 50.0)))
   (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
	double tmp;
	if ((n <= -1.65e+16) || !(n <= 1.88e-59)) {
		tmp = n * (100.0 + (i * 50.0));
	} else {
		tmp = 100.0 * (i / (i / n));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((n <= (-1.65d+16)) .or. (.not. (n <= 1.88d-59))) then
        tmp = n * (100.0d0 + (i * 50.0d0))
    else
        tmp = 100.0d0 * (i / (i / n))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if ((n <= -1.65e+16) || !(n <= 1.88e-59)) {
		tmp = n * (100.0 + (i * 50.0));
	} else {
		tmp = 100.0 * (i / (i / n));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if (n <= -1.65e+16) or not (n <= 1.88e-59):
		tmp = n * (100.0 + (i * 50.0))
	else:
		tmp = 100.0 * (i / (i / n))
	return tmp
function code(i, n)
	tmp = 0.0
	if ((n <= -1.65e+16) || !(n <= 1.88e-59))
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	else
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if ((n <= -1.65e+16) || ~((n <= 1.88e-59)))
		tmp = n * (100.0 + (i * 50.0));
	else
		tmp = 100.0 * (i / (i / n));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[Or[LessEqual[n, -1.65e+16], N[Not[LessEqual[n, 1.88e-59]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.65 \cdot 10^{+16} \lor \neg \left(n \leq 1.88 \cdot 10^{-59}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.65e16 or 1.88e-59 < n

    1. Initial program 27.3%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative38.6%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*38.5%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def89.6%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified89.6%

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

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]
    6. Step-by-step derivation
      1. associate-*r*62.3%

        \[\leadsto \color{blue}{\left(50 \cdot i\right) \cdot n} + 100 \cdot n \]
      2. distribute-rgt-out62.3%

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
    7. Simplified62.3%

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

    if -1.65e16 < n < 1.88e-59

    1. Initial program 38.9%

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

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification63.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.65 \cdot 10^{+16} \lor \neg \left(n \leq 1.88 \cdot 10^{-59}\right):\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \]

Alternative 17: 58.3% accurate, 12.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -2 \cdot 10^{+73}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 2:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -2e+73)
   (* 100.0 (/ i (/ i n)))
   (if (<= i 2.0) (* n 100.0) (* (* i n) 50.0))))
double code(double i, double n) {
	double tmp;
	if (i <= -2e+73) {
		tmp = 100.0 * (i / (i / n));
	} else if (i <= 2.0) {
		tmp = n * 100.0;
	} else {
		tmp = (i * n) * 50.0;
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (i <= (-2d+73)) then
        tmp = 100.0d0 * (i / (i / n))
    else if (i <= 2.0d0) then
        tmp = n * 100.0d0
    else
        tmp = (i * n) * 50.0d0
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (i <= -2e+73) {
		tmp = 100.0 * (i / (i / n));
	} else if (i <= 2.0) {
		tmp = n * 100.0;
	} else {
		tmp = (i * n) * 50.0;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= -2e+73:
		tmp = 100.0 * (i / (i / n))
	elif i <= 2.0:
		tmp = n * 100.0
	else:
		tmp = (i * n) * 50.0
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= -2e+73)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	elseif (i <= 2.0)
		tmp = Float64(n * 100.0);
	else
		tmp = Float64(Float64(i * n) * 50.0);
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= -2e+73)
		tmp = 100.0 * (i / (i / n));
	elseif (i <= 2.0)
		tmp = n * 100.0;
	else
		tmp = (i * n) * 50.0;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, -2e+73], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.0], N[(n * 100.0), $MachinePrecision], N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq -2 \cdot 10^{+73}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{elif}\;i \leq 2:\\
\;\;\;\;n \cdot 100\\

\mathbf{else}:\\
\;\;\;\;\left(i \cdot n\right) \cdot 50\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -1.99999999999999997e73

    1. Initial program 79.9%

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

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]

    if -1.99999999999999997e73 < i < 2

    1. Initial program 10.9%

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

      \[\leadsto \color{blue}{100 \cdot n} \]
    3. Step-by-step derivation
      1. *-commutative81.2%

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified81.2%

      \[\leadsto \color{blue}{n \cdot 100} \]

    if 2 < i

    1. Initial program 47.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative47.9%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*48.2%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg48.2%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval48.2%

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

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

      \[\leadsto \color{blue}{\frac{e^{i} - 1}{i}} \cdot \left(n \cdot 100\right) \]
    5. Step-by-step derivation
      1. expm1-def56.7%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(i\right)}}{i} \cdot \left(n \cdot 100\right) \]
    6. Simplified56.7%

      \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(i\right)}{i}} \cdot \left(n \cdot 100\right) \]
    7. Step-by-step derivation
      1. div-inv56.7%

        \[\leadsto \color{blue}{\left(\mathsf{expm1}\left(i\right) \cdot \frac{1}{i}\right)} \cdot \left(n \cdot 100\right) \]
    8. Applied egg-rr56.7%

      \[\leadsto \color{blue}{\left(\mathsf{expm1}\left(i\right) \cdot \frac{1}{i}\right)} \cdot \left(n \cdot 100\right) \]
    9. Taylor expanded in i around 0 27.6%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot i\right)} \cdot \left(n \cdot 100\right) \]
    10. Step-by-step derivation
      1. *-commutative27.6%

        \[\leadsto \left(1 + \color{blue}{i \cdot 0.5}\right) \cdot \left(n \cdot 100\right) \]
    11. Simplified27.6%

      \[\leadsto \color{blue}{\left(1 + i \cdot 0.5\right)} \cdot \left(n \cdot 100\right) \]
    12. Taylor expanded in i around inf 27.6%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification60.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2 \cdot 10^{+73}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 2:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \]

Alternative 18: 54.7% accurate, 16.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 2:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \end{array} \]
(FPCore (i n) :precision binary64 (if (<= i 2.0) (* n 100.0) (* (* i n) 50.0)))
double code(double i, double n) {
	double tmp;
	if (i <= 2.0) {
		tmp = n * 100.0;
	} else {
		tmp = (i * n) * 50.0;
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (i <= 2.0d0) then
        tmp = n * 100.0d0
    else
        tmp = (i * n) * 50.0d0
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (i <= 2.0) {
		tmp = n * 100.0;
	} else {
		tmp = (i * n) * 50.0;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= 2.0:
		tmp = n * 100.0
	else:
		tmp = (i * n) * 50.0
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= 2.0)
		tmp = Float64(n * 100.0);
	else
		tmp = Float64(Float64(i * n) * 50.0);
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= 2.0)
		tmp = n * 100.0;
	else
		tmp = (i * n) * 50.0;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, 2.0], N[(n * 100.0), $MachinePrecision], N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 2:\\
\;\;\;\;n \cdot 100\\

\mathbf{else}:\\
\;\;\;\;\left(i \cdot n\right) \cdot 50\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < 2

    1. Initial program 26.9%

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

      \[\leadsto \color{blue}{100 \cdot n} \]
    3. Step-by-step derivation
      1. *-commutative63.4%

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified63.4%

      \[\leadsto \color{blue}{n \cdot 100} \]

    if 2 < i

    1. Initial program 47.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative47.9%

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

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. associate-*l*48.2%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot \left(n \cdot 100\right)} \]
      4. sub-neg48.2%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot \left(n \cdot 100\right) \]
      5. metadata-eval48.2%

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

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

      \[\leadsto \color{blue}{\frac{e^{i} - 1}{i}} \cdot \left(n \cdot 100\right) \]
    5. Step-by-step derivation
      1. expm1-def56.7%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(i\right)}}{i} \cdot \left(n \cdot 100\right) \]
    6. Simplified56.7%

      \[\leadsto \color{blue}{\frac{\mathsf{expm1}\left(i\right)}{i}} \cdot \left(n \cdot 100\right) \]
    7. Step-by-step derivation
      1. div-inv56.7%

        \[\leadsto \color{blue}{\left(\mathsf{expm1}\left(i\right) \cdot \frac{1}{i}\right)} \cdot \left(n \cdot 100\right) \]
    8. Applied egg-rr56.7%

      \[\leadsto \color{blue}{\left(\mathsf{expm1}\left(i\right) \cdot \frac{1}{i}\right)} \cdot \left(n \cdot 100\right) \]
    9. Taylor expanded in i around 0 27.6%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot i\right)} \cdot \left(n \cdot 100\right) \]
    10. Step-by-step derivation
      1. *-commutative27.6%

        \[\leadsto \left(1 + \color{blue}{i \cdot 0.5}\right) \cdot \left(n \cdot 100\right) \]
    11. Simplified27.6%

      \[\leadsto \color{blue}{\left(1 + i \cdot 0.5\right)} \cdot \left(n \cdot 100\right) \]
    12. Taylor expanded in i around inf 27.6%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 2:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \]

Alternative 19: 2.8% accurate, 38.0× speedup?

\[\begin{array}{l} \\ i \cdot -50 \end{array} \]
(FPCore (i n) :precision binary64 (* i -50.0))
double code(double i, double n) {
	return i * -50.0;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = i * (-50.0d0)
end function
public static double code(double i, double n) {
	return i * -50.0;
}
def code(i, n):
	return i * -50.0
function code(i, n)
	return Float64(i * -50.0)
end
function tmp = code(i, n)
	tmp = i * -50.0;
end
code[i_, n_] := N[(i * -50.0), $MachinePrecision]
\begin{array}{l}

\\
i \cdot -50
\end{array}
Derivation
  1. Initial program 31.5%

    \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
  2. Step-by-step derivation
    1. *-commutative31.5%

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

      \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
    3. associate-*l*31.5%

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

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

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

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

    \[\leadsto \color{blue}{\left(1 + i \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)} \cdot \left(n \cdot 100\right) \]
  5. Step-by-step derivation
    1. associate-*r/54.7%

      \[\leadsto \left(1 + i \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \cdot \left(n \cdot 100\right) \]
    2. metadata-eval54.7%

      \[\leadsto \left(1 + i \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \cdot \left(n \cdot 100\right) \]
  6. Simplified54.7%

    \[\leadsto \color{blue}{\left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \cdot \left(n \cdot 100\right) \]
  7. Taylor expanded in n around 0 2.8%

    \[\leadsto \color{blue}{-50 \cdot i} \]
  8. Simplified2.8%

    \[\leadsto \color{blue}{i \cdot -50} \]
  9. Final simplification2.8%

    \[\leadsto i \cdot -50 \]

Alternative 20: 49.3% accurate, 38.0× speedup?

\[\begin{array}{l} \\ n \cdot 100 \end{array} \]
(FPCore (i n) :precision binary64 (* n 100.0))
double code(double i, double n) {
	return n * 100.0;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = n * 100.0d0
end function
public static double code(double i, double n) {
	return n * 100.0;
}
def code(i, n):
	return n * 100.0
function code(i, n)
	return Float64(n * 100.0)
end
function tmp = code(i, n)
	tmp = n * 100.0;
end
code[i_, n_] := N[(n * 100.0), $MachinePrecision]
\begin{array}{l}

\\
n \cdot 100
\end{array}
Derivation
  1. Initial program 31.5%

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

    \[\leadsto \color{blue}{100 \cdot n} \]
  3. Step-by-step derivation
    1. *-commutative51.1%

      \[\leadsto \color{blue}{n \cdot 100} \]
  4. Simplified51.1%

    \[\leadsto \color{blue}{n \cdot 100} \]
  5. Final simplification51.1%

    \[\leadsto n \cdot 100 \]

Developer target: 33.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{i}{n}\\ 100 \cdot \frac{e^{n \cdot \begin{array}{l} \mathbf{if}\;t_0 = 1:\\ \;\;\;\;\frac{i}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{i}{n} \cdot \log t_0}{\left(\frac{i}{n} + 1\right) - 1}\\ \end{array}} - 1}{\frac{i}{n}} \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ i n))))
   (*
    100.0
    (/
     (-
      (exp
       (*
        n
        (if (== t_0 1.0)
          (/ i n)
          (/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
      1.0)
     (/ i n)))))
double code(double i, double n) {
	double t_0 = 1.0 + (i / n);
	double tmp;
	if (t_0 == 1.0) {
		tmp = i / n;
	} else {
		tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
	}
	return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + (i / n)
    if (t_0 == 1.0d0) then
        tmp = i / n
    else
        tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
    end if
    code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
	double t_0 = 1.0 + (i / n);
	double tmp;
	if (t_0 == 1.0) {
		tmp = i / n;
	} else {
		tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
	}
	return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n):
	t_0 = 1.0 + (i / n)
	tmp = 0
	if t_0 == 1.0:
		tmp = i / n
	else:
		tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0)
	return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n)
	t_0 = Float64(1.0 + Float64(i / n))
	tmp = 0.0
	if (t_0 == 1.0)
		tmp = Float64(i / n);
	else
		tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0));
	end
	return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n)))
end
function tmp_2 = code(i, n)
	t_0 = 1.0 + (i / n);
	tmp = 0.0;
	if (t_0 == 1.0)
		tmp = i / n;
	else
		tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
	end
	tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t_0 = 1:\\
\;\;\;\;\frac{i}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t_0}{\left(\frac{i}{n} + 1\right) - 1}\\


\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}

Reproduce

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