Compound Interest

Percentage Accurate: 27.9% → 98.7%
Time: 21.2s
Alternatives: 24
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 24 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: 27.9% 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.7% 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 -\infty:\\ \;\;\;\;100 \cdot \left(\frac{n}{i} \cdot t_1\right)\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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 (- INFINITY))
     (* 100.0 (* (/ n i) t_1))
     (if (<= t_2 0.0)
       (/ (* n 100.0) (/ i (expm1 (* n (log1p (/ i n))))))
       (if (<= t_2 INFINITY)
         (* 100.0 (- (* t_0 (/ n i)) (/ n i)))
         (/ (* n 100.0) (+ 1.0 (* (/ i n) 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 <= -((double) INFINITY)) {
		tmp = 100.0 * ((n / i) * t_1);
	} else if (t_2 <= 0.0) {
		tmp = (n * 100.0) / (i / expm1((n * log1p((i / n)))));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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 <= -Double.POSITIVE_INFINITY) {
		tmp = 100.0 * ((n / i) * t_1);
	} else if (t_2 <= 0.0) {
		tmp = (n * 100.0) / (i / Math.expm1((n * Math.log1p((i / n)))));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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 <= -math.inf:
		tmp = 100.0 * ((n / i) * t_1)
	elif t_2 <= 0.0:
		tmp = (n * 100.0) / (i / math.expm1((n * math.log1p((i / n)))))
	elif t_2 <= math.inf:
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i))
	else:
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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 <= Float64(-Inf))
		tmp = Float64(100.0 * Float64(Float64(n / i) * t_1));
	elseif (t_2 <= 0.0)
		tmp = Float64(Float64(n * 100.0) / Float64(i / expm1(Float64(n * log1p(Float64(i / n))))));
	elseif (t_2 <= Inf)
		tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i)));
	else
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(Float64(i / n) * 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, (-Infinity)], N[(100.0 * N[(N[(n / i), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(n * 100.0), $MachinePrecision] / N[(i / N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(N[(i / n), $MachinePrecision] * 0.5), $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 -\infty:\\
\;\;\;\;100 \cdot \left(\frac{n}{i} \cdot t_1\right)\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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}} \]
    2. Step-by-step derivation
      1. div-sub100.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. clear-num100.0%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 27.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp27.0%

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp27.0%

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\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 98.6%

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

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

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

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

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

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

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

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

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\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. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp2.0%

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp2.0%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

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

Alternative 2: 97.7% accurate, 0.3× 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}}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-42}:\\ \;\;\;\;t_1 \cdot 100\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;100 \cdot \left(\frac{n}{i} \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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))))
   (if (<= t_1 -1e-42)
     (* t_1 100.0)
     (if (<= t_1 0.0)
       (* 100.0 (* (/ n i) (expm1 (* n (log1p (/ i n))))))
       (if (<= t_1 INFINITY)
         (* 100.0 (- (* t_0 (/ n i)) (/ n i)))
         (/ (* n 100.0) (+ 1.0 (* (/ i n) 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 tmp;
	if (t_1 <= -1e-42) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * ((n / i) * expm1((n * log1p((i / n)))));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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) / (i / n);
	double tmp;
	if (t_1 <= -1e-42) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * ((n / i) * Math.expm1((n * Math.log1p((i / n)))));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	}
	return tmp;
}
def code(i, n):
	t_0 = math.pow((1.0 + (i / n)), n)
	t_1 = (t_0 + -1.0) / (i / n)
	tmp = 0
	if t_1 <= -1e-42:
		tmp = t_1 * 100.0
	elif t_1 <= 0.0:
		tmp = 100.0 * ((n / i) * math.expm1((n * math.log1p((i / n)))))
	elif t_1 <= math.inf:
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i))
	else:
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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))
	tmp = 0.0
	if (t_1 <= -1e-42)
		tmp = Float64(t_1 * 100.0);
	elseif (t_1 <= 0.0)
		tmp = Float64(100.0 * Float64(Float64(n / i) * expm1(Float64(n * log1p(Float64(i / n))))));
	elseif (t_1 <= Inf)
		tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i)));
	else
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(Float64(i / n) * 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]}, If[LessEqual[t$95$1, -1e-42], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(N[(n / i), $MachinePrecision] * N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(N[(i / n), $MachinePrecision] * 0.5), $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}}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-42}:\\
\;\;\;\;t_1 \cdot 100\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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.00000000000000004e-42

    1. Initial program 99.9%

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

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

    1. Initial program 25.6%

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

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

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

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

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

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

        \[\leadsto 100 \cdot \left(\frac{n}{i} \cdot \mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)\right) \]
      7. pow-to-exp25.6%

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

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

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

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

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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\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. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp2.0%

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp2.0%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -1 \cdot 10^{-42}:\\ \;\;\;\;\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:\\ \;\;\;\;100 \cdot \left(\frac{n}{i} \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\ \end{array} \]

Alternative 3: 98.6% accurate, 0.3× 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}}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-42}:\\ \;\;\;\;t_1 \cdot 100\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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))))
   (if (<= t_1 -1e-42)
     (* t_1 100.0)
     (if (<= t_1 0.0)
       (* 100.0 (* n (/ (expm1 (* n (log1p (/ i n)))) i)))
       (if (<= t_1 INFINITY)
         (* 100.0 (- (* t_0 (/ n i)) (/ n i)))
         (/ (* n 100.0) (+ 1.0 (* (/ i n) 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 tmp;
	if (t_1 <= -1e-42) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n * (expm1((n * log1p((i / n)))) / i));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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) / (i / n);
	double tmp;
	if (t_1 <= -1e-42) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n * (Math.expm1((n * Math.log1p((i / n)))) / i));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	}
	return tmp;
}
def code(i, n):
	t_0 = math.pow((1.0 + (i / n)), n)
	t_1 = (t_0 + -1.0) / (i / n)
	tmp = 0
	if t_1 <= -1e-42:
		tmp = t_1 * 100.0
	elif t_1 <= 0.0:
		tmp = 100.0 * (n * (math.expm1((n * math.log1p((i / n)))) / i))
	elif t_1 <= math.inf:
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i))
	else:
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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))
	tmp = 0.0
	if (t_1 <= -1e-42)
		tmp = Float64(t_1 * 100.0);
	elseif (t_1 <= 0.0)
		tmp = Float64(100.0 * Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i)));
	elseif (t_1 <= Inf)
		tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i)));
	else
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(Float64(i / n) * 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]}, If[LessEqual[t$95$1, -1e-42], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(N[(i / n), $MachinePrecision] * 0.5), $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}}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-42}:\\
\;\;\;\;t_1 \cdot 100\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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.00000000000000004e-42

    1. Initial program 99.9%

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

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

    1. Initial program 25.6%

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

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

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

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

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

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

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

        \[\leadsto 100 \cdot \left(\frac{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}{i} \cdot n\right) \]
      8. pow-to-exp25.6%

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

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

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

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

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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\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. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp2.0%

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp2.0%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -1 \cdot 10^{-42}:\\ \;\;\;\;\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:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\ \end{array} \]

Alternative 4: 98.6% accurate, 0.3× 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}}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-94}:\\ \;\;\;\;t_1 \cdot 100\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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))))
   (if (<= t_1 -5e-94)
     (* t_1 100.0)
     (if (<= t_1 0.0)
       (* n (* 100.0 (/ (expm1 (* n (log1p (/ i n)))) i)))
       (if (<= t_1 INFINITY)
         (* 100.0 (- (* t_0 (/ n i)) (/ n i)))
         (/ (* n 100.0) (+ 1.0 (* (/ i n) 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 tmp;
	if (t_1 <= -5e-94) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = n * (100.0 * (expm1((n * log1p((i / n)))) / i));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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) / (i / n);
	double tmp;
	if (t_1 <= -5e-94) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = n * (100.0 * (Math.expm1((n * Math.log1p((i / n)))) / i));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	}
	return tmp;
}
def code(i, n):
	t_0 = math.pow((1.0 + (i / n)), n)
	t_1 = (t_0 + -1.0) / (i / n)
	tmp = 0
	if t_1 <= -5e-94:
		tmp = t_1 * 100.0
	elif t_1 <= 0.0:
		tmp = n * (100.0 * (math.expm1((n * math.log1p((i / n)))) / i))
	elif t_1 <= math.inf:
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i))
	else:
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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))
	tmp = 0.0
	if (t_1 <= -5e-94)
		tmp = Float64(t_1 * 100.0);
	elseif (t_1 <= 0.0)
		tmp = Float64(n * Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i)));
	elseif (t_1 <= Inf)
		tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i)));
	else
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(Float64(i / n) * 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]}, If[LessEqual[t$95$1, -5e-94], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(n * N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(N[(i / n), $MachinePrecision] * 0.5), $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}}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-94}:\\
\;\;\;\;t_1 \cdot 100\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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)) < -4.9999999999999995e-94

    1. Initial program 99.7%

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

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

    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.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp23.8%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\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. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp2.0%

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp2.0%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -5 \cdot 10^{-94}:\\ \;\;\;\;\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:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\ \end{array} \]

