Compound Interest

Percentage Accurate: 28.1% → 97.2%
Time: 17.9s
Alternatives: 17
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 17 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: 97.2% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\

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


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

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt{\frac{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}{i}}\right)}^{2} \cdot \left(n \cdot 100\right) \]
      8. pow-to-exp26.2%

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

        \[\leadsto {\left(\sqrt{\frac{\mathsf{expm1}\left(\color{blue}{n \cdot \log \left(1 + \frac{i}{n}\right)}\right)}{i}}\right)}^{2} \cdot \left(n \cdot 100\right) \]
      10. log1p-udef98.8%

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

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

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

    1. Initial program 99.9%

      \[100 \cdot \frac{{\left(1 + \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))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 83.5% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\

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


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

    1. Initial program 26.7%

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

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

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

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

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

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

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

    1. Initial program 99.9%

      \[100 \cdot \frac{{\left(1 + \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))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 96.4% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\

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


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

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.9%

      \[100 \cdot \frac{{\left(1 + \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))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\

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


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

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.9%

      \[100 \cdot \frac{{\left(1 + \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))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.2% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\

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


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

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{-i}{n \cdot 100}}} \]
      3. neg-mul-198.6%

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

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

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

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

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

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

    1. Initial program 99.9%

      \[100 \cdot \frac{{\left(1 + \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))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{n}{\color{blue}{1 + i \cdot -0.5}} \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 0:\\ \;\;\;\;\frac{-\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n} \cdot -0.01}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\ \;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \cdot 100\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \end{array} \]

Alternative 6: 85.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -2.9 \cdot 10^{-70} \lor \neg \left(i \leq 9 \cdot 10^{-54}\right):\\
\;\;\;\;\frac{100}{i} \cdot \left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;n \cdot 100 + i \cdot -50\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < -2.89999999999999971e-70 or 8.9999999999999997e-54 < i

    1. Initial program 48.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.89999999999999971e-70 < i < 8.9999999999999997e-54

    1. Initial program 5.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -2.9 \cdot 10^{-70} \lor \neg \left(i \leq 9 \cdot 10^{-54}\right):\\ \;\;\;\;\frac{100}{i} \cdot \left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;n \cdot 100 + i \cdot -50\\ \end{array} \]

Alternative 7: 80.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{if}\;n \leq -3.85 \cdot 10^{-219}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 1.05 \cdot 10^{-208}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 3.7 \cdot 10^{-154}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\ \mathbf{elif}\;n \leq 1.55 \cdot 10^{-152}:\\ \;\;\;\;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 -3.85e-219)
     t_0
     (if (<= n 1.05e-208)
       (* (* n 100.0) (/ 0.0 i))
       (if (<= n 3.7e-154)
         (* (* n 100.0) (/ n (/ i (log (/ i n)))))
         (if (<= n 1.55e-152) (* 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 <= -3.85e-219) {
		tmp = t_0;
	} else if (n <= 1.05e-208) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 3.7e-154) {
		tmp = (n * 100.0) * (n / (i / log((i / n))));
	} else if (n <= 1.55e-152) {
		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 <= -3.85e-219) {
		tmp = t_0;
	} else if (n <= 1.05e-208) {
		tmp = (n * 100.0) * (0.0 / i);
	} else if (n <= 3.7e-154) {
		tmp = (n * 100.0) * (n / (i / Math.log((i / n))));
	} else if (n <= 1.55e-152) {
		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 <= -3.85e-219:
		tmp = t_0
	elif n <= 1.05e-208:
		tmp = (n * 100.0) * (0.0 / i)
	elif n <= 3.7e-154:
		tmp = (n * 100.0) * (n / (i / math.log((i / n))))
	elif n <= 1.55e-152:
		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 <= -3.85e-219)
		tmp = t_0;
	elseif (n <= 1.05e-208)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	elseif (n <= 3.7e-154)
		tmp = Float64(Float64(n * 100.0) * Float64(n / Float64(i / log(Float64(i / n)))));
	elseif (n <= 1.55e-152)
		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, -3.85e-219], t$95$0, If[LessEqual[n, 1.05e-208], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.7e-154], N[(N[(n * 100.0), $MachinePrecision] * N[(n / N[(i / N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.55e-152], 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 -3.85 \cdot 10^{-219}:\\
\;\;\;\;t_0\\

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

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

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

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


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

    1. Initial program 23.3%

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

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

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

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

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

    if -3.85000000000000006e-219 < n < 1.05000000000000006e-208

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

    if 1.05000000000000006e-208 < n < 3.69999999999999987e-154

    1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n}{\frac{i}{\log i - \log n}}} \cdot \left(n \cdot 100\right) \]
    7. Taylor expanded in i around inf 77.6%

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

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

        \[\leadsto \frac{n}{\frac{i}{\left(-\color{blue}{\left(-\log i\right)}\right) - \log n}} \cdot \left(n \cdot 100\right) \]
      3. remove-double-neg77.6%

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

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

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

    if 3.69999999999999987e-154 < n < 1.5499999999999999e-152

    1. Initial program 0.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.85 \cdot 10^{-219}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{elif}\;n \leq 1.05 \cdot 10^{-208}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{elif}\;n \leq 3.7 \cdot 10^{-154}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\ \mathbf{elif}\;n \leq 1.55 \cdot 10^{-152}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]

Alternative 8: 75.5% accurate, 1.0× speedup?

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

\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 2 regimes
  2. if i < -3.0999999999999998e-27 or 6.99999999999999994e-43 < i

    1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{n}{i \cdot 0.01} \cdot \mathsf{expm1}\left(i\right)\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def41.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{n}{i \cdot 0.01} \cdot \mathsf{expm1}\left(i\right)\right)\right)} \]
      2. expm1-log1p64.5%

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

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

    if -3.0999999999999998e-27 < i < 6.99999999999999994e-43

    1. Initial program 6.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -3.1 \cdot 10^{-27} \lor \neg \left(i \leq 7 \cdot 10^{-43}\right):\\ \;\;\;\;\mathsf{expm1}\left(i\right) \cdot \frac{n}{i \cdot 0.01}\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\ \end{array} \]

