Compound Interest

Percentage Accurate: 28.5% → 95.8%
Time: 9.0s
Alternatives: 8
Speedup: N/A×

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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(i, n)
use fmin_fmax_functions
    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 8 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.5% 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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(i, n)
use fmin_fmax_functions
    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: 95.8% accurate, N/A× speedup?

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

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

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

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))) < -9.99999999999999939e-12 or -0.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))) < +inf.0

    1. Initial program 97.3%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing

    if -9.99999999999999939e-12 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))) < -0.0

    1. Initial program 26.6%

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

        \[\leadsto \color{blue}{100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      2. lift-/.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      3. lift--.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \]
      4. lift-pow.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{i}{n}} \]
      5. lift-+.f64N/A

        \[\leadsto 100 \cdot \frac{{\color{blue}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \]
      6. lift-/.f64N/A

        \[\leadsto 100 \cdot \frac{{\left(1 + \color{blue}{\frac{i}{n}}\right)}^{n} - 1}{\frac{i}{n}} \]
      7. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}{\frac{i}{n}} \]
      11. pow-to-expN/A

        \[\leadsto \frac{100 \cdot \left(\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1\right)}{\frac{i}{n}} \]
      12. lower-expm1.f64N/A

        \[\leadsto \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}{\frac{i}{n}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}{\frac{i}{n}} \]
      14. lower-log1p.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)} \cdot n\right)}{\frac{i}{n}} \]
      15. lift-/.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\frac{i}{n}}\right) \cdot n\right)}{\frac{i}{n}} \]
      16. lift-/.f6499.6

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

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

    if +inf.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)))

    1. Initial program 0.0%

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

        \[\leadsto \color{blue}{100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      2. lift-/.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      3. lift--.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \]
      4. lift-pow.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{i}{n}} \]
      5. lift-+.f64N/A

        \[\leadsto 100 \cdot \frac{{\color{blue}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \]
      6. lift-/.f64N/A

        \[\leadsto 100 \cdot \frac{{\left(1 + \color{blue}{\frac{i}{n}}\right)}^{n} - 1}{\frac{i}{n}} \]
      7. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}{\frac{i}{n}} \]
      11. pow-to-expN/A

        \[\leadsto \frac{100 \cdot \left(\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1\right)}{\frac{i}{n}} \]
      12. lower-expm1.f64N/A

        \[\leadsto \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}{\frac{i}{n}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}{\frac{i}{n}} \]
      14. lower-log1p.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)} \cdot n\right)}{\frac{i}{n}} \]
      15. lift-/.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\frac{i}{n}}\right) \cdot n\right)}{\frac{i}{n}} \]
      16. lift-/.f640.0

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

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

      \[\leadsto \color{blue}{100 \cdot n + 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(100, \color{blue}{n}, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      5. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      7. inv-powN/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot {n}^{-1}\right)\right)\right)\right) \]
      8. lower-pow.f6488.0

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right) \]
    7. Applied rewrites88.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.5%

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

Alternative 2: 95.5% accurate, N/A× speedup?

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

\\
\begin{array}{l}
t_0 := 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(100 \cdot \mathsf{fma}\left(n \cdot i, \mathsf{fma}\left(0.4583333333333333, {n}^{-2}, 0.041666666666666664\right) - \mathsf{fma}\left({n}^{-3}, 0.25, \frac{0.25}{n}\right), \left(\mathsf{fma}\left({n}^{-2}, 0.3333333333333333, 0.16666666666666666\right) - \frac{0.5}{n}\right) \cdot n\right), i, \left(\left(0.5 - \frac{0.5}{n}\right) \cdot n\right) \cdot 100\right), i, n \cdot 100\right)\\

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

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right)\\


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{100 \cdot n + i \cdot \left(100 \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right) + i \cdot \left(100 \cdot \left(i \cdot \left(n \cdot \left(\left(\frac{1}{24} + \frac{11}{24} \cdot \frac{1}{{n}^{2}}\right) - \left(\frac{1}{4} \cdot \frac{1}{n} + \frac{1}{4} \cdot \frac{1}{{n}^{3}}\right)\right)\right)\right) + 100 \cdot \left(n \cdot \left(\left(\frac{1}{6} + \frac{1}{3} \cdot \frac{1}{{n}^{2}}\right) - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right)} \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(100 \cdot \mathsf{fma}\left(n \cdot i, \mathsf{fma}\left(0.4583333333333333, {n}^{-2}, 0.041666666666666664\right) - \mathsf{fma}\left({n}^{-3}, 0.25, \frac{0.25}{n}\right), \left(\mathsf{fma}\left({n}^{-2}, 0.3333333333333333, 0.16666666666666666\right) - \frac{0.5}{n}\right) \cdot n\right), i, \left(\left(0.5 - \frac{0.5}{n}\right) \cdot n\right) \cdot 100\right), i, n \cdot 100\right)} \]

    if -inf.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.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. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      2. lift-/.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      3. lift--.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \]
      4. lift-pow.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{i}{n}} \]
      5. lift-+.f64N/A

        \[\leadsto 100 \cdot \frac{{\color{blue}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \]
      6. lift-/.f64N/A

        \[\leadsto 100 \cdot \frac{{\left(1 + \color{blue}{\frac{i}{n}}\right)}^{n} - 1}{\frac{i}{n}} \]
      7. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \cdot 100} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \cdot 100} \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \cdot 100 \]
      11. pow-to-expN/A

        \[\leadsto \frac{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}{\frac{i}{n}} \cdot 100 \]
      12. lower-expm1.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}{\frac{i}{n}} \cdot 100 \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}{\frac{i}{n}} \cdot 100 \]
      14. lower-log1p.f64N/A

        \[\leadsto \frac{\mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)} \cdot n\right)}{\frac{i}{n}} \cdot 100 \]
      15. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\frac{i}{n}}\right) \cdot n\right)}{\frac{i}{n}} \cdot 100 \]
      16. lift-/.f6499.6

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

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

    if -0.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))) < +inf.0

    1. Initial program 96.2%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing

    if +inf.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)))

    1. Initial program 0.0%

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

        \[\leadsto \color{blue}{100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      2. lift-/.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      3. lift--.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \]
      4. lift-pow.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{i}{n}} \]
      5. lift-+.f64N/A

        \[\leadsto 100 \cdot \frac{{\color{blue}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \]
      6. lift-/.f64N/A

        \[\leadsto 100 \cdot \frac{{\left(1 + \color{blue}{\frac{i}{n}}\right)}^{n} - 1}{\frac{i}{n}} \]
      7. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}{\frac{i}{n}} \]
      11. pow-to-expN/A

        \[\leadsto \frac{100 \cdot \left(\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1\right)}{\frac{i}{n}} \]
      12. lower-expm1.f64N/A

        \[\leadsto \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}{\frac{i}{n}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}{\frac{i}{n}} \]
      14. lower-log1p.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)} \cdot n\right)}{\frac{i}{n}} \]
      15. lift-/.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\frac{i}{n}}\right) \cdot n\right)}{\frac{i}{n}} \]
      16. lift-/.f640.0

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

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

      \[\leadsto \color{blue}{100 \cdot n + 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(100, \color{blue}{n}, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      5. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      7. inv-powN/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot {n}^{-1}\right)\right)\right)\right) \]
      8. lower-pow.f6488.0

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right) \]
    7. Applied rewrites88.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification97.5%

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