Alternative 5: 98.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 -5 \cdot 10^{-24}:\\ \;\;\;\;100 \cdot \left(\frac{n}{i} \cdot t_1\right)\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;n \cdot \left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{100}{i}\right)\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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 -5e-24)
     (* 100.0 (* (/ n i) t_1))
     (if (<= t_2 0.0)
       (* n (* (expm1 (* n (log1p (/ i n)))) (/ 100.0 i)))
       (if (<= t_2 INFINITY)
         (* 100.0 (- (* t_0 (/ n i)) (/ n i)))
         (/ (* n 100.0) (+ 1.0 (* (/ i n) 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 <= -5e-24) {
		tmp = 100.0 * ((n / i) * t_1);
	} else if (t_2 <= 0.0) {
		tmp = n * (expm1((n * log1p((i / n)))) * (100.0 / i));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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 <= -5e-24) {
		tmp = 100.0 * ((n / i) * t_1);
	} else if (t_2 <= 0.0) {
		tmp = n * (Math.expm1((n * Math.log1p((i / n)))) * (100.0 / i));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
	} else {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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 <= -5e-24:
		tmp = 100.0 * ((n / i) * t_1)
	elif t_2 <= 0.0:
		tmp = n * (math.expm1((n * math.log1p((i / n)))) * (100.0 / i))
	elif t_2 <= math.inf:
		tmp = 100.0 * ((t_0 * (n / i)) - (n / i))
	else:
		tmp = (n * 100.0) / (1.0 + ((i / n) * 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 <= -5e-24)
		tmp = Float64(100.0 * Float64(Float64(n / i) * t_1));
	elseif (t_2 <= 0.0)
		tmp = Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(100.0 / i)));
	elseif (t_2 <= Inf)
		tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i)));
	else
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(Float64(i / n) * 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, -5e-24], N[(100.0 * N[(N[(n / i), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(100.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(N[(i / n), $MachinePrecision] * 0.5), $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 -5 \cdot 10^{-24}:\\
\;\;\;\;100 \cdot \left(\frac{n}{i} \cdot t_1\right)\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \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)) < -4.9999999999999998e-24

    1. Initial program 100.0%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. div-sub100.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. clear-num100.0%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.5%

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

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

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

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

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

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

        \[\leadsto 100 \cdot \left(\frac{n}{i} \cdot \mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)\right) \]
      7. pow-to-exp26.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\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. Step-by-step derivation
      1. *-commutative0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp2.0%

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp2.0%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

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

Alternative 6: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2050:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 0.58:\\ \;\;\;\;n \cdot \frac{1}{\mathsf{fma}\left(i, \frac{0.5}{n} + -0.5, 1\right) \cdot 0.01}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -2050.0)
   (/ (* n 100.0) (/ i (expm1 i)))
   (if (<= n 0.58)
     (* n (/ 1.0 (* (fma i (+ (/ 0.5 n) -0.5) 1.0) 0.01)))
     (* n (* 100.0 (/ (expm1 i) i))))))
double code(double i, double n) {
	double tmp;
	if (n <= -2050.0) {
		tmp = (n * 100.0) / (i / expm1(i));
	} else if (n <= 0.58) {
		tmp = n * (1.0 / (fma(i, ((0.5 / n) + -0.5), 1.0) * 0.01));
	} else {
		tmp = n * (100.0 * (expm1(i) / i));
	}
	return tmp;
}
function code(i, n)
	tmp = 0.0
	if (n <= -2050.0)
		tmp = Float64(Float64(n * 100.0) / Float64(i / expm1(i)));
	elseif (n <= 0.58)
		tmp = Float64(n * Float64(1.0 / Float64(fma(i, Float64(Float64(0.5 / n) + -0.5), 1.0) * 0.01)));
	else
		tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i)));
	end
	return tmp
end
code[i_, n_] := If[LessEqual[n, -2050.0], N[(N[(n * 100.0), $MachinePrecision] / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.58], N[(n * N[(1.0 / N[(N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * 0.01), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;n \leq 0.58:\\
\;\;\;\;n \cdot \frac{1}{\mathsf{fma}\left(i, \frac{0.5}{n} + -0.5, 1\right) \cdot 0.01}\\

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


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

    1. Initial program 29.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/87.8%

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

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

    if -2050 < n < 0.57999999999999996

    1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp35.6%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg80.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{1}{\mathsf{fma}\left(i, \frac{0.5}{n} + -0.5, 1\right) \cdot \color{blue}{0.01}} \]
    8. Applied egg-rr80.4%

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

    if 0.57999999999999996 < n

    1. Initial program 29.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2050:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 0.58:\\ \;\;\;\;n \cdot \frac{1}{\mathsf{fma}\left(i, \frac{0.5}{n} + -0.5, 1\right) \cdot 0.01}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \end{array} \]

Alternative 7: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2050:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 0.58:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{1}{\mathsf{fma}\left(i, \frac{0.5}{n} + -0.5, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -2050.0)
   (/ (* n 100.0) (/ i (expm1 i)))
   (if (<= n 0.58)
     (* (* n 100.0) (/ 1.0 (fma i (+ (/ 0.5 n) -0.5) 1.0)))
     (* n (* 100.0 (/ (expm1 i) i))))))
double code(double i, double n) {
	double tmp;
	if (n <= -2050.0) {
		tmp = (n * 100.0) / (i / expm1(i));
	} else if (n <= 0.58) {
		tmp = (n * 100.0) * (1.0 / fma(i, ((0.5 / n) + -0.5), 1.0));
	} else {
		tmp = n * (100.0 * (expm1(i) / i));
	}
	return tmp;
}
function code(i, n)
	tmp = 0.0
	if (n <= -2050.0)
		tmp = Float64(Float64(n * 100.0) / Float64(i / expm1(i)));
	elseif (n <= 0.58)
		tmp = Float64(Float64(n * 100.0) * Float64(1.0 / fma(i, Float64(Float64(0.5 / n) + -0.5), 1.0)));
	else
		tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i)));
	end
	return tmp
end
code[i_, n_] := If[LessEqual[n, -2050.0], N[(N[(n * 100.0), $MachinePrecision] / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.58], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 / N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;n \leq 0.58:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{1}{\mathsf{fma}\left(i, \frac{0.5}{n} + -0.5, 1\right)}\\

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


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

    1. Initial program 29.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/87.8%

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

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

    if -2050 < n < 0.57999999999999996

    1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp35.6%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg80.4%

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

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

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

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

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

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

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

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

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

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

    if 0.57999999999999996 < n

    1. Initial program 29.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 80.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{if}\;i \leq -2.1 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;i \leq 1.6 \cdot 10^{-20}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\ \mathbf{elif}\;i \leq 6.8 \cdot 10^{+229}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;i \leq 6.3 \cdot 10^{+255}:\\ \;\;\;\;\frac{100}{\frac{1 + i \cdot -0.5}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* 100.0 (/ (expm1 i) (/ i n)))))
   (if (<= i -2.1e-15)
     t_0
     (if (<= i 1.6e-20)
       (/ (* n 100.0) (+ 1.0 (* (/ i n) 0.5)))
       (if (<= i 6.8e+229)
         t_0
         (if (<= i 6.3e+255)
           (/ 100.0 (/ (+ 1.0 (* i -0.5)) n))
           (* 100.0 (/ (* i n) i))))))))
double code(double i, double n) {
	double t_0 = 100.0 * (expm1(i) / (i / n));
	double tmp;
	if (i <= -2.1e-15) {
		tmp = t_0;
	} else if (i <= 1.6e-20) {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	} else if (i <= 6.8e+229) {
		tmp = t_0;
	} else if (i <= 6.3e+255) {
		tmp = 100.0 / ((1.0 + (i * -0.5)) / n);
	} else {
		tmp = 100.0 * ((i * n) / i);
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = 100.0 * (Math.expm1(i) / (i / n));
	double tmp;
	if (i <= -2.1e-15) {
		tmp = t_0;
	} else if (i <= 1.6e-20) {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	} else if (i <= 6.8e+229) {
		tmp = t_0;
	} else if (i <= 6.3e+255) {
		tmp = 100.0 / ((1.0 + (i * -0.5)) / n);
	} else {
		tmp = 100.0 * ((i * n) / i);
	}
	return tmp;
}
def code(i, n):
	t_0 = 100.0 * (math.expm1(i) / (i / n))
	tmp = 0
	if i <= -2.1e-15:
		tmp = t_0
	elif i <= 1.6e-20:
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5))
	elif i <= 6.8e+229:
		tmp = t_0
	elif i <= 6.3e+255:
		tmp = 100.0 / ((1.0 + (i * -0.5)) / n)
	else:
		tmp = 100.0 * ((i * n) / i)
	return tmp
