Compound Interest

Percentage Accurate: 28.1% → 99.6%
Time: 38.2s
Alternatives: 25
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 25 alternatives:

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

Initial Program: 28.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.2× speedup?

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

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

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e7 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0

    1. Initial program 20.3%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

Alternative 2: 83.6% accurate, 0.2× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

    1. Initial program 21.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

Alternative 3: 84.1% accurate, 0.2× speedup?

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

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

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000033e-5 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0

    1. Initial program 19.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 40.3%

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

Alternative 4: 97.9% accurate, 0.2× speedup?

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

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

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 17.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

Alternative 5: 98.8% accurate, 0.2× speedup?

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

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

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 17.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

Alternative 6: 83.5% accurate, 0.2× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

    1. Initial program 21.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 81.7% accurate, 0.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -2.8e-213 or 1.7500000000000001e-37 < n

    1. Initial program 29.3%

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

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

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

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

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

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

    if -2.8e-213 < n < 2.69999999999999989e-245

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 2.69999999999999989e-245 < n < 1.7500000000000001e-37

    1. Initial program 3.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.8 \cdot 10^{-213}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 2.7 \cdot 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 1.75 \cdot 10^{-37}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 81.7% accurate, 0.9× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{t\_0}\\


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

    1. Initial program 34.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 34.2%

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

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

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

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

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

    if -5.99999999999999989e-214 < n < 1.9e-245

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 1.9e-245 < n < 2.8000000000000001e-37

    1. Initial program 3.3%

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

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

    if 2.8000000000000001e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -6 \cdot 10^{-214}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 1.9 \cdot 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 81.7% accurate, 0.9× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{t\_0}\\


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

    1. Initial program 34.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 34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.1999999999999997e-213 < n < 3.10000000000000003e-245

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 3.10000000000000003e-245 < n < 5.00000000000000033e-38

    1. Initial program 3.3%

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

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

    if 5.00000000000000033e-38 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.2 \cdot 10^{-213}:\\ \;\;\;\;\frac{1}{\frac{i}{\mathsf{expm1}\left(i\right)} \cdot \frac{0.01}{n}}\\ \mathbf{elif}\;n \leq 3.1 \cdot 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{-38}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 81.6% accurate, 0.9× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{t\_0}\\


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

    1. Initial program 34.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 34.2%

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

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

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

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

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

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

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

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

    if -5.7999999999999997e-214 < n < 2.4e-245

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 2.4e-245 < n < 2.8000000000000001e-37

    1. Initial program 3.3%

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

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

    if 2.8000000000000001e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5.8 \cdot 10^{-214}:\\ \;\;\;\;\frac{1}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n \cdot 100}}\\ \mathbf{elif}\;n \leq 2.4 \cdot 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 75.4% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < -0.00165 or 6.1000000000000003e-12 < i

    1. Initial program 49.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 58.0%

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

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

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

    if -0.00165 < i < 6.1000000000000003e-12

    1. Initial program 7.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 75.4% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 60.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 75.6%

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

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

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

    if -0.00165 < i < 8.59999999999999971e-12

    1. Initial program 7.0%

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

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

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

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

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

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

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

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

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

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

    if 8.59999999999999971e-12 < i

    1. Initial program 42.3%

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

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

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

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

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

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

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

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

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

Alternative 13: 77.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 6.9 \cdot 10^{+118}:\\ \;\;\;\;\frac{1}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n \cdot 100}}\\ \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 6.9e+118)
   (/ 1.0 (/ (/ i (expm1 i)) (* n 100.0)))
   (* 100.0 (/ (+ (pow (/ i n) n) -1.0) (/ i n)))))
