Compound Interest

Percentage Accurate: 27.5% → 97.6%
Time: 17.0s
Alternatives: 20
Speedup: 38.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 alternatives:

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

Initial Program: 27.5% 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: 97.6% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 20.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.1% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 20.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.2% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 20.4%

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

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

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

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

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

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

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

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

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 82.4% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 20.4%

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

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

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

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

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

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 82.0% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 20.4%

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

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

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

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

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

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 80.3% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -2.30000000000000003e-213 or 8.20000000000000043e-196 < n

    1. Initial program 22.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.30000000000000003e-213 < n < 8.20000000000000043e-196

    1. Initial program 40.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{-213} \lor \neg \left(n \leq 8.2 \cdot 10^{-196}\right):\\ \;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{\frac{i}{n}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 77.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 18.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.79999999999999963e87 < i

    1. Initial program 57.3%

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

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

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

Alternative 8: 73.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 45.8%

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

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

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

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

    if -1.74999999999999997e-6 < i

    1. Initial program 19.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 2 regimes into one program.
  4. Final simplification73.7%

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

Alternative 9: 68.0% accurate, 3.2× speedup?

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

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

\mathbf{elif}\;n \leq -2.2 \cdot 10^{-213}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\

\mathbf{elif}\;n \leq 3.3 \cdot 10^{-196}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\

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


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

    1. Initial program 8.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.49999999999999959e219 < n < -2.2000000000000001e-213

    1. Initial program 34.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.2000000000000001e-213 < n < 3.29999999999999999e-196

    1. Initial program 40.6%

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

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

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

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

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

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

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

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

    if 3.29999999999999999e-196 < n

    1. Initial program 13.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 4 regimes into one program.
  4. Final simplification69.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -9.5 \cdot 10^{+219}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq -2.2 \cdot 10^{-213}:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{-196}:\\ \;\;\;\;\frac{0}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot 100 + i \cdot \left(n \cdot 50 + i \cdot \left(4.166666666666667 \cdot \left(i \cdot n\right) + n \cdot 16.666666666666668\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 68.0% accurate, 3.8× speedup?

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

\mathbf{elif}\;n \leq -2.3 \cdot 10^{-211}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\

\mathbf{elif}\;n \leq 8.6 \cdot 10^{-196}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\

\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 4 regimes
  2. if n < -7.0000000000000002e219

    1. Initial program 8.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.0000000000000002e219 < n < -2.29999999999999988e-211

    1. Initial program 34.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.29999999999999988e-211 < n < 8.59999999999999959e-196

    1. Initial program 40.6%

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

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

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

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

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

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

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

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

    if 8.59999999999999959e-196 < n

    1. Initial program 13.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 4 regimes into one program.
  4. Final simplification69.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -7 \cdot 10^{+219}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq -2.3 \cdot 10^{-211}:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 8.6 \cdot 10^{-196}:\\ \;\;\;\;\frac{0}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 66.2% accurate, 4.4× speedup?

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

\\
\begin{array}{l}
t_0 := n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{if}\;n \leq -7 \cdot 10^{+219}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;n \leq -5.1 \cdot 10^{-214}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\

\mathbf{elif}\;n \leq 5 \cdot 10^{-196}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -7.0000000000000002e219 or 5.0000000000000005e-196 < n

    1. Initial program 12.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.0000000000000002e219 < n < -5.09999999999999987e-214

    1. Initial program 34.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.09999999999999987e-214 < n < 5.0000000000000005e-196

    1. Initial program 40.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -7 \cdot 10^{+219}:\\ \;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\ \mathbf{elif}\;n \leq -5.1 \cdot 10^{-214}:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{-196}:\\ \;\;\;\;\frac{0}{\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: 64.7% accurate, 4.7× speedup?

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

\\
\begin{array}{l}
t_0 := \left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\mathbf{if}\;n \leq -2.3 \cdot 10^{+221}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;n \leq -1.4 \cdot 10^{-213}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\

\mathbf{elif}\;n \leq 2.7 \cdot 10^{-196}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -2.29999999999999987e221 or 2.69999999999999982e-196 < n

    1. Initial program 12.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 65.8%

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

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

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

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

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

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

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

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

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

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

    if -2.29999999999999987e221 < n < -1.4e-213

    1. Initial program 34.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4e-213 < n < 2.69999999999999982e-196

    1. Initial program 40.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{+221}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \mathbf{elif}\;n \leq -1.4 \cdot 10^{-213}:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 2.7 \cdot 10^{-196}:\\ \;\;\;\;\frac{0}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 62.7% accurate, 5.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq 3.6 \cdot 10^{-165}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\

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

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


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

    1. Initial program 17.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.59999999999999984e-165 < i < 1.95000000000000002e-13

    1. Initial program 23.9%

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

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

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

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

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

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

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

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

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

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

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

    if 1.95000000000000002e-13 < i

    1. Initial program 46.7%

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

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

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

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

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg47.1%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in47.1%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval47.1%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval47.1%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval47.1%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define47.1%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval47.1%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified47.1%

      \[\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 41.9%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} - 100}}{i} \]
    6. Step-by-step derivation
      1. sub-neg41.9%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} + \left(-100\right)}}{i} \]
      2. metadata-eval41.9%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval41.9%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in41.9%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \left(e^{i} + -1\right)}}{i} \]
      5. metadata-eval41.9%

        \[\leadsto n \cdot \frac{100 \cdot \left(e^{i} + \color{blue}{\left(-1\right)}\right)}{i} \]
      6. sub-neg41.9%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left(e^{i} - 1\right)}}{i} \]
      7. expm1-define41.9%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{i} \]
    7. Simplified41.9%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{i} \]
    8. Taylor expanded in i around 0 37.2%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + 16.666666666666668 \cdot i\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutative37.2%

        \[\leadsto n \cdot \left(100 + i \cdot \left(50 + \color{blue}{i \cdot 16.666666666666668}\right)\right) \]
    10. Simplified37.2%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)} \]
    11. Taylor expanded in i around inf 37.2%

      \[\leadsto \color{blue}{16.666666666666668 \cdot \left({i}^{2} \cdot n\right)} \]
    12. Step-by-step derivation
      1. unpow237.2%

        \[\leadsto 16.666666666666668 \cdot \left(\color{blue}{\left(i \cdot i\right)} \cdot n\right) \]
    13. Applied egg-rr37.2%

      \[\leadsto 16.666666666666668 \cdot \left(\color{blue}{\left(i \cdot i\right)} \cdot n\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 3.6 \cdot 10^{-165}:\\ \;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot -0.5}\\ \mathbf{elif}\;i \leq 1.95 \cdot 10^{-13}:\\ \;\;\;\;100 \cdot \left(\frac{1}{i} \cdot \frac{i}{\frac{1}{n}}\right)\\ \mathbf{else}:\\ \;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 61.9% accurate, 6.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1.5 \cdot 10^{-210}:\\ \;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\ \mathbf{elif}\;n \leq 3.1 \cdot 10^{-196}:\\ \;\;\;\;\frac{0}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -1.5e-210)
   (+ (* n 100.0) (* 50.0 (* i n)))
   (if (<= n 3.1e-196) (/ 0.0 (/ i n)) (* (* n 100.0) (+ 1.0 (* i 0.5))))))