function code(i, n)
	t_0 = Float64(100.0 * Float64(expm1(i) / Float64(i / n)))
	tmp = 0.0
	if (i <= -2.1e-15)
		tmp = t_0;
	elseif (i <= 1.6e-20)
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(Float64(i / n) * 0.5)));
	elseif (i <= 6.8e+229)
		tmp = t_0;
	elseif (i <= 6.3e+255)
		tmp = Float64(100.0 / Float64(Float64(1.0 + Float64(i * -0.5)) / n));
	else
		tmp = Float64(100.0 * Float64(Float64(i * n) / i));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -2.1e-15], t$95$0, If[LessEqual[i, 1.6e-20], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(N[(i / n), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 6.8e+229], t$95$0, If[LessEqual[i, 6.3e+255], N[(100.0 / N[(N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;i \leq 6.8 \cdot 10^{+229}:\\
\;\;\;\;t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if i < -2.09999999999999981e-15 or 1.59999999999999985e-20 < i < 6.8000000000000002e229

    1. Initial program 55.0%

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

      \[\leadsto 100 \cdot \frac{\color{blue}{e^{i} - 1}}{\frac{i}{n}} \]
    3. Step-by-step derivation
      1. expm1-def69.2%

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

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

    if -2.09999999999999981e-15 < i < 1.59999999999999985e-20

    1. Initial program 8.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp9.0%

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp9.0%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg92.3%

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

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

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

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

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

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

    if 6.8000000000000002e229 < i < 6.3e255

    1. Initial program 33.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. *-commutative1.4%

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

        \[\leadsto 100 \cdot \color{blue}{\frac{1}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n}}} \]
      3. un-div-inv1.4%

        \[\leadsto \color{blue}{\frac{100}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n}}} \]
    6. Applied egg-rr1.4%

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

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

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

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

    if 6.3e255 < i

    1. Initial program 83.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2.1 \cdot 10^{-15}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 1.6 \cdot 10^{-20}:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\ \mathbf{elif}\;i \leq 6.8 \cdot 10^{+229}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 6.3 \cdot 10^{+255}:\\ \;\;\;\;\frac{100}{\frac{1 + i \cdot -0.5}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \end{array} \]

Alternative 9: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2050 \lor \neg \left(n \leq 0.58\right):\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (or (<= n -2050.0) (not (<= n 0.58)))
   (* n (* 100.0 (/ (expm1 i) i)))
   (/ (* n 100.0) (+ 1.0 (* i (+ (/ 0.5 n) -0.5))))))
double code(double i, double n) {
	double tmp;
	if ((n <= -2050.0) || !(n <= 0.58)) {
		tmp = n * (100.0 * (expm1(i) / i));
	} else {
		tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
	}
	return tmp;
}
public static double code(double i, double n) {
	double tmp;
	if ((n <= -2050.0) || !(n <= 0.58)) {
		tmp = n * (100.0 * (Math.expm1(i) / i));
	} else {
		tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if (n <= -2050.0) or not (n <= 0.58):
		tmp = n * (100.0 * (math.expm1(i) / i))
	else:
		tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)))
	return tmp
function code(i, n)
	tmp = 0.0
	if ((n <= -2050.0) || !(n <= 0.58))
		tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i)));
	else
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(Float64(0.5 / n) + -0.5))));
	end
	return tmp
end
code[i_, n_] := If[Or[LessEqual[n, -2050.0], N[Not[LessEqual[n, 0.58]], $MachinePrecision]], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2050 \lor \neg \left(n \leq 0.58\right):\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -2050 or 0.57999999999999996 < n

    1. Initial program 29.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/90.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2050 < n < 0.57999999999999996

    1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp35.6%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg80.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2050 \lor \neg \left(n \leq 0.58\right):\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\ \end{array} \]

Alternative 10: 87.7% accurate, 1.0× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 \cdot t_0\right)\\


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

    1. Initial program 29.0%

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

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

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

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

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

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

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

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

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

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

    if -2050 < n < 0.57999999999999996

    1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp35.6%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg80.4%

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

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

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

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

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

    if 0.57999999999999996 < n

    1. Initial program 29.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 87.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 29.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/87.8%

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

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

    if -2050 < n < 0.57999999999999996

    1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp35.6%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg80.4%

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

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

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

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

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

    if 0.57999999999999996 < n

    1. Initial program 29.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 65.2% accurate, 6.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 200 \cdot \frac{n \cdot n}{i}\\ \mathbf{if}\;i \leq -1600000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;i \leq 5.7 \cdot 10^{-188}:\\ \;\;\;\;n \cdot 100\\ \mathbf{elif}\;i \leq 29:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{elif}\;i \leq 1.35 \cdot 10^{+260} \lor \neg \left(i \leq 8.5 \cdot 10^{+283}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* 200.0 (/ (* n n) i))))
   (if (<= i -1600000000000.0)
     t_0
     (if (<= i 5.7e-188)
       (* n 100.0)
       (if (<= i 29.0)
         (* 100.0 (/ (* i n) i))
         (if (or (<= i 1.35e+260) (not (<= i 8.5e+283)))
           t_0
           (* (* i n) 50.0)))))))
double code(double i, double n) {
	double t_0 = 200.0 * ((n * n) / i);
	double tmp;
	if (i <= -1600000000000.0) {
		tmp = t_0;
	} else if (i <= 5.7e-188) {
		tmp = n * 100.0;
	} else if (i <= 29.0) {
		tmp = 100.0 * ((i * n) / i);
	} else if ((i <= 1.35e+260) || !(i <= 8.5e+283)) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = 200.0d0 * ((n * n) / i)
    if (i <= (-1600000000000.0d0)) then
        tmp = t_0
    else if (i <= 5.7d-188) then
        tmp = n * 100.0d0
    else if (i <= 29.0d0) then
        tmp = 100.0d0 * ((i * n) / i)
    else if ((i <= 1.35d+260) .or. (.not. (i <= 8.5d+283))) then
        tmp = t_0
    else
        tmp = (i * n) * 50.0d0
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double t_0 = 200.0 * ((n * n) / i);
	double tmp;
	if (i <= -1600000000000.0) {
		tmp = t_0;
	} else if (i <= 5.7e-188) {
		tmp = n * 100.0;
	} else if (i <= 29.0) {
		tmp = 100.0 * ((i * n) / i);
	} else if ((i <= 1.35e+260) || !(i <= 8.5e+283)) {
		tmp = t_0;
	} else {
		tmp = (i * n) * 50.0;
	}
	return tmp;
}
def code(i, n):
	t_0 = 200.0 * ((n * n) / i)
	tmp = 0
	if i <= -1600000000000.0:
		tmp = t_0
	elif i <= 5.7e-188:
		tmp = n * 100.0
	elif i <= 29.0:
		tmp = 100.0 * ((i * n) / i)
	elif (i <= 1.35e+260) or not (i <= 8.5e+283):
		tmp = t_0
	else:
		tmp = (i * n) * 50.0
	return tmp
function code(i, n)
	t_0 = Float64(200.0 * Float64(Float64(n * n) / i))
	tmp = 0.0
	if (i <= -1600000000000.0)
		tmp = t_0;
	elseif (i <= 5.7e-188)
		tmp = Float64(n * 100.0);
	elseif (i <= 29.0)
		tmp = Float64(100.0 * Float64(Float64(i * n) / i));
	elseif ((i <= 1.35e+260) || !(i <= 8.5e+283))
		tmp = t_0;
	else
		tmp = Float64(Float64(i * n) * 50.0);
	end
	return tmp
end
function tmp_2 = code(i, n)
	t_0 = 200.0 * ((n * n) / i);
	tmp = 0.0;
	if (i <= -1600000000000.0)
		tmp = t_0;
	elseif (i <= 5.7e-188)
		tmp = n * 100.0;
	elseif (i <= 29.0)
		tmp = 100.0 * ((i * n) / i);
	elseif ((i <= 1.35e+260) || ~((i <= 8.5e+283)))
		tmp = t_0;
	else
		tmp = (i * n) * 50.0;
	end
	tmp_2 = tmp;
end
code[i_, n_] := Block[{t$95$0 = N[(200.0 * N[(N[(n * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -1600000000000.0], t$95$0, If[LessEqual[i, 5.7e-188], N[(n * 100.0), $MachinePrecision], If[LessEqual[i, 29.0], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[i, 1.35e+260], N[Not[LessEqual[i, 8.5e+283]], $MachinePrecision]], t$95$0, N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 200 \cdot \frac{n \cdot n}{i}\\
\mathbf{if}\;i \leq -1600000000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;i \leq 5.7 \cdot 10^{-188}:\\
\;\;\;\;n \cdot 100\\

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

\mathbf{elif}\;i \leq 1.35 \cdot 10^{+260} \lor \neg \left(i \leq 8.5 \cdot 10^{+283}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if i < -1.6e12 or 29 < i < 1.3499999999999999e260 or 8.5000000000000008e283 < i

    1. Initial program 56.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp56.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{200 \cdot \frac{{n}^{2}}{i}} \]
    8. Step-by-step derivation
      1. unpow243.2%

        \[\leadsto 200 \cdot \frac{\color{blue}{n \cdot n}}{i} \]
    9. Simplified43.2%

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

    if -1.6e12 < i < 5.70000000000000025e-188

    1. Initial program 4.4%

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

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

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

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

    if 5.70000000000000025e-188 < i < 29

    1. Initial program 18.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3499999999999999e260 < i < 8.5000000000000008e283

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \]
    7. Simplified100.0%

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

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right)} \]
    9. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto 50 \cdot \color{blue}{\left(n \cdot i\right)} \]
    10. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -1600000000000:\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{elif}\;i \leq 5.7 \cdot 10^{-188}:\\ \;\;\;\;n \cdot 100\\ \mathbf{elif}\;i \leq 29:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{elif}\;i \leq 1.35 \cdot 10^{+260} \lor \neg \left(i \leq 8.5 \cdot 10^{+283}\right):\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \]

Alternative 13: 72.3% accurate, 6.7× speedup?

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

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

\mathbf{elif}\;n \leq 0.58:\\
\;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\

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


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

    1. Initial program 15.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.9999999999999998e179 < n < 0.57999999999999996

    1. Initial program 36.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp37.3%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg72.8%

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

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

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

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

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

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

    if 0.57999999999999996 < n

    1. Initial program 29.1%

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

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

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

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

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

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

      \[\leadsto 100 \cdot \color{blue}{\frac{n \cdot \left(i + 0.5 \cdot {i}^{2}\right)}{i}} \]
    6. Step-by-step derivation
      1. associate-/l*77.6%

        \[\leadsto 100 \cdot \color{blue}{\frac{n}{\frac{i}{i + 0.5 \cdot {i}^{2}}}} \]
      2. *-commutative77.6%

        \[\leadsto 100 \cdot \frac{n}{\frac{i}{i + \color{blue}{{i}^{2} \cdot 0.5}}} \]
      3. unpow277.6%

        \[\leadsto 100 \cdot \frac{n}{\frac{i}{i + \color{blue}{\left(i \cdot i\right)} \cdot 0.5}} \]
      4. associate-*l*77.6%

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

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

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

Alternative 14: 65.6% accurate, 7.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{if}\;n \leq -1.1 \cdot 10^{+46}:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{elif}\;n \leq -3.8 \cdot 10^{-175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 3.4 \cdot 10^{-241}:\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{elif}\;n \leq 0.58:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* 100.0 (/ i (/ i n)))))
   (if (<= n -1.1e+46)
     (* 100.0 (/ (* i n) i))
     (if (<= n -3.8e-175)
       t_0
       (if (<= n 3.4e-241)
         (* 200.0 (/ (* n n) i))
         (if (<= n 0.58) t_0 (* n (+ 100.0 (* i 50.0)))))))))
