Compound Interest

Percentage Accurate: 27.9% → 98.1%
Time: 18.5s
Alternatives: 15
Speedup: 16.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 15 alternatives:

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

Initial Program: 27.9% accurate, 1.0× speedup?

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

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

Alternative 1: 98.1% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 24.9%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

Alternative 2: 84.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 -1 \cdot 10^{-305}:\\ \;\;\;\;n \cdot \frac{-100 + 100 \cdot {\left(\frac{i}{n}\right)}^{n}}{i}\\ \mathbf{elif}\;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 -1e-305)
     (* n (/ (+ -100.0 (* 100.0 (pow (/ i n) n))) i))
     (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 <= -1e-305) {
		tmp = n * ((-100.0 + (100.0 * pow((i / n), n))) / i);
	} else 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 <= -1e-305) {
		tmp = n * ((-100.0 + (100.0 * Math.pow((i / n), n))) / i);
	} else 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 <= -1e-305:
		tmp = n * ((-100.0 + (100.0 * math.pow((i / n), n))) / i)
	elif 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 <= -1e-305)
		tmp = Float64(n * Float64(Float64(-100.0 + Float64(100.0 * (Float64(i / n) ^ n))) / i));
	elseif (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, -1e-305], N[(n * N[(N[(-100.0 + N[(100.0 * N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $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 -1 \cdot 10^{-305}:\\
\;\;\;\;n \cdot \frac{-100 + 100 \cdot {\left(\frac{i}{n}\right)}^{n}}{i}\\

\mathbf{elif}\;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 4 regimes
  2. if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -9.99999999999999996e-306

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999996e-306 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0

    1. Initial program 18.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq -1 \cdot 10^{-305}:\\ \;\;\;\;n \cdot \frac{-100 + 100 \cdot {\left(\frac{i}{n}\right)}^{n}}{i}\\ \mathbf{elif}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq 0:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(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: 84.5% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{-100 + t_0 \cdot 100}{i}\\

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


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

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999996e-306 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0

    1. Initial program 18.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

Alternative 4: 84.8% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{-100 + t_0 \cdot 100}{i}\\

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


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

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

    if -9.99999999999999996e-306 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0

    1. Initial program 18.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

Alternative 5: 98.1% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{-100 + t_0 \cdot 100}{i}\\

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


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

    1. Initial program 24.9%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

Alternative 6: 84.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.20000000000000003e-4 or 0.0060000000000000001 < n

    1. Initial program 25.0%

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

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

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

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

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

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

    if -1.20000000000000003e-4 < n < 0.0060000000000000001

    1. Initial program 32.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -0.00012 \lor \neg \left(n \leq 0.006\right):\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{n \cdot \left(n \cdot 10000\right)}{n \cdot 100 - 100 \cdot \left(n \cdot \left(i \cdot \left(0.5 + \frac{-0.5}{n}\right)\right)\right)}\\ \end{array} \]

Alternative 7: 84.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;n \leq 0.006:\\
\;\;\;\;\frac{n \cdot \left(n \cdot 10000\right)}{n \cdot 100 - 100 \cdot \left(n \cdot \left(i \cdot \left(0.5 + \frac{-0.5}{n}\right)\right)\right)}\\

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


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

    1. Initial program 21.8%

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

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

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

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

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

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

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

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

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

    if -5.8e-4 < n < 0.0060000000000000001

    1. Initial program 32.8%

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

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

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

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

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

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

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

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

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

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

    if 0.0060000000000000001 < n

    1. Initial program 28.9%

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

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

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

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

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

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

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

Alternative 8: 69.9% accurate, 3.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.6 \cdot 10^{+121} \lor \neg \left(n \leq 0.006\right):\\
\;\;\;\;100 \cdot \left(n + n \cdot \left(\left(i \cdot i\right) \cdot \left(\frac{0.3333333333333333}{n \cdot n} + \left(0.16666666666666666 - \frac{0.5}{n}\right)\right) + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -6.59999999999999958e121 or 0.0060000000000000001 < n

    1. Initial program 22.5%

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

      \[\leadsto 100 \cdot \color{blue}{\left(n + \left(n \cdot \left({i}^{2} \cdot \left(\left(0.3333333333333333 \cdot \frac{1}{{n}^{2}} + 0.16666666666666666\right) - 0.5 \cdot \frac{1}{n}\right)\right) + n \cdot \left(i \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right)\right)} \]
    3. Step-by-step derivation
      1. distribute-lft-out79.8%

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

        \[\leadsto 100 \cdot \left(n + n \cdot \left(\color{blue}{\left(i \cdot i\right)} \cdot \left(\left(0.3333333333333333 \cdot \frac{1}{{n}^{2}} + 0.16666666666666666\right) - 0.5 \cdot \frac{1}{n}\right) + i \cdot \left(0.5 - 0.5 \cdot \frac{1}{n}\right)\right)\right) \]
      3. associate--l+79.8%

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

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

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

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

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

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

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

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

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

    if -6.59999999999999958e121 < n < 0.0060000000000000001

    1. Initial program 32.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -6.6 \cdot 10^{+121} \lor \neg \left(n \leq 0.006\right):\\ \;\;\;\;100 \cdot \left(n + n \cdot \left(\left(i \cdot i\right) \cdot \left(\frac{0.3333333333333333}{n \cdot n} + \left(0.16666666666666666 - \frac{0.5}{n}\right)\right) + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{100}{\frac{1}{n} + i \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)}\\ \end{array} \]

Alternative 9: 67.7% accurate, 6.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq 500:\\
\;\;\;\;\frac{100}{\frac{1}{n} + i \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)}\\

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


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

    1. Initial program 27.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 500 < n

    1. Initial program 29.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(10000 - 2500 \cdot {i}^{2}\right)}{100 - 50 \cdot i}} \]
    6. Step-by-step derivation
      1. associate-/l*76.9%

        \[\leadsto \color{blue}{\frac{n}{\frac{100 - 50 \cdot i}{10000 - 2500 \cdot {i}^{2}}}} \]
      2. *-commutative76.9%

        \[\leadsto \frac{n}{\frac{100 - \color{blue}{i \cdot 50}}{10000 - 2500 \cdot {i}^{2}}} \]
      3. *-commutative76.9%

        \[\leadsto \frac{n}{\frac{100 - i \cdot 50}{10000 - \color{blue}{{i}^{2} \cdot 2500}}} \]
      4. unpow276.9%

        \[\leadsto \frac{n}{\frac{100 - i \cdot 50}{10000 - \color{blue}{\left(i \cdot i\right)} \cdot 2500}} \]
    7. Simplified76.9%

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

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

Alternative 10: 63.3% accurate, 6.7× speedup?

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

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

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


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

    1. Initial program 28.1%

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

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

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

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

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

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

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

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

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

    if 1.06000000000000003e-76 < n

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(10000 - 2500 \cdot {i}^{2}\right)}{100 - 50 \cdot i}} \]
    6. Step-by-step derivation
      1. associate-/l*74.4%

        \[\leadsto \color{blue}{\frac{n}{\frac{100 - 50 \cdot i}{10000 - 2500 \cdot {i}^{2}}}} \]
      2. *-commutative74.4%

        \[\leadsto \frac{n}{\frac{100 - \color{blue}{i \cdot 50}}{10000 - 2500 \cdot {i}^{2}}} \]
      3. *-commutative74.4%

        \[\leadsto \frac{n}{\frac{100 - i \cdot 50}{10000 - \color{blue}{{i}^{2} \cdot 2500}}} \]
      4. unpow274.4%

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

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

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

Alternative 11: 60.1% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -0.76:\\
\;\;\;\;0\\

\mathbf{elif}\;i \leq 0.088:\\
\;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\

\mathbf{elif}\;i \leq 7.5 \cdot 10^{+108}:\\
\;\;\;\;0\\

\mathbf{elif}\;i \leq 1.9 \cdot 10^{+244}:\\
\;\;\;\;n \cdot \left(i \cdot 50\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -0.76000000000000001 or 0.087999999999999995 < i < 7.50000000000000039e108 or 1.89999999999999991e244 < i

    1. Initial program 53.4%

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

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

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

    if -0.76000000000000001 < i < 0.087999999999999995

    1. Initial program 7.3%

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

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

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

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

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

    if 7.50000000000000039e108 < i < 1.89999999999999991e244

    1. Initial program 60.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(n \cdot i\right) \cdot 50} \]
      2. associate-*l*37.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -0.76:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 0.088:\\ \;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\ \mathbf{elif}\;i \leq 7.5 \cdot 10^{+108}:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 1.9 \cdot 10^{+244}:\\ \;\;\;\;n \cdot \left(i \cdot 50\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 12: 62.2% accurate, 8.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.15 \cdot 10^{+68} \lor \neg \left(n \leq 4.9 \cdot 10^{-8}\right):\\
\;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -2.1500000000000001e68 or 4.9000000000000002e-8 < n

    1. Initial program 24.8%

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

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

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

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

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

    if -2.1500000000000001e68 < n < 4.9000000000000002e-8

    1. Initial program 31.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.15 \cdot 10^{+68} \lor \neg \left(n \leq 4.9 \cdot 10^{-8}\right):\\ \;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \end{array} \]

Alternative 13: 62.0% accurate, 10.3× speedup?

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

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

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


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

    1. Initial program 28.1%

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

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

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

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

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

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

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

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

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

    if 1.06000000000000003e-76 < n

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

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

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

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

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

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

Alternative 14: 59.2% accurate, 16.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -165000:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 0.085:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (if (<= i -165000.0) 0.0 (if (<= i 0.085) (* n 100.0) 0.0)))
double code(double i, double n) {
	double tmp;
	if (i <= -165000.0) {
		tmp = 0.0;
	} else if (i <= 0.085) {
		tmp = n * 100.0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(i, n)
    real(8), intent (in) :: i
    real(8), intent (in) :: n
    real(8) :: tmp
    if (i <= (-165000.0d0)) then
        tmp = 0.0d0
    else if (i <= 0.085d0) then
        tmp = n * 100.0d0
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double i, double n) {
	double tmp;
	if (i <= -165000.0) {
		tmp = 0.0;
	} else if (i <= 0.085) {
		tmp = n * 100.0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(i, n):
	tmp = 0
	if i <= -165000.0:
		tmp = 0.0
	elif i <= 0.085:
		tmp = n * 100.0
	else:
		tmp = 0.0
	return tmp
function code(i, n)
	tmp = 0.0
	if (i <= -165000.0)
		tmp = 0.0;
	elseif (i <= 0.085)
		tmp = Float64(n * 100.0);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(i, n)
	tmp = 0.0;
	if (i <= -165000.0)
		tmp = 0.0;
	elseif (i <= 0.085)
		tmp = n * 100.0;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[i_, n_] := If[LessEqual[i, -165000.0], 0.0, If[LessEqual[i, 0.085], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq -165000:\\
\;\;\;\;0\\

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

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


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

    1. Initial program 55.3%

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

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

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

    if -165000 < i < 0.0850000000000000061

    1. Initial program 7.3%

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified84.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -165000:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 0.085:\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 15: 17.5% accurate, 114.0× speedup?

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

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

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

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

    \[\leadsto 100 \cdot \color{blue}{0} \]
  4. Final simplification17.7%

    \[\leadsto 0 \]

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 2023240 
(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))))