Compound Interest

Percentage Accurate: 28.2% → 99.4%
Time: 28.3s
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: 28.2% 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: 99.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 -4 \cdot 10^{-167}:\\ \;\;\;\;n \cdot \frac{\mathsf{fma}\left(100, t_0, -100\right)}{i}\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\frac{t_1}{i} \cdot \left(n \cdot 100\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + \mathsf{fma}\left(-0.5, i, \left(i \cdot i\right) \cdot 0.08333333333333333\right)}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (+ t_0 -1.0)) (t_2 (/ t_1 (/ i n))))
   (if (<= t_2 -4e-167)
     (* n (/ (fma 100.0 t_0 -100.0) i))
     (if (<= t_2 0.0)
       (* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
       (if (<= t_2 INFINITY)
         (* (/ t_1 i) (* n 100.0))
         (*
          100.0
          (/ n (+ 1.0 (fma -0.5 i (* (* i i) 0.08333333333333333))))))))))
double code(double i, double n) {
	double t_0 = pow((1.0 + (i / n)), n);
	double t_1 = t_0 + -1.0;
	double t_2 = t_1 / (i / n);
	double tmp;
	if (t_2 <= -4e-167) {
		tmp = n * (fma(100.0, t_0, -100.0) / i);
	} else if (t_2 <= 0.0) {
		tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = (t_1 / i) * (n * 100.0);
	} else {
		tmp = 100.0 * (n / (1.0 + fma(-0.5, i, ((i * i) * 0.08333333333333333))));
	}
	return tmp;
}
function code(i, n)
	t_0 = Float64(1.0 + Float64(i / n)) ^ n
	t_1 = Float64(t_0 + -1.0)
	t_2 = Float64(t_1 / Float64(i / n))
	tmp = 0.0
	if (t_2 <= -4e-167)
		tmp = Float64(n * Float64(fma(100.0, t_0, -100.0) / i));
	elseif (t_2 <= 0.0)
		tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n)));
	elseif (t_2 <= Inf)
		tmp = Float64(Float64(t_1 / i) * Float64(n * 100.0));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + fma(-0.5, i, Float64(Float64(i * i) * 0.08333333333333333)))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + -1.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-167], N[(n * N[(N[(100.0 * t$95$0 + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(t$95$1 / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(-0.5 * i + N[(N[(i * i), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

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

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


\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.00000000000000001e-167

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 20.2%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \left(-0.5 \cdot i + 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
    6. Step-by-step derivation
      1. fma-def99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{\mathsf{fma}\left(-0.5, i, 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
      2. *-commutative99.9%

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \mathsf{fma}\left(-0.5, i, \left(i \cdot i\right) \cdot 0.08333333333333333\right)}} \cdot 100 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification99.8%

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

Alternative 2: 84.6% accurate, 0.3× speedup?

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

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

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

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

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


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

    1. Initial program 99.7%

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

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

    1. Initial program 23.3%

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \left(-0.5 \cdot i + 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
    6. Step-by-step derivation
      1. fma-def99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{\mathsf{fma}\left(-0.5, i, 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
      2. *-commutative99.9%

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

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

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

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

Alternative 3: 84.6% accurate, 0.3× speedup?

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

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

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

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

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


\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.9999999999999999e-40

    1. Initial program 100.0%

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

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

    1. Initial program 23.3%

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \left(-0.5 \cdot i + 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
    6. Step-by-step derivation
      1. fma-def99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{\mathsf{fma}\left(-0.5, i, 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
      2. *-commutative99.9%

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \mathsf{fma}\left(-0.5, i, \left(i \cdot i\right) \cdot 0.08333333333333333\right)}} \cdot 100 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.5%

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

Alternative 4: 84.8% 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^{-210}:\\ \;\;\;\;\frac{-100 + t_0 \cdot 100}{\frac{i}{n}}\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;100 \cdot {\left(\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n}\right)}^{-1}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\frac{t_1}{i} \cdot \left(n \cdot 100\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + \mathsf{fma}\left(-0.5, i, \left(i \cdot i\right) \cdot 0.08333333333333333\right)}\\ \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-210)
     (/ (+ -100.0 (* t_0 100.0)) (/ i n))
     (if (<= t_2 0.0)
       (* 100.0 (pow (/ (/ i (expm1 i)) n) -1.0))
       (if (<= t_2 INFINITY)
         (* (/ t_1 i) (* n 100.0))
         (*
          100.0
          (/ n (+ 1.0 (fma -0.5 i (* (* i i) 0.08333333333333333))))))))))
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-210) {
		tmp = (-100.0 + (t_0 * 100.0)) / (i / n);
	} else if (t_2 <= 0.0) {
		tmp = 100.0 * pow(((i / expm1(i)) / n), -1.0);
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = (t_1 / i) * (n * 100.0);
	} else {
		tmp = 100.0 * (n / (1.0 + fma(-0.5, i, ((i * i) * 0.08333333333333333))));
	}
	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-210)
		tmp = Float64(Float64(-100.0 + Float64(t_0 * 100.0)) / Float64(i / n));
	elseif (t_2 <= 0.0)
		tmp = Float64(100.0 * (Float64(Float64(i / expm1(i)) / n) ^ -1.0));
	elseif (t_2 <= Inf)
		tmp = Float64(Float64(t_1 / i) * Float64(n * 100.0));
	else
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + fma(-0.5, i, Float64(Float64(i * i) * 0.08333333333333333)))));
	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-210], N[(N[(-100.0 + N[(t$95$0 * 100.0), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(100.0 * N[Power[N[(N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(t$95$1 / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(-0.5 * i + N[(N[(i * i), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

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

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


\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)) < -5.0000000000000002e-210

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \left(-0.5 \cdot i + 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
    6. Step-by-step derivation
      1. fma-def99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{\mathsf{fma}\left(-0.5, i, 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
      2. *-commutative99.9%

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \mathsf{fma}\left(-0.5, i, \left(i \cdot i\right) \cdot 0.08333333333333333\right)}} \cdot 100 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.7%

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

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

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

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

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

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


\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)) < -5.0000000000000002e-210

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \left(-0.5 \cdot i + 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
    6. Step-by-step derivation
      1. fma-def99.9%

        \[\leadsto \frac{n}{1 + \color{blue}{\mathsf{fma}\left(-0.5, i, 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
      2. *-commutative99.9%

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + \mathsf{fma}\left(-0.5, i, \left(i \cdot i\right) \cdot 0.08333333333333333\right)}} \cdot 100 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification99.8%

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

Alternative 6: 80.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{-230}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{-257}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 3.2 \cdot 10^{-94}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 2.05 \cdot 10^{-36}:\\ \;\;\;\;100 \cdot \frac{n \cdot n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -2.3e-230)
   (* 100.0 (/ n (/ i (expm1 i))))
   (if (<= n 5e-257)
     (* (* n 100.0) (/ 0.0 i))
     (if (<= n 3.2e-94)
       (* 100.0 (/ i (/ i n)))
       (if (<= n 2.05e-36)
         (* 100.0 (/ (* n n) (/ i (log (/ i n)))))
         (* (* n 100.0) (/ (expm1 i) i)))))))
double code(double i, double n) {
	double tmp;
	if (n <= -2.3e-230) {
		tmp = 100.0 * (n / (i / expm1(i)));
	} else if (n <= 5e-257) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 3.2e-94) {
		tmp = 100.0 * (i / (i / n));
	} else if (n <= 2.05e-36) {
		tmp = 100.0 * ((n * n) / (i / log((i / n))));
	} else {
		tmp = (n * 100.0) * (expm1(i) / i);
	}
	return tmp;
}
public static double code(double i, double n) {
	double tmp;
	if (n <= -2.3e-230) {
		tmp = 100.0 * (n / (i / Math.expm1(i)));
	} else if (n <= 5e-257) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 3.2e-94) {
		tmp = 100.0 * (i / (i / n));
	} else if (n <= 2.05e-36) {
		tmp = 100.0 * ((n * n) / (i / Math.log((i / n))));
	} else {
		tmp = (n * 100.0) * (Math.expm1(i) / i);
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -2.3e-230:
		tmp = 100.0 * (n / (i / math.expm1(i)))
	elif n <= 5e-257:
		tmp = (n * 100.0) * (0.0 / i)
	elif n <= 3.2e-94:
		tmp = 100.0 * (i / (i / n))
	elif n <= 2.05e-36:
		tmp = 100.0 * ((n * n) / (i / math.log((i / n))))
	else:
		tmp = (n * 100.0) * (math.expm1(i) / i)
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -2.3e-230)
		tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i))));
	elseif (n <= 5e-257)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (n <= 3.2e-94)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	elseif (n <= 2.05e-36)
		tmp = Float64(100.0 * Float64(Float64(n * n) / Float64(i / log(Float64(i / n)))));
	else
		tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i));
	end
	return tmp
end
code[i_, n_] := If[LessEqual[n, -2.3e-230], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 5e-257], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.2e-94], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.05e-36], N[(100.0 * N[(N[(n * n), $MachinePrecision] / N[(i / N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;n \leq 3.2 \cdot 10^{-94}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{elif}\;n \leq 2.05 \cdot 10^{-36}:\\
\;\;\;\;100 \cdot \frac{n \cdot n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -2.2999999999999998e-230

    1. Initial program 29.6%

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

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

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

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

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

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

    if -2.2999999999999998e-230 < n < 4.99999999999999989e-257

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

    if 4.99999999999999989e-257 < n < 3.19999999999999997e-94

    1. Initial program 10.0%

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

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

    if 3.19999999999999997e-94 < n < 2.05000000000000006e-36

    1. Initial program 17.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 100 \cdot \color{blue}{\frac{{n}^{2}}{\frac{i}{\log i + -1 \cdot \log n}}} \]
      2. unpow263.5%

        \[\leadsto 100 \cdot \frac{\color{blue}{n \cdot n}}{\frac{i}{\log i + -1 \cdot \log n}} \]
      3. mul-1-neg63.5%

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

        \[\leadsto 100 \cdot \frac{n \cdot n}{\frac{i}{\color{blue}{\log i - \log n}}} \]
      5. log-div63.5%

        \[\leadsto 100 \cdot \frac{n \cdot n}{\frac{i}{\color{blue}{\log \left(\frac{i}{n}\right)}}} \]
    8. Simplified63.5%

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

    if 2.05000000000000006e-36 < n

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{-230}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{-257}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 3.2 \cdot 10^{-94}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 2.05 \cdot 10^{-36}:\\ \;\;\;\;100 \cdot \frac{n \cdot n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \]

Alternative 7: 80.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -9.5 \cdot 10^{-226}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 7 \cdot 10^{-260}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 1.7 \cdot 10^{-94}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 1.95 \cdot 10^{-36}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -9.5e-226)
   (* 100.0 (/ n (/ i (expm1 i))))
   (if (<= n 7e-260)
     (* (* n 100.0) (/ 0.0 i))
     (if (<= n 1.7e-94)
       (* 100.0 (/ i (/ i n)))
       (if (<= n 1.95e-36)
         (* (* n 100.0) (/ n (/ i (log (/ i n)))))
         (* (* n 100.0) (/ (expm1 i) i)))))))
double code(double i, double n) {
	double tmp;
	if (n <= -9.5e-226) {
		tmp = 100.0 * (n / (i / expm1(i)));
	} else if (n <= 7e-260) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 1.7e-94) {
		tmp = 100.0 * (i / (i / n));
	} else if (n <= 1.95e-36) {
		tmp = (n * 100.0) * (n / (i / log((i / n))));
	} else {
		tmp = (n * 100.0) * (expm1(i) / i);
	}
	return tmp;
}
public static double code(double i, double n) {
	double tmp;
	if (n <= -9.5e-226) {
		tmp = 100.0 * (n / (i / Math.expm1(i)));
	} else if (n <= 7e-260) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 1.7e-94) {
		tmp = 100.0 * (i / (i / n));
	} else if (n <= 1.95e-36) {
		tmp = (n * 100.0) * (n / (i / Math.log((i / n))));
	} else {
		tmp = (n * 100.0) * (Math.expm1(i) / i);
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -9.5e-226:
		tmp = 100.0 * (n / (i / math.expm1(i)))
	elif n <= 7e-260:
		tmp = (n * 100.0) * (0.0 / i)
	elif n <= 1.7e-94:
		tmp = 100.0 * (i / (i / n))
	elif n <= 1.95e-36:
		tmp = (n * 100.0) * (n / (i / math.log((i / n))))
	else:
		tmp = (n * 100.0) * (math.expm1(i) / i)
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -9.5e-226)
		tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i))));
	elseif (n <= 7e-260)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (n <= 1.7e-94)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	elseif (n <= 1.95e-36)
		tmp = Float64(Float64(n * 100.0) * Float64(n / Float64(i / log(Float64(i / n)))));
	else
		tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i));
	end
	return tmp
end
code[i_, n_] := If[LessEqual[n, -9.5e-226], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7e-260], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.7e-94], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.95e-36], N[(N[(n * 100.0), $MachinePrecision] * N[(n / N[(i / N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;n \leq 1.7 \cdot 10^{-94}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{elif}\;n \leq 1.95 \cdot 10^{-36}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -9.5000000000000007e-226

    1. Initial program 29.6%

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

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

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

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

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

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

    if -9.5000000000000007e-226 < n < 6.9999999999999999e-260

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

    if 6.9999999999999999e-260 < n < 1.6999999999999999e-94

    1. Initial program 10.0%

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

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

    if 1.6999999999999999e-94 < n < 1.95e-36

    1. Initial program 17.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{\frac{i}{\color{blue}{\log i - \log n}}} \cdot \left(n \cdot 100\right) \]
      4. log-div63.6%

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

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

    if 1.95e-36 < n

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -9.5 \cdot 10^{-226}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 7 \cdot 10^{-260}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 1.7 \cdot 10^{-94}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 1.95 \cdot 10^{-36}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \]

Alternative 8: 82.2% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 29.6%

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

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

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

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

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

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

    if -7.50000000000000044e-226 < n < 2.89999999999999985e-261

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

    if 2.89999999999999985e-261 < n < 9e17

    1. Initial program 15.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{1 + \color{blue}{\mathsf{fma}\left(-0.5, i, 0.08333333333333333 \cdot {i}^{2}\right)}} \cdot 100 \]
      2. *-commutative71.4%

        \[\leadsto \frac{n}{1 + \mathsf{fma}\left(-0.5, i, \color{blue}{{i}^{2} \cdot 0.08333333333333333}\right)} \cdot 100 \]
      3. unpow271.4%

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

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

    if 9e17 < n

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -7.5 \cdot 10^{-226}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 2.9 \cdot 10^{-261}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 9 \cdot 10^{+17}:\\ \;\;\;\;100 \cdot \frac{n}{1 + \mathsf{fma}\left(-0.5, i, \left(i \cdot i\right) \cdot 0.08333333333333333\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \]

Alternative 9: 77.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.02 \cdot 10^{+86} \lor \neg \left(i \leq 5.5 \cdot 10^{+106}\right):\\
\;\;\;\;100 \cdot \frac{-1 + {\left(\frac{i}{n}\right)}^{n}}{\frac{i}{n}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < -1.01999999999999996e86 or 5.5e106 < i

    1. Initial program 67.0%

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

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

    if -1.01999999999999996e86 < i < 5.5e106

    1. Initial program 10.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -1.02 \cdot 10^{+86} \lor \neg \left(i \leq 5.5 \cdot 10^{+106}\right):\\ \;\;\;\;100 \cdot \frac{-1 + {\left(\frac{i}{n}\right)}^{n}}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]

Alternative 10: 78.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;i \leq 6.8 \cdot 10^{+108}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\

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


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

    1. Initial program 85.7%

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

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

    if -1.1499999999999999e85 < i < 6.79999999999999992e108

    1. Initial program 10.8%

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

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

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

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

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

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

    if 6.79999999999999992e108 < i

    1. Initial program 51.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 78.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 85.7%

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

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

    if -9.49999999999999945e85 < i < 9.99999999999999982e108

    1. Initial program 10.8%

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

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

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

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

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

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

    if 9.99999999999999982e108 < i

    1. Initial program 51.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 75.3% 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 -4.5 \cdot 10^{-30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;i \leq 3.8 \cdot 10^{-36}:\\ \;\;\;\;\mathsf{fma}\left(n, 100, i \cdot -50\right)\\ \mathbf{elif}\;i \leq 6.5 \cdot 10^{+242}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|n \cdot \frac{-200}{i}\right|\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* 100.0 (/ (expm1 i) (/ i n)))))
   (if (<= i -4.5e-30)
     t_0
     (if (<= i 3.8e-36)
       (fma n 100.0 (* i -50.0))
       (if (<= i 6.5e+242) t_0 (fabs (* n (/ -200.0 i))))))))
double code(double i, double n) {
	double t_0 = 100.0 * (expm1(i) / (i / n));
	double tmp;
	if (i <= -4.5e-30) {
		tmp = t_0;
	} else if (i <= 3.8e-36) {
		tmp = fma(n, 100.0, (i * -50.0));
	} else if (i <= 6.5e+242) {
		tmp = t_0;
	} else {
		tmp = fabs((n * (-200.0 / i)));
	}
	return tmp;
}
function code(i, n)
	t_0 = Float64(100.0 * Float64(expm1(i) / Float64(i / n)))
	tmp = 0.0
	if (i <= -4.5e-30)
		tmp = t_0;
	elseif (i <= 3.8e-36)
		tmp = fma(n, 100.0, Float64(i * -50.0));
	elseif (i <= 6.5e+242)
		tmp = t_0;
	else
		tmp = abs(Float64(n * Float64(-200.0 / 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, -4.5e-30], t$95$0, If[LessEqual[i, 3.8e-36], N[(n * 100.0 + N[(i * -50.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 6.5e+242], t$95$0, N[Abs[N[(n * N[(-200.0 / i), $MachinePrecision]), $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 -4.5 \cdot 10^{-30}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;i \leq 3.8 \cdot 10^{-36}:\\
\;\;\;\;\mathsf{fma}\left(n, 100, i \cdot -50\right)\\

\mathbf{elif}\;i \leq 6.5 \cdot 10^{+242}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\left|n \cdot \frac{-200}{i}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -4.49999999999999967e-30 or 3.79999999999999971e-36 < i < 6.49999999999999992e242

    1. Initial program 51.4%

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

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

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

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

    if -4.49999999999999967e-30 < i < 3.79999999999999971e-36

    1. Initial program 7.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n, 100, \left(\left(n \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right) \cdot 100\right)} \]
    7. Taylor expanded in n around 0 90.5%

      \[\leadsto \mathsf{fma}\left(n, 100, \color{blue}{-50 \cdot i}\right) \]
    8. Step-by-step derivation
      1. *-commutative90.5%

        \[\leadsto \mathsf{fma}\left(n, 100, \color{blue}{i \cdot -50}\right) \]
    9. Simplified90.5%

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

    if 6.49999999999999992e242 < i

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
    8. Taylor expanded in i around inf 59.8%

      \[\leadsto \color{blue}{-200 \cdot \frac{n}{i}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt59.7%

        \[\leadsto \color{blue}{\sqrt{-200 \cdot \frac{n}{i}} \cdot \sqrt{-200 \cdot \frac{n}{i}}} \]
      2. sqrt-unprod59.0%

        \[\leadsto \color{blue}{\sqrt{\left(-200 \cdot \frac{n}{i}\right) \cdot \left(-200 \cdot \frac{n}{i}\right)}} \]
      3. pow259.0%

        \[\leadsto \sqrt{\color{blue}{{\left(-200 \cdot \frac{n}{i}\right)}^{2}}} \]
      4. associate-*r/59.0%

        \[\leadsto \sqrt{{\color{blue}{\left(\frac{-200 \cdot n}{i}\right)}}^{2}} \]
    10. Applied egg-rr59.0%

      \[\leadsto \color{blue}{\sqrt{{\left(\frac{-200 \cdot n}{i}\right)}^{2}}} \]
    11. Step-by-step derivation
      1. unpow259.0%

        \[\leadsto \sqrt{\color{blue}{\frac{-200 \cdot n}{i} \cdot \frac{-200 \cdot n}{i}}} \]
      2. rem-sqrt-square60.1%

        \[\leadsto \color{blue}{\left|\frac{-200 \cdot n}{i}\right|} \]
      3. associate-*l/60.1%

        \[\leadsto \left|\color{blue}{\frac{-200}{i} \cdot n}\right| \]
    12. Simplified60.1%

      \[\leadsto \color{blue}{\left|\frac{-200}{i} \cdot n\right|} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -4.5 \cdot 10^{-30}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 3.8 \cdot 10^{-36}:\\ \;\;\;\;\mathsf{fma}\left(n, 100, i \cdot -50\right)\\ \mathbf{elif}\;i \leq 6.5 \cdot 10^{+242}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left|n \cdot \frac{-200}{i}\right|\\ \end{array} \]

Alternative 13: 75.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -2.9 \cdot 10^{-30}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 2.25 \cdot 10^{-35}:\\ \;\;\;\;\mathsf{fma}\left(n, 100, i \cdot -50\right)\\ \mathbf{elif}\;i \leq 2.9 \cdot 10^{+242}:\\ \;\;\;\;\mathsf{expm1}\left(i\right) \cdot \frac{n}{\frac{i}{100}}\\ \mathbf{else}:\\ \;\;\;\;\left|n \cdot \frac{-200}{i}\right|\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -2.9e-30)
   (* 100.0 (/ (expm1 i) (/ i n)))
   (if (<= i 2.25e-35)
     (fma n 100.0 (* i -50.0))
     (if (<= i 2.9e+242)
       (* (expm1 i) (/ n (/ i 100.0)))
       (fabs (* n (/ -200.0 i)))))))
double code(double i, double n) {
	double tmp;
	if (i <= -2.9e-30) {
		tmp = 100.0 * (expm1(i) / (i / n));
	} else if (i <= 2.25e-35) {
		tmp = fma(n, 100.0, (i * -50.0));
	} else if (i <= 2.9e+242) {
		tmp = expm1(i) * (n / (i / 100.0));
	} else {
		tmp = fabs((n * (-200.0 / i)));
	}
	return tmp;
}
function code(i, n)
	tmp = 0.0
	if (i <= -2.9e-30)
		tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n)));
	elseif (i <= 2.25e-35)
		tmp = fma(n, 100.0, Float64(i * -50.0));
	elseif (i <= 2.9e+242)
		tmp = Float64(expm1(i) * Float64(n / Float64(i / 100.0)));
	else
		tmp = abs(Float64(n * Float64(-200.0 / i)));
	end
	return tmp
end
code[i_, n_] := If[LessEqual[i, -2.9e-30], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.25e-35], N[(n * 100.0 + N[(i * -50.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.9e+242], N[(N[(Exp[i] - 1), $MachinePrecision] * N[(n / N[(i / 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(n * N[(-200.0 / i), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;i \leq 2.25 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(n, 100, i \cdot -50\right)\\

\mathbf{elif}\;i \leq 2.9 \cdot 10^{+242}:\\
\;\;\;\;\mathsf{expm1}\left(i\right) \cdot \frac{n}{\frac{i}{100}}\\

\mathbf{else}:\\
\;\;\;\;\left|n \cdot \frac{-200}{i}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if i < -2.89999999999999989e-30

    1. Initial program 59.9%

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

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

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

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

    if -2.89999999999999989e-30 < i < 2.25000000000000005e-35

    1. Initial program 7.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(n, 100, \left(\left(n \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right) \cdot 100\right)} \]
    7. Taylor expanded in n around 0 90.5%

      \[\leadsto \mathsf{fma}\left(n, 100, \color{blue}{-50 \cdot i}\right) \]
    8. Step-by-step derivation
      1. *-commutative90.5%

        \[\leadsto \mathsf{fma}\left(n, 100, \color{blue}{i \cdot -50}\right) \]
    9. Simplified90.5%

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

    if 2.25000000000000005e-35 < i < 2.89999999999999997e242

    1. Initial program 41.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.89999999999999997e242 < i

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
    8. Taylor expanded in i around inf 59.8%

      \[\leadsto \color{blue}{-200 \cdot \frac{n}{i}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt59.7%

        \[\leadsto \color{blue}{\sqrt{-200 \cdot \frac{n}{i}} \cdot \sqrt{-200 \cdot \frac{n}{i}}} \]
      2. sqrt-unprod59.0%

        \[\leadsto \color{blue}{\sqrt{\left(-200 \cdot \frac{n}{i}\right) \cdot \left(-200 \cdot \frac{n}{i}\right)}} \]
      3. pow259.0%

        \[\leadsto \sqrt{\color{blue}{{\left(-200 \cdot \frac{n}{i}\right)}^{2}}} \]
      4. associate-*r/59.0%

        \[\leadsto \sqrt{{\color{blue}{\left(\frac{-200 \cdot n}{i}\right)}}^{2}} \]
    10. Applied egg-rr59.0%

      \[\leadsto \color{blue}{\sqrt{{\left(\frac{-200 \cdot n}{i}\right)}^{2}}} \]
    11. Step-by-step derivation
      1. unpow259.0%

        \[\leadsto \sqrt{\color{blue}{\frac{-200 \cdot n}{i} \cdot \frac{-200 \cdot n}{i}}} \]
      2. rem-sqrt-square60.1%

        \[\leadsto \color{blue}{\left|\frac{-200 \cdot n}{i}\right|} \]
      3. associate-*l/60.1%

        \[\leadsto \left|\color{blue}{\frac{-200}{i} \cdot n}\right| \]
    12. Simplified60.1%

      \[\leadsto \color{blue}{\left|\frac{-200}{i} \cdot n\right|} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification79.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2.9 \cdot 10^{-30}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 2.25 \cdot 10^{-35}:\\ \;\;\;\;\mathsf{fma}\left(n, 100, i \cdot -50\right)\\ \mathbf{elif}\;i \leq 2.9 \cdot 10^{+242}:\\ \;\;\;\;\mathsf{expm1}\left(i\right) \cdot \frac{n}{\frac{i}{100}}\\ \mathbf{else}:\\ \;\;\;\;\left|n \cdot \frac{-200}{i}\right|\\ \end{array} \]

Alternative 14: 79.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.2 \cdot 10^{-232} \lor \neg \left(n \leq 3.4 \cdot 10^{-213}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -5.19999999999999992e-232 or 3.4000000000000002e-213 < n

    1. Initial program 24.1%

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

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

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

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

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

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

    if -5.19999999999999992e-232 < n < 3.4000000000000002e-213

    1. Initial program 60.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5.2 \cdot 10^{-232} \lor \neg \left(n \leq 3.4 \cdot 10^{-213}\right):\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \end{array} \]

Alternative 15: 79.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 29.6%

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

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

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

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

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

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

    if -4.80000000000000022e-235 < n < 1.0499999999999999e-213

    1. Initial program 60.5%

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

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

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

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

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

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

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

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

    if 1.0499999999999999e-213 < n

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.8 \cdot 10^{-235}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 1.05 \cdot 10^{-213}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \end{array} \]

Alternative 16: 65.2% accurate, 4.9× speedup?

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

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

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

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

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


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

    1. Initial program 11.4%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
    8. Taylor expanded in i around 0 89.4%

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

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

        \[\leadsto \left(n + \left(\color{blue}{\left(0.5 \cdot i\right) \cdot n} + 0.25 \cdot \left({i}^{2} \cdot n\right)\right)\right) \cdot 100 \]
      3. associate-*r*89.4%

        \[\leadsto \left(n + \left(\left(0.5 \cdot i\right) \cdot n + \color{blue}{\left(0.25 \cdot {i}^{2}\right) \cdot n}\right)\right) \cdot 100 \]
      4. distribute-rgt-out89.5%

        \[\leadsto \left(n + \color{blue}{n \cdot \left(0.5 \cdot i + 0.25 \cdot {i}^{2}\right)}\right) \cdot 100 \]
      5. *-commutative89.5%

        \[\leadsto \left(n + n \cdot \left(0.5 \cdot i + \color{blue}{{i}^{2} \cdot 0.25}\right)\right) \cdot 100 \]
      6. unpow289.5%

        \[\leadsto \left(n + n \cdot \left(0.5 \cdot i + \color{blue}{\left(i \cdot i\right)} \cdot 0.25\right)\right) \cdot 100 \]
    10. Simplified89.5%

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

    if -2.6999999999999999e198 < n < -3.60000000000000009e-225

    1. Initial program 35.2%

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

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

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

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

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

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

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

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

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

    if -3.60000000000000009e-225 < n < 3.0999999999999998e-213

    1. Initial program 60.5%

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

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

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

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

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

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

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

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

    if 3.0999999999999998e-213 < n

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.7 \cdot 10^{+198}:\\ \;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5 + \left(i \cdot i\right) \cdot 0.25\right)\right)\\ \mathbf{elif}\;n \leq -3.6 \cdot 10^{-225}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 3.1 \cdot 10^{-213}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \frac{100 \cdot \left(i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}{i}\\ \end{array} \]

Alternative 17: 65.7% accurate, 5.4× speedup?

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

\\
\begin{array}{l}
t_0 := 100 \cdot \left(n + n \cdot \left(i \cdot 0.5 + \left(i \cdot i\right) \cdot 0.25\right)\right)\\
\mathbf{if}\;n \leq -2.2 \cdot 10^{+200}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -2.2e200 or 1.4e-213 < n

    1. Initial program 17.1%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
    8. Taylor expanded in i around 0 73.7%

      \[\leadsto \color{blue}{\left(n + \left(0.25 \cdot \left({i}^{2} \cdot n\right) + 0.5 \cdot \left(i \cdot n\right)\right)\right)} \cdot 100 \]
    9. Step-by-step derivation
      1. +-commutative73.7%

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

        \[\leadsto \left(n + \left(\color{blue}{\left(0.5 \cdot i\right) \cdot n} + 0.25 \cdot \left({i}^{2} \cdot n\right)\right)\right) \cdot 100 \]
      3. associate-*r*73.7%

        \[\leadsto \left(n + \left(\left(0.5 \cdot i\right) \cdot n + \color{blue}{\left(0.25 \cdot {i}^{2}\right) \cdot n}\right)\right) \cdot 100 \]
      4. distribute-rgt-out73.8%

        \[\leadsto \left(n + \color{blue}{n \cdot \left(0.5 \cdot i + 0.25 \cdot {i}^{2}\right)}\right) \cdot 100 \]
      5. *-commutative73.8%

        \[\leadsto \left(n + n \cdot \left(0.5 \cdot i + \color{blue}{{i}^{2} \cdot 0.25}\right)\right) \cdot 100 \]
      6. unpow273.8%

        \[\leadsto \left(n + n \cdot \left(0.5 \cdot i + \color{blue}{\left(i \cdot i\right)} \cdot 0.25\right)\right) \cdot 100 \]
    10. Simplified73.8%

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

    if -2.2e200 < n < -4.99999999999999972e-228

    1. Initial program 35.2%

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

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

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

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

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

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

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

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

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

    if -4.99999999999999972e-228 < n < 1.4e-213

    1. Initial program 60.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.2 \cdot 10^{+200}:\\ \;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5 + \left(i \cdot i\right) \cdot 0.25\right)\right)\\ \mathbf{elif}\;n \leq -5 \cdot 10^{-228}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 1.4 \cdot 10^{-213}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5 + \left(i \cdot i\right) \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 18: 63.9% accurate, 8.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -2.29999999999999999e202 or 2.8999999999999999e-213 < n

    1. Initial program 17.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
      3. *-commutative73.0%

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

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

    if -2.29999999999999999e202 < n < -8.00000000000000037e-230

    1. Initial program 35.2%

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

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

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

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

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

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

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

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

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

    if -8.00000000000000037e-230 < n < 2.8999999999999999e-213

    1. Initial program 60.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{+202}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq -8 \cdot 10^{-230}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 2.9 \cdot 10^{-213}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 19: 63.1% accurate, 8.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.3 \cdot 10^{+199} \lor \neg \left(n \leq 2.5 \cdot 10^{-37}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.3000000000000001e199 or 2.4999999999999999e-37 < n

    1. Initial program 18.0%

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

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

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

        \[\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. Taylor expanded in i around 0 78.9%

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

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

        \[\leadsto \color{blue}{n \cdot \left(50 \cdot i + 100\right)} \]
      3. *-commutative79.0%

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

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

    if -1.3000000000000001e199 < n < 2.4999999999999999e-37

    1. Initial program 33.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.3 \cdot 10^{+199} \lor \neg \left(n \leq 2.5 \cdot 10^{-37}\right):\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 20: 62.0% accurate, 10.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.6 \cdot 10^{+38} \lor \neg \left(n \leq 4.7 \cdot 10^{-26}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -2.5999999999999999e38 or 4.69999999999999989e-26 < n

    1. Initial program 24.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]
    6. 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)} \]
      3. *-commutative72.1%

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

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

    if -2.5999999999999999e38 < n < 4.69999999999999989e-26

    1. Initial program 31.1%

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

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

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

Alternative 21: 58.0% accurate, 12.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -2 \lor \neg \left(i \leq 3.8 \cdot 10^{+111}\right):\\
\;\;\;\;-200 \cdot \frac{n}{i}\\

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


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

    1. Initial program 64.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
    8. Taylor expanded in i around inf 27.4%

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

    if -2 < i < 3.79999999999999976e111

    1. Initial program 8.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2 \lor \neg \left(i \leq 3.8 \cdot 10^{+111}\right):\\ \;\;\;\;-200 \cdot \frac{n}{i}\\ \mathbf{else}:\\ \;\;\;\;n \cdot 100\\ \end{array} \]

Alternative 22: 58.2% accurate, 12.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;\frac{-200}{\frac{i}{n}}\\

\mathbf{elif}\;i \leq 5 \cdot 10^{+111}:\\
\;\;\;\;n \cdot 100\\

\mathbf{else}:\\
\;\;\;\;-200 \cdot \frac{n}{i}\\


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

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
    8. Taylor expanded in i around inf 26.7%

      \[\leadsto \color{blue}{-200 \cdot \frac{n}{i}} \]
    9. Step-by-step derivation
      1. clear-num28.3%

        \[\leadsto -200 \cdot \color{blue}{\frac{1}{\frac{i}{n}}} \]
      2. un-div-inv28.3%

        \[\leadsto \color{blue}{\frac{-200}{\frac{i}{n}}} \]
    10. Applied egg-rr28.3%

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

    if -2 < i < 4.9999999999999997e111

    1. Initial program 8.0%

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

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

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

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

    if 4.9999999999999997e111 < i

    1. Initial program 54.4%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \cdot 100 \]
    8. Taylor expanded in i around inf 28.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2:\\ \;\;\;\;\frac{-200}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 5 \cdot 10^{+111}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;-200 \cdot \frac{n}{i}\\ \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 27.1%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-50 \cdot i} \]
  6. Step-by-step derivation
    1. *-commutative2.7%

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

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

    \[\leadsto i \cdot -50 \]

Alternative 24: 49.1% 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 27.1%

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

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

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

    \[\leadsto \color{blue}{n \cdot 100} \]
  5. Final simplification54.7%

    \[\leadsto n \cdot 100 \]

Developer target: 34.3% 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 2023279 
(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))))