double code(double i, double n) {
	double t_0 = 100.0 * (i / (i / n));
	double tmp;
	if (n <= -1.1e+46) {
		tmp = 100.0 * ((i * n) / i);
	} else if (n <= -3.8e-175) {
		tmp = t_0;
	} else if (n <= 3.4e-241) {
		tmp = 200.0 * ((n * n) / i);
	} else if (n <= 0.58) {
		tmp = t_0;
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
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 = 100.0d0 * (i / (i / n))
    if (n <= (-1.1d+46)) then
        tmp = 100.0d0 * ((i * n) / i)
    else if (n <= (-3.8d-175)) then
        tmp = t_0
    else if (n <= 3.4d-241) then
        tmp = 200.0d0 * ((n * n) / i)
    else if (n <= 0.58d0) then
        tmp = t_0
    else
        tmp = n * (100.0d0 + (i * 50.0d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double t_0 = 100.0 * (i / (i / n));
	double tmp;
	if (n <= -1.1e+46) {
		tmp = 100.0 * ((i * n) / i);
	} else if (n <= -3.8e-175) {
		tmp = t_0;
	} else if (n <= 3.4e-241) {
		tmp = 200.0 * ((n * n) / i);
	} else if (n <= 0.58) {
		tmp = t_0;
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
def code(i, n):
	t_0 = 100.0 * (i / (i / n))
	tmp = 0
	if n <= -1.1e+46:
		tmp = 100.0 * ((i * n) / i)
	elif n <= -3.8e-175:
		tmp = t_0
	elif n <= 3.4e-241:
		tmp = 200.0 * ((n * n) / i)
	elif n <= 0.58:
		tmp = t_0
	else:
		tmp = n * (100.0 + (i * 50.0))
	return tmp
function code(i, n)
	t_0 = Float64(100.0 * Float64(i / Float64(i / n)))
	tmp = 0.0
	if (n <= -1.1e+46)
		tmp = Float64(100.0 * Float64(Float64(i * n) / i));
	elseif (n <= -3.8e-175)
		tmp = t_0;
	elseif (n <= 3.4e-241)
		tmp = Float64(200.0 * Float64(Float64(n * n) / i));
	elseif (n <= 0.58)
		tmp = t_0;
	else
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	t_0 = 100.0 * (i / (i / n));
	tmp = 0.0;
	if (n <= -1.1e+46)
		tmp = 100.0 * ((i * n) / i);
	elseif (n <= -3.8e-175)
		tmp = t_0;
	elseif (n <= 3.4e-241)
		tmp = 200.0 * ((n * n) / i);
	elseif (n <= 0.58)
		tmp = t_0;
	else
		tmp = n * (100.0 + (i * 50.0));
	end
	tmp_2 = tmp;
end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.1e+46], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -3.8e-175], t$95$0, If[LessEqual[n, 3.4e-241], N[(200.0 * N[(N[(n * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.58], t$95$0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{if}\;n \leq -1.1 \cdot 10^{+46}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\

\mathbf{elif}\;n \leq -3.8 \cdot 10^{-175}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;n \leq 3.4 \cdot 10^{-241}:\\
\;\;\;\;200 \cdot \frac{n \cdot n}{i}\\

\mathbf{elif}\;n \leq 0.58:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 20.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.1e46 < n < -3.8e-175 or 3.3999999999999999e-241 < n < 0.57999999999999996

    1. Initial program 29.7%

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

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

    if -3.8e-175 < n < 3.3999999999999999e-241

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp65.8%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg92.0%

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

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

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

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

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

      \[\leadsto \color{blue}{200 \cdot \frac{{n}^{2}}{i}} \]
    8. Step-by-step derivation
      1. unpow281.7%

        \[\leadsto 200 \cdot \frac{\color{blue}{n \cdot n}}{i} \]
    9. Simplified81.7%

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

    if 0.57999999999999996 < n

    1. Initial program 29.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/92.7%

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

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

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

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

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
    9. Simplified72.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.1 \cdot 10^{+46}:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{elif}\;n \leq -3.8 \cdot 10^{-175}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 3.4 \cdot 10^{-241}:\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{elif}\;n \leq 0.58:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 15: 65.4% accurate, 7.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + i \cdot -0.5\\ \mathbf{if}\;n \leq -1.22 \cdot 10^{-175}:\\ \;\;\;\;100 \cdot \frac{n}{t_0}\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-245}:\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{elif}\;n \leq 7.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{100}{\frac{t_0}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* i -0.5))))
   (if (<= n -1.22e-175)
     (* 100.0 (/ n t_0))
     (if (<= n 2.8e-245)
       (* 200.0 (/ (* n n) i))
       (if (<= n 7.5e-61) (/ 100.0 (/ t_0 n)) (* n (+ 100.0 (* i 50.0))))))))
double code(double i, double n) {
	double t_0 = 1.0 + (i * -0.5);
	double tmp;
	if (n <= -1.22e-175) {
		tmp = 100.0 * (n / t_0);
	} else if (n <= 2.8e-245) {
		tmp = 200.0 * ((n * n) / i);
	} else if (n <= 7.5e-61) {
		tmp = 100.0 / (t_0 / n);
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
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 * (-0.5d0))
    if (n <= (-1.22d-175)) then
        tmp = 100.0d0 * (n / t_0)
    else if (n <= 2.8d-245) then
        tmp = 200.0d0 * ((n * n) / i)
    else if (n <= 7.5d-61) then
        tmp = 100.0d0 / (t_0 / n)
    else
        tmp = n * (100.0d0 + (i * 50.0d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double t_0 = 1.0 + (i * -0.5);
	double tmp;
	if (n <= -1.22e-175) {
		tmp = 100.0 * (n / t_0);
	} else if (n <= 2.8e-245) {
		tmp = 200.0 * ((n * n) / i);
	} else if (n <= 7.5e-61) {
		tmp = 100.0 / (t_0 / n);
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
def code(i, n):
	t_0 = 1.0 + (i * -0.5)
	tmp = 0
	if n <= -1.22e-175:
		tmp = 100.0 * (n / t_0)
	elif n <= 2.8e-245:
		tmp = 200.0 * ((n * n) / i)
	elif n <= 7.5e-61:
		tmp = 100.0 / (t_0 / n)
	else:
		tmp = n * (100.0 + (i * 50.0))
	return tmp
function code(i, n)
	t_0 = Float64(1.0 + Float64(i * -0.5))
	tmp = 0.0
	if (n <= -1.22e-175)
		tmp = Float64(100.0 * Float64(n / t_0));
	elseif (n <= 2.8e-245)
		tmp = Float64(200.0 * Float64(Float64(n * n) / i));
	elseif (n <= 7.5e-61)
		tmp = Float64(100.0 / Float64(t_0 / n));
	else
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	t_0 = 1.0 + (i * -0.5);
	tmp = 0.0;
	if (n <= -1.22e-175)
		tmp = 100.0 * (n / t_0);
	elseif (n <= 2.8e-245)
		tmp = 200.0 * ((n * n) / i);
	elseif (n <= 7.5e-61)
		tmp = 100.0 / (t_0 / n);
	else
		tmp = n * (100.0 + (i * 50.0));
	end
	tmp_2 = tmp;
end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.22e-175], N[(100.0 * N[(n / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.8e-245], N[(200.0 * N[(N[(n * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.5e-61], N[(100.0 / N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + i \cdot -0.5\\
\mathbf{if}\;n \leq -1.22 \cdot 10^{-175}:\\
\;\;\;\;100 \cdot \frac{n}{t_0}\\

\mathbf{elif}\;n \leq 2.8 \cdot 10^{-245}:\\
\;\;\;\;200 \cdot \frac{n \cdot n}{i}\\

\mathbf{elif}\;n \leq 7.5 \cdot 10^{-61}:\\
\;\;\;\;\frac{100}{\frac{t_0}{n}}\\

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


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

    1. Initial program 28.6%

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

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

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

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

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

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

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

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

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

    if -1.2200000000000001e-175 < n < 2.8000000000000001e-245

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp65.8%

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

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

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

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

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg92.0%

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

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

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

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

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

      \[\leadsto \color{blue}{200 \cdot \frac{{n}^{2}}{i}} \]
    8. Step-by-step derivation
      1. unpow281.7%

        \[\leadsto 200 \cdot \frac{\color{blue}{n \cdot n}}{i} \]
    9. Simplified81.7%

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

    if 2.8000000000000001e-245 < n < 7.50000000000000047e-61

    1. Initial program 19.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. *-commutative47.2%

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

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

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

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

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

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

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

    if 7.50000000000000047e-61 < n

    1. Initial program 27.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/87.6%

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

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

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

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

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
    9. Simplified70.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.22 \cdot 10^{-175}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-245}:\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{elif}\;n \leq 7.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{100}{\frac{1 + i \cdot -0.5}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 16: 65.5% accurate, 7.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + i \cdot -0.5\\ \mathbf{if}\;n \leq -6 \cdot 10^{-170}:\\ \;\;\;\;100 \cdot \frac{n}{t_0}\\ \mathbf{elif}\;n \leq 6.5 \cdot 10^{-245}:\\ \;\;\;\;100 \cdot \frac{\frac{n}{i}}{\frac{0.5}{n} + -0.5}\\ \mathbf{elif}\;n \leq 7.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{100}{\frac{t_0}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* i -0.5))))
   (if (<= n -6e-170)
     (* 100.0 (/ n t_0))
     (if (<= n 6.5e-245)
       (* 100.0 (/ (/ n i) (+ (/ 0.5 n) -0.5)))
       (if (<= n 7.5e-61) (/ 100.0 (/ t_0 n)) (* n (+ 100.0 (* i 50.0))))))))
double code(double i, double n) {
	double t_0 = 1.0 + (i * -0.5);
	double tmp;
	if (n <= -6e-170) {
		tmp = 100.0 * (n / t_0);
	} else if (n <= 6.5e-245) {
		tmp = 100.0 * ((n / i) / ((0.5 / n) + -0.5));
	} else if (n <= 7.5e-61) {
		tmp = 100.0 / (t_0 / n);
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
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 * (-0.5d0))
    if (n <= (-6d-170)) then
        tmp = 100.0d0 * (n / t_0)
    else if (n <= 6.5d-245) then
        tmp = 100.0d0 * ((n / i) / ((0.5d0 / n) + (-0.5d0)))
    else if (n <= 7.5d-61) then
        tmp = 100.0d0 / (t_0 / n)
    else
        tmp = n * (100.0d0 + (i * 50.0d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double t_0 = 1.0 + (i * -0.5);
	double tmp;
	if (n <= -6e-170) {
		tmp = 100.0 * (n / t_0);
	} else if (n <= 6.5e-245) {
		tmp = 100.0 * ((n / i) / ((0.5 / n) + -0.5));
	} else if (n <= 7.5e-61) {
		tmp = 100.0 / (t_0 / n);
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
def code(i, n):
	t_0 = 1.0 + (i * -0.5)
	tmp = 0
	if n <= -6e-170:
		tmp = 100.0 * (n / t_0)
	elif n <= 6.5e-245:
		tmp = 100.0 * ((n / i) / ((0.5 / n) + -0.5))
	elif n <= 7.5e-61:
		tmp = 100.0 / (t_0 / n)
	else:
		tmp = n * (100.0 + (i * 50.0))
	return tmp
function code(i, n)
	t_0 = Float64(1.0 + Float64(i * -0.5))
	tmp = 0.0
	if (n <= -6e-170)
		tmp = Float64(100.0 * Float64(n / t_0));
	elseif (n <= 6.5e-245)
		tmp = Float64(100.0 * Float64(Float64(n / i) / Float64(Float64(0.5 / n) + -0.5)));
	elseif (n <= 7.5e-61)
		tmp = Float64(100.0 / Float64(t_0 / n));
	else
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	t_0 = 1.0 + (i * -0.5);
	tmp = 0.0;
	if (n <= -6e-170)
		tmp = 100.0 * (n / t_0);
	elseif (n <= 6.5e-245)
		tmp = 100.0 * ((n / i) / ((0.5 / n) + -0.5));
	elseif (n <= 7.5e-61)
		tmp = 100.0 / (t_0 / n);
	else
		tmp = n * (100.0 + (i * 50.0));
	end
	tmp_2 = tmp;
end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -6e-170], N[(100.0 * N[(n / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6.5e-245], N[(100.0 * N[(N[(n / i), $MachinePrecision] / N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.5e-61], N[(100.0 / N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + i \cdot -0.5\\
\mathbf{if}\;n \leq -6 \cdot 10^{-170}:\\
\;\;\;\;100 \cdot \frac{n}{t_0}\\

\mathbf{elif}\;n \leq 6.5 \cdot 10^{-245}:\\
\;\;\;\;100 \cdot \frac{\frac{n}{i}}{\frac{0.5}{n} + -0.5}\\

\mathbf{elif}\;n \leq 7.5 \cdot 10^{-61}:\\
\;\;\;\;\frac{100}{\frac{t_0}{n}}\\

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


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

    1. Initial program 28.6%

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

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

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

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

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

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

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

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

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

    if -6.00000000000000027e-170 < n < 6.5000000000000004e-245

    1. Initial program 65.5%

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

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

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

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval65.8%

        \[\leadsto \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}}{i} \cdot n\right) \cdot 100 \]
      5. associate-*r*65.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. *-commutative65.8%

        \[\leadsto \color{blue}{\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}} \]
      7. clear-num65.8%

        \[\leadsto \left(n \cdot 100\right) \cdot \color{blue}{\frac{1}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      8. un-div-inv65.8%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      9. metadata-eval65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}}} \]
      10. sub-neg65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}} \]
      12. expm1-def78.4%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}} \]
      13. add-log-exp65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\log \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}\right)}} \]
      15. log-pow78.4%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}} \]
      16. log1p-udef84.0%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right)}} \]
    3. Applied egg-rr84.0%

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}} \]
    4. Taylor expanded in i around 0 92.0%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \color{blue}{\left(0.5 \cdot \frac{1}{n} + \left(-0.5\right)\right)}} \]
      2. associate-*r/92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\color{blue}{\frac{0.5 \cdot 1}{n}} + \left(-0.5\right)\right)} \]
      3. metadata-eval92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{\color{blue}{0.5}}{n} + \left(-0.5\right)\right)} \]
      4. metadata-eval92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + \color{blue}{-0.5}\right)} \]
    6. Simplified92.0%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}} \]
    7. Taylor expanded in i around inf 82.4%

      \[\leadsto \color{blue}{100 \cdot \frac{n}{i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    8. Step-by-step derivation
      1. associate-/r*82.4%

        \[\leadsto 100 \cdot \color{blue}{\frac{\frac{n}{i}}{0.5 \cdot \frac{1}{n} - 0.5}} \]
      2. sub-neg82.4%

        \[\leadsto 100 \cdot \frac{\frac{n}{i}}{\color{blue}{0.5 \cdot \frac{1}{n} + \left(-0.5\right)}} \]
      3. metadata-eval82.4%

        \[\leadsto 100 \cdot \frac{\frac{n}{i}}{0.5 \cdot \frac{1}{n} + \color{blue}{-0.5}} \]
      4. associate-*r/82.4%

        \[\leadsto 100 \cdot \frac{\frac{n}{i}}{\color{blue}{\frac{0.5 \cdot 1}{n}} + -0.5} \]
      5. metadata-eval82.4%

        \[\leadsto 100 \cdot \frac{\frac{n}{i}}{\frac{\color{blue}{0.5}}{n} + -0.5} \]
      6. +-commutative82.4%

        \[\leadsto 100 \cdot \frac{\frac{n}{i}}{\color{blue}{-0.5 + \frac{0.5}{n}}} \]
    9. Simplified82.4%

      \[\leadsto \color{blue}{100 \cdot \frac{\frac{n}{i}}{-0.5 + \frac{0.5}{n}}} \]

    if 6.5000000000000004e-245 < n < 7.50000000000000047e-61

    1. Initial program 19.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in n around inf 4.4%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative4.4%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*4.4%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def47.2%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified47.2%

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. *-commutative47.2%

        \[\leadsto \color{blue}{100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
      2. clear-num47.2%

        \[\leadsto 100 \cdot \color{blue}{\frac{1}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n}}} \]
      3. un-div-inv47.2%

        \[\leadsto \color{blue}{\frac{100}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n}}} \]
    6. Applied egg-rr47.2%

      \[\leadsto \color{blue}{\frac{100}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n}}} \]
    7. Taylor expanded in i around 0 63.3%

      \[\leadsto \frac{100}{\frac{\color{blue}{1 + -0.5 \cdot i}}{n}} \]
    8. Step-by-step derivation
      1. *-commutative59.1%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    9. Simplified63.3%

      \[\leadsto \frac{100}{\frac{\color{blue}{1 + i \cdot -0.5}}{n}} \]

    if 7.50000000000000047e-61 < n

    1. Initial program 27.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in n around inf 38.8%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative38.8%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*38.8%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def87.6%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified87.6%

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/87.6%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    6. Applied egg-rr87.6%

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    7. Taylor expanded in i around 0 70.2%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]
    8. Step-by-step derivation
      1. associate-*r*70.2%

        \[\leadsto \color{blue}{\left(50 \cdot i\right) \cdot n} + 100 \cdot n \]
      2. distribute-rgt-out70.2%

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
    9. Simplified70.2%

      \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification67.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -6 \cdot 10^{-170}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 6.5 \cdot 10^{-245}:\\ \;\;\;\;100 \cdot \frac{\frac{n}{i}}{\frac{0.5}{n} + -0.5}\\ \mathbf{elif}\;n \leq 7.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{100}{\frac{1 + i \cdot -0.5}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 17: 71.3% accurate, 7.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1.55 \cdot 10^{+182}:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{elif}\;n \leq 0.58:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -1.55e+182)
   (* 100.0 (/ (* i n) i))
   (if (<= n 0.58)
     (/ (* n 100.0) (+ 1.0 (* (/ i n) 0.5)))
     (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
	double tmp;
	if (n <= -1.55e+182) {
		tmp = 100.0 * ((i * n) / i);
	} else if (n <= 0.58) {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-1.55d+182)) then
        tmp = 100.0d0 * ((i * n) / i)
    else if (n <= 0.58d0) then
        tmp = (n * 100.0d0) / (1.0d0 + ((i / n) * 0.5d0))
    else
        tmp = n * (100.0d0 + (i * 50.0d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= -1.55e+182) {
		tmp = 100.0 * ((i * n) / i);
	} else if (n <= 0.58) {
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -1.55e+182:
		tmp = 100.0 * ((i * n) / i)
	elif n <= 0.58:
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5))
	else:
		tmp = n * (100.0 + (i * 50.0))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -1.55e+182)
		tmp = Float64(100.0 * Float64(Float64(i * n) / i));
	elseif (n <= 0.58)
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(Float64(i / n) * 0.5)));
	else
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= -1.55e+182)
		tmp = 100.0 * ((i * n) / i);
	elseif (n <= 0.58)
		tmp = (n * 100.0) / (1.0 + ((i / n) * 0.5));
	else
		tmp = n * (100.0 + (i * 50.0));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -1.55e+182], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.58], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(N[(i / n), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.55 \cdot 10^{+182}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\

\mathbf{elif}\;n \leq 0.58:\\
\;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\

\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -1.54999999999999998e182

    1. Initial program 15.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. div-sub15.4%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)} \]
      2. clear-num15.6%

        \[\leadsto 100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \color{blue}{\frac{n}{i}}\right) \]
      3. sub-neg15.6%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} + \left(-\frac{n}{i}\right)\right)} \]
      4. div-inv15.6%

        \[\leadsto 100 \cdot \left(\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{1}{\frac{i}{n}}} + \left(-\frac{n}{i}\right)\right) \]
      5. clear-num15.4%

        \[\leadsto 100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \color{blue}{\frac{n}{i}} + \left(-\frac{n}{i}\right)\right) \]
    3. Applied egg-rr15.4%

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} + \left(-\frac{n}{i}\right)\right)} \]
    4. Step-by-step derivation
      1. sub-neg15.4%

        \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)} \]
    5. Simplified15.4%

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/15.4%

        \[\leadsto 100 \cdot \left(\color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot n}{i}} - \frac{n}{i}\right) \]
      2. sub-div16.2%

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot n - n}{i}} \]
    7. Applied egg-rr16.2%

      \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot n - n}{i}} \]
    8. Taylor expanded in i around 0 72.0%

      \[\leadsto 100 \cdot \frac{\color{blue}{i \cdot n}}{i} \]

    if -1.54999999999999998e182 < n < 0.57999999999999996

    1. Initial program 36.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative36.9%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \cdot 100} \]
      2. associate-/r/37.2%

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg37.2%

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval37.2%

        \[\leadsto \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}}{i} \cdot n\right) \cdot 100 \]
      5. associate-*r*37.2%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. *-commutative37.2%

        \[\leadsto \color{blue}{\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}} \]
      7. clear-num37.2%

        \[\leadsto \left(n \cdot 100\right) \cdot \color{blue}{\frac{1}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      8. un-div-inv37.3%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      9. metadata-eval37.3%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}}} \]
      10. sub-neg37.3%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp30.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}} \]
      12. expm1-def46.2%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}} \]
      13. add-log-exp30.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp37.3%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\log \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}\right)}} \]
      15. log-pow46.2%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}} \]
      16. log1p-udef78.3%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right)}} \]
    3. Applied egg-rr78.3%

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}} \]
    4. Taylor expanded in i around 0 72.8%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg72.8%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \color{blue}{\left(0.5 \cdot \frac{1}{n} + \left(-0.5\right)\right)}} \]
      2. associate-*r/72.8%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\color{blue}{\frac{0.5 \cdot 1}{n}} + \left(-0.5\right)\right)} \]
      3. metadata-eval72.8%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{\color{blue}{0.5}}{n} + \left(-0.5\right)\right)} \]
      4. metadata-eval72.8%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + \color{blue}{-0.5}\right)} \]
    6. Simplified72.8%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}} \]
    7. Taylor expanded in n around 0 71.3%

      \[\leadsto \frac{n \cdot 100}{1 + \color{blue}{0.5 \cdot \frac{i}{n}}} \]

    if 0.57999999999999996 < n

    1. Initial program 29.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in n around inf 45.0%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative45.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*44.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def92.6%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified92.6%

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/92.7%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    6. Applied egg-rr92.7%

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    7. Taylor expanded in i around 0 72.1%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]
    8. Step-by-step derivation
      1. associate-*r*72.1%

        \[\leadsto \color{blue}{\left(50 \cdot i\right) \cdot n} + 100 \cdot n \]
      2. distribute-rgt-out72.1%

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
    9. Simplified72.1%

      \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.55 \cdot 10^{+182}:\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{elif}\;n \leq 0.58:\\ \;\;\;\;\frac{n \cdot 100}{1 + \frac{i}{n} \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 18: 72.0% accurate, 7.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 0.58:\\ \;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{i + i \cdot \left(i \cdot 0.5\right)}}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n 0.58)
   (/ (* n 100.0) (+ 1.0 (* i (+ (/ 0.5 n) -0.5))))
   (* 100.0 (/ n (/ i (+ i (* i (* i 0.5))))))))
