Compound Interest

Percentage Accurate: 28.7% → 98.3%
Time: 22.2s
Alternatives: 16
Speedup: 9.5×

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 16 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.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \end{array} \]
(FPCore (i n)
 :precision binary64
 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
	return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
	return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n):
	return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n)
	return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n)))
end
function tmp = code(i, n)
	tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n));
end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 98.3% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{n \cdot \mathsf{fma}\left(t\_0, 100, -100\right)}{i}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0

    1. Initial program 25.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg25.4%

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

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

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

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

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

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

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

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

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

      \[\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 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.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. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r/99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    4. 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}{\left(n \cdot \frac{e^{i} - 1}{i}\right)} \cdot 100 \]
      3. expm1-define85.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*85.4%

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

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

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

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

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\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{n \cdot \mathsf{fma}\left({\left(1 + \frac{i}{n}\right)}^{n}, 100, -100\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 84.4% accurate, 0.2× speedup?

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

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

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

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_2\\

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


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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

    if -2e-174 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*79.5%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified79.5%

      \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    10. Step-by-step derivation
      1. div-inv79.6%

        \[\leadsto \frac{\color{blue}{n \cdot \frac{1}{0.01}}}{\frac{i}{\mathsf{expm1}\left(i\right)}} \]
      2. metadata-eval79.6%

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

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    4. 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}{\left(n \cdot \frac{e^{i} - 1}{i}\right)} \cdot 100 \]
      3. expm1-define85.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*85.4%

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

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

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

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

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 99.9%

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

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

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

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

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

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 99.4%

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

    if -2e-174 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*79.5%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified79.5%

      \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    10. Step-by-step derivation
      1. div-inv79.6%

        \[\leadsto \frac{\color{blue}{n \cdot \frac{1}{0.01}}}{\frac{i}{\mathsf{expm1}\left(i\right)}} \]
      2. metadata-eval79.6%

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

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    4. 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}{\left(n \cdot \frac{e^{i} - 1}{i}\right)} \cdot 100 \]
      3. expm1-define85.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*85.4%

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

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

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

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

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -2 \cdot 10^{-174}:\\ \;\;\;\;\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:\\ \;\;\;\;\frac{n \cdot 100}{\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 + i \cdot -0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.3% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t\_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0

    1. Initial program 25.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg25.4%

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

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

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

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

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

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

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

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

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

      \[\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 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.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. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub99.8%

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

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

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

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

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

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

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

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

    if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    4. 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}{\left(n \cdot \frac{e^{i} - 1}{i}\right)} \cdot 100 \]
      3. expm1-define85.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*85.4%

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

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

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

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

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\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:\\ \;\;\;\;100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot \frac{n}{i} - \frac{n}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 81.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -4.80000000000000004e-27 or 1.5 < n

    1. Initial program 31.6%

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

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

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

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

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg32.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-in32.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval36.4%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in36.5%

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

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

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

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

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

    if -4.80000000000000004e-27 < n < 1.5

    1. Initial program 26.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*58.8%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified58.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.8 \cdot 10^{-27} \lor \neg \left(n \leq 1.5\right):\\ \;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot \left(i \cdot 0.08333333333333333 - 0.5\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 81.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.5 \cdot 10^{-43} \lor \neg \left(n \leq 1.7\right):\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.50000000000000002e-43 or 1.69999999999999996 < n

    1. Initial program 31.2%

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

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

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

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

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

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

    if -1.50000000000000002e-43 < n < 1.69999999999999996

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{\frac{\color{blue}{1 \cdot i}}{100 \cdot \mathsf{expm1}\left(i\right)}} \]
      7. times-frac58.0%

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*58.0%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified58.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.5 \cdot 10^{-43} \lor \neg \left(n \leq 1.7\right):\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot \left(i \cdot 0.08333333333333333 - 0.5\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 81.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*79.5%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified79.5%

      \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    10. Step-by-step derivation
      1. div-inv79.6%

        \[\leadsto \frac{\color{blue}{n \cdot \frac{1}{0.01}}}{\frac{i}{\mathsf{expm1}\left(i\right)}} \]
      2. metadata-eval79.6%

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

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

    if -3.25e-43 < n < 1.55000000000000004

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{\frac{\color{blue}{1 \cdot i}}{100 \cdot \mathsf{expm1}\left(i\right)}} \]
      7. times-frac58.0%

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*58.0%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified58.0%

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

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

    if 1.55000000000000004 < n

    1. Initial program 25.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.25 \cdot 10^{-43}:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 1.55:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot \left(i \cdot 0.08333333333333333 - 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 72.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{\frac{\color{blue}{1 \cdot i}}{100 \cdot \mathsf{expm1}\left(i\right)}} \]
      7. times-frac73.0%

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*73.1%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified73.1%

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

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

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

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

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

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

    if -2.9e-4 < i

    1. Initial program 20.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval19.5%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in19.6%

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

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

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

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

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

      \[\leadsto n \cdot \frac{\color{blue}{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + 4.166666666666667 \cdot i\right)\right)\right)}}{i} \]
    9. Step-by-step derivation
      1. *-commutative76.1%

        \[\leadsto n \cdot \frac{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + \color{blue}{i \cdot 4.166666666666667}\right)\right)\right)}{i} \]
    10. Simplified76.1%

      \[\leadsto n \cdot \frac{\color{blue}{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)}}{i} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification75.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -0.00029:\\ \;\;\;\;100 \cdot \left(\frac{n}{i} \cdot \mathsf{expm1}\left(i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 64.7% accurate, 4.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.116:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

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


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

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*69.0%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified69.0%

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

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

        \[\leadsto \frac{\frac{n}{0.01}}{1 + \color{blue}{i \cdot -0.5}} \]
    12. Simplified62.5%

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 62.6%

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

    if 0.116000000000000006 < n

    1. Initial program 25.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval43.0%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in43.2%

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

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

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

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

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

      \[\leadsto n \cdot \frac{\color{blue}{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + 4.166666666666667 \cdot i\right)\right)\right)}}{i} \]
    9. Step-by-step derivation
      1. *-commutative86.4%

        \[\leadsto n \cdot \frac{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + \color{blue}{i \cdot 4.166666666666667}\right)\right)\right)}{i} \]
    10. Simplified86.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 0.116:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 64.6% accurate, 5.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.0037:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

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


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

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*69.0%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified69.0%

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

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

        \[\leadsto \frac{\frac{n}{0.01}}{1 + \color{blue}{i \cdot -0.5}} \]
    12. Simplified62.5%

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 62.6%

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

    if 0.0037000000000000002 < n

    1. Initial program 25.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval43.0%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in43.2%

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

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

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

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

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

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + 4.166666666666667 \cdot i\right)\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutative85.2%

        \[\leadsto n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + \color{blue}{i \cdot 4.166666666666667}\right)\right)\right) \]
    10. Simplified85.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 0.0037:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 62.9% accurate, 7.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq 5.5 \cdot 10^{+18}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 5.5e18

    1. Initial program 31.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*69.4%

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

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

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

        \[\leadsto \frac{\frac{n}{0.01}}{1 + \color{blue}{i \cdot -0.5}} \]
    12. Simplified62.2%

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 62.3%

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

    if 5.5e18 < n

    1. Initial program 22.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval43.8%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in44.0%

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

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

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

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

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

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + 16.666666666666668 \cdot i\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutative81.2%

        \[\leadsto n \cdot \left(100 + i \cdot \left(50 + \color{blue}{i \cdot 16.666666666666668}\right)\right) \]
    10. Simplified81.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 5.5 \cdot 10^{+18}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 57.4% accurate, 7.6× speedup?

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

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

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


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

    1. Initial program 63.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*59.3%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified59.3%

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

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + -0.5 \cdot i}} \]
    11. Step-by-step derivation
      1. *-commutative25.4%

        \[\leadsto \frac{\frac{n}{0.01}}{1 + \color{blue}{i \cdot -0.5}} \]
    12. Simplified25.4%

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in i around inf 25.4%

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

    if -2 < i < 7.4999999999999999e35

    1. Initial program 7.8%

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    5. Simplified83.3%

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

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