double code(double i, double n) {
	double tmp;
	if (n <= -1.5e-210) {
		tmp = (n * 100.0) + (50.0 * (i * n));
	} else if (n <= 3.1e-196) {
		tmp = 0.0 / (i / n);
	} else {
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-1.5d-210)) then
        tmp = (n * 100.0d0) + (50.0d0 * (i * n))
    else if (n <= 3.1d-196) then
        tmp = 0.0d0 / (i / n)
    else
        tmp = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= -1.5e-210) {
		tmp = (n * 100.0) + (50.0 * (i * n));
	} else if (n <= 3.1e-196) {
		tmp = 0.0 / (i / n);
	} else {
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -1.5e-210:
		tmp = (n * 100.0) + (50.0 * (i * n))
	elif n <= 3.1e-196:
		tmp = 0.0 / (i / n)
	else:
		tmp = (n * 100.0) * (1.0 + (i * 0.5))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -1.5e-210)
		tmp = Float64(Float64(n * 100.0) + Float64(50.0 * Float64(i * n)));
	elseif (n <= 3.1e-196)
		tmp = Float64(0.0 / Float64(i / n));
	else
		tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= -1.5e-210)
		tmp = (n * 100.0) + (50.0 * (i * n));
	elseif (n <= 3.1e-196)
		tmp = 0.0 / (i / n);
	else
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -1.5e-210], N[(N[(n * 100.0), $MachinePrecision] + N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.1e-196], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.5 \cdot 10^{-210}:\\
\;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\

\mathbf{elif}\;n \leq 3.1 \cdot 10^{-196}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\

\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -1.5000000000000001e-210

    1. Initial program 29.5%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/29.4%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      2. associate-*r*29.5%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative29.5%

        \[\leadsto \color{blue}{n \cdot \left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)} \]
      4. associate-*r/29.5%

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg29.5%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in29.5%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval29.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval29.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval29.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define29.5%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval29.5%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified29.5%

      \[\leadsto \color{blue}{n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}} \]
    4. Add Preprocessing
    5. Taylor expanded in n around inf 26.4%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} - 100}}{i} \]
    6. Step-by-step derivation
      1. sub-neg26.4%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} + \left(-100\right)}}{i} \]
      2. metadata-eval26.4%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval26.4%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in26.4%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \left(e^{i} + -1\right)}}{i} \]
      5. metadata-eval26.4%

        \[\leadsto n \cdot \frac{100 \cdot \left(e^{i} + \color{blue}{\left(-1\right)}\right)}{i} \]
      6. sub-neg26.4%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left(e^{i} - 1\right)}}{i} \]
      7. expm1-define78.0%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{i} \]
    7. Simplified78.0%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{i} \]
    8. Taylor expanded in i around 0 59.4%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]

    if -1.5000000000000001e-210 < n < 3.09999999999999993e-196

    1. Initial program 40.6%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-*r/40.6%

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      2. sub-neg40.6%

        \[\leadsto \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{\frac{i}{n}} \]
      3. distribute-rgt-in40.6%

        \[\leadsto \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \left(-1\right) \cdot 100}}{\frac{i}{n}} \]
      4. metadata-eval40.6%

        \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \color{blue}{-1} \cdot 100}{\frac{i}{n}} \]
      5. metadata-eval40.6%

        \[\leadsto \frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \color{blue}{-100}}{\frac{i}{n}} \]
    3. Simplified40.6%

      \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + -100}{\frac{i}{n}}} \]
    4. Add Preprocessing
    5. Taylor expanded in i around 0 72.8%

      \[\leadsto \frac{\color{blue}{1} \cdot 100 + -100}{\frac{i}{n}} \]

    if 3.09999999999999993e-196 < n

    1. Initial program 13.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 62.4%

      \[\leadsto 100 \cdot \color{blue}{\left(n + i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*62.4%

        \[\leadsto 100 \cdot \left(n + \color{blue}{\left(i \cdot n\right) \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}\right) \]
      2. *-commutative62.4%

        \[\leadsto 100 \cdot \left(n + \color{blue}{\left(n \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right) \]
      3. associate-*r/62.4%

        \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \]
      4. metadata-eval62.4%

        \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \]
    5. Simplified62.4%

      \[\leadsto 100 \cdot \color{blue}{\left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \]
    6. Taylor expanded in n around inf 62.6%

      \[\leadsto \color{blue}{100 \cdot \left(n \cdot \left(1 + 0.5 \cdot i\right)\right)} \]
    7. Step-by-step derivation
      1. associate-*r*62.6%

        \[\leadsto \color{blue}{\left(100 \cdot n\right) \cdot \left(1 + 0.5 \cdot i\right)} \]
      2. *-commutative62.6%

        \[\leadsto \left(100 \cdot n\right) \cdot \left(1 + \color{blue}{i \cdot 0.5}\right) \]
    8. Simplified62.6%

      \[\leadsto \color{blue}{\left(100 \cdot n\right) \cdot \left(1 + i \cdot 0.5\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification62.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.5 \cdot 10^{-210}:\\ \;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\ \mathbf{elif}\;n \leq 3.1 \cdot 10^{-196}:\\ \;\;\;\;\frac{0}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 62.7% accurate, 6.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{+31}:\\ \;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\ \mathbf{elif}\;n \leq 1.5:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -2.3e+31)
   (+ (* n 100.0) (* 50.0 (* i n)))
   (if (<= n 1.5) (* 100.0 (/ i (/ i n))) (* (* n 100.0) (+ 1.0 (* i 0.5))))))
double code(double i, double n) {
	double tmp;
	if (n <= -2.3e+31) {
		tmp = (n * 100.0) + (50.0 * (i * n));
	} else if (n <= 1.5) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-2.3d+31)) then
        tmp = (n * 100.0d0) + (50.0d0 * (i * n))
    else if (n <= 1.5d0) then
        tmp = 100.0d0 * (i / (i / n))
    else
        tmp = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= -2.3e+31) {
		tmp = (n * 100.0) + (50.0 * (i * n));
	} else if (n <= 1.5) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -2.3e+31:
		tmp = (n * 100.0) + (50.0 * (i * n))
	elif n <= 1.5:
		tmp = 100.0 * (i / (i / n))
	else:
		tmp = (n * 100.0) * (1.0 + (i * 0.5))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -2.3e+31)
		tmp = Float64(Float64(n * 100.0) + Float64(50.0 * Float64(i * n)));
	elseif (n <= 1.5)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	else
		tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= -2.3e+31)
		tmp = (n * 100.0) + (50.0 * (i * n));
	elseif (n <= 1.5)
		tmp = 100.0 * (i / (i / n));
	else
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -2.3e+31], N[(N[(n * 100.0), $MachinePrecision] + N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.5], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.3 \cdot 10^{+31}:\\
\;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\

\mathbf{elif}\;n \leq 1.5:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -2.3e31

    1. Initial program 30.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/31.4%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      2. associate-*r*31.5%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative31.5%

        \[\leadsto \color{blue}{n \cdot \left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)} \]
      4. associate-*r/31.5%

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg31.5%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in31.5%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define31.5%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval31.5%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified31.5%

      \[\leadsto \color{blue}{n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}} \]
    4. Add Preprocessing
    5. Taylor expanded in n around inf 31.5%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} - 100}}{i} \]
    6. Step-by-step derivation
      1. sub-neg31.5%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} + \left(-100\right)}}{i} \]
      2. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in31.4%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \left(e^{i} + -1\right)}}{i} \]
      5. metadata-eval31.4%

        \[\leadsto n \cdot \frac{100 \cdot \left(e^{i} + \color{blue}{\left(-1\right)}\right)}{i} \]
      6. sub-neg31.4%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left(e^{i} - 1\right)}}{i} \]
      7. expm1-define79.5%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{i} \]
    7. Simplified79.5%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{i} \]
    8. Taylor expanded in i around 0 58.0%

      \[\leadsto \color{blue}{50 \cdot \left(i \cdot n\right) + 100 \cdot n} \]

    if -2.3e31 < n < 1.5

    1. Initial program 25.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 63.3%

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]

    if 1.5 < n

    1. Initial program 15.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 62.9%

      \[\leadsto 100 \cdot \color{blue}{\left(n + i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*62.9%

        \[\leadsto 100 \cdot \left(n + \color{blue}{\left(i \cdot n\right) \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}\right) \]
      2. *-commutative62.9%

        \[\leadsto 100 \cdot \left(n + \color{blue}{\left(n \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right) \]
      3. associate-*r/62.9%

        \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \]
      4. metadata-eval62.9%

        \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \]
    5. Simplified62.9%

      \[\leadsto 100 \cdot \color{blue}{\left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \]
    6. Taylor expanded in n around inf 62.9%

      \[\leadsto \color{blue}{100 \cdot \left(n \cdot \left(1 + 0.5 \cdot i\right)\right)} \]
    7. Step-by-step derivation
      1. associate-*r*62.9%

        \[\leadsto \color{blue}{\left(100 \cdot n\right) \cdot \left(1 + 0.5 \cdot i\right)} \]
      2. *-commutative62.9%

        \[\leadsto \left(100 \cdot n\right) \cdot \left(1 + \color{blue}{i \cdot 0.5}\right) \]
    8. Simplified62.9%

      \[\leadsto \color{blue}{\left(100 \cdot n\right) \cdot \left(1 + i \cdot 0.5\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification61.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.3 \cdot 10^{+31}:\\ \;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\ \mathbf{elif}\;n \leq 1.5:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 62.7% accurate, 6.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -4.65 \cdot 10^{+30}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq 1.5:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= n -4.65e+30)
   (* n (+ 100.0 (* i 50.0)))
   (if (<= n 1.5) (* 100.0 (/ i (/ i n))) (* (* n 100.0) (+ 1.0 (* i 0.5))))))
double code(double i, double n) {
	double tmp;
	if (n <= -4.65e+30) {
		tmp = n * (100.0 + (i * 50.0));
	} else if (n <= 1.5) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-4.65d+30)) then
        tmp = n * (100.0d0 + (i * 50.0d0))
    else if (n <= 1.5d0) then
        tmp = 100.0d0 * (i / (i / n))
    else
        tmp = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (n <= -4.65e+30) {
		tmp = n * (100.0 + (i * 50.0));
	} else if (n <= 1.5) {
		tmp = 100.0 * (i / (i / n));
	} else {
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -4.65e+30:
		tmp = n * (100.0 + (i * 50.0))
	elif n <= 1.5:
		tmp = 100.0 * (i / (i / n))
	else:
		tmp = (n * 100.0) * (1.0 + (i * 0.5))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -4.65e+30)
		tmp = Float64(n * Float64(100.0 + Float64(i * 50.0)));
	elseif (n <= 1.5)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	else
		tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (n <= -4.65e+30)
		tmp = n * (100.0 + (i * 50.0));
	elseif (n <= 1.5)
		tmp = 100.0 * (i / (i / n));
	else
		tmp = (n * 100.0) * (1.0 + (i * 0.5));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -4.65e+30], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.5], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -4.65 \cdot 10^{+30}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\

\mathbf{elif}\;n \leq 1.5:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -4.65000000000000019e30

    1. Initial program 30.9%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/31.4%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      2. associate-*r*31.5%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative31.5%

        \[\leadsto \color{blue}{n \cdot \left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)} \]
      4. associate-*r/31.5%

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg31.5%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in31.5%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define31.5%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval31.5%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified31.5%

      \[\leadsto \color{blue}{n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i}} \]
    4. Add Preprocessing
    5. Taylor expanded in n around inf 31.5%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} - 100}}{i} \]
    6. Step-by-step derivation
      1. sub-neg31.5%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} + \left(-100\right)}}{i} \]
      2. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval31.5%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in31.4%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \left(e^{i} + -1\right)}}{i} \]
      5. metadata-eval31.4%

        \[\leadsto n \cdot \frac{100 \cdot \left(e^{i} + \color{blue}{\left(-1\right)}\right)}{i} \]
      6. sub-neg31.4%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left(e^{i} - 1\right)}}{i} \]
      7. expm1-define79.5%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{i} \]
    7. Simplified79.5%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{i} \]
    8. Taylor expanded in i around 0 58.0%

      \[\leadsto n \cdot \color{blue}{\left(100 + 50 \cdot i\right)} \]
    9. Step-by-step derivation
      1. *-commutative58.0%

        \[\leadsto n \cdot \left(100 + \color{blue}{i \cdot 50}\right) \]
    10. Simplified58.0%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot 50\right)} \]

    if -4.65000000000000019e30 < n < 1.5

    1. Initial program 25.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 63.3%

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]

    if 1.5 < n

    1. Initial program 15.4%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 62.9%

      \[\leadsto 100 \cdot \color{blue}{\left(n + i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*62.9%

        \[\leadsto 100 \cdot \left(n + \color{blue}{\left(i \cdot n\right) \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}\right) \]
      2. *-commutative62.9%

        \[\leadsto 100 \cdot \left(n + \color{blue}{\left(n \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right) \]
      3. associate-*r/62.9%

        \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \]
      4. metadata-eval62.9%

        \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \]
    5. Simplified62.9%

      \[\leadsto 100 \cdot \color{blue}{\left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \]
    6. Taylor expanded in n around inf 62.9%

      \[\leadsto \color{blue}{100 \cdot \left(n \cdot \left(1 + 0.5 \cdot i\right)\right)} \]
    7. Step-by-step derivation
      1. associate-*r*62.9%

        \[\leadsto \color{blue}{\left(100 \cdot n\right) \cdot \left(1 + 0.5 \cdot i\right)} \]
      2. *-commutative62.9%

        \[\leadsto \left(100 \cdot n\right) \cdot \left(1 + \color{blue}{i \cdot 0.5}\right) \]
    8. Simplified62.9%

      \[\leadsto \color{blue}{\left(100 \cdot n\right) \cdot \left(1 + i \cdot 0.5\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification61.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.65 \cdot 10^{+30}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq 1.5:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 62.7% accurate, 6.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -3.6 \cdot 10^{+30} \lor \neg \left(n \leq 1.5\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 -3.6e+30) (not (<= n 1.5)))
   (* n (+ 100.0 (* i 50.0)))
   (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
	double tmp;
	if ((n <= -3.6e+30) || !(n <= 1.5)) {
		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 <= (-3.6d+30)) .or. (.not. (n <= 1.5d0))) 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 <= -3.6e+30) || !(n <= 1.5)) {
		tmp = n * (100.0 + (i * 50.0));
	} else {
		tmp = 100.0 * (i / (i / n));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if (n <= -3.6e+30) or not (n <= 1.5):
		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 <= -3.6e+30) || !(n <= 1.5))
		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 <= -3.6e+30) || ~((n <= 1.5)))
		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, -3.6e+30], N[Not[LessEqual[n, 1.5]], $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 -3.6 \cdot 10^{+30} \lor \neg \left(n \leq 1.5\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 < -3.6000000000000002e30 or 1.5 < n

    1. Initial program 24.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/24.5%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      2. associate-*r*24.6%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative24.6%

        \[\leadsto \color{blue}{n \cdot \left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)} \]
      4. associate-*r/24.6%

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg24.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-in24.6%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval24.6%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval24.6%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval24.6%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define24.6%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval24.6%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified24.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 39.1%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} - 100}}{i} \]
    6. Step-by-step derivation
      1. sub-neg39.1%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} + \left(-100\right)}}{i} \]
      2. metadata-eval39.1%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval39.1%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in39.0%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \left(e^{i} + -1\right)}}{i} \]
      5. metadata-eval39.0%

        \[\leadsto n \cdot \frac{100 \cdot \left(e^{i} + \color{blue}{\left(-1\right)}\right)}{i} \]
      6. sub-neg39.0%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left(e^{i} - 1\right)}}{i} \]
      7. expm1-define87.8%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{i} \]
    7. Simplified87.8%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{i} \]
    8. Taylor expanded in i around 0 60.1%

      \[\leadsto n \cdot \color{blue}{\left(100 + 50 \cdot i\right)} \]
    9. Step-by-step derivation
      1. *-commutative60.1%

        \[\leadsto n \cdot \left(100 + \color{blue}{i \cdot 50}\right) \]
    10. Simplified60.1%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot 50\right)} \]

    if -3.6000000000000002e30 < n < 1.5

    1. Initial program 25.1%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 63.3%

      \[\leadsto 100 \cdot \frac{\color{blue}{i}}{\frac{i}{n}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.6 \cdot 10^{+30} \lor \neg \left(n \leq 1.5\right):\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 57.1% accurate, 9.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 1.95 \cdot 10^{-13}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i 1.95e-13) (* n 100.0) (* 16.666666666666668 (* n (* i i)))))