double code(double i, double n) {
	double tmp;
	if (n <= 0.58) {
		tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
	} else {
		tmp = 100.0 * (n / (i / (i + (i * (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 (n <= 0.58d0) then
        tmp = (n * 100.0d0) / (1.0d0 + (i * ((0.5d0 / n) + (-0.5d0))))
    else
        tmp = 100.0d0 * (n / (i / (i + (i * (i * 0.5d0)))))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= 0.58) {
		tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
	} else {
		tmp = 100.0 * (n / (i / (i + (i * (i * 0.5)))));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= 0.58:
		tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)))
	else:
		tmp = 100.0 * (n / (i / (i + (i * (i * 0.5)))))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= 0.58)
		tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(Float64(0.5 / n) + -0.5))));
	else
		tmp = Float64(100.0 * Float64(n / Float64(i / Float64(i + Float64(i * Float64(i * 0.5))))));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= 0.58)
		tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
	else
		tmp = 100.0 * (n / (i / (i + (i * (i * 0.5)))));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, 0.58], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(i / N[(i + N[(i * N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.58:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{i + i \cdot \left(i \cdot 0.5\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 0.57999999999999996

    1. Initial program 32.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative32.7%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \cdot 100} \]
      2. associate-/r/33.1%

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg33.1%

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval33.1%

        \[\leadsto \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}}{i} \cdot n\right) \cdot 100 \]
      5. associate-*r*33.1%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. *-commutative33.1%

        \[\leadsto \color{blue}{\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}} \]
      7. clear-num33.1%

        \[\leadsto \left(n \cdot 100\right) \cdot \color{blue}{\frac{1}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      8. un-div-inv33.2%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      9. metadata-eval33.2%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}}} \]
      10. sub-neg33.2%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp28.0%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}} \]
      12. expm1-def40.3%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}} \]
      13. add-log-exp28.0%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp33.2%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\log \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}\right)}} \]
      15. log-pow40.3%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}} \]
      16. log1p-udef73.5%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right)}} \]
    3. Applied egg-rr73.5%

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}} \]
    4. Taylor expanded in i around 0 70.5%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg70.5%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \color{blue}{\left(0.5 \cdot \frac{1}{n} + \left(-0.5\right)\right)}} \]
      2. associate-*r/70.5%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\color{blue}{\frac{0.5 \cdot 1}{n}} + \left(-0.5\right)\right)} \]
      3. metadata-eval70.5%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{\color{blue}{0.5}}{n} + \left(-0.5\right)\right)} \]
      4. metadata-eval70.5%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + \color{blue}{-0.5}\right)} \]
    6. Simplified70.5%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}} \]

    if 0.57999999999999996 < n

    1. Initial program 29.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 56.4%

      \[\leadsto 100 \cdot \frac{\color{blue}{i + {i}^{2} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}}{\frac{i}{n}} \]
    3. Step-by-step derivation
      1. unpow256.4%

        \[\leadsto 100 \cdot \frac{i + \color{blue}{\left(i \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}{\frac{i}{n}} \]
      2. associate-*r/56.4%

        \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)}{\frac{i}{n}} \]
      3. metadata-eval56.4%

        \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)}{\frac{i}{n}} \]
    4. Simplified56.4%

      \[\leadsto 100 \cdot \frac{\color{blue}{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)}}{\frac{i}{n}} \]
    5. Taylor expanded in n around inf 85.6%

      \[\leadsto 100 \cdot \color{blue}{\frac{n \cdot \left(i + 0.5 \cdot {i}^{2}\right)}{i}} \]
    6. Step-by-step derivation
      1. associate-/l*77.6%

        \[\leadsto 100 \cdot \color{blue}{\frac{n}{\frac{i}{i + 0.5 \cdot {i}^{2}}}} \]
      2. *-commutative77.6%

        \[\leadsto 100 \cdot \frac{n}{\frac{i}{i + \color{blue}{{i}^{2} \cdot 0.5}}} \]
      3. unpow277.6%

        \[\leadsto 100 \cdot \frac{n}{\frac{i}{i + \color{blue}{\left(i \cdot i\right)} \cdot 0.5}} \]
      4. associate-*l*77.6%

        \[\leadsto 100 \cdot \frac{n}{\frac{i}{i + \color{blue}{i \cdot \left(i \cdot 0.5\right)}}} \]
    7. Simplified77.6%

      \[\leadsto 100 \cdot \color{blue}{\frac{n}{\frac{i}{i + i \cdot \left(i \cdot 0.5\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 0.58:\\ \;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{i + i \cdot \left(i \cdot 0.5\right)}}\\ \end{array} \]

Alternative 19: 65.4% accurate, 8.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1.45 \cdot 10^{-175}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 4.8 \cdot 10^{-248}:\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{elif}\;n \leq 0.48:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -1.45e-175)
   (* 100.0 (/ n (+ 1.0 (* i -0.5))))
   (if (<= n 4.8e-248)
     (* 200.0 (/ (* n n) i))
     (if (<= n 0.48) (* 100.0 (/ i (/ i n))) (* n (+ 100.0 (* i 50.0)))))))