double code(double i, double n) {
	double tmp;
	if (i <= 6.9e+118) {
		tmp = 1.0 / ((i / expm1(i)) / (n * 100.0));
	} 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 <= 6.9e+118) {
		tmp = 1.0 / ((i / Math.expm1(i)) / (n * 100.0));
	} else {
		tmp = 100.0 * ((Math.pow((i / n), n) + -1.0) / (i / n));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= 6.9e+118:
		tmp = 1.0 / ((i / math.expm1(i)) / (n * 100.0))
	else:
		tmp = 100.0 * ((math.pow((i / n), n) + -1.0) / (i / n))
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= 6.9e+118)
		tmp = Float64(1.0 / Float64(Float64(i / expm1(i)) / Float64(n * 100.0)));
	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, 6.9e+118], N[(1.0 / N[(N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / N[(n * 100.0), $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 6.9 \cdot 10^{+118}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{\mathsf{expm1}\left(i\right)}}{n \cdot 100}}\\

\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 < 6.90000000000000003e118

    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 31.2%

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

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

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

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

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

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

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

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

    if 6.90000000000000003e118 < i

    1. Initial program 62.4%

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

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

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

Alternative 14: 65.4% accurate, 3.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -3.40000000000000011e251

    1. Initial program 31.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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.40000000000000011e251 < n < -4.9999999999999998e-214

    1. Initial program 34.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 29.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    10. Simplified55.4%

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

    if -4.9999999999999998e-214 < n < 1.1500000000000001e-245

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 1.1500000000000001e-245 < n < 8.2999999999999995e-38

    1. Initial program 3.3%

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

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

    if 8.2999999999999995e-38 < n

    1. Initial program 21.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 78.6%

      \[\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/78.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.4 \cdot 10^{+251}:\\ \;\;\;\;\frac{1}{i} \cdot \left(i \cdot \left(n \cdot 100\right)\right)\\ \mathbf{elif}\;n \leq -5 \cdot 10^{-214}:\\ \;\;\;\;\frac{1}{\frac{1 + i \cdot -0.5}{n \cdot 100}}\\ \mathbf{elif}\;n \leq 1.15 \cdot 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 8.3 \cdot 10^{-38}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(n + i \cdot \left(n \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 65.4% accurate, 3.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -3.40000000000000011e251

    1. Initial program 31.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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.40000000000000011e251 < n < -1.6499999999999999e-214

    1. Initial program 34.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 29.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    10. Simplified55.4%

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

    if -1.6499999999999999e-214 < n < 3.3999999999999999e-245

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 3.3999999999999999e-245 < n < 2.8000000000000001e-37

    1. Initial program 3.3%

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

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

    if 2.8000000000000001e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.4 \cdot 10^{+251}:\\ \;\;\;\;\frac{1}{i} \cdot \left(i \cdot \left(n \cdot 100\right)\right)\\ \mathbf{elif}\;n \leq -1.65 \cdot 10^{-214}:\\ \;\;\;\;\frac{1}{\frac{1 + i \cdot -0.5}{n \cdot 100}}\\ \mathbf{elif}\;n \leq 3.4 \cdot 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 65.4% accurate, 4.2× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -3.40000000000000011e251

    1. Initial program 31.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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.40000000000000011e251 < n < -1.7999999999999999e-216

    1. Initial program 34.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 29.1%

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

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

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

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

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

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

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

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

    if -1.7999999999999999e-216 < n < 9.9999999999999993e-246

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 9.9999999999999993e-246 < n < 2.4999999999999999e-37

    1. Initial program 3.3%

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

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

    if 2.4999999999999999e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.4 \cdot 10^{+251}:\\ \;\;\;\;\frac{1}{i} \cdot \left(i \cdot \left(n \cdot 100\right)\right)\\ \mathbf{elif}\;n \leq -1.8 \cdot 10^{-216}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.5 \cdot 10^{-37}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 65.4% accurate, 4.2× speedup?

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

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

\mathbf{elif}\;n \leq -2.35 \cdot 10^{-213}:\\
\;\;\;\;\frac{1}{\left(1 + i \cdot -0.5\right) \cdot \frac{0.01}{n}}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -3.89999999999999976e251

    1. Initial program 31.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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.89999999999999976e251 < n < -2.35e-213

    1. Initial program 34.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 29.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(1 + -0.5 \cdot i\right)} \cdot \frac{0.01}{n}} \]
    11. Step-by-step derivation
      1. *-commutative54.9%

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

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

    if -2.35e-213 < n < 1.5000000000000001e-245

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 1.5000000000000001e-245 < n < 2.8000000000000001e-37

    1. Initial program 3.3%

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

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

    if 2.8000000000000001e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.9 \cdot 10^{+251}:\\ \;\;\;\;\frac{1}{i} \cdot \left(i \cdot \left(n \cdot 100\right)\right)\\ \mathbf{elif}\;n \leq -2.35 \cdot 10^{-213}:\\ \;\;\;\;\frac{1}{\left(1 + i \cdot -0.5\right) \cdot \frac{0.01}{n}}\\ \mathbf{elif}\;n \leq 1.5 \cdot 10^{-245}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 65.4% accurate, 4.2× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -3.40000000000000011e251

    1. Initial program 31.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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.40000000000000011e251 < n < -1.15e-215

    1. Initial program 34.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 29.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{n}{1 + \color{blue}{i \cdot -0.5}} \cdot 100 \]
    10. Simplified55.4%

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

    if -1.15e-215 < n < 3.3000000000000001e-246

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

    if 3.3000000000000001e-246 < n < 2.8000000000000001e-37

    1. Initial program 3.3%

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

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

    if 2.8000000000000001e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.4 \cdot 10^{+251}:\\ \;\;\;\;\frac{1}{i} \cdot \left(i \cdot \left(n \cdot 100\right)\right)\\ \mathbf{elif}\;n \leq -1.15 \cdot 10^{-215}:\\ \;\;\;\;\frac{1}{\frac{1 + i \cdot -0.5}{n \cdot 100}}\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{-246}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 62.9% accurate, 6.0× speedup?

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

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

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

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


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

    1. Initial program 31.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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.40000000000000011e251 < n < 0.0539999999999999994

    1. Initial program 31.1%

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

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

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

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

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

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

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

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

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

    if 0.0539999999999999994 < n

    1. Initial program 21.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 20: 62.1% accurate, 6.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -4.2 \cdot 10^{+56} \lor \neg \left(n \leq 2.8 \cdot 10^{-37}\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 -4.2e+56) (not (<= n 2.8e-37)))
   (* n (+ 100.0 (* i 50.0)))
   (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
	double tmp;
	if ((n <= -4.2e+56) || !(n <= 2.8e-37)) {
		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 <= (-4.2d+56)) .or. (.not. (n <= 2.8d-37))) 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 <= -4.2e+56) || !(n <= 2.8e-37)) {
		tmp = n * (100.0 + (i * 50.0));
	} else {
		tmp = 100.0 * (i / (i / n));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if (n <= -4.2e+56) or not (n <= 2.8e-37):
		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 <= -4.2e+56) || !(n <= 2.8e-37))
		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 <= -4.2e+56) || ~((n <= 2.8e-37)))
		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, -4.2e+56], N[Not[LessEqual[n, 2.8e-37]], $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 -4.2 \cdot 10^{+56} \lor \neg \left(n \leq 2.8 \cdot 10^{-37}\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 < -4.20000000000000034e56 or 2.8000000000000001e-37 < n

    1. Initial program 26.3%

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

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

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

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

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

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

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

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

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

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

    if -4.20000000000000034e56 < n < 2.8000000000000001e-37

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.2 \cdot 10^{+56} \lor \neg \left(n \leq 2.8 \cdot 10^{-37}\right):\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 62.8% accurate, 6.7× speedup?

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

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

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

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


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

    1. Initial program 31.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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.3e251 < n < 1.45000000000000002e-37

    1. Initial program 31.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 26.7%

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

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

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

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

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

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

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

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

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

    if 1.45000000000000002e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 22: 57.6% accurate, 7.6× speedup?

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

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

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


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

    1. Initial program 60.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 56.8%

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

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

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

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

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

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

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

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

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

    if -2 < i < 1.08e92

    1. Initial program 7.0%

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    5. Simplified72.9%

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

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

Alternative 23: 58.0% accurate, 7.6× speedup?

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

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

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


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

    1. Initial program 60.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 56.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-200 \cdot \frac{n}{i}} \]
    10. Step-by-step derivation
      1. associate-*r/31.1%

        \[\leadsto \color{blue}{\frac{-200 \cdot n}{i}} \]
      2. associate-/l*32.5%

        \[\leadsto \color{blue}{\frac{-200}{\frac{i}{n}}} \]
    11. Simplified32.5%

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

    if -2 < i < 3.99999999999999987e90

    1. Initial program 7.0%

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    5. Simplified72.9%

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

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

Alternative 24: 62.0% accurate, 9.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 2.20000000000000002e-37

    1. Initial program 31.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 30.5%

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

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

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

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

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

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

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

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

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

    if 2.20000000000000002e-37 < n

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 25: 49.0% 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 28.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 45.8%

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

      \[\leadsto \color{blue}{n \cdot 100} \]
  5. Simplified45.8%

    \[\leadsto \color{blue}{n \cdot 100} \]
  6. Final simplification45.8%

    \[\leadsto n \cdot 100 \]
  7. Add Preprocessing

Developer target: 34.5% 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 2024031 
(FPCore (i n)
  :name "Compound Interest"
  :precision binary64

  :herbie-target
  (* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))

  (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))