Alternative 13: 61.6% accurate, 8.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.1 \cdot 10^{+18}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 3.1e18

    1. Initial program 31.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*69.4%

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

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

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

        \[\leadsto \frac{\frac{n}{0.01}}{1 + \color{blue}{i \cdot -0.5}} \]
    12. Simplified62.2%

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in n around 0 62.3%

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

    if 3.1e18 < n

    1. Initial program 22.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \color{blue}{\left(100 + 50 \cdot i\right)} \]
      4. *-commutative80.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 3.1 \cdot 10^{+18}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 58.2% accurate, 8.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -2.5 \cdot 10^{+19}:\\
\;\;\;\;0\\

\mathbf{elif}\;i \leq 1.7 \cdot 10^{+33}:\\
\;\;\;\;n \cdot 100\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < -2.5e19 or 1.7e33 < i

    1. Initial program 64.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -2.5e19 < i < 1.7e33

    1. Initial program 8.3%

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    5. Simplified82.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2.5 \cdot 10^{+19}:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 1.7 \cdot 10^{+33}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 59.8% accurate, 9.5× speedup?

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

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

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


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

    1. Initial program 66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r*73.9%

        \[\leadsto \color{blue}{\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    9. Simplified73.9%

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

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + -0.5 \cdot i}} \]
    11. Step-by-step derivation
      1. *-commutative30.1%

        \[\leadsto \frac{\frac{n}{0.01}}{1 + \color{blue}{i \cdot -0.5}} \]
    12. Simplified30.1%

      \[\leadsto \frac{\frac{n}{0.01}}{\color{blue}{1 + i \cdot -0.5}} \]
    13. Taylor expanded in i around inf 30.1%

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

    if -1.6000000000000001 < i

    1. Initial program 20.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -1.6:\\ \;\;\;\;\frac{n}{i} \cdot -200\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 18.0% accurate, 114.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
	return 0.0;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = 0.0d0
end function
public static double code(double i, double n) {
	return 0.0;
}
def code(i, n):
	return 0.0
function code(i, n)
	return 0.0
end
function tmp = code(i, n)
	tmp = 0.0;
end
code[i_, n_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 29.6%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  7. Final simplification13.5%

    \[\leadsto 0 \]
  8. Add Preprocessing

Developer target: 34.7% accurate, 0.5× speedup?

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

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

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


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

Reproduce

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

  :alt
  (* 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))))