double code(double i, double n) {
	double tmp;
	if (n <= -1.45e-175) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else if (n <= 4.8e-248) {
		tmp = 200.0 * ((n * n) / i);
	} else if (n <= 0.48) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-1.45d-175)) then
        tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
    else if (n <= 4.8d-248) then
        tmp = 200.0d0 * ((n * n) / i)
    else if (n <= 0.48d0) then
        tmp = 100.0d0 * (i / (i / n))
    else
        tmp = n * (100.0d0 + (i * 50.0d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= -1.45e-175) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else if (n <= 4.8e-248) {
		tmp = 200.0 * ((n * n) / i);
	} else if (n <= 0.48) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = n * (100.0 + (i * 50.0));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -1.45e-175:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	elif n <= 4.8e-248:
		tmp = 200.0 * ((n * n) / i)
	elif n <= 0.48:
		tmp = 100.0 * (i / (i / n))
	else:
		tmp = n * (100.0 + (i * 50.0))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -1.45e-175)
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	elseif (n <= 4.8e-248)
		tmp = Float64(200.0 * Float64(Float64(n * n) / i));
	elseif (n <= 0.48)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	else
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= -1.45e-175)
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	elseif (n <= 4.8e-248)
		tmp = 200.0 * ((n * n) / i);
	elseif (n <= 0.48)
		tmp = 100.0 * (i / (i / n));
	else
		tmp = n * (100.0 + (i * 50.0));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -1.45e-175], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.8e-248], N[(200.0 * N[(N[(n * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.48], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.45 \cdot 10^{-175}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

\mathbf{elif}\;n \leq 4.8 \cdot 10^{-248}:\\
\;\;\;\;200 \cdot \frac{n \cdot n}{i}\\

\mathbf{elif}\;n \leq 0.48:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -1.44999999999999999e-175

    1. Initial program 28.6%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in n around inf 34.8%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative34.8%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*34.8%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def83.1%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified83.1%

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Taylor expanded in i around 0 61.1%

      \[\leadsto \frac{n}{\color{blue}{1 + -0.5 \cdot i}} \cdot 100 \]
    6. Step-by-step derivation
      1. *-commutative61.1%

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    7. Simplified61.1%

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]

    if -1.44999999999999999e-175 < n < 4.80000000000000006e-248

    1. Initial program 65.5%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. *-commutative65.5%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \cdot 100} \]
      2. associate-/r/65.8%

        \[\leadsto \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \cdot 100 \]
      3. sub-neg65.8%

        \[\leadsto \left(\frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)}}{i} \cdot n\right) \cdot 100 \]
      4. metadata-eval65.8%

        \[\leadsto \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-1}}{i} \cdot n\right) \cdot 100 \]
      5. associate-*r*65.8%

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i} \cdot \left(n \cdot 100\right)} \]
      6. *-commutative65.8%

        \[\leadsto \color{blue}{\left(n \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{i}} \]
      7. clear-num65.8%

        \[\leadsto \left(n \cdot 100\right) \cdot \color{blue}{\frac{1}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      8. un-div-inv65.8%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + -1}}} \]
      9. metadata-eval65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{{\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-1\right)}}} \]
      10. sub-neg65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}} \]
      11. pow-to-exp65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}} \]
      12. expm1-def78.4%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}} \]
      13. add-log-exp65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}} \]
      14. pow-to-exp65.8%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\log \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}\right)}} \]
      15. log-pow78.4%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}} \]
      16. log1p-udef84.0%

        \[\leadsto \frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)}\right)}} \]
    3. Applied egg-rr84.0%

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}} \]
    4. Taylor expanded in i around 0 92.0%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(0.5 \cdot \frac{1}{n} - 0.5\right)}} \]
    5. Step-by-step derivation
      1. sub-neg92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \color{blue}{\left(0.5 \cdot \frac{1}{n} + \left(-0.5\right)\right)}} \]
      2. associate-*r/92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\color{blue}{\frac{0.5 \cdot 1}{n}} + \left(-0.5\right)\right)} \]
      3. metadata-eval92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{\color{blue}{0.5}}{n} + \left(-0.5\right)\right)} \]
      4. metadata-eval92.0%

        \[\leadsto \frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + \color{blue}{-0.5}\right)} \]
    6. Simplified92.0%

      \[\leadsto \frac{n \cdot 100}{\color{blue}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}} \]
    7. Taylor expanded in n around 0 81.7%

      \[\leadsto \color{blue}{200 \cdot \frac{{n}^{2}}{i}} \]
    8. Step-by-step derivation
      1. unpow281.7%

        \[\leadsto 200 \cdot \frac{\color{blue}{n \cdot n}}{i} \]
    9. Simplified81.7%

      \[\leadsto \color{blue}{200 \cdot \frac{n \cdot n}{i}} \]

    if 4.80000000000000006e-248 < n < 0.47999999999999998

    1. Initial program 17.8%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 61.6%

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]

    if 0.47999999999999998 < n

    1. Initial program 29.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in n around inf 45.0%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    3. Step-by-step derivation
      1. *-commutative45.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*44.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{e^{i} - 1}}} \cdot 100 \]
      3. expm1-def92.6%

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\mathsf{expm1}\left(i\right)}}} \cdot 100 \]
    4. Simplified92.6%

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}} \cdot 100} \]
    5. Step-by-step derivation
      1. associate-*l/92.7%

        \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    6. Applied egg-rr92.7%

      \[\leadsto \color{blue}{\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    7. Taylor expanded in i around 0 72.1%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]
    8. Step-by-step derivation
      1. associate-*r*72.1%

        \[\leadsto \color{blue}{\left(50 \cdot i\right) \cdot n} + 100 \cdot n \]
      2. distribute-rgt-out72.1%

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
    9. Simplified72.1%

      \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification67.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.45 \cdot 10^{-175}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 4.8 \cdot 10^{-248}:\\ \;\;\;\;200 \cdot \frac{n \cdot n}{i}\\ \mathbf{elif}\;n \leq 0.48:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 20: 62.7% accurate, 10.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1.36 \cdot 10^{+45} \lor \neg \left(n \leq 3 \cdot 10^{+16}\right):\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (or (<= n -1.36e+45) (not (<= n 3e+16)))
   (* 100.0 (/ (* i n) i))
   (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
	double tmp;
	if ((n <= -1.36e+45) || !(n <= 3e+16)) {
		tmp = 100.0 * ((i * n) / i);
	} 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.36d+45)) .or. (.not. (n <= 3d+16))) then
        tmp = 100.0d0 * ((i * n) / i)
    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.36e+45) || !(n <= 3e+16)) {
		tmp = 100.0 * ((i * n) / i);
	} else {
		tmp = 100.0 * (i / (i / n));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if (n <= -1.36e+45) or not (n <= 3e+16):
		tmp = 100.0 * ((i * n) / i)
	else:
		tmp = 100.0 * (i / (i / n))
	return tmp
function code(i, n)
	tmp = 0.0
	if ((n <= -1.36e+45) || !(n <= 3e+16))
		tmp = Float64(100.0 * Float64(Float64(i * n) / i));
	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.36e+45) || ~((n <= 3e+16)))
		tmp = 100.0 * ((i * n) / i);
	else
		tmp = 100.0 * (i / (i / n));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[Or[LessEqual[n, -1.36e+45], N[Not[LessEqual[n, 3e+16]], $MachinePrecision]], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.36 \cdot 10^{+45} \lor \neg \left(n \leq 3 \cdot 10^{+16}\right):\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.36e45 or 3e16 < n

    1. Initial program 24.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. div-sub24.6%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)} \]
      2. clear-num24.9%

        \[\leadsto 100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \color{blue}{\frac{n}{i}}\right) \]
      3. sub-neg24.9%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} + \left(-\frac{n}{i}\right)\right)} \]
      4. div-inv24.9%

        \[\leadsto 100 \cdot \left(\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{1}{\frac{i}{n}}} + \left(-\frac{n}{i}\right)\right) \]
      5. clear-num24.6%

        \[\leadsto 100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \color{blue}{\frac{n}{i}} + \left(-\frac{n}{i}\right)\right) \]
    3. Applied egg-rr24.6%

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} + \left(-\frac{n}{i}\right)\right)} \]
    4. Step-by-step derivation
      1. sub-neg24.6%

        \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)} \]
    5. Simplified24.6%

      \[\leadsto 100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/24.6%

        \[\leadsto 100 \cdot \left(\color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot n}{i}} - \frac{n}{i}\right) \]
      2. sub-div25.3%

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot n - n}{i}} \]
    7. Applied egg-rr25.3%

      \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot n - n}{i}} \]
    8. Taylor expanded in i around 0 67.9%

      \[\leadsto 100 \cdot \frac{\color{blue}{i \cdot n}}{i} \]

    if -1.36e45 < n < 3e16

    1. Initial program 40.3%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 59.2%

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.36 \cdot 10^{+45} \lor \neg \left(n \leq 3 \cdot 10^{+16}\right):\\ \;\;\;\;100 \cdot \frac{i \cdot n}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \]

