Compound Interest

Percentage Accurate: 28.8% → 98.5%
Time: 29.3s
Alternatives: 10
Speedup: 8.7×

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 10 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.8% 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.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\ t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\ t_2 := n \cdot \frac{t_0 \cdot 100 + -100}{i}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-43}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;t_2\\ \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)))
        (t_2 (* n (/ (+ (* t_0 100.0) -100.0) i))))
   (if (<= t_1 -5e-43)
     t_2
     (if (<= t_1 0.0)
       (* (/ (expm1 (* n (log1p (/ i n)))) i) (* n 100.0))
       (if (<= t_1 INFINITY) t_2 (* 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 t_2 = n * (((t_0 * 100.0) + -100.0) / i);
	double tmp;
	if (t_1 <= -5e-43) {
		tmp = t_2;
	} else if (t_1 <= 0.0) {
		tmp = (expm1((n * log1p((i / n)))) / i) * (n * 100.0);
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = t_2;
	} 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 t_2 = n * (((t_0 * 100.0) + -100.0) / i);
	double tmp;
	if (t_1 <= -5e-43) {
		tmp = t_2;
	} else if (t_1 <= 0.0) {
		tmp = (Math.expm1((n * Math.log1p((i / n)))) / i) * (n * 100.0);
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_2;
	} 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)
	t_2 = n * (((t_0 * 100.0) + -100.0) / i)
	tmp = 0
	if t_1 <= -5e-43:
		tmp = t_2
	elif t_1 <= 0.0:
		tmp = (math.expm1((n * math.log1p((i / n)))) / i) * (n * 100.0)
	elif t_1 <= math.inf:
		tmp = t_2
	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))
	t_2 = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i))
	tmp = 0.0
	if (t_1 <= -5e-43)
		tmp = t_2;
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i) * Float64(n * 100.0));
	elseif (t_1 <= Inf)
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(n * N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-43], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$2, 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}}\\
t_2 := n \cdot \frac{t_0 \cdot 100 + -100}{i}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-43}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;t_2\\

\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)) < -5.00000000000000019e-43 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-43 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0

    1. Initial program 27.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.8 \lor \neg \left(n \leq 1.3 \cdot 10^{+15}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -2.7999999999999998 or 1.3e15 < n

    1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

    if -2.7999999999999998 < n < 1.3e15

    1. Initial program 31.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 64.5% accurate, 4.7× speedup?

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

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

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

\mathbf{elif}\;n \leq 1.95 \cdot 10^{-159}:\\
\;\;\;\;0\\

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


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

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

    if -2.05e210 < n < -2.7999999999999998e-196

    1. Initial program 37.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7999999999999998e-196 < n < 1.94999999999999988e-159

    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/54.6%

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

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

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

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

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

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

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

    if 1.94999999999999988e-159 < n

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.05 \cdot 10^{+210}:\\ \;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\ \mathbf{elif}\;n \leq -2.8 \cdot 10^{-196}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 1.95 \cdot 10^{-159}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;n \cdot 100 + \left(i \cdot n\right) \cdot 50\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 71.1% accurate, 4.9× speedup?

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

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

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

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


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

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

    if -2.8e211 < n < 1.96

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.96 < n

    1. Initial program 24.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 62.6% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{if}\;n \leq -5.8 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -2.45 \cdot 10^{-185}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 4.2 \cdot 10^{-159}:\\ \;\;\;\;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 -5.8e+102)
     t_0
     (if (<= n -2.45e-185)
       (* 100.0 (/ i (/ i n)))
       (if (<= n 4.2e-159) 0.0 t_0)))))
double code(double i, double n) {
	double t_0 = n * (100.0 + (i * 50.0));
	double tmp;
	if (n <= -5.8e+102) {
		tmp = t_0;
	} else if (n <= -2.45e-185) {
		tmp = 100.0 * (i / (i / n));
	} else if (n <= 4.2e-159) {
		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 <= (-5.8d+102)) then
        tmp = t_0
    else if (n <= (-2.45d-185)) then
        tmp = 100.0d0 * (i / (i / n))
    else if (n <= 4.2d-159) 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 <= -5.8e+102) {
		tmp = t_0;
	} else if (n <= -2.45e-185) {
		tmp = 100.0 * (i / (i / n));
	} else if (n <= 4.2e-159) {
		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 <= -5.8e+102:
		tmp = t_0
	elif n <= -2.45e-185:
		tmp = 100.0 * (i / (i / n))
	elif n <= 4.2e-159:
		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 <= -5.8e+102)
		tmp = t_0;
	elseif (n <= -2.45e-185)
		tmp = Float64(100.0 * Float64(i / Float64(i / n)));
	elseif (n <= 4.2e-159)
		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 <= -5.8e+102)
		tmp = t_0;
	elseif (n <= -2.45e-185)
		tmp = 100.0 * (i / (i / n));
	elseif (n <= 4.2e-159)
		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, -5.8e+102], t$95$0, If[LessEqual[n, -2.45e-185], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.2e-159], 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 -5.8 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;n \leq 4.2 \cdot 10^{-159}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -5.8000000000000005e102 or 4.1999999999999998e-159 < n

    1. Initial program 26.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{\color{blue}{e^{i} \cdot 100} - 100}{i} \]
      2. fma-neg41.7%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
      3. metadata-eval41.7%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(e^{i}, 100, \color{blue}{-100}\right)}{i} \]
    7. Simplified41.7%

      \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
    8. Taylor expanded in i around 0 67.5%

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

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

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

    if -5.8000000000000005e102 < n < -2.4500000000000001e-185

    1. Initial program 30.7%

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

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

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

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

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

    if -2.4500000000000001e-185 < n < 4.1999999999999998e-159

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5.8 \cdot 10^{+102}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \mathbf{elif}\;n \leq -2.45 \cdot 10^{-185}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 4.2 \cdot 10^{-159}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 62.6% accurate, 5.2× speedup?

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

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

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

