Compound Interest

Percentage Accurate: 28.0% → 98.6%
Time: 22.5s
Alternatives: 20
Speedup: 8.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 alternatives:

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

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

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-241}:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\


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

    1. Initial program 99.6%

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

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

        \[\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.9%

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

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

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

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

    if -1.00000000000000006e-158 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 1.9999999999999999e-241

    1. Initial program 18.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 96.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -1 \cdot 10^{-158}:\\ \;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + -100}{\frac{i}{n}}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 2 \cdot 10^{-241}:\\ \;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 84.3% 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 -4 \cdot 10^{-294}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))) (t_1 (* t_0 100.0)))
   (if (<= t_0 -4e-294)
     t_1
     (if (<= t_0 0.0)
       (* 100.0 (* n (/ (expm1 i) i)))
       (if (<= t_0 INFINITY)
         t_1
         (/ n (+ 0.01 (* i (- (* i 0.0008333333333333334) 0.005)))))))))
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 <= -4e-294) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = 100.0 * (n * (expm1(i) / i));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	}
	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 <= -4e-294) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = 100.0 * (n * (Math.expm1(i) / i));
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	}
	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 <= -4e-294:
		tmp = t_1
	elif t_0 <= 0.0:
		tmp = 100.0 * (n * (math.expm1(i) / i))
	elif t_0 <= math.inf:
		tmp = t_1
	else:
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)))
	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 <= -4e-294)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i)));
	elseif (t_0 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(n / Float64(0.01 + Float64(i * Float64(Float64(i * 0.0008333333333333334) - 0.005))));
	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, -4e-294], t$95$1, If[LessEqual[t$95$0, 0.0], N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$1, N[(n / N[(0.01 + N[(i * N[(N[(i * 0.0008333333333333334), $MachinePrecision] - 0.005), $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 -4 \cdot 10^{-294}:\\
\;\;\;\;t\_1\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\


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

    1. Initial program 96.7%

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

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

    1. Initial program 17.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 35.3%

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -4 \cdot 10^{-294}:\\ \;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \cdot 100\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{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}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.3% 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}}\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{-294}:\\ \;\;\;\;t\_1 \cdot 100\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;n \cdot \frac{t\_0 \cdot 100 + -100}{i}\\ \mathbf{else}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
   (if (<= t_1 -4e-294)
     (* t_1 100.0)
     (if (<= t_1 0.0)
       (* 100.0 (* n (/ (expm1 i) i)))
       (if (<= t_1 INFINITY)
         (* n (/ (+ (* t_0 100.0) -100.0) i))
         (/ n (+ 0.01 (* i (- (* i 0.0008333333333333334) 0.005)))))))))
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 <= -4e-294) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n * (expm1(i) / i));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = n * (((t_0 * 100.0) + -100.0) / i);
	} else {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	}
	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 <= -4e-294) {
		tmp = t_1 * 100.0;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n * (Math.expm1(i) / i));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = n * (((t_0 * 100.0) + -100.0) / i);
	} else {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	}
	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 <= -4e-294:
		tmp = t_1 * 100.0
	elif t_1 <= 0.0:
		tmp = 100.0 * (n * (math.expm1(i) / i))
	elif t_1 <= math.inf:
		tmp = n * (((t_0 * 100.0) + -100.0) / i)
	else:
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)))
	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 <= -4e-294)
		tmp = Float64(t_1 * 100.0);
	elseif (t_1 <= 0.0)
		tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i)));
	elseif (t_1 <= Inf)
		tmp = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i));
	else
		tmp = Float64(n / Float64(0.01 + Float64(i * Float64(Float64(i * 0.0008333333333333334) - 0.005))));
	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, -4e-294], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n / N[(0.01 + N[(i * N[(N[(i * 0.0008333333333333334), $MachinePrecision] - 0.005), $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 -4 \cdot 10^{-294}:\\
\;\;\;\;t\_1 \cdot 100\\

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

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t\_0 \cdot 100 + -100}{i}\\

\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\


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

    1. Initial program 97.6%

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

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

    1. Initial program 17.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 35.3%

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

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

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

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

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

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

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified96.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. Step-by-step derivation
      1. fma-undefine96.1%

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.3% 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 := t\_0 \cdot 100 + -100\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{-294}:\\ \;\;\;\;\frac{t\_2}{\frac{i}{n}}\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;n \cdot \frac{t\_2}{i}\\ \mathbf{else}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (pow (+ 1.0 (/ i n)) n))
        (t_1 (/ (+ t_0 -1.0) (/ i n)))
        (t_2 (+ (* t_0 100.0) -100.0)))
   (if (<= t_1 -4e-294)
     (/ t_2 (/ i n))
     (if (<= t_1 0.0)
       (* 100.0 (* n (/ (expm1 i) i)))
       (if (<= t_1 INFINITY)
         (* n (/ t_2 i))
         (/ n (+ 0.01 (* i (- (* i 0.0008333333333333334) 0.005)))))))))
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 = (t_0 * 100.0) + -100.0;
	double tmp;
	if (t_1 <= -4e-294) {
		tmp = t_2 / (i / n);
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n * (expm1(i) / i));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = n * (t_2 / i);
	} else {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	}
	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 = (t_0 * 100.0) + -100.0;
	double tmp;
	if (t_1 <= -4e-294) {
		tmp = t_2 / (i / n);
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * (n * (Math.expm1(i) / i));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = n * (t_2 / i);
	} else {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	}
	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 = (t_0 * 100.0) + -100.0
	tmp = 0
	if t_1 <= -4e-294:
		tmp = t_2 / (i / n)
	elif t_1 <= 0.0:
		tmp = 100.0 * (n * (math.expm1(i) / i))
	elif t_1 <= math.inf:
		tmp = n * (t_2 / i)
	else:
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)))
	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(Float64(t_0 * 100.0) + -100.0)
	tmp = 0.0
	if (t_1 <= -4e-294)
		tmp = Float64(t_2 / Float64(i / n));
	elseif (t_1 <= 0.0)
		tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i)));
	elseif (t_1 <= Inf)
		tmp = Float64(n * Float64(t_2 / i));
	else
		tmp = Float64(n / Float64(0.01 + Float64(i * Float64(Float64(i * 0.0008333333333333334) - 0.005))));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-294], N[(t$95$2 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(t$95$2 / i), $MachinePrecision]), $MachinePrecision], N[(n / N[(0.01 + N[(i * N[(N[(i * 0.0008333333333333334), $MachinePrecision] - 0.005), $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 := t\_0 \cdot 100 + -100\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-294}:\\
\;\;\;\;\frac{t\_2}{\frac{i}{n}}\\

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

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t\_2}{i}\\

\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\


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

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

    1. Initial program 17.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 35.3%

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

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

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

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

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

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

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified96.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. Step-by-step derivation
      1. fma-undefine96.1%

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-241}:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1 \cdot 100\\

\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\


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

    1. Initial program 99.6%

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

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

        \[\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.9%

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

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

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

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

    if -1.00000000000000006e-158 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 1.9999999999999999e-241

    1. Initial program 18.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 96.6%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 75.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{if}\;i \leq -2.5 \cdot 10^{-32}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;i \leq 3.8 \cdot 10^{-34}:\\ \;\;\;\;i \cdot -50 + n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;i \leq 2.35 \cdot 10^{+247}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;i \leq 2.4 \cdot 10^{+295}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{else}:\\ \;\;\;\;50 \cdot \left(i \cdot n\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0 (* 100.0 (/ (expm1 i) (/ i n)))))
   (if (<= i -2.5e-32)
     t_0
     (if (<= i 3.8e-34)
       (+ (* i -50.0) (* n (+ 100.0 (* i 50.0))))
       (if (<= i 2.35e+247)
         t_0
         (if (<= i 2.4e+295) (/ n (+ 0.01 (* i -0.005))) (* 50.0 (* i n))))))))
double code(double i, double n) {
	double t_0 = 100.0 * (expm1(i) / (i / n));
	double tmp;
	if (i <= -2.5e-32) {
		tmp = t_0;
	} else if (i <= 3.8e-34) {
		tmp = (i * -50.0) + (n * (100.0 + (i * 50.0)));
	} else if (i <= 2.35e+247) {
		tmp = t_0;
	} else if (i <= 2.4e+295) {
		tmp = n / (0.01 + (i * -0.005));
	} else {
		tmp = 50.0 * (i * n);
	}
	return tmp;
}
public static double code(double i, double n) {
	double t_0 = 100.0 * (Math.expm1(i) / (i / n));
	double tmp;
	if (i <= -2.5e-32) {
		tmp = t_0;
	} else if (i <= 3.8e-34) {
		tmp = (i * -50.0) + (n * (100.0 + (i * 50.0)));
	} else if (i <= 2.35e+247) {
		tmp = t_0;
	} else if (i <= 2.4e+295) {
		tmp = n / (0.01 + (i * -0.005));
	} else {
		tmp = 50.0 * (i * n);
	}
	return tmp;
}
def code(i, n):
	t_0 = 100.0 * (math.expm1(i) / (i / n))
	tmp = 0
	if i <= -2.5e-32:
		tmp = t_0
	elif i <= 3.8e-34:
		tmp = (i * -50.0) + (n * (100.0 + (i * 50.0)))
	elif i <= 2.35e+247:
		tmp = t_0
	elif i <= 2.4e+295:
		tmp = n / (0.01 + (i * -0.005))
	else:
		tmp = 50.0 * (i * n)
	return tmp
function code(i, n)
	t_0 = Float64(100.0 * Float64(expm1(i) / Float64(i / n)))
	tmp = 0.0
	if (i <= -2.5e-32)
		tmp = t_0;
	elseif (i <= 3.8e-34)
		tmp = Float64(Float64(i * -50.0) + Float64(n * Float64(100.0 + Float64(i * 50.0))));
	elseif (i <= 2.35e+247)
		tmp = t_0;
	elseif (i <= 2.4e+295)
		tmp = Float64(n / Float64(0.01 + Float64(i * -0.005)));
	else
		tmp = Float64(50.0 * Float64(i * n));
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -2.5e-32], t$95$0, If[LessEqual[i, 3.8e-34], N[(N[(i * -50.0), $MachinePrecision] + N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.35e+247], t$95$0, If[LessEqual[i, 2.4e+295], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;i \leq 3.8 \cdot 10^{-34}:\\
\;\;\;\;i \cdot -50 + n \cdot \left(100 + i \cdot 50\right)\\

\mathbf{elif}\;i \leq 2.35 \cdot 10^{+247}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;i \leq 2.4 \cdot 10^{+295}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if i < -2.5e-32 or 3.8000000000000001e-34 < i < 2.3500000000000001e247

    1. Initial program 52.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 67.3%

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

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

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

    if -2.5e-32 < i < 3.8000000000000001e-34

    1. Initial program 6.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 i around 0 90.3%

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

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

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

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

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

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

    if 2.3500000000000001e247 < i < 2.40000000000000005e295

    1. Initial program 30.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 21.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{0.01 + \color{blue}{i \cdot -0.005}} \]
    10. Simplified62.8%

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot -0.005}} \]

    if 2.40000000000000005e295 < i

    1. Initial program 100.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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2.5 \cdot 10^{-32}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 3.8 \cdot 10^{-34}:\\ \;\;\;\;i \cdot -50 + n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;i \leq 2.35 \cdot 10^{+247}:\\ \;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 2.4 \cdot 10^{+295}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{else}:\\ \;\;\;\;50 \cdot \left(i \cdot n\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 82.6% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;n \leq 10^{-227}:\\
\;\;\;\;0\\

\mathbf{elif}\;n \leq 1.95:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -4.39999999999999973e-220 or 1.94999999999999996 < n

    1. Initial program 25.3%

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

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

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

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

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

        \[\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.4%

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

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

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

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

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

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

      \[\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 37.0%

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

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

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

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

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

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

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

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

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

    if -4.39999999999999973e-220 < n < 9.99999999999999945e-228

    1. Initial program 73.3%

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

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

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

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

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

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

      \[\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 74.1%

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

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

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

      \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
    9. Taylor expanded in i around 0 82.4%

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

    if 9.99999999999999945e-228 < n < 1.94999999999999996

    1. Initial program 15.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.4 \cdot 10^{-220}:\\ \;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\ \mathbf{elif}\;n \leq 10^{-227}:\\ \;\;\;\;0\\ \mathbf{elif}\;n \leq 1.95:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 82.6% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;n \leq 5.8 \cdot 10^{-228}:\\
\;\;\;\;0\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -6.00000000000000059e-222 or 1 < n

    1. Initial program 25.3%

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

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

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

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

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

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

    if -6.00000000000000059e-222 < n < 5.8000000000000002e-228

    1. Initial program 73.3%

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

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

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

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

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

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

      \[\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 74.1%

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

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

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

      \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
    9. Taylor expanded in i around 0 82.4%

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

    if 5.8000000000000002e-228 < n < 1

    1. Initial program 15.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -6 \cdot 10^{-222}:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{elif}\;n \leq 5.8 \cdot 10^{-228}:\\ \;\;\;\;0\\ \mathbf{elif}\;n \leq 1:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 69.3% accurate, 3.5× speedup?

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

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

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

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


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

    1. Initial program 8.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.75e194 < n < 1

    1. Initial program 34.1%

      \[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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]

    if 1 < n

    1. Initial program 25.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 43.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{i \cdot \left(100 \cdot n + i \cdot \left(50 \cdot n + i \cdot \left(4.166666666666667 \cdot \left(i \cdot n\right) + 16.666666666666668 \cdot n\right)\right)\right)}}{i} \]
    9. Taylor expanded in n around 0 82.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.75 \cdot 10^{+194}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq 1:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{i \cdot \left(n \cdot 100 + i \cdot \left(n \cdot 50 + \left(i \cdot n\right) \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 68.9% accurate, 3.7× speedup?

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

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

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

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


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

    1. Initial program 8.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.45000000000000013e194 < n < 1

    1. Initial program 34.1%

      \[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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]

    if 1 < n

    1. Initial program 25.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 43.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.45 \cdot 10^{+194}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq 1:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \mathbf{else}:\\ \;\;\;\;n \cdot 100 + i \cdot \left(n \cdot 50 + i \cdot \left(\left(i \cdot n\right) \cdot 4.166666666666667 + n \cdot 16.666666666666668\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 66.5% accurate, 4.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{-220}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{elif}\;n \leq 3.9 \cdot 10^{-228}:\\ \;\;\;\;0\\ \mathbf{elif}\;n \leq 1.7:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \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 -2.3e-220)
   (/ n (+ 0.01 (* i -0.005)))
   (if (<= n 3.9e-228)
     0.0
     (if (<= n 1.7)
       (* 100.0 (/ i (/ i n)))
       (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))))))
double code(double i, double n) {
	double tmp;
	if (n <= -2.3e-220) {
		tmp = n / (0.01 + (i * -0.005));
	} else if (n <= 3.9e-228) {
		tmp = 0.0;
	} else if (n <= 1.7) {
		tmp = 100.0 * (i / (i / n));
	} 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 <= (-2.3d-220)) then
        tmp = n / (0.01d0 + (i * (-0.005d0)))
    else if (n <= 3.9d-228) then
        tmp = 0.0d0
    else if (n <= 1.7d0) then
        tmp = 100.0d0 * (i / (i / n))
    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 <= -2.3e-220) {
		tmp = n / (0.01 + (i * -0.005));
	} else if (n <= 3.9e-228) {
		tmp = 0.0;
	} else if (n <= 1.7) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -2.3e-220:
		tmp = n / (0.01 + (i * -0.005))
	elif n <= 3.9e-228:
		tmp = 0.0
	elif n <= 1.7:
		tmp = 100.0 * (i / (i / n))
	else:
		tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -2.3e-220)
		tmp = Float64(n / Float64(0.01 + Float64(i * -0.005)));
	elseif (n <= 3.9e-228)
		tmp = 0.0;
	elseif (n <= 1.7)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	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 <= -2.3e-220)
		tmp = n / (0.01 + (i * -0.005));
	elseif (n <= 3.9e-228)
		tmp = 0.0;
	elseif (n <= 1.7)
		tmp = 100.0 * (i / (i / n));
	else
		tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -2.3e-220], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.9e-228], 0.0, If[LessEqual[n, 1.7], N[(100.0 * N[(i / N[(i / n), $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 -2.3 \cdot 10^{-220}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\

\mathbf{elif}\;n \leq 3.9 \cdot 10^{-228}:\\
\;\;\;\;0\\

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

\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 4 regimes
  2. if n < -2.29999999999999981e-220

    1. Initial program 25.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 32.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + -0.005 \cdot i}} \]
    9. Step-by-step derivation
      1. *-commutative63.9%

        \[\leadsto \frac{n}{0.01 + \color{blue}{i \cdot -0.005}} \]
    10. Simplified63.9%

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot -0.005}} \]

    if -2.29999999999999981e-220 < n < 3.90000000000000029e-228

    1. Initial program 73.3%

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

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

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

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

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

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

      \[\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 74.1%

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

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

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

      \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
    9. Taylor expanded in i around 0 82.4%

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

    if 3.90000000000000029e-228 < n < 1.69999999999999996

    1. Initial program 15.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 72.5%

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

    if 1.69999999999999996 < n

    1. Initial program 25.0%

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

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

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

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

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

        \[\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.3%

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

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

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

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

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

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

      \[\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-in43.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{-220}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{elif}\;n \leq 3.9 \cdot 10^{-228}:\\ \;\;\;\;0\\ \mathbf{elif}\;n \leq 1.7:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 66.1% accurate, 4.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.6 \cdot 10^{-219}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\

\mathbf{elif}\;n \leq 2 \cdot 10^{-230}:\\
\;\;\;\;0\\

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

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


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

    1. Initial program 25.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 32.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + -0.005 \cdot i}} \]
    9. Step-by-step derivation
      1. *-commutative63.9%

        \[\leadsto \frac{n}{0.01 + \color{blue}{i \cdot -0.005}} \]
    10. Simplified63.9%

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot -0.005}} \]

    if -9.60000000000000056e-219 < n < 2.00000000000000009e-230

    1. Initial program 73.3%

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

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

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

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

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

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

      \[\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 74.1%

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

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

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

      \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
    9. Taylor expanded in i around 0 82.4%

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

    if 2.00000000000000009e-230 < n < 1.55000000000000004

    1. Initial program 15.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 72.5%

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

    if 1.55000000000000004 < n

    1. Initial program 25.0%

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

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

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

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

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

        \[\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.3%

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

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

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

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

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

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

      \[\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 i around 0 74.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -9.6 \cdot 10^{-219}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{elif}\;n \leq 2 \cdot 10^{-230}:\\ \;\;\;\;0\\ \mathbf{elif}\;n \leq 1.55:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot 50\right)}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 69.0% accurate, 4.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -3.2 \cdot 10^{+194}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq 1:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \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 -3.2e+194)
   (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
   (if (<= n 1.0)
     (/ n (+ 0.01 (* i (- (* i 0.0008333333333333334) 0.005))))
     (*
      n
      (+
       100.0
       (* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667))))))))))