Alternative 21: 58.8% accurate, 12.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -2.8 \cdot 10^{+76}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 8.2 \cdot 10^{+92}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -2.8e+76)
   (* 100.0 (/ i (/ i n)))
   (if (<= i 8.2e+92) (* n 100.0) (* (* i n) 50.0))))
double code(double i, double n) {
	double tmp;
	if (i <= -2.8e+76) {
		tmp = 100.0 * (i / (i / n));
	} else if (i <= 8.2e+92) {
		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.8d+76)) then
        tmp = 100.0d0 * (i / (i / n))
    else if (i <= 8.2d+92) 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.8e+76) {
		tmp = 100.0 * (i / (i / n));
	} else if (i <= 8.2e+92) {
		tmp = n * 100.0;
	} else {
		tmp = (i * n) * 50.0;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= -2.8e+76:
		tmp = 100.0 * (i / (i / n))
	elif i <= 8.2e+92:
		tmp = n * 100.0
	else:
		tmp = (i * n) * 50.0
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= -2.8e+76)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	elseif (i <= 8.2e+92)
		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.8e+76)
		tmp = 100.0 * (i / (i / n));
	elseif (i <= 8.2e+92)
		tmp = n * 100.0;
	else
		tmp = (i * n) * 50.0;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, -2.8e+76], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 8.2e+92], N[(n * 100.0), $MachinePrecision], N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq -2.8 \cdot 10^{+76}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{elif}\;i \leq 8.2 \cdot 10^{+92}:\\