double code(double i, double n) {
	double tmp;
	if (i <= 1.95e-13) {
		tmp = n * 100.0;
	} else {
		tmp = 16.666666666666668 * (n * (i * i));
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (i <= 1.95d-13) then
        tmp = n * 100.0d0
    else
        tmp = 16.666666666666668d0 * (n * (i * i))
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (i <= 1.95e-13) {
		tmp = n * 100.0;
	} else {
		tmp = 16.666666666666668 * (n * (i * i));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= 1.95e-13:
		tmp = n * 100.0
	else:
		tmp = 16.666666666666668 * (n * (i * i))
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= 1.95e-13)
		tmp = Float64(n * 100.0);
	else
		tmp = Float64(16.666666666666668 * Float64(n * Float64(i * i)));
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= 1.95e-13)
		tmp = n * 100.0;
	else
		tmp = 16.666666666666668 * (n * (i * i));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, 1.95e-13], N[(n * 100.0), $MachinePrecision], N[(16.666666666666668 * N[(n * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 1.95 \cdot 10^{-13}:\\
\;\;\;\;n \cdot 100\\

\mathbf{else}:\\
\;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < 1.95000000000000002e-13

    1. Initial program 18.3%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. 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.4%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative18.4%

        \[\leadsto \color{blue}{n \cdot \left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)} \]
      4. associate-*r/18.4%

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg18.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-in18.4%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval18.4%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval18.4%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval18.4%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define18.4%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval18.4%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified18.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 i around 0 65.1%

      \[\leadsto \color{blue}{100 \cdot n} \]
    6. Step-by-step derivation
      1. *-commutative65.1%

        \[\leadsto \color{blue}{n \cdot 100} \]
    7. Simplified65.1%

      \[\leadsto \color{blue}{n \cdot 100} \]

    if 1.95000000000000002e-13 < i

    1. Initial program 46.7%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Step-by-step derivation
      1. associate-/r/47.1%

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      2. associate-*r*47.1%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
      3. *-commutative47.1%

        \[\leadsto \color{blue}{n \cdot \left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)} \]
      4. associate-*r/47.1%

        \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
      5. sub-neg47.1%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
      6. distribute-lft-in47.1%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
      7. metadata-eval47.1%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
      8. metadata-eval47.1%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
      9. metadata-eval47.1%

        \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
      10. fma-define47.1%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
      11. metadata-eval47.1%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
    3. Simplified47.1%

      \[\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 41.9%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} - 100}}{i} \]
    6. Step-by-step derivation
      1. sub-neg41.9%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot e^{i} + \left(-100\right)}}{i} \]
      2. metadata-eval41.9%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{-100}}{i} \]
      3. metadata-eval41.9%

        \[\leadsto n \cdot \frac{100 \cdot e^{i} + \color{blue}{100 \cdot -1}}{i} \]
      4. distribute-lft-in41.9%

        \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \left(e^{i} + -1\right)}}{i} \]
      5. metadata-eval41.9%

        \[\leadsto n \cdot \frac{100 \cdot \left(e^{i} + \color{blue}{\left(-1\right)}\right)}{i} \]
      6. sub-neg41.9%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left(e^{i} - 1\right)}}{i} \]
      7. expm1-define41.9%

        \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(i\right)}}{i} \]
    7. Simplified41.9%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot \mathsf{expm1}\left(i\right)}}{i} \]
    8. Taylor expanded in i around 0 37.2%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + 16.666666666666668 \cdot i\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutative37.2%

        \[\leadsto n \cdot \left(100 + i \cdot \left(50 + \color{blue}{i \cdot 16.666666666666668}\right)\right) \]
    10. Simplified37.2%

      \[\leadsto n \cdot \color{blue}{\left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)} \]
    11. Taylor expanded in i around inf 37.2%

      \[\leadsto \color{blue}{16.666666666666668 \cdot \left({i}^{2} \cdot n\right)} \]
    12. Step-by-step derivation
      1. unpow237.2%

        \[\leadsto 16.666666666666668 \cdot \left(\color{blue}{\left(i \cdot i\right)} \cdot n\right) \]
    13. Applied egg-rr37.2%

      \[\leadsto 16.666666666666668 \cdot \left(\color{blue}{\left(i \cdot i\right)} \cdot n\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 1.95 \cdot 10^{-13}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 49.8% accurate, 38.0× speedup?

\[\begin{array}{l} \\ n \cdot 100 \end{array} \]
(FPCore (i n) :precision binary64 (* n 100.0))
double code(double i, double n) {
	return n * 100.0;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = n * 100.0d0
end function
public static double code(double i, double n) {
	return n * 100.0;
}
def code(i, n):
	return n * 100.0
function code(i, n)
	return Float64(n * 100.0)
end
function tmp = code(i, n)
	tmp = n * 100.0;
end
code[i_, n_] := N[(n * 100.0), $MachinePrecision]
\begin{array}{l}

\\
n \cdot 100
\end{array}
Derivation
  1. Initial program 24.5%

    \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
  2. Step-by-step derivation
    1. associate-/r/24.6%

      \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
    2. associate-*r*24.7%

      \[\leadsto \color{blue}{\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n} \]
    3. *-commutative24.7%

      \[\leadsto \color{blue}{n \cdot \left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)} \]
    4. associate-*r/24.7%

      \[\leadsto n \cdot \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}} \]
    5. sub-neg24.7%

      \[\leadsto n \cdot \frac{100 \cdot \color{blue}{\left({\left(1 + \frac{i}{n}\right)}^{n} + \left(-1\right)\right)}}{i} \]
    6. distribute-lft-in24.6%

      \[\leadsto n \cdot \frac{\color{blue}{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \left(-1\right)}}{i} \]
    7. metadata-eval24.6%

      \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + 100 \cdot \color{blue}{-1}}{i} \]
    8. metadata-eval24.6%

      \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{-100}}{i} \]
    9. metadata-eval24.6%

      \[\leadsto n \cdot \frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \color{blue}{\left(-100\right)}}{i} \]
    10. fma-define24.7%

      \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}}{i} \]
    11. metadata-eval24.7%

      \[\leadsto n \cdot \frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, \color{blue}{-100}\right)}{i} \]
  3. Simplified24.7%

    \[\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 51.9%

    \[\leadsto \color{blue}{100 \cdot n} \]
  6. Step-by-step derivation
    1. *-commutative51.9%

      \[\leadsto \color{blue}{n \cdot 100} \]
  7. Simplified51.9%

    \[\leadsto \color{blue}{n \cdot 100} \]
  8. Add Preprocessing

Alternative 20: 2.8% accurate, 38.0× speedup?

\[\begin{array}{l} \\ i \cdot -50 \end{array} \]
(FPCore (i n) :precision binary64 (* i -50.0))
double code(double i, double n) {
	return i * -50.0;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = i * (-50.0d0)
end function
public static double code(double i, double n) {
	return i * -50.0;
}
def code(i, n):
	return i * -50.0
function code(i, n)
	return Float64(i * -50.0)
end
function tmp = code(i, n)
	tmp = i * -50.0;
end
code[i_, n_] := N[(i * -50.0), $MachinePrecision]
\begin{array}{l}

\\
i \cdot -50
\end{array}
Derivation
  1. Initial program 24.5%

    \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
  2. Add Preprocessing
  3. Taylor expanded in i around 0 55.5%

    \[\leadsto 100 \cdot \color{blue}{\left(n + i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)} \]
  4. Step-by-step derivation
    1. associate-*r*55.4%

      \[\leadsto 100 \cdot \left(n + \color{blue}{\left(i \cdot n\right) \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)}\right) \]
    2. *-commutative55.4%

      \[\leadsto 100 \cdot \left(n + \color{blue}{\left(n \cdot i\right)} \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right) \]
    3. associate-*r/55.4%

      \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \color{blue}{\frac{0.5 \cdot 1}{n}}\right)\right) \]
    4. metadata-eval55.4%

      \[\leadsto 100 \cdot \left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right) \]
  5. Simplified55.4%

    \[\leadsto 100 \cdot \color{blue}{\left(n + \left(n \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)} \]
  6. Taylor expanded in n around 0 3.0%

    \[\leadsto \color{blue}{-50 \cdot i} \]
  7. Step-by-step derivation
    1. *-commutative3.0%

      \[\leadsto \color{blue}{i \cdot -50} \]
  8. Simplified3.0%

    \[\leadsto \color{blue}{i \cdot -50} \]
  9. Add Preprocessing

Developer Target 1: 34.1% 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 2024144 
(FPCore (i n)
  :name "Compound Interest"
  :precision binary64

  :alt
  (! :herbie-platform default (let ((lnbase (if (== (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) (* 100 (/ (- (exp (* n lnbase)) 1) (/ i n)))))

  (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))