Alternative 9: 80.9% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -3.85000000000000006e-219 or 9.50000000000000031e-153 < n

    1. Initial program 23.3%

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

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

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

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

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

    if -3.85000000000000006e-219 < n < 9.50000000000000031e-153

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

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

Alternative 10: 63.3% accurate, 6.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -3.85 \cdot 10^{-219}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 9.2 \cdot 10^{-153}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \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.85e-219)
   (* 100.0 (/ n (+ 1.0 (* i -0.5))))
   (if (<= n 9.2e-153)
     (* (* n 100.0) (/ 0.0 i))
     (* 100.0 (+ n (* i (* n (- 0.5 (/ 0.5 n)))))))))
double code(double i, double n) {
	double tmp;
	if (n <= -3.85e-219) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else if (n <= 9.2e-153) {
		tmp = (n * 100.0) * (0.0 / i);
	} 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.85d-219)) then
        tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
    else if (n <= 9.2d-153) then
        tmp = (n * 100.0d0) * (0.0d0 / i)
    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.85e-219) {
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	} else if (n <= 9.2e-153) {
		tmp = (n * 100.0) * (0.0 / i);
	} else {
		tmp = 100.0 * (n + (i * (n * (0.5 - (0.5 / n)))));
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if n <= -3.85e-219:
		tmp = 100.0 * (n / (1.0 + (i * -0.5)))
	elif n <= 9.2e-153:
		tmp = (n * 100.0) * (0.0 / i)
	else:
		tmp = 100.0 * (n + (i * (n * (0.5 - (0.5 / n)))))
	return tmp
function code(i, n)
	tmp = 0.0
	if (n <= -3.85e-219)
		tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5))));
	elseif (n <= 9.2e-153)
		tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i));
	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.85e-219)
		tmp = 100.0 * (n / (1.0 + (i * -0.5)));
	elseif (n <= 9.2e-153)
		tmp = (n * 100.0) * (0.0 / i);
	else
		tmp = 100.0 * (n + (i * (n * (0.5 - (0.5 / n)))));
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[n, -3.85e-219], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 9.2e-153], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $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.85 \cdot 10^{-219}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

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

\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 3 regimes
  2. if n < -3.85000000000000006e-219

    1. Initial program 28.4%

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

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

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

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

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

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

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

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

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

    if -3.85000000000000006e-219 < n < 9.19999999999999988e-153

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

    if 9.19999999999999988e-153 < n

    1. Initial program 17.0%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Taylor expanded in i around 0 72.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)} \]
    3. Step-by-step derivation
      1. associate-*r/72.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-eval72.6%

        \[\leadsto 100 \cdot \left(n + i \cdot \left(n \cdot \left(0.5 - \frac{\color{blue}{0.5}}{n}\right)\right)\right) \]
    4. Simplified72.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 3 regimes into one program.
  4. Final simplification67.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.85 \cdot 10^{-219}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 9.2 \cdot 10^{-153}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(n + i \cdot \left(n \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\ \end{array} \]

Alternative 11: 62.1% accurate, 10.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -4.3 \cdot 10^{+29} \lor \neg \left(n \leq 6 \cdot 10^{-21}\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.3e+29) (not (<= n 6e-21)))
   (* n (+ 100.0 (* i 50.0)))
   (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
	double tmp;
	if ((n <= -4.3e+29) || !(n <= 6e-21)) {
		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.3d+29)) .or. (.not. (n <= 6d-21))) 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.3e+29) || !(n <= 6e-21)) {
		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.3e+29) or not (n <= 6e-21):
		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.3e+29) || !(n <= 6e-21))
		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.3e+29) || ~((n <= 6e-21)))
		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.3e+29], N[Not[LessEqual[n, 6e-21]], $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.3 \cdot 10^{+29} \lor \neg \left(n \leq 6 \cdot 10^{-21}\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.3000000000000003e29 or 5.99999999999999982e-21 < n

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

    if -4.3000000000000003e29 < n < 5.99999999999999982e-21

    1. Initial program 36.4%

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

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

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

Alternative 12: 56.8% accurate, 10.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -5 \cdot 10^{-31}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\

\mathbf{elif}\;i \leq 3.95 \cdot 10^{+146}:\\
\;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\

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


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

    1. Initial program 59.5%

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

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

    if -5e-31 < i < 3.9499999999999999e146

    1. Initial program 11.4%

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

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

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

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

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

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

    if 3.9499999999999999e146 < i

    1. Initial program 63.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt{\frac{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}{i}}\right)}^{2} \cdot \left(n \cdot 100\right) \]
      8. pow-to-exp43.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{6.25 \cdot \frac{{i}^{2}}{n}} \]
    10. Step-by-step derivation
      1. unpow244.2%

        \[\leadsto 6.25 \cdot \frac{\color{blue}{i \cdot i}}{n} \]
    11. Simplified44.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -5 \cdot 10^{-31}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;i \leq 3.95 \cdot 10^{+146}:\\ \;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;6.25 \cdot \frac{i \cdot i}{n}\\ \end{array} \]