\;\;\;\;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 < -2.7999999999999999e76

    1. Initial program 74.0%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 41.3%

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]

    if -2.7999999999999999e76 < i < 8.20000000000000047e92

    1. Initial program 11.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 70.7%

      \[\leadsto \color{blue}{100 \cdot n} \]
    3. Step-by-step derivation
      1. *-commutative70.7%

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified70.7%

      \[\leadsto \color{blue}{n \cdot 100} \]

    if 8.20000000000000047e92 < i

    1. Initial program 61.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 50.9%

      \[\leadsto 100 \cdot \frac{\color{blue}{i + {i}^{2} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}}{\frac{i}{n}} \]
    3. Step-by-step derivation
      1. unpow250.9%

        \[\leadsto 100 \cdot \frac{i + \color{blue}{\left(i \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}{\frac{i}{n}} \]
      2. associate-*r/50.9%

        \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)}{\frac{i}{n}} \]
      3. metadata-eval50.9%

        \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)}{\frac{i}{n}} \]
    4. Simplified50.9%

      \[\leadsto 100 \cdot \frac{\color{blue}{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)}}{\frac{i}{n}} \]
    5. Taylor expanded in i around inf 43.8%

      \[\leadsto \color{blue}{100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*43.8%

        \[\leadsto \color{blue}{\left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)} \]
      2. associate-*r/43.8%

        \[\leadsto \left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \]
      3. metadata-eval43.8%

        \[\leadsto \left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \]
    7. Simplified43.8%

      \[\leadsto \color{blue}{\left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \]
    8. Taylor expanded in n around inf 44.1%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right)} \]
    9. Step-by-step derivation
      1. *-commutative44.1%

        \[\leadsto 50 \cdot \color{blue}{\left(n \cdot i\right)} \]
    10. Simplified44.1%

      \[\leadsto \color{blue}{50 \cdot \left(n \cdot i\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification60.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2.8 \cdot 10^{+76}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 8.2 \cdot 10^{+92}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \]

Alternative 22: 55.2% accurate, 16.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 8.2 \cdot 10^{+92}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i 8.2e+92) (* n 100.0) (* (* i n) 50.0)))
double code(double i, double n) {
	double tmp;
	if (i <= 8.2e+92) {
		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 <= 8.2d+92) 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 <= 8.2e+92) {
		tmp = n * 100.0;
	} else {
		tmp = (i * n) * 50.0;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= 8.2e+92:
		tmp = n * 100.0
	else:
		tmp = (i * n) * 50.0
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= 8.2e+92)
		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 <= 8.2e+92)
		tmp = n * 100.0;
	else
		tmp = (i * n) * 50.0;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, 8.2e+92], N[(n * 100.0), $MachinePrecision], N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 8.2 \cdot 10^{+92}:\\
\;\;\;\;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 < 8.20000000000000047e92

    1. Initial program 24.3%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 57.5%

      \[\leadsto \color{blue}{100 \cdot n} \]
    3. Step-by-step derivation
      1. *-commutative57.5%

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified57.5%

      \[\leadsto \color{blue}{n \cdot 100} \]

    if 8.20000000000000047e92 < i

    1. Initial program 61.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 50.9%

      \[\leadsto 100 \cdot \frac{\color{blue}{i + {i}^{2} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}}{\frac{i}{n}} \]
    3. Step-by-step derivation
      1. unpow250.9%

        \[\leadsto 100 \cdot \frac{i + \color{blue}{\left(i \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}{\frac{i}{n}} \]
      2. associate-*r/50.9%

        \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)}{\frac{i}{n}} \]
      3. metadata-eval50.9%

        \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)}{\frac{i}{n}} \]
    4. Simplified50.9%

      \[\leadsto 100 \cdot \frac{\color{blue}{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)}}{\frac{i}{n}} \]
    5. Taylor expanded in i around inf 43.8%

      \[\leadsto \color{blue}{100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*43.8%

        \[\leadsto \color{blue}{\left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)} \]
      2. associate-*r/43.8%

        \[\leadsto \left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \]
      3. metadata-eval43.8%

        \[\leadsto \left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \]
    7. Simplified43.8%

      \[\leadsto \color{blue}{\left(100 \cdot i\right) \cdot \left(n \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \]
    8. Taylor expanded in n around inf 44.1%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right)} \]
    9. Step-by-step derivation
      1. *-commutative44.1%

        \[\leadsto 50 \cdot \color{blue}{\left(n \cdot i\right)} \]
    10. Simplified44.1%

      \[\leadsto \color{blue}{50 \cdot \left(n \cdot i\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 8.2 \cdot 10^{+92}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;\left(i \cdot n\right) \cdot 50\\ \end{array} \]

Alternative 23: 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.6%

    \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
  2. Taylor expanded in i around 0 38.8%

    \[\leadsto 100 \cdot \frac{\color{blue}{i + {i}^{2} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}}{\frac{i}{n}} \]
  3. Step-by-step derivation
    1. unpow238.8%

      \[\leadsto 100 \cdot \frac{i + \color{blue}{\left(i \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}{\frac{i}{n}} \]
    2. associate-*r/38.8%

      \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)}{\frac{i}{n}} \]
    3. metadata-eval38.8%

      \[\leadsto 100 \cdot \frac{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)}{\frac{i}{n}} \]
  4. Simplified38.8%

    \[\leadsto 100 \cdot \frac{\color{blue}{i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)}}{\frac{i}{n}} \]
  5. Taylor expanded in n around 0 2.6%

    \[\leadsto \color{blue}{-50 \cdot i} \]
  6. Step-by-step derivation
    1. *-commutative2.6%

      \[\leadsto \color{blue}{i \cdot -50} \]
  7. Simplified2.6%

    \[\leadsto \color{blue}{i \cdot -50} \]
  8. Final simplification2.6%

    \[\leadsto i \cdot -50 \]

Alternative 24: 50.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.6%

    \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
  2. Taylor expanded in i around 0 47.3%

    \[\leadsto \color{blue}{100 \cdot n} \]
  3. Step-by-step derivation
    1. *-commutative47.3%

      \[\leadsto \color{blue}{n \cdot 100} \]
  4. Simplified47.3%

    \[\leadsto \color{blue}{n \cdot 100} \]
  5. Final simplification47.3%

    \[\leadsto n \cdot 100 \]

Developer target: 33.7% 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 2023271 
(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))))