\mathbf{elif}\;n \leq 3 \cdot 10^{-159}:\\
\;\;\;\;0\\

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


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

    1. Initial program 38.6%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{100}{\frac{i}{n \cdot i}}} \]
      2. associate-/r/50.0%

        \[\leadsto \color{blue}{\frac{100}{i} \cdot \left(n \cdot i\right)} \]
    10. Applied egg-rr50.0%

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

    if -5e102 < n < -2.4500000000000001e-185

    1. Initial program 30.7%

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

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

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

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

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

    if -2.4500000000000001e-185 < n < 3.00000000000000009e-159

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

    if 3.00000000000000009e-159 < n

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{\color{blue}{e^{i} \cdot 100} - 100}{i} \]
      2. fma-neg32.7%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
      3. metadata-eval32.7%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(e^{i}, 100, \color{blue}{-100}\right)}{i} \]
    7. Simplified32.7%

      \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
    8. Taylor expanded in i around 0 76.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5 \cdot 10^{+102}:\\ \;\;\;\;\left(i \cdot n\right) \cdot \frac{100}{i}\\ \mathbf{elif}\;n \leq -2.45 \cdot 10^{-185}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 3 \cdot 10^{-159}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 62.6% accurate, 5.2× speedup?

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

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

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

\mathbf{elif}\;n \leq 5.1 \cdot 10^{-160}:\\
\;\;\;\;0\\

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


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

    1. Initial program 38.6%

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

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

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

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

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

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

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

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

    if -5e102 < n < -3.6999999999999999e-184

    1. Initial program 30.7%

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

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

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

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

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

    if -3.6999999999999999e-184 < n < 5.1e-160

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

    if 5.1e-160 < n

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{\color{blue}{e^{i} \cdot 100} - 100}{i} \]
      2. fma-neg32.7%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
      3. metadata-eval32.7%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(e^{i}, 100, \color{blue}{-100}\right)}{i} \]
    7. Simplified32.7%

      \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
    8. Taylor expanded in i around 0 76.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5 \cdot 10^{+102}:\\ \;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\ \mathbf{elif}\;n \leq -3.7 \cdot 10^{-184}:\\ \;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\ \mathbf{elif}\;n \leq 5.1 \cdot 10^{-160}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 64.5% accurate, 5.2× speedup?

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

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

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

\mathbf{elif}\;n \leq 7.5 \cdot 10^{-158}:\\
\;\;\;\;0\\

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


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

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

    if -3e211 < n < -1.5e-196

    1. Initial program 37.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.5e-196 < n < 7.5e-158

    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/54.6%

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

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

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

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

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

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

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

    if 7.5e-158 < n

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto n \cdot \frac{\color{blue}{e^{i} \cdot 100} - 100}{i} \]
      2. fma-neg32.7%

        \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
      3. metadata-eval32.7%

        \[\leadsto n \cdot \frac{\mathsf{fma}\left(e^{i}, 100, \color{blue}{-100}\right)}{i} \]
    7. Simplified32.7%

      \[\leadsto n \cdot \frac{\color{blue}{\mathsf{fma}\left(e^{i}, 100, -100\right)}}{i} \]
    8. Taylor expanded in i around 0 76.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3 \cdot 10^{+211}:\\ \;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\ \mathbf{elif}\;n \leq -1.5 \cdot 10^{-196}:\\ \;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\ \mathbf{elif}\;n \leq 7.5 \cdot 10^{-158}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 56.4% accurate, 8.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.6 \cdot 10^{-183} \lor \neg \left(n \leq 5.9 \cdot 10^{-158}\right):\\
\;\;\;\;n \cdot 100\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -2.5999999999999999e-183 or 5.9000000000000002e-158 < n

    1. Initial program 27.7%

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

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

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

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

    if -2.5999999999999999e-183 < n < 5.9000000000000002e-158

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.6 \cdot 10^{-183} \lor \neg \left(n \leq 5.9 \cdot 10^{-158}\right):\\ \;\;\;\;n \cdot 100\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 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 32.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto 0 \]
  8. Add Preprocessing

Developer target: 35.1% accurate, 0.5× speedup?

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

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

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


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

Reproduce

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