Alternative 3: 94.7% accurate, N/A× speedup?

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

\\
\begin{array}{l}
t_0 := 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(100 \cdot \mathsf{fma}\left(n \cdot i, \mathsf{fma}\left(0.4583333333333333, {n}^{-2}, 0.041666666666666664\right) - \mathsf{fma}\left({n}^{-3}, 0.25, \frac{0.25}{n}\right), \left(\mathsf{fma}\left({n}^{-2}, 0.3333333333333333, 0.16666666666666666\right) - \frac{0.5}{n}\right) \cdot n\right), i, \left(\left(0.5 - \frac{0.5}{n}\right) \cdot n\right) \cdot 100\right), i, n \cdot 100\right)\\

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

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right)\\


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{100 \cdot n + i \cdot \left(100 \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right) + i \cdot \left(100 \cdot \left(i \cdot \left(n \cdot \left(\left(\frac{1}{24} + \frac{11}{24} \cdot \frac{1}{{n}^{2}}\right) - \left(\frac{1}{4} \cdot \frac{1}{n} + \frac{1}{4} \cdot \frac{1}{{n}^{3}}\right)\right)\right)\right) + 100 \cdot \left(n \cdot \left(\left(\frac{1}{6} + \frac{1}{3} \cdot \frac{1}{{n}^{2}}\right) - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right)} \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(100 \cdot \mathsf{fma}\left(n \cdot i, \mathsf{fma}\left(0.4583333333333333, {n}^{-2}, 0.041666666666666664\right) - \mathsf{fma}\left({n}^{-3}, 0.25, \frac{0.25}{n}\right), \left(\mathsf{fma}\left({n}^{-2}, 0.3333333333333333, 0.16666666666666666\right) - \frac{0.5}{n}\right) \cdot n\right), i, \left(\left(0.5 - \frac{0.5}{n}\right) \cdot n\right) \cdot 100\right), i, n \cdot 100\right)} \]

    if -inf.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.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. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      2. lift--.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \]
      3. lift-pow.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{i}{n}} \]
      4. lift-+.f64N/A

        \[\leadsto 100 \cdot \frac{{\color{blue}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \]
      5. lift-/.f64N/A

        \[\leadsto 100 \cdot \frac{{\left(1 + \color{blue}{\frac{i}{n}}\right)}^{n} - 1}{\frac{i}{n}} \]
      6. lift-/.f64N/A

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

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      8. lower-*.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      9. lower-/.f64N/A

        \[\leadsto 100 \cdot \left(\color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}} \cdot n\right) \]
      10. pow-to-expN/A

        \[\leadsto 100 \cdot \left(\frac{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}{i} \cdot n\right) \]
      11. lower-expm1.f64N/A

        \[\leadsto 100 \cdot \left(\frac{\color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}{i} \cdot n\right) \]
      12. lower-*.f64N/A

        \[\leadsto 100 \cdot \left(\frac{\mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}{i} \cdot n\right) \]
      13. lower-log1p.f64N/A

        \[\leadsto 100 \cdot \left(\frac{\mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)} \cdot n\right)}{i} \cdot n\right) \]
      14. lift-/.f6497.7

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

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

    if -0.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))) < +inf.0

    1. Initial program 96.2%

      \[100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}} \]
    2. Add Preprocessing

    if +inf.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)))

    1. Initial program 0.0%

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

        \[\leadsto \color{blue}{100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      2. lift-/.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      3. lift--.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \]
      4. lift-pow.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{i}{n}} \]
      5. lift-+.f64N/A

        \[\leadsto 100 \cdot \frac{{\color{blue}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \]
      6. lift-/.f64N/A

        \[\leadsto 100 \cdot \frac{{\left(1 + \color{blue}{\frac{i}{n}}\right)}^{n} - 1}{\frac{i}{n}} \]
      7. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}{\frac{i}{n}} \]
      11. pow-to-expN/A

        \[\leadsto \frac{100 \cdot \left(\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1\right)}{\frac{i}{n}} \]
      12. lower-expm1.f64N/A

        \[\leadsto \frac{100 \cdot \color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}{\frac{i}{n}} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}{\frac{i}{n}} \]
      14. lower-log1p.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)} \cdot n\right)}{\frac{i}{n}} \]
      15. lift-/.f64N/A

        \[\leadsto \frac{100 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\frac{i}{n}}\right) \cdot n\right)}{\frac{i}{n}} \]
      16. lift-/.f640.0

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

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

      \[\leadsto \color{blue}{100 \cdot n + 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(100, \color{blue}{n}, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      5. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right) \]
      7. inv-powN/A

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot {n}^{-1}\right)\right)\right)\right) \]
      8. lower-pow.f6488.0

        \[\leadsto \mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right) \]
    7. Applied rewrites88.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(100, n, 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 - 0.5 \cdot {n}^{-1}\right)\right)\right)\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification96.1%

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