double code(double i, double n) {
	double tmp;
	if (n <= -3.2e+194) {
		tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
	} else if (n <= 1.0) {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	} 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 <= (-3.2d+194)) then
        tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
    else if (n <= 1.0d0) then
        tmp = n / (0.01d0 + (i * ((i * 0.0008333333333333334d0) - 0.005d0)))
    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 <= -3.2e+194) {
		tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
	} else if (n <= 1.0) {
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	} else {
		tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -3.2e+194:
		tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))))
	elif n <= 1.0:
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)))
	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 <= -3.2e+194)
		tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668)))));
	elseif (n <= 1.0)
		tmp = Float64(n / Float64(0.01 + Float64(i * Float64(Float64(i * 0.0008333333333333334) - 0.005))));
	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 <= -3.2e+194)
		tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
	elseif (n <= 1.0)
		tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
	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, -3.2e+194], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.0], N[(n / N[(0.01 + N[(i * N[(N[(i * 0.0008333333333333334), $MachinePrecision] - 0.005), $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 -3.2 \cdot 10^{+194}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\

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

\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 3 regimes
  2. if n < -3.20000000000000021e194

    1. Initial program 8.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.20000000000000021e194 < n < 1

    1. Initial program 34.1%

      \[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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]

    if 1 < n

    1. Initial program 25.0%

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

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

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

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

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

        \[\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.3%

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

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

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

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

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

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

      \[\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-in43.8%

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

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

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

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

      \[\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 + i \cdot \left(16.666666666666668 + 4.166666666666667 \cdot i\right)\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutative81.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. Simplified81.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 3 regimes into one program.
  4. Final simplification71.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.2 \cdot 10^{+194}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq 1:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \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 14: 65.0% accurate, 4.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.7 \cdot 10^{-217}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\

\mathbf{elif}\;n \leq 1.65 \cdot 10^{-229}:\\
\;\;\;\;0\\

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

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


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

    1. Initial program 25.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 32.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + -0.005 \cdot i}} \]
    9. Step-by-step derivation
      1. *-commutative63.9%

        \[\leadsto \frac{n}{0.01 + \color{blue}{i \cdot -0.005}} \]
    10. Simplified63.9%

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot -0.005}} \]

    if -2.70000000000000016e-217 < n < 1.65000000000000011e-229

    1. Initial program 73.3%

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

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

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

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

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

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

      \[\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 74.1%

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

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

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

      \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
    9. Taylor expanded in i around 0 82.4%

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

    if 1.65000000000000011e-229 < n < 1.5

    1. Initial program 15.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 72.5%

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

    if 1.5 < n

    1. Initial program 25.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 43.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.7 \cdot 10^{-217}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{elif}\;n \leq 1.65 \cdot 10^{-229}:\\ \;\;\;\;0\\ \mathbf{elif}\;n \leq 1.5:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 65.0% accurate, 5.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -8 \cdot 10^{-223}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\

\mathbf{elif}\;n \leq 7.5 \cdot 10^{-228}:\\
\;\;\;\;0\\

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

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


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

    1. Initial program 25.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 32.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + -0.005 \cdot i}} \]
    9. Step-by-step derivation
      1. *-commutative63.9%

        \[\leadsto \frac{n}{0.01 + \color{blue}{i \cdot -0.005}} \]
    10. Simplified63.9%

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot -0.005}} \]

    if -7.9999999999999998e-223 < n < 7.4999999999999999e-228

    1. Initial program 73.3%

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

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

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

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

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

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

      \[\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 74.1%

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

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

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

      \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
    9. Taylor expanded in i around 0 82.4%

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

    if 7.4999999999999999e-228 < n < 1.5

    1. Initial program 15.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 72.5%

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

    if 1.5 < n

    1. Initial program 25.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 43.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -8 \cdot 10^{-223}:\\ \;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\ \mathbf{elif}\;n \leq 7.5 \cdot 10^{-228}:\\ \;\;\;\;0\\ \mathbf{elif}\;n \leq 1.5:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 66.9% accurate, 5.4× speedup?

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

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

\mathbf{elif}\;n \leq 0.7:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\

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


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

    1. Initial program 8.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.8000000000000001e194 < n < 0.69999999999999996

    1. Initial program 34.1%

      \[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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]

    if 0.69999999999999996 < n

    1. Initial program 25.0%

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

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

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

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

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

        \[\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.3%

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

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

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

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

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

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

      \[\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 i around 0 74.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.8 \cdot 10^{+194}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq 0.7:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot 50\right)}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 67.9% accurate, 5.4× speedup?

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

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

\mathbf{elif}\;n \leq 0.9:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\

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


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

    1. Initial program 8.9%

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

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

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

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

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg9.6%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in9.6%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval9.6%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval9.6%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval9.6%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define9.6%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval9.6%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified9.6%

      \[\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 48.0%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} - 100}}{i} \]
    6. Step-by-step derivation
      1. sub-neg48.0%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} + \left(-100\right)}}{i} \]
      2. metadata-eval48.0%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval48.0%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in48.0%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \left(e^{i} + -1\right)}}{i} \]
      5. metadata-eval48.0%

        \[\leadsto n \cdot \frac{100 \cdot \left(e^{i} + \color{blue}{\left(-1\right)}\right)}{i} \]
      6. sub-neg48.0%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left(e^{i} - 1\right)}}{i} \]
      7. expm1-define99.7%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{i} \]
    7. Simplified99.7%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{i} \]
    8. Taylor expanded in i around 0 68.7%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + 16.666666666666668 \cdot i\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutative68.7%

        \[\leadsto n \cdot \left(100 + i \cdot \left(50 + \color{blue}{i \cdot 16.666666666666668}\right)\right) \]
    10. Simplified68.7%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)} \]

    if -2.8000000000000001e194 < n < 0.900000000000000022

    1. Initial program 34.1%

      \[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.3%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    4. Step-by-step derivation
      1. *-commutative25.3%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*25.3%

        \[\leadsto \color{blue}{\left(n \cdot \frac{e^{i} - 1}{i}\right)} \cdot 100 \]
      3. expm1-define66.0%

        \[\leadsto \left(n \cdot \frac{\color{blue}{\mathsf{expm1}\left(i\right)}}{i}\right) \cdot 100 \]
    5. Simplified66.0%

      \[\leadsto \color{blue}{\left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right) \cdot 100} \]
    6. Step-by-step derivation
      1. *-commutative66.0%

        \[\leadsto \color{blue}{100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)} \]
      2. *-commutative66.0%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{\mathsf{expm1}\left(i\right)}{i} \cdot n\right)} \]
      3. associate-*r*66.0%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right) \cdot n} \]
      4. associate-/l*65.9%

        \[\leadsto \color{blue}{\frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}} \cdot n \]
      5. *-commutative65.9%

        \[\leadsto \color{blue}{n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}} \]
      6. clear-num65.9%

        \[\leadsto n \cdot \color{blue}{\frac{1}{\frac{i}{100 \cdot \mathsf{expm1}\left(i\right)}}} \]
      7. un-div-inv65.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{i}{100 \cdot \mathsf{expm1}\left(i\right)}}} \]
      8. *-un-lft-identity65.9%

        \[\leadsto \frac{n}{\frac{\color{blue}{1 \cdot i}}{100 \cdot \mathsf{expm1}\left(i\right)}} \]
      9. times-frac66.0%

        \[\leadsto \frac{n}{\color{blue}{\frac{1}{100} \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
      10. metadata-eval66.0%

        \[\leadsto \frac{n}{\color{blue}{0.01} \cdot \frac{i}{\mathsf{expm1}\left(i\right)}} \]
    7. Applied egg-rr66.0%

      \[\leadsto \color{blue}{\frac{n}{0.01 \cdot \frac{i}{\mathsf{expm1}\left(i\right)}}} \]
    8. Taylor expanded in i around 0 67.0%

      \[\leadsto \frac{n}{\color{blue}{0.01 + i \cdot \left(0.0008333333333333334 \cdot i - 0.005\right)}} \]

    if 0.900000000000000022 < n

    1. Initial program 25.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 43.8%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    4. Step-by-step derivation
      1. *-commutative43.8%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*43.8%

        \[\leadsto \color{blue}{\left(n \cdot \frac{e^{i} - 1}{i}\right)} \cdot 100 \]
      3. expm1-define94.4%

        \[\leadsto \left(n \cdot \frac{\color{blue}{\mathsf{expm1}\left(i\right)}}{i}\right) \cdot 100 \]
    5. Simplified94.4%

      \[\leadsto \color{blue}{\left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right) \cdot 100} \]
    6. Step-by-step derivation
      1. *-commutative94.4%

        \[\leadsto \color{blue}{100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)} \]
      2. associate-*r/94.3%

        \[\leadsto 100 \cdot \color{blue}{\frac{n \cdot \mathsf{expm1}\left(i\right)}{i}} \]
      3. associate-*r/94.2%

        \[\leadsto \color{blue}{\frac{100 \cdot \left(n \cdot \mathsf{expm1}\left(i\right)\right)}{i}} \]
    7. Applied egg-rr94.2%

      \[\leadsto \color{blue}{\frac{100 \cdot \left(n \cdot \mathsf{expm1}\left(i\right)\right)}{i}} \]
    8. Taylor expanded in i around 0 77.0%

      \[\leadsto \frac{\color{blue}{i \cdot \left(50 \cdot \left(i \cdot n\right) + 100 \cdot n\right)}}{i} \]
    9. Step-by-step derivation
      1. +-commutative77.0%

        \[\leadsto \frac{i \cdot \color{blue}{\left(100 \cdot n + 50 \cdot \left(i \cdot n\right)\right)}}{i} \]
      2. associate-*r*77.0%

        \[\leadsto \frac{i \cdot \left(100 \cdot n + \color{blue}{\left(50 \cdot i\right) \cdot n}\right)}{i} \]
      3. *-commutative77.0%

        \[\leadsto \frac{i \cdot \left(100 \cdot n + \color{blue}{\left(i \cdot 50\right)} \cdot n\right)}{i} \]
      4. distribute-rgt-out77.0%

        \[\leadsto \frac{i \cdot \color{blue}{\left(n \cdot \left(100 + i \cdot 50\right)\right)}}{i} \]
    10. Simplified77.0%

      \[\leadsto \frac{\color{blue}{i \cdot \left(n \cdot \left(100 + i \cdot 50\right)\right)}}{i} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification70.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.8 \cdot 10^{+194}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq 0.9:\\ \;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{i \cdot \left(n \cdot \left(100 + i \cdot 50\right)\right)}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 62.9% accurate, 6.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -12000 \lor \neg \left(n \leq 1.45\right):\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (or (<= n -12000.0) (not (<= n 1.45)))
   (* n (+ 100.0 (* i 50.0)))
   (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
	double tmp;
	if ((n <= -12000.0) || !(n <= 1.45)) {
		tmp = n * (100.0 + (i * 50.0));
	} else {
		tmp = 100.0 * (i / (i / n));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((n <= (-12000.0d0)) .or. (.not. (n <= 1.45d0))) then
        tmp = n * (100.0d0 + (i * 50.0d0))
    else
        tmp = 100.0d0 * (i / (i / n))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if ((n <= -12000.0) || !(n <= 1.45)) {
		tmp = n * (100.0 + (i * 50.0));
	} else {
		tmp = 100.0 * (i / (i / n));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if (n <= -12000.0) or not (n <= 1.45):
		tmp = n * (100.0 + (i * 50.0))
	else:
		tmp = 100.0 * (i / (i / n))
	return tmp
function code(i, n)
	tmp = 0.0
	if ((n <= -12000.0) || !(n <= 1.45))
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	else
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if ((n <= -12000.0) || ~((n <= 1.45)))
		tmp = n * (100.0 + (i * 50.0));
	else
		tmp = 100.0 * (i / (i / n));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[Or[LessEqual[n, -12000.0], N[Not[LessEqual[n, 1.45]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -12000 \lor \neg \left(n \leq 1.45\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\

\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -12000 or 1.44999999999999996 < n

    1. Initial program 25.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 41.0%

      \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \left(e^{i} - 1\right)}{i}} \]
    4. Step-by-step derivation
      1. *-commutative41.0%

        \[\leadsto \color{blue}{\frac{n \cdot \left(e^{i} - 1\right)}{i} \cdot 100} \]
      2. associate-/l*40.9%

        \[\leadsto \color{blue}{\left(n \cdot \frac{e^{i} - 1}{i}\right)} \cdot 100 \]
      3. expm1-define91.8%

        \[\leadsto \left(n \cdot \frac{\color{blue}{\mathsf{expm1}\left(i\right)}}{i}\right) \cdot 100 \]
    5. Simplified91.8%

      \[\leadsto \color{blue}{\left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right) \cdot 100} \]
    6. Taylor expanded in i around 0 63.4%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]
    7. Step-by-step derivation
      1. +-commutative63.4%

        \[\leadsto \color{blue}{100 \cdot n + 50 \cdot \left(i \cdot n\right)} \]
      2. associate-*r*63.4%

        \[\leadsto 100 \cdot n + \color{blue}{\left(50 \cdot i\right) \cdot n} \]
      3. distribute-rgt-in63.3%

        \[\leadsto \color{blue}{n \cdot \left(100 + 50 \cdot i\right)} \]
      4. *-commutative63.3%

        \[\leadsto n \cdot \left(100 + \color{blue}{i \cdot 50}\right) \]
    8. Simplified63.3%

      \[\leadsto \color{blue}{n \cdot \left(100 + i \cdot 50\right)} \]

    if -12000 < n < 1.44999999999999996

    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 i around 0 67.9%

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -12000 \lor \neg \left(n \leq 1.45\right):\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 59.0% accurate, 8.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -1.45 \cdot 10^{+36}:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 3.5 \cdot 10^{-18}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -1.45e+36) 0.0 (if (<= i 3.5e-18) (* n 100.0) 0.0)))
double code(double i, double n) {
	double tmp;
	if (i <= -1.45e+36) {
		tmp = 0.0;
	} else if (i <= 3.5e-18) {
		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 <= (-1.45d+36)) then
        tmp = 0.0d0
    else if (i <= 3.5d-18) 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 <= -1.45e+36) {
		tmp = 0.0;
	} else if (i <= 3.5e-18) {
		tmp = n * 100.0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= -1.45e+36:
		tmp = 0.0
	elif i <= 3.5e-18:
		tmp = n * 100.0
	else:
		tmp = 0.0
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= -1.45e+36)
		tmp = 0.0;
	elseif (i <= 3.5e-18)
		tmp = Float64(n * 100.0);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= -1.45e+36)
		tmp = 0.0;
	elseif (i <= 3.5e-18)
		tmp = n * 100.0;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, -1.45e+36], 0.0, If[LessEqual[i, 3.5e-18], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.45 \cdot 10^{+36}:\\
\;\;\;\;0\\

\mathbf{elif}\;i \leq 3.5 \cdot 10^{-18}:\\
\;\;\;\;n \cdot 100\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < -1.45e36 or 3.4999999999999999e-18 < i

    1. Initial program 57.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-*r/57.2%

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      2. sub-neg57.2%

        \[\leadsto \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{\frac{i}{n}} \]
      3. distribute-rgt-in57.2%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \left(-1\right) \cdot 100}}{\frac{i}{n}} \]
      4. metadata-eval57.2%

        \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \color{blue}{-1} \cdot 100}{\frac{i}{n}} \]
      5. metadata-eval57.2%

        \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \color{blue}{-100}}{\frac{i}{n}} \]
    3. Simplified57.2%

      \[\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 26.0%

      \[\leadsto \frac{\color{blue}{\left(1 + i\right)} \cdot 100 + -100}{\frac{i}{n}} \]
    6. Step-by-step derivation
      1. +-commutative26.0%

        \[\leadsto \frac{\color{blue}{\left(i + 1\right)} \cdot 100 + -100}{\frac{i}{n}} \]
    7. Simplified26.0%

      \[\leadsto \frac{\color{blue}{\left(i + 1\right)} \cdot 100 + -100}{\frac{i}{n}} \]
    8. Taylor expanded in i around 0 29.1%

      \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
    9. Taylor expanded in i around 0 29.1%

      \[\leadsto \color{blue}{0} \]

    if -1.45e36 < i < 3.4999999999999999e-18

    1. Initial program 7.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 84.2%

      \[\leadsto \color{blue}{100 \cdot n} \]
    4. Step-by-step derivation
      1. *-commutative84.2%

        \[\leadsto \color{blue}{n \cdot 100} \]
    5. Simplified84.2%

      \[\leadsto \color{blue}{n \cdot 100} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -1.45 \cdot 10^{+36}:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 3.5 \cdot 10^{-18}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 17.8% 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 27.8%

    \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
  2. Step-by-step derivation
    1. associate-*r/27.8%

      \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
    2. sub-neg27.8%

      \[\leadsto \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{\frac{i}{n}} \]
    3. distribute-rgt-in27.8%

      \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \left(-1\right) \cdot 100}}{\frac{i}{n}} \]
    4. metadata-eval27.8%

      \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \color{blue}{-1} \cdot 100}{\frac{i}{n}} \]
    5. metadata-eval27.8%

      \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \color{blue}{-100}}{\frac{i}{n}} \]
  3. Simplified27.8%

    \[\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 15.0%

    \[\leadsto \frac{\color{blue}{\left(1 + i\right)} \cdot 100 + -100}{\frac{i}{n}} \]
  6. Step-by-step derivation
    1. +-commutative15.0%

      \[\leadsto \frac{\color{blue}{\left(i + 1\right)} \cdot 100 + -100}{\frac{i}{n}} \]
  7. Simplified15.0%

    \[\leadsto \frac{\color{blue}{\left(i + 1\right)} \cdot 100 + -100}{\frac{i}{n}} \]
  8. Taylor expanded in i around 0 15.6%

    \[\leadsto \frac{\color{blue}{100} + -100}{\frac{i}{n}} \]
  9. Taylor expanded in i around 0 15.9%

    \[\leadsto \color{blue}{0} \]
  10. Final simplification15.9%

    \[\leadsto 0 \]
  11. Add Preprocessing

Developer target: 33.4% 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 2024076 
(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))))