Alternative 13: 63.3% accurate, 10.2× speedup?

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

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

\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.85000000000000006e-219

    1. Initial program 28.4%

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

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

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

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

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

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

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

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

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

    if -3.85000000000000006e-219 < n < 8.2e-153

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

    if 8.2e-153 < n

    1. Initial program 17.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.85 \cdot 10^{-219}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 8.2 \cdot 10^{-153}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 14: 61.9% accurate, 10.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 4.8 \cdot 10^{-21}:\\ \;\;\;\;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 4.8e-21)
   (* 100.0 (/ n (+ 1.0 (* i -0.5))))
   (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
	double tmp;
	if (n <= 4.8e-21) {
		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 <= 4.8d-21) 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 <= 4.8e-21) {
		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 <= 4.8e-21:
		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 <= 4.8e-21)
		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 <= 4.8e-21)
		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, 4.8e-21], 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 4.8 \cdot 10^{-21}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 4.7999999999999999e-21

    1. Initial program 30.8%

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

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

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

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

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

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

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

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

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

    if 4.7999999999999999e-21 < n

    1. Initial program 19.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 53.1% accurate, 12.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq 8 \cdot 10^{+146}:\\
\;\;\;\;n \cdot 100\\

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


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

    1. Initial program 22.9%

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified58.8%

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

    if 7.99999999999999947e146 < i

    1. Initial program 63.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\sqrt{\frac{\mathsf{expm1}\left(\color{blue}{\log \left(e^{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}\right)}{i}}\right)}^{2} \cdot \left(n \cdot 100\right) \]
      8. pow-to-exp43.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{6.25 \cdot \frac{{i}^{2}}{n}} \]
    10. Step-by-step derivation
      1. unpow244.2%

        \[\leadsto 6.25 \cdot \frac{\color{blue}{i \cdot i}}{n} \]
    11. Simplified44.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 8 \cdot 10^{+146}:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;6.25 \cdot \frac{i \cdot i}{n}\\ \end{array} \]

Alternative 16: 2.8% accurate, 38.0× speedup?

\[\begin{array}{l} \\ i \cdot -50 \end{array} \]
(FPCore (i n) :precision binary64 (* i -50.0))
double code(double i, double n) {
	return i * -50.0;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = i * (-50.0d0)
end function
public static double code(double i, double n) {
	return i * -50.0;
}
def code(i, n):
	return i * -50.0
function code(i, n)
	return Float64(i * -50.0)
end
function tmp = code(i, n)
	tmp = i * -50.0;
end
code[i_, n_] := N[(i * -50.0), $MachinePrecision]
\begin{array}{l}

\\
i \cdot -50
\end{array}
Derivation
  1. Initial program 27.7%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-50 \cdot i} \]
  7. Step-by-step derivation
    1. *-commutative2.8%

      \[\leadsto \color{blue}{i \cdot -50} \]
  8. Simplified2.8%

    \[\leadsto \color{blue}{i \cdot -50} \]
  9. Final simplification2.8%

    \[\leadsto i \cdot -50 \]

Alternative 17: 48.8% accurate, 38.0× speedup?

\[\begin{array}{l} \\ n \cdot 100 \end{array} \]
(FPCore (i n) :precision binary64 (* n 100.0))
double code(double i, double n) {
	return n * 100.0;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    code = n * 100.0d0
end function
public static double code(double i, double n) {
	return n * 100.0;
}
def code(i, n):
	return n * 100.0
function code(i, n)
	return Float64(n * 100.0)
end
function tmp = code(i, n)
	tmp = n * 100.0;
end
code[i_, n_] := N[(n * 100.0), $MachinePrecision]
\begin{array}{l}

\\
n \cdot 100
\end{array}
Derivation
  1. Initial program 27.7%

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

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

      \[\leadsto \color{blue}{n \cdot 100} \]
  4. Simplified52.5%

    \[\leadsto \color{blue}{n \cdot 100} \]
  5. Final simplification52.5%

    \[\leadsto n \cdot 100 \]

Developer target: 34.3% accurate, 0.5× speedup?

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

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

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


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

Reproduce

?
herbie shell --seed 2023293 
(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))))