Alternative 4: 93.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\mathsf{fma}\left(100 \cdot \mathsf{fma}\left(n \cdot i, \mathsf{fma}\left(0.4583333333333333, {n}^{-2}, 0.041666666666666664\right) - \mathsf{fma}\left({n}^{-3}, 0.25, \frac{0.25}{n}\right), \left(\mathsf{fma}\left({n}^{-2}, 0.3333333333333333, 0.16666666666666666\right) - \frac{0.5}{n}\right) \cdot n\right), i, \left(\left(0.5 - \frac{0.5}{n}\right) \cdot n\right) \cdot 100\right), i, n \cdot 100\right)\\ t_1 := 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;100 \cdot \left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)}{i} \cdot n\right)\\ \mathbf{elif}\;t\_1 \leq 1000:\\ \;\;\;\;100 \cdot \frac{n \cdot \mathsf{expm1}\left(\log \left({\left(\frac{i}{n}\right)}^{n}\right)\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (i n)
 :precision binary64
 (let* ((t_0
         (fma
          (fma
           (*
            100.0
            (fma
             (* n i)
             (-
              (fma 0.4583333333333333 (pow n -2.0) 0.041666666666666664)
              (fma (pow n -3.0) 0.25 (/ 0.25 n)))
             (*
              (-
               (fma (pow n -2.0) 0.3333333333333333 0.16666666666666666)
               (/ 0.5 n))
              n)))
           i
           (* (* (- 0.5 (/ 0.5 n)) n) 100.0))
          i
          (* n 100.0)))
        (t_1 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n)))))
   (if (<= t_1 (- INFINITY))
     t_0
     (if (<= t_1 0.0)
       (* 100.0 (* (/ (expm1 (* (log1p (/ i n)) n)) i) n))
       (if (<= t_1 1000.0)
         (* 100.0 (/ (* n (expm1 (log (pow (/ i n) n)))) i))
         t_0)))))
double code(double i, double n) {
	double t_0 = fma(fma((100.0 * fma((n * i), (fma(0.4583333333333333, pow(n, -2.0), 0.041666666666666664) - fma(pow(n, -3.0), 0.25, (0.25 / n))), ((fma(pow(n, -2.0), 0.3333333333333333, 0.16666666666666666) - (0.5 / n)) * n))), i, (((0.5 - (0.5 / n)) * n) * 100.0)), i, (n * 100.0));
	double t_1 = 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_0;
	} else if (t_1 <= 0.0) {
		tmp = 100.0 * ((expm1((log1p((i / n)) * n)) / i) * n);
	} else if (t_1 <= 1000.0) {
		tmp = 100.0 * ((n * expm1(log(pow((i / n), n)))) / i);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(i, n)
	t_0 = fma(fma(Float64(100.0 * fma(Float64(n * i), Float64(fma(0.4583333333333333, (n ^ -2.0), 0.041666666666666664) - fma((n ^ -3.0), 0.25, Float64(0.25 / n))), Float64(Float64(fma((n ^ -2.0), 0.3333333333333333, 0.16666666666666666) - Float64(0.5 / n)) * n))), i, Float64(Float64(Float64(0.5 - Float64(0.5 / n)) * n) * 100.0)), i, Float64(n * 100.0))
	t_1 = Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n)))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = t_0;
	elseif (t_1 <= 0.0)
		tmp = Float64(100.0 * Float64(Float64(expm1(Float64(log1p(Float64(i / n)) * n)) / i) * n));
	elseif (t_1 <= 1000.0)
		tmp = Float64(100.0 * Float64(Float64(n * expm1(log((Float64(i / n) ^ n)))) / i));
	else
		tmp = t_0;
	end
	return tmp
