Compound Interest

Percentage Accurate: 28.3% → 94.1%
Time: 25.7s
Alternatives: 12
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 12 alternatives:

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

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

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

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

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


\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 25.2%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified83.3%

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

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

Alternative 2: 75.0% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < -1.15e-9 or 1.89999999999999988e-29 < i

    1. Initial program 45.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.15e-9 < i < 1.89999999999999988e-29

    1. Initial program 9.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -1.15 \cdot 10^{-9} \lor \neg \left(i \leq 1.9 \cdot 10^{-29}\right):\\ \;\;\;\;\mathsf{expm1}\left(i\right) \cdot \left(n \cdot \frac{100}{i}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \]

Alternative 3: 79.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.15 \cdot 10^{-206} \lor \neg \left(n \leq 8.5 \cdot 10^{-118}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.15e-206 or 8.50000000000000087e-118 < n

    1. Initial program 20.9%

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

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

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

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

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

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

    if -1.15e-206 < n < 8.50000000000000087e-118

    1. Initial program 56.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.6%

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

Alternative 4: 75.2% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 47.2%

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000006e-9 < i < 1.89999999999999988e-29

    1. Initial program 9.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.89999999999999988e-29 < i

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 79.7% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\

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


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

    1. Initial program 28.3%

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

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

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

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

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

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

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

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

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

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

    if -2.5000000000000001e-211 < n < 8.50000000000000087e-118

    1. Initial program 56.2%

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

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

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

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

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

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

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

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

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

    if 8.50000000000000087e-118 < n

    1. Initial program 12.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.5 \cdot 10^{-211}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\ \mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\ \end{array} \]

Alternative 6: 64.0% accurate, 5.9× speedup?

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

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

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

\mathbf{elif}\;n \leq 3.4 \cdot 10^{-107}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -7.4999999999999999e82 or 3.39999999999999994e-107 < n

    1. Initial program 15.3%

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

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

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

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

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

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

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

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

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

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

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

    if -7.4999999999999999e82 < n < -5.09999999999999995e-210

    1. Initial program 36.5%

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

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

    if -5.09999999999999995e-210 < n < 3.39999999999999994e-107

    1. Initial program 56.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification67.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -7.5 \cdot 10^{+82}:\\ \;\;\;\;100 \cdot \frac{n \cdot \left(i + i \cdot \left(i \cdot 0.5\right)\right)}{i}\\ \mathbf{elif}\;n \leq -5.1 \cdot 10^{-210}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 3.4 \cdot 10^{-107}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{n \cdot \left(i + i \cdot \left(i \cdot 0.5\right)\right)}{i}\\ \end{array} \]

Alternative 7: 62.1% accurate, 7.5× speedup?

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

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

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

\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\

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


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

    1. Initial program 20.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.20000000000000065e82 < n < -1.15e-206

    1. Initial program 36.5%

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

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

    if -1.15e-206 < n < 8.50000000000000087e-118

    1. Initial program 56.2%

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

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

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

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

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

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

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

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

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

    if 8.50000000000000087e-118 < n

    1. Initial program 12.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -6.2 \cdot 10^{+82}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq -1.15 \cdot 10^{-206}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \left(n + 0.5 \cdot \left(i \cdot n\right)\right)\\ \end{array} \]

Alternative 8: 62.1% accurate, 7.5× speedup?

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

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

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

\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -8.9999999999999993e82 or 8.50000000000000087e-118 < n

    1. Initial program 15.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.9999999999999993e82 < n < -3.7999999999999999e-209

    1. Initial program 36.5%

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

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

    if -3.7999999999999999e-209 < n < 8.50000000000000087e-118

    1. Initial program 56.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification65.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -9 \cdot 10^{+82}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \mathbf{elif}\;n \leq -3.8 \cdot 10^{-209}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\ \end{array} \]

Alternative 9: 62.1% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
t_0 := n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{if}\;n \leq -6.2 \cdot 10^{+82}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -6.20000000000000065e82 or 8.50000000000000087e-118 < n

    1. Initial program 15.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.20000000000000065e82 < n < -2.04999999999999989e-209

    1. Initial program 36.5%

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

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

    if -2.04999999999999989e-209 < n < 8.50000000000000087e-118

    1. Initial program 56.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification65.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -6.2 \cdot 10^{+82}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq -2.05 \cdot 10^{-209}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]

Alternative 10: 59.2% accurate, 10.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq -6.2 \cdot 10^{+30}:\\
\;\;\;\;0\\

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

\mathbf{elif}\;i \leq 5.6 \cdot 10^{+61}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -6.1999999999999995e30 or 10500 < i < 5.6000000000000003e61

    1. Initial program 50.3%

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

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

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

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

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

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

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

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

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

    if -6.1999999999999995e30 < i < 10500

    1. Initial program 9.8%

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

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

        \[\leadsto \color{blue}{n \cdot 100} \]
    4. Simplified80.2%

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

    if 5.6000000000000003e61 < i

    1. Initial program 48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -6.2 \cdot 10^{+30}:\\ \;\;\;\;0\\ \mathbf{elif}\;i \leq 10500:\\ \;\;\;\;n \cdot 100\\ \mathbf{elif}\;i \leq 5.6 \cdot 10^{+61}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;50 \cdot \left(i \cdot n\right)\\ \end{array} \]

Alternative 11: 55.5% accurate, 16.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.6 \cdot 10^{-104}:\\
\;\;\;\;n \cdot 100\\

\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -9.6000000000000003e-104 or 8.50000000000000087e-118 < n

    1. Initial program 18.7%

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

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

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

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

    if -9.6000000000000003e-104 < n < 8.50000000000000087e-118

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -9.6 \cdot 10^{-104}:\\ \;\;\;\;n \cdot 100\\ \mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;n \cdot 100\\ \end{array} \]

Alternative 12: 17.6% 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 26.7%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  6. Final simplification18.0%

    \[\leadsto 0 \]

Developer target: 34.2% 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 2023277 
(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))))