end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[(100.0 * N[(N[(n * i), $MachinePrecision] * N[(N[(0.4583333333333333 * N[Power[n, -2.0], $MachinePrecision] + 0.041666666666666664), $MachinePrecision] - N[(N[Power[n, -3.0], $MachinePrecision] * 0.25 + N[(0.25 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[Power[n, -2.0], $MachinePrecision] * 0.3333333333333333 + 0.16666666666666666), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * i + N[(N[(N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision] * 100.0), $MachinePrecision]), $MachinePrecision] * i + N[(n * 100.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, (-Infinity)], t$95$0, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(N[(N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1000.0], N[(100.0 * N[(N[(n * N[(Exp[N[Log[N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(100 \cdot \mathsf{fma}\left(n \cdot i, \mathsf{fma}\left(0.4583333333333333, {n}^{-2}, 0.041666666666666664\right) - \mathsf{fma}\left({n}^{-3}, 0.25, \frac{0.25}{n}\right), \left(\mathsf{fma}\left({n}^{-2}, 0.3333333333333333, 0.16666666666666666\right) - \frac{0.5}{n}\right) \cdot n\right), i, \left(\left(0.5 - \frac{0.5}{n}\right) \cdot n\right) \cdot 100\right), i, n \cdot 100\right)\\
t_1 := 100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))) < -inf.0 or 1e3 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)))

    1. Initial program 21.2%

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

      \[\leadsto \color{blue}{100 \cdot n + i \cdot \left(100 \cdot \left(n \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \frac{1}{n}\right)\right) + i \cdot \left(100 \cdot \left(i \cdot \left(n \cdot \left(\left(\frac{1}{24} + \frac{11}{24} \cdot \frac{1}{{n}^{2}}\right) - \left(\frac{1}{4} \cdot \frac{1}{n} + \frac{1}{4} \cdot \frac{1}{{n}^{3}}\right)\right)\right)\right) + 100 \cdot \left(n \cdot \left(\left(\frac{1}{6} + \frac{1}{3} \cdot \frac{1}{{n}^{2}}\right) - \frac{1}{2} \cdot \frac{1}{n}\right)\right)\right)\right)} \]
    4. Applied rewrites88.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(100 \cdot \mathsf{fma}\left(n \cdot i, \mathsf{fma}\left(0.4583333333333333, {n}^{-2}, 0.041666666666666664\right) - \mathsf{fma}\left({n}^{-3}, 0.25, \frac{0.25}{n}\right), \left(\mathsf{fma}\left({n}^{-2}, 0.3333333333333333, 0.16666666666666666\right) - \frac{0.5}{n}\right) \cdot n\right), i, \left(\left(0.5 - \frac{0.5}{n}\right) \cdot n\right) \cdot 100\right), i, n \cdot 100\right)} \]

    if -inf.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.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. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}} \]
      2. lift--.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{i}{n}} \]
      3. lift-pow.f64N/A

        \[\leadsto 100 \cdot \frac{\color{blue}{{\left(1 + \frac{i}{n}\right)}^{n}} - 1}{\frac{i}{n}} \]
      4. lift-+.f64N/A

        \[\leadsto 100 \cdot \frac{{\color{blue}{\left(1 + \frac{i}{n}\right)}}^{n} - 1}{\frac{i}{n}} \]
      5. lift-/.f64N/A

        \[\leadsto 100 \cdot \frac{{\left(1 + \color{blue}{\frac{i}{n}}\right)}^{n} - 1}{\frac{i}{n}} \]
      6. lift-/.f64N/A

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

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      8. lower-*.f64N/A

        \[\leadsto 100 \cdot \color{blue}{\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)} \]
      9. lower-/.f64N/A

        \[\leadsto 100 \cdot \left(\color{blue}{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}} \cdot n\right) \]
      10. pow-to-expN/A

        \[\leadsto 100 \cdot \left(\frac{\color{blue}{e^{\log \left(1 + \frac{i}{n}\right) \cdot n}} - 1}{i} \cdot n\right) \]
      11. lower-expm1.f64N/A

        \[\leadsto 100 \cdot \left(\frac{\color{blue}{\mathsf{expm1}\left(\log \left(1 + \frac{i}{n}\right) \cdot n\right)}}{i} \cdot n\right) \]
      12. lower-*.f64N/A

        \[\leadsto 100 \cdot \left(\frac{\mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{i}{n}\right) \cdot n}\right)}{i} \cdot n\right) \]
      13. lower-log1p.f64N/A

        \[\leadsto 100 \cdot \left(\frac{\mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{i}{n}\right)} \cdot n\right)}{i} \cdot n\right) \]
      14. lift-/.f6497.7

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

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

    if -0.0 < (*.f64 #s(literal 100 binary64) (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n))) < 1e3

    1. Initial program 94.3%

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

      \[\leadsto 100 \cdot \color{blue}{\frac{n \cdot \left(e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1\right)}{i}} \]
    4. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
      2. lower-*.f64N/A

        \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
      3. lower-/.f64N/A

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

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

      \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{\color{blue}{i}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
      2. lower-*.f64N/A

        \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
      3. lower-expm1.f64N/A

        \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
      4. lower-*.f64N/A

        \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
      5. diff-logN/A

        \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
      6. lower-log.f64N/A

        \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
      7. lift-/.f6415.8

        \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
    8. Applied rewrites15.8%

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

        \[\leadsto \color{blue}{100 \cdot \frac{n \cdot \mathsf{expm1}\left(\log \left({\left(\frac{i}{n}\right)}^{n}\right)\right)}{i}} \]
    10. Recombined 3 regimes into one program.
    11. Add Preprocessing

    Alternative 5: 78.2% accurate, N/A× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq -8.6 \cdot 10^{+229} \lor \neg \left(i \leq 700\right):\\ \;\;\;\;100 \cdot \frac{n \cdot \mathsf{expm1}\left(\log \left({\left(\frac{i}{n}\right)}^{n}\right)\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n\\ \end{array} \end{array} \]
    (FPCore (i n)
     :precision binary64
     (if (or (<= i -8.6e+229) (not (<= i 700.0)))
       (* 100.0 (/ (* n (expm1 (log (pow (/ i n) n)))) i))
       (* (fma (/ (expm1 i) i) 100.0 (* (/ (* (exp i) i) n) -50.0)) n)))
    double code(double i, double n) {
    	double tmp;
    	if ((i <= -8.6e+229) || !(i <= 700.0)) {
    		tmp = 100.0 * ((n * expm1(log(pow((i / n), n)))) / i);
    	} else {
    		tmp = fma((expm1(i) / i), 100.0, (((exp(i) * i) / n) * -50.0)) * n;
    	}
    	return tmp;
    }
    
    function code(i, n)
    	tmp = 0.0
    	if ((i <= -8.6e+229) || !(i <= 700.0))
    		tmp = Float64(100.0 * Float64(Float64(n * expm1(log((Float64(i / n) ^ n)))) / i));
    	else
    		tmp = Float64(fma(Float64(expm1(i) / i), 100.0, Float64(Float64(Float64(exp(i) * i) / n) * -50.0)) * n);
    	end
    	return tmp
    end
    
    code[i_, n_] := If[Or[LessEqual[i, -8.6e+229], N[Not[LessEqual[i, 700.0]], $MachinePrecision]], N[(100.0 * N[(N[(n * N[(Exp[N[Log[N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision] * 100.0 + N[(N[(N[(N[Exp[i], $MachinePrecision] * i), $MachinePrecision] / n), $MachinePrecision] * -50.0), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;i \leq -8.6 \cdot 10^{+229} \lor \neg \left(i \leq 700\right):\\
    \;\;\;\;100 \cdot \frac{n \cdot \mathsf{expm1}\left(\log \left({\left(\frac{i}{n}\right)}^{n}\right)\right)}{i}\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if i < -8.59999999999999982e229 or 700 < i

      1. Initial program 54.9%

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

        \[\leadsto 100 \cdot \color{blue}{\frac{n \cdot \left(e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1\right)}{i}} \]
      4. Step-by-step derivation
        1. associate-/l*N/A

          \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
        2. lower-*.f64N/A

          \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
        3. lower-/.f64N/A

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

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

        \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{\color{blue}{i}} \]
      7. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
        2. lower-*.f64N/A

          \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
        3. lower-expm1.f64N/A

          \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
        4. lower-*.f64N/A

          \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
        5. diff-logN/A

          \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
        6. lower-log.f64N/A

          \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
        7. lift-/.f6439.2

          \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
      8. Applied rewrites39.2%

        \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{\color{blue}{i}} \]
      9. Step-by-step derivation
        1. Applied rewrites65.1%

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

        if -8.59999999999999982e229 < i < 700

        1. Initial program 20.8%

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

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

            \[\leadsto \left(-50 \cdot \frac{i \cdot e^{i}}{n} + 100 \cdot \frac{e^{i} - 1}{i}\right) \cdot \color{blue}{n} \]
          2. lower-*.f64N/A

            \[\leadsto \left(-50 \cdot \frac{i \cdot e^{i}}{n} + 100 \cdot \frac{e^{i} - 1}{i}\right) \cdot \color{blue}{n} \]
          3. +-commutativeN/A

            \[\leadsto \left(100 \cdot \frac{e^{i} - 1}{i} + -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          4. *-commutativeN/A

            \[\leadsto \left(\frac{e^{i} - 1}{i} \cdot 100 + -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          5. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{i} - 1}{i}, 100, -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          6. lower-/.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{i} - 1}{i}, 100, -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          7. lower-expm1.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          8. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{i \cdot e^{i}}{n} \cdot -50\right) \cdot n \]
          9. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{i \cdot e^{i}}{n} \cdot -50\right) \cdot n \]
          10. lower-/.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{i \cdot e^{i}}{n} \cdot -50\right) \cdot n \]
          11. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n \]
          12. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n \]
          13. lower-exp.f6485.5

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n \]
        5. Applied rewrites85.5%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n} \]
      10. Recombined 2 regimes into one program.
      11. Final simplification80.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -8.6 \cdot 10^{+229} \lor \neg \left(i \leq 700\right):\\ \;\;\;\;100 \cdot \frac{n \cdot \mathsf{expm1}\left(\log \left({\left(\frac{i}{n}\right)}^{n}\right)\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n\\ \end{array} \]
      12. Add Preprocessing

      Alternative 6: 71.0% accurate, N/A× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\frac{i}{n}\right)\\ \mathbf{if}\;i \leq 1.05 \cdot 10^{+27}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n\\ \mathbf{else}:\\ \;\;\;\;\left(100 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{{t\_0}^{2}}{i}, 0.5, {i}^{-2}\right), n, \frac{t\_0}{i}\right)\right) \cdot \left(n \cdot n\right)\\ \end{array} \end{array} \]
      (FPCore (i n)
       :precision binary64
       (let* ((t_0 (log (/ i n))))
         (if (<= i 1.05e+27)
           (* (fma (/ (expm1 i) i) 100.0 (* (/ (* (exp i) i) n) -50.0)) n)
           (*
            (* 100.0 (fma (fma (/ (pow t_0 2.0) i) 0.5 (pow i -2.0)) n (/ t_0 i)))
            (* n n)))))
      double code(double i, double n) {
      	double t_0 = log((i / n));
      	double tmp;
      	if (i <= 1.05e+27) {
      		tmp = fma((expm1(i) / i), 100.0, (((exp(i) * i) / n) * -50.0)) * n;
      	} else {
      		tmp = (100.0 * fma(fma((pow(t_0, 2.0) / i), 0.5, pow(i, -2.0)), n, (t_0 / i))) * (n * n);
      	}
      	return tmp;
      }
      
      function code(i, n)
      	t_0 = log(Float64(i / n))
      	tmp = 0.0
      	if (i <= 1.05e+27)
      		tmp = Float64(fma(Float64(expm1(i) / i), 100.0, Float64(Float64(Float64(exp(i) * i) / n) * -50.0)) * n);
      	else
      		tmp = Float64(Float64(100.0 * fma(fma(Float64((t_0 ^ 2.0) / i), 0.5, (i ^ -2.0)), n, Float64(t_0 / i))) * Float64(n * n));
      	end
      	return tmp
      end
      
      code[i_, n_] := Block[{t$95$0 = N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[i, 1.05e+27], N[(N[(N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision] * 100.0 + N[(N[(N[(N[Exp[i], $MachinePrecision] * i), $MachinePrecision] / n), $MachinePrecision] * -50.0), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], N[(N[(100.0 * N[(N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] / i), $MachinePrecision] * 0.5 + N[Power[i, -2.0], $MachinePrecision]), $MachinePrecision] * n + N[(t$95$0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(n * n), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \log \left(\frac{i}{n}\right)\\
      \mathbf{if}\;i \leq 1.05 \cdot 10^{+27}:\\
      \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(100 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{{t\_0}^{2}}{i}, 0.5, {i}^{-2}\right), n, \frac{t\_0}{i}\right)\right) \cdot \left(n \cdot n\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if i < 1.04999999999999997e27

        1. Initial program 25.9%

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

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

            \[\leadsto \left(-50 \cdot \frac{i \cdot e^{i}}{n} + 100 \cdot \frac{e^{i} - 1}{i}\right) \cdot \color{blue}{n} \]
          2. lower-*.f64N/A

            \[\leadsto \left(-50 \cdot \frac{i \cdot e^{i}}{n} + 100 \cdot \frac{e^{i} - 1}{i}\right) \cdot \color{blue}{n} \]
          3. +-commutativeN/A

            \[\leadsto \left(100 \cdot \frac{e^{i} - 1}{i} + -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          4. *-commutativeN/A

            \[\leadsto \left(\frac{e^{i} - 1}{i} \cdot 100 + -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          5. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{i} - 1}{i}, 100, -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          6. lower-/.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{e^{i} - 1}{i}, 100, -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          7. lower-expm1.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, -50 \cdot \frac{i \cdot e^{i}}{n}\right) \cdot n \]
          8. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{i \cdot e^{i}}{n} \cdot -50\right) \cdot n \]
          9. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{i \cdot e^{i}}{n} \cdot -50\right) \cdot n \]
          10. lower-/.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{i \cdot e^{i}}{n} \cdot -50\right) \cdot n \]
          11. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n \]
          12. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n \]
          13. lower-exp.f6482.9

            \[\leadsto \mathsf{fma}\left(\frac{\mathsf{expm1}\left(i\right)}{i}, 100, \frac{e^{i} \cdot i}{n} \cdot -50\right) \cdot n \]
        5. Applied rewrites82.9%

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

        if 1.04999999999999997e27 < i

        1. Initial program 47.5%

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

          \[\leadsto 100 \cdot \color{blue}{\frac{n \cdot \left(e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1\right)}{i}} \]
        4. Step-by-step derivation
          1. associate-/l*N/A

            \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
          2. lower-*.f64N/A

            \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
          3. lower-/.f64N/A

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

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

          \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{\color{blue}{i}} \]
        7. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
          2. lower-*.f64N/A

            \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
          3. lower-expm1.f64N/A

            \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
          4. lower-*.f64N/A

            \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
          5. diff-logN/A

            \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
          6. lower-log.f64N/A

            \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
          7. lift-/.f6430.4

            \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
        8. Applied rewrites30.4%

          \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{\color{blue}{i}} \]
        9. Step-by-step derivation
          1. Applied rewrites54.4%

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

            \[\leadsto \color{blue}{{n}^{2} \cdot \left(100 \cdot \left(n \cdot \left(\frac{1}{2} \cdot \frac{{\left(\log i + -1 \cdot \log n\right)}^{2}}{i} + \frac{1}{{i}^{2}}\right)\right) + 100 \cdot \frac{\log i + -1 \cdot \log n}{i}\right)} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \left(100 \cdot \left(n \cdot \left(\frac{1}{2} \cdot \frac{{\left(\log i + -1 \cdot \log n\right)}^{2}}{i} + \frac{1}{{i}^{2}}\right)\right) + 100 \cdot \frac{\log i + -1 \cdot \log n}{i}\right) \cdot \color{blue}{{n}^{2}} \]
            2. lower-*.f64N/A

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

            \[\leadsto \color{blue}{\left(100 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{{\log \left(\frac{i}{n}\right)}^{2}}{i}, 0.5, {i}^{-2}\right), n, \frac{\log \left(\frac{i}{n}\right)}{i}\right)\right) \cdot \left(n \cdot n\right)} \]
        10. Recombined 2 regimes into one program.
        11. Add Preprocessing

        Alternative 7: 23.6% accurate, N/A× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\frac{i}{n}\right)\\ t_1 := \mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right)\\ \mathbf{if}\;i \leq -3.2 \cdot 10^{+36}:\\ \;\;\;\;\frac{\left(--100\right) \cdot \mathsf{fma}\left(\mathsf{expm1}\left(t\_1 \cdot n\right), n, {n}^{3} \cdot \frac{{\left(e^{n}\right)}^{t\_1}}{i}\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;\left(100 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{{t\_0}^{2}}{i}, 0.5, {i}^{-2}\right), n, \frac{t\_0}{i}\right)\right) \cdot \left(n \cdot n\right)\\ \end{array} \end{array} \]
        (FPCore (i n)
         :precision binary64
         (let* ((t_0 (log (/ i n))) (t_1 (fma (log (/ -1.0 i)) -1.0 (log (/ -1.0 n)))))
           (if (<= i -3.2e+36)
             (/
              (*
               (- -100.0)
               (fma (expm1 (* t_1 n)) n (* (pow n 3.0) (/ (pow (exp n) t_1) i))))
              i)
             (*
              (* 100.0 (fma (fma (/ (pow t_0 2.0) i) 0.5 (pow i -2.0)) n (/ t_0 i)))
              (* n n)))))
        double code(double i, double n) {
        	double t_0 = log((i / n));
        	double t_1 = fma(log((-1.0 / i)), -1.0, log((-1.0 / n)));
        	double tmp;
        	if (i <= -3.2e+36) {
        		tmp = (-(-100.0) * fma(expm1((t_1 * n)), n, (pow(n, 3.0) * (pow(exp(n), t_1) / i)))) / i;
        	} else {
        		tmp = (100.0 * fma(fma((pow(t_0, 2.0) / i), 0.5, pow(i, -2.0)), n, (t_0 / i))) * (n * n);
        	}
        	return tmp;
        }
        
        function code(i, n)
        	t_0 = log(Float64(i / n))
        	t_1 = fma(log(Float64(-1.0 / i)), -1.0, log(Float64(-1.0 / n)))
        	tmp = 0.0
        	if (i <= -3.2e+36)
        		tmp = Float64(Float64(Float64(-(-100.0)) * fma(expm1(Float64(t_1 * n)), n, Float64((n ^ 3.0) * Float64((exp(n) ^ t_1) / i)))) / i);
        	else
        		tmp = Float64(Float64(100.0 * fma(fma(Float64((t_0 ^ 2.0) / i), 0.5, (i ^ -2.0)), n, Float64(t_0 / i))) * Float64(n * n));
        	end
        	return tmp
        end
        
        code[i_, n_] := Block[{t$95$0 = N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(-1.0 / i), $MachinePrecision]], $MachinePrecision] * -1.0 + N[Log[N[(-1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -3.2e+36], N[(N[((--100.0) * N[(N[(Exp[N[(t$95$1 * n), $MachinePrecision]] - 1), $MachinePrecision] * n + N[(N[Power[n, 3.0], $MachinePrecision] * N[(N[Power[N[Exp[n], $MachinePrecision], t$95$1], $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], N[(N[(100.0 * N[(N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] / i), $MachinePrecision] * 0.5 + N[Power[i, -2.0], $MachinePrecision]), $MachinePrecision] * n + N[(t$95$0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(n * n), $MachinePrecision]), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \log \left(\frac{i}{n}\right)\\
        t_1 := \mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right)\\
        \mathbf{if}\;i \leq -3.2 \cdot 10^{+36}:\\
        \;\;\;\;\frac{\left(--100\right) \cdot \mathsf{fma}\left(\mathsf{expm1}\left(t\_1 \cdot n\right), n, {n}^{3} \cdot \frac{{\left(e^{n}\right)}^{t\_1}}{i}\right)}{i}\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(100 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{{t\_0}^{2}}{i}, 0.5, {i}^{-2}\right), n, \frac{t\_0}{i}\right)\right) \cdot \left(n \cdot n\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if i < -3.1999999999999999e36

          1. Initial program 69.7%

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

            \[\leadsto \color{blue}{-1 \cdot \frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i}} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i}\right) \]
            2. lower-neg.f64N/A

              \[\leadsto -\frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i} \]
            3. lower-/.f64N/A

              \[\leadsto -\frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i} \]
          5. Applied rewrites58.9%

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

          if -3.1999999999999999e36 < i

          1. Initial program 17.0%

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

            \[\leadsto 100 \cdot \color{blue}{\frac{n \cdot \left(e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1\right)}{i}} \]
          4. Step-by-step derivation
            1. associate-/l*N/A

              \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
            2. lower-*.f64N/A

              \[\leadsto 100 \cdot \left(n \cdot \color{blue}{\frac{e^{n \cdot \left(\log \left(\frac{1}{n}\right) + -1 \cdot \log \left(\frac{1}{i}\right)\right)} - 1}{i}}\right) \]
            3. lower-/.f64N/A

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

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

            \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{\color{blue}{i}} \]
          7. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
            2. lower-*.f64N/A

              \[\leadsto 100 \cdot \frac{n \cdot \left(e^{n \cdot \left(\log i - \log n\right)} - 1\right)}{i} \]
            3. lower-expm1.f64N/A

              \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
            4. lower-*.f64N/A

              \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \left(\log i - \log n\right)\right)}{i} \]
            5. diff-logN/A

              \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
            6. lower-log.f64N/A

              \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
            7. lift-/.f6415.3

              \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{i} \]
          8. Applied rewrites15.3%

            \[\leadsto 100 \cdot \frac{n \cdot \mathsf{expm1}\left(n \cdot \log \left(\frac{i}{n}\right)\right)}{\color{blue}{i}} \]
          9. Step-by-step derivation
            1. Applied rewrites22.1%

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

              \[\leadsto \color{blue}{{n}^{2} \cdot \left(100 \cdot \left(n \cdot \left(\frac{1}{2} \cdot \frac{{\left(\log i + -1 \cdot \log n\right)}^{2}}{i} + \frac{1}{{i}^{2}}\right)\right) + 100 \cdot \frac{\log i + -1 \cdot \log n}{i}\right)} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \left(100 \cdot \left(n \cdot \left(\frac{1}{2} \cdot \frac{{\left(\log i + -1 \cdot \log n\right)}^{2}}{i} + \frac{1}{{i}^{2}}\right)\right) + 100 \cdot \frac{\log i + -1 \cdot \log n}{i}\right) \cdot \color{blue}{{n}^{2}} \]
              2. lower-*.f64N/A

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

              \[\leadsto \color{blue}{\left(100 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{{\log \left(\frac{i}{n}\right)}^{2}}{i}, 0.5, {i}^{-2}\right), n, \frac{\log \left(\frac{i}{n}\right)}{i}\right)\right) \cdot \left(n \cdot n\right)} \]
          10. Recombined 2 regimes into one program.
          11. Final simplification27.8%

            \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -3.2 \cdot 10^{+36}:\\ \;\;\;\;\frac{\left(--100\right) \cdot \mathsf{fma}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right) \cdot n\right), n, {n}^{3} \cdot \frac{{\left(e^{n}\right)}^{\left(\mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right)\right)}}{i}\right)}{i}\\ \mathbf{else}:\\ \;\;\;\;\left(100 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{{\log \left(\frac{i}{n}\right)}^{2}}{i}, 0.5, {i}^{-2}\right), n, \frac{\log \left(\frac{i}{n}\right)}{i}\right)\right) \cdot \left(n \cdot n\right)\\ \end{array} \]
          12. Add Preprocessing

          Alternative 8: 13.2% accurate, N/A× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right)\\ \frac{\left(--100\right) \cdot \mathsf{fma}\left(\mathsf{expm1}\left(t\_0 \cdot n\right), n, {n}^{3} \cdot \frac{{\left(e^{n}\right)}^{t\_0}}{i}\right)}{i} \end{array} \end{array} \]
          (FPCore (i n)
           :precision binary64
           (let* ((t_0 (fma (log (/ -1.0 i)) -1.0 (log (/ -1.0 n)))))
             (/
              (*
               (- -100.0)
               (fma (expm1 (* t_0 n)) n (* (pow n 3.0) (/ (pow (exp n) t_0) i))))
              i)))
          double code(double i, double n) {
          	double t_0 = fma(log((-1.0 / i)), -1.0, log((-1.0 / n)));
          	return (-(-100.0) * fma(expm1((t_0 * n)), n, (pow(n, 3.0) * (pow(exp(n), t_0) / i)))) / i;
          }
          
          function code(i, n)
          	t_0 = fma(log(Float64(-1.0 / i)), -1.0, log(Float64(-1.0 / n)))
          	return Float64(Float64(Float64(-(-100.0)) * fma(expm1(Float64(t_0 * n)), n, Float64((n ^ 3.0) * Float64((exp(n) ^ t_0) / i)))) / i)
          end
          
          code[i_, n_] := Block[{t$95$0 = N[(N[Log[N[(-1.0 / i), $MachinePrecision]], $MachinePrecision] * -1.0 + N[Log[N[(-1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[((--100.0) * N[(N[(Exp[N[(t$95$0 * n), $MachinePrecision]] - 1), $MachinePrecision] * n + N[(N[Power[n, 3.0], $MachinePrecision] * N[(N[Power[N[Exp[n], $MachinePrecision], t$95$0], $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right)\\
          \frac{\left(--100\right) \cdot \mathsf{fma}\left(\mathsf{expm1}\left(t\_0 \cdot n\right), n, {n}^{3} \cdot \frac{{\left(e^{n}\right)}^{t\_0}}{i}\right)}{i}
          \end{array}
          \end{array}
          
          Derivation
          1. Initial program 29.6%

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

            \[\leadsto \color{blue}{-1 \cdot \frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i}} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(\frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i}\right) \]
            2. lower-neg.f64N/A

              \[\leadsto -\frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i} \]
            3. lower-/.f64N/A

              \[\leadsto -\frac{-100 \cdot \left(n \cdot \left(e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)} - 1\right)\right) + -100 \cdot \frac{{n}^{3} \cdot e^{n \cdot \left(\log \left(\mathsf{neg}\left(\frac{1}{n}\right)\right) + -1 \cdot \log \left(\frac{-1}{i}\right)\right)}}{i}}{i} \]
          5. Applied rewrites17.6%

            \[\leadsto \color{blue}{-\frac{-100 \cdot \mathsf{fma}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right) \cdot n\right), n, {n}^{3} \cdot \frac{{\left(e^{n}\right)}^{\left(\mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right)\right)}}{i}\right)}{i}} \]
          6. Final simplification17.6%

            \[\leadsto \frac{\left(--100\right) \cdot \mathsf{fma}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right) \cdot n\right), n, {n}^{3} \cdot \frac{{\left(e^{n}\right)}^{\left(\mathsf{fma}\left(\log \left(\frac{-1}{i}\right), -1, \log \left(\frac{-1}{n}\right)\right)\right)}}{i}\right)}{i} \]
          7. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025057 
          (FPCore (i n)
            :name "Compound Interest"
            :precision binary64
          
            :alt
            (! :herbie-platform default (let ((lnbase (if (== (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) (* 100 (/ (- (exp (* n lnbase)) 1) (/ i n)))))
          
            (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))