
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 -5e-24)
(* 100.0 (+ (* t_0 (/ n i)) (* n (/ -1.0 i))))
(if (<= t_1 0.0)
(/ (* 100.0 (expm1 (* n (log1p (/ i n))))) (/ i n))
(if (<= t_1 INFINITY)
(/ (+ (* t_0 100.0) -100.0) (/ i n))
(* n 100.0))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -5e-24) {
tmp = 100.0 * ((t_0 * (n / i)) + (n * (-1.0 / i)));
} else if (t_1 <= 0.0) {
tmp = (100.0 * expm1((n * log1p((i / n))))) / (i / n);
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -5e-24) {
tmp = 100.0 * ((t_0 * (n / i)) + (n * (-1.0 / i)));
} else if (t_1 <= 0.0) {
tmp = (100.0 * Math.expm1((n * Math.log1p((i / n))))) / (i / n);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= -5e-24: tmp = 100.0 * ((t_0 * (n / i)) + (n * (-1.0 / i))) elif t_1 <= 0.0: tmp = (100.0 * math.expm1((n * math.log1p((i / n))))) / (i / n) elif t_1 <= math.inf: tmp = ((t_0 * 100.0) + -100.0) / (i / n) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -5e-24) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) + Float64(n * Float64(-1.0 / i)))); elseif (t_1 <= 0.0) tmp = Float64(Float64(100.0 * expm1(Float64(n * log1p(Float64(i / n))))) / Float64(i / n)); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(t_0 * 100.0) + -100.0) / Float64(i / n)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-24], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] + N[(n * N[(-1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(100.0 * N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-24}:\\
\;\;\;\;100 \cdot \left(t\_0 \cdot \frac{n}{i} + n \cdot \frac{-1}{i}\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{t\_0 \cdot 100 + -100}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -4.9999999999999998e-24Initial program 99.7%
div-sub99.7%
clear-num99.7%
div-inv100.0%
cancel-sign-sub-inv100.0%
div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
if -4.9999999999999998e-24 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 26.2%
associate-*r/26.2%
*-commutative26.2%
add-exp-log26.2%
expm1-define26.2%
log-pow36.0%
log1p-define99.6%
Applied egg-rr99.6%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.7%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 78.0%
*-commutative78.0%
Simplified78.0%
Final simplification96.0%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 -5e-24)
(* 100.0 (+ (* t_0 (/ n i)) (* n (/ -1.0 i))))
(if (<= t_1 0.0)
(* n (* (expm1 (* n (log1p (/ i n)))) (/ 100.0 i)))
(if (<= t_1 INFINITY)
(/ (+ (* t_0 100.0) -100.0) (/ i n))
(* n 100.0))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -5e-24) {
tmp = 100.0 * ((t_0 * (n / i)) + (n * (-1.0 / i)));
} else if (t_1 <= 0.0) {
tmp = n * (expm1((n * log1p((i / n)))) * (100.0 / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -5e-24) {
tmp = 100.0 * ((t_0 * (n / i)) + (n * (-1.0 / i)));
} else if (t_1 <= 0.0) {
tmp = n * (Math.expm1((n * Math.log1p((i / n)))) * (100.0 / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= -5e-24: tmp = 100.0 * ((t_0 * (n / i)) + (n * (-1.0 / i))) elif t_1 <= 0.0: tmp = n * (math.expm1((n * math.log1p((i / n)))) * (100.0 / i)) elif t_1 <= math.inf: tmp = ((t_0 * 100.0) + -100.0) / (i / n) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -5e-24) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) + Float64(n * Float64(-1.0 / i)))); elseif (t_1 <= 0.0) tmp = Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(100.0 / i))); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(t_0 * 100.0) + -100.0) / Float64(i / n)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-24], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] + N[(n * N[(-1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(100.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-24}:\\
\;\;\;\;100 \cdot \left(t\_0 \cdot \frac{n}{i} + n \cdot \frac{-1}{i}\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;n \cdot \left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{100}{i}\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{t\_0 \cdot 100 + -100}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -4.9999999999999998e-24Initial program 99.7%
div-sub99.7%
clear-num99.7%
div-inv100.0%
cancel-sign-sub-inv100.0%
div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
if -4.9999999999999998e-24 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 26.2%
associate-*r/26.2%
clear-num26.2%
*-commutative26.2%
add-exp-log26.2%
expm1-define26.2%
log-pow35.7%
log1p-define99.2%
Applied egg-rr99.2%
associate-/r/98.5%
/-rgt-identity98.5%
times-frac99.6%
*-lft-identity99.6%
*-rgt-identity99.6%
associate-/r/99.0%
*-commutative99.0%
associate-/l*99.0%
Simplified99.0%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.7%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 78.0%
*-commutative78.0%
Simplified78.0%
Final simplification95.5%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (* n (/ (expm1 i) i)))))
(if (<= n -5.2e-185)
t_0
(if (<= n -1e-308)
0.0
(if (<= n 6.5e-161)
(* n (* 100.0 (* n (/ (- (log i) (log n)) i))))
t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (n * (expm1(i) / i));
double tmp;
if (n <= -5.2e-185) {
tmp = t_0;
} else if (n <= -1e-308) {
tmp = 0.0;
} else if (n <= 6.5e-161) {
tmp = n * (100.0 * (n * ((log(i) - log(n)) / i)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (n * (Math.expm1(i) / i));
double tmp;
if (n <= -5.2e-185) {
tmp = t_0;
} else if (n <= -1e-308) {
tmp = 0.0;
} else if (n <= 6.5e-161) {
tmp = n * (100.0 * (n * ((Math.log(i) - Math.log(n)) / i)));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (n * (math.expm1(i) / i)) tmp = 0 if n <= -5.2e-185: tmp = t_0 elif n <= -1e-308: tmp = 0.0 elif n <= 6.5e-161: tmp = n * (100.0 * (n * ((math.log(i) - math.log(n)) / i))) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(n * Float64(expm1(i) / i))) tmp = 0.0 if (n <= -5.2e-185) tmp = t_0; elseif (n <= -1e-308) tmp = 0.0; elseif (n <= 6.5e-161) tmp = Float64(n * Float64(100.0 * Float64(n * Float64(Float64(log(i) - log(n)) / i)))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -5.2e-185], t$95$0, If[LessEqual[n, -1e-308], 0.0, If[LessEqual[n, 6.5e-161], N[(n * N[(100.0 * N[(n * N[(N[(N[Log[i], $MachinePrecision] - N[Log[n], $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{if}\;n \leq -5.2 \cdot 10^{-185}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -1 \cdot 10^{-308}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 6.5 \cdot 10^{-161}:\\
\;\;\;\;n \cdot \left(100 \cdot \left(n \cdot \frac{\log i - \log n}{i}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -5.1999999999999997e-185 or 6.50000000000000008e-161 < n Initial program 21.5%
Taylor expanded in n around inf 37.5%
*-commutative37.5%
associate-/l*37.4%
expm1-define85.3%
Simplified85.3%
if -5.1999999999999997e-185 < n < -9.9999999999999991e-309Initial program 79.4%
div-sub79.4%
clear-num73.1%
div-inv78.1%
cancel-sign-sub-inv78.1%
div-inv78.1%
clear-num73.0%
Applied egg-rr73.0%
Taylor expanded in i around 0 79.4%
distribute-rgt1-in79.4%
metadata-eval79.4%
mul0-lft79.4%
div079.4%
Simplified79.4%
if -9.9999999999999991e-309 < n < 6.50000000000000008e-161Initial program 48.7%
associate-*r/48.7%
clear-num48.7%
*-commutative48.7%
add-exp-log48.7%
expm1-define48.7%
log-pow64.2%
log1p-define68.2%
Applied egg-rr68.2%
associate-/r/70.8%
/-rgt-identity70.8%
times-frac70.8%
*-lft-identity70.8%
*-rgt-identity70.8%
associate-/r/71.2%
*-commutative71.2%
associate-/l*71.1%
Simplified71.1%
Taylor expanded in n around 0 95.1%
associate-/l*95.2%
mul-1-neg95.2%
unsub-neg95.2%
Simplified95.2%
Final simplification85.8%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ (expm1 i) (/ i n)))))
(if (<= i -7.1e-40)
t_0
(if (<= i 3.2e-54)
(+ (* n 100.0) (* 100.0 (* i -0.5)))
(if (<= i 6.4e+205) t_0 (* 100.0 (* (/ 1.0 i) (+ n n))))))))
double code(double i, double n) {
double t_0 = 100.0 * (expm1(i) / (i / n));
double tmp;
if (i <= -7.1e-40) {
tmp = t_0;
} else if (i <= 3.2e-54) {
tmp = (n * 100.0) + (100.0 * (i * -0.5));
} else if (i <= 6.4e+205) {
tmp = t_0;
} else {
tmp = 100.0 * ((1.0 / i) * (n + n));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (Math.expm1(i) / (i / n));
double tmp;
if (i <= -7.1e-40) {
tmp = t_0;
} else if (i <= 3.2e-54) {
tmp = (n * 100.0) + (100.0 * (i * -0.5));
} else if (i <= 6.4e+205) {
tmp = t_0;
} else {
tmp = 100.0 * ((1.0 / i) * (n + n));
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (math.expm1(i) / (i / n)) tmp = 0 if i <= -7.1e-40: tmp = t_0 elif i <= 3.2e-54: tmp = (n * 100.0) + (100.0 * (i * -0.5)) elif i <= 6.4e+205: tmp = t_0 else: tmp = 100.0 * ((1.0 / i) * (n + n)) return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(expm1(i) / Float64(i / n))) tmp = 0.0 if (i <= -7.1e-40) tmp = t_0; elseif (i <= 3.2e-54) tmp = Float64(Float64(n * 100.0) + Float64(100.0 * Float64(i * -0.5))); elseif (i <= 6.4e+205) tmp = t_0; else tmp = Float64(100.0 * Float64(Float64(1.0 / i) * Float64(n + n))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -7.1e-40], t$95$0, If[LessEqual[i, 3.2e-54], N[(N[(n * 100.0), $MachinePrecision] + N[(100.0 * N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 6.4e+205], t$95$0, N[(100.0 * N[(N[(1.0 / i), $MachinePrecision] * N[(n + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{if}\;i \leq -7.1 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;i \leq 3.2 \cdot 10^{-54}:\\
\;\;\;\;n \cdot 100 + 100 \cdot \left(i \cdot -0.5\right)\\
\mathbf{elif}\;i \leq 6.4 \cdot 10^{+205}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\frac{1}{i} \cdot \left(n + n\right)\right)\\
\end{array}
\end{array}
if i < -7.10000000000000023e-40 or 3.19999999999999998e-54 < i < 6.39999999999999993e205Initial program 44.7%
Taylor expanded in n around inf 68.9%
expm1-define74.7%
Simplified74.7%
if -7.10000000000000023e-40 < i < 3.19999999999999998e-54Initial program 9.5%
Taylor expanded in i around 0 84.7%
Taylor expanded in n around 0 84.7%
if 6.39999999999999993e205 < i Initial program 42.9%
div-sub42.9%
clear-num36.6%
div-inv42.9%
cancel-sign-sub-inv42.9%
div-inv42.9%
clear-num36.3%
Applied egg-rr36.3%
Taylor expanded in i around 0 52.3%
*-un-lft-identity52.3%
div-inv58.3%
distribute-rgt-out58.3%
add-sqr-sqrt1.4%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod51.0%
add-sqr-sqrt58.6%
Applied egg-rr58.6%
Final simplification78.5%
(FPCore (i n) :precision binary64 (if (or (<= n -2.5e-190) (not (<= n 7e-182))) (* 100.0 (* n (/ (expm1 i) i))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -2.5e-190) || !(n <= 7e-182)) {
tmp = 100.0 * (n * (expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -2.5e-190) || !(n <= 7e-182)) {
tmp = 100.0 * (n * (Math.expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2.5e-190) or not (n <= 7e-182): tmp = 100.0 * (n * (math.expm1(i) / i)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -2.5e-190) || !(n <= 7e-182)) tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2.5e-190], N[Not[LessEqual[n, 7e-182]], $MachinePrecision]], N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.5 \cdot 10^{-190} \lor \neg \left(n \leq 7 \cdot 10^{-182}\right):\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -2.50000000000000017e-190 or 6.99999999999999966e-182 < n Initial program 21.5%
Taylor expanded in n around inf 36.7%
*-commutative36.7%
associate-/l*36.7%
expm1-define84.0%
Simplified84.0%
if -2.50000000000000017e-190 < n < 6.99999999999999966e-182Initial program 66.9%
div-sub66.9%
clear-num55.9%
div-inv55.9%
cancel-sign-sub-inv55.9%
div-inv55.9%
clear-num61.1%
Applied egg-rr61.1%
Taylor expanded in i around 0 85.8%
distribute-rgt1-in85.8%
metadata-eval85.8%
mul0-lft85.8%
div085.8%
Simplified85.8%
Final simplification84.2%
(FPCore (i n) :precision binary64 (if (or (<= n -3.4e-179) (not (<= n 4.2e-162))) (+ (* n 100.0) (* (* n (- 0.5 (/ 0.5 n))) (* i 100.0))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -3.4e-179) || !(n <= 4.2e-162)) {
tmp = (n * 100.0) + ((n * (0.5 - (0.5 / n))) * (i * 100.0));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-3.4d-179)) .or. (.not. (n <= 4.2d-162))) then
tmp = (n * 100.0d0) + ((n * (0.5d0 - (0.5d0 / n))) * (i * 100.0d0))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -3.4e-179) || !(n <= 4.2e-162)) {
tmp = (n * 100.0) + ((n * (0.5 - (0.5 / n))) * (i * 100.0));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -3.4e-179) or not (n <= 4.2e-162): tmp = (n * 100.0) + ((n * (0.5 - (0.5 / n))) * (i * 100.0)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -3.4e-179) || !(n <= 4.2e-162)) tmp = Float64(Float64(n * 100.0) + Float64(Float64(n * Float64(0.5 - Float64(0.5 / n))) * Float64(i * 100.0))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -3.4e-179) || ~((n <= 4.2e-162))) tmp = (n * 100.0) + ((n * (0.5 - (0.5 / n))) * (i * 100.0)); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -3.4e-179], N[Not[LessEqual[n, 4.2e-162]], $MachinePrecision]], N[(N[(n * 100.0), $MachinePrecision] + N[(N[(n * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(i * 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.4 \cdot 10^{-179} \lor \neg \left(n \leq 4.2 \cdot 10^{-162}\right):\\
\;\;\;\;n \cdot 100 + \left(n \cdot \left(0.5 - \frac{0.5}{n}\right)\right) \cdot \left(i \cdot 100\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -3.3999999999999997e-179 or 4.2e-162 < n Initial program 21.5%
Taylor expanded in i around 0 58.0%
add-log-exp49.5%
associate-*r*49.5%
*-commutative49.5%
exp-prod63.0%
*-commutative63.0%
exp-prod63.0%
cancel-sign-sub-inv63.0%
un-div-inv63.0%
metadata-eval63.0%
Applied egg-rr63.0%
log-pow65.6%
metadata-eval65.6%
distribute-neg-frac65.6%
metadata-eval65.6%
associate-*r/65.6%
sub-neg65.6%
associate-*r/65.6%
metadata-eval65.6%
log-pow58.0%
rem-log-exp58.0%
*-commutative58.0%
Simplified58.0%
if -3.3999999999999997e-179 < n < 4.2e-162Initial program 61.9%
div-sub61.9%
clear-num51.0%
div-inv52.1%
cancel-sign-sub-inv52.1%
div-inv52.1%
clear-num55.6%
Applied egg-rr55.6%
Taylor expanded in i around 0 78.5%
distribute-rgt1-in78.5%
metadata-eval78.5%
mul0-lft78.5%
div078.5%
Simplified78.5%
Final simplification61.4%
(FPCore (i n) :precision binary64 (if (or (<= n -5.5e-175) (not (<= n 7e-162))) (* 100.0 (+ n (* i (* n (- 0.5 (/ 0.5 n)))))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -5.5e-175) || !(n <= 7e-162)) {
tmp = 100.0 * (n + (i * (n * (0.5 - (0.5 / n)))));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-5.5d-175)) .or. (.not. (n <= 7d-162))) then
tmp = 100.0d0 * (n + (i * (n * (0.5d0 - (0.5d0 / n)))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -5.5e-175) || !(n <= 7e-162)) {
tmp = 100.0 * (n + (i * (n * (0.5 - (0.5 / n)))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -5.5e-175) or not (n <= 7e-162): tmp = 100.0 * (n + (i * (n * (0.5 - (0.5 / n))))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -5.5e-175) || !(n <= 7e-162)) tmp = Float64(100.0 * Float64(n + Float64(i * Float64(n * Float64(0.5 - Float64(0.5 / n)))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -5.5e-175) || ~((n <= 7e-162))) tmp = 100.0 * (n + (i * (n * (0.5 - (0.5 / n))))); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -5.5e-175], N[Not[LessEqual[n, 7e-162]], $MachinePrecision]], N[(100.0 * N[(n + N[(i * N[(n * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.5 \cdot 10^{-175} \lor \neg \left(n \leq 7 \cdot 10^{-162}\right):\\
\;\;\;\;100 \cdot \left(n + i \cdot \left(n \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -5.50000000000000054e-175 or 6.9999999999999998e-162 < n Initial program 21.5%
Taylor expanded in i around 0 58.0%
associate-*r/58.0%
metadata-eval58.0%
Simplified58.0%
if -5.50000000000000054e-175 < n < 6.9999999999999998e-162Initial program 61.9%
div-sub61.9%
clear-num51.0%
div-inv52.1%
cancel-sign-sub-inv52.1%
div-inv52.1%
clear-num55.6%
Applied egg-rr55.6%
Taylor expanded in i around 0 78.5%
distribute-rgt1-in78.5%
metadata-eval78.5%
mul0-lft78.5%
div078.5%
Simplified78.5%
Final simplification61.4%
(FPCore (i n) :precision binary64 (if (or (<= n -1.4e-181) (not (<= n 1.45e-182))) (* n (+ 100.0 (* i 50.0))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.4e-181) || !(n <= 1.45e-182)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-1.4d-181)) .or. (.not. (n <= 1.45d-182))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.4e-181) || !(n <= 1.45e-182)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.4e-181) or not (n <= 1.45e-182): tmp = n * (100.0 + (i * 50.0)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.4e-181) || !(n <= 1.45e-182)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.4e-181) || ~((n <= 1.45e-182))) tmp = n * (100.0 + (i * 50.0)); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.4e-181], N[Not[LessEqual[n, 1.45e-182]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.4 \cdot 10^{-181} \lor \neg \left(n \leq 1.45 \cdot 10^{-182}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.39999999999999993e-181 or 1.44999999999999993e-182 < n Initial program 21.5%
Taylor expanded in n around inf 36.7%
*-commutative36.7%
associate-/l*36.7%
expm1-define84.0%
Simplified84.0%
Taylor expanded in i around 0 57.2%
associate-*r*57.2%
distribute-rgt-out57.2%
Applied egg-rr57.2%
if -1.39999999999999993e-181 < n < 1.44999999999999993e-182Initial program 66.9%
div-sub66.9%
clear-num55.9%
div-inv55.9%
cancel-sign-sub-inv55.9%
div-inv55.9%
clear-num61.1%
Applied egg-rr61.1%
Taylor expanded in i around 0 85.8%
distribute-rgt1-in85.8%
metadata-eval85.8%
mul0-lft85.8%
div085.8%
Simplified85.8%
Final simplification61.3%
(FPCore (i n) :precision binary64 (if (<= n -1.16e-175) (+ (* n 100.0) (* 50.0 (* i n))) (if (<= n 2.6e-182) 0.0 (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -1.16e-175) {
tmp = (n * 100.0) + (50.0 * (i * n));
} else if (n <= 2.6e-182) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-1.16d-175)) then
tmp = (n * 100.0d0) + (50.0d0 * (i * n))
else if (n <= 2.6d-182) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -1.16e-175) {
tmp = (n * 100.0) + (50.0 * (i * n));
} else if (n <= 2.6e-182) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.16e-175: tmp = (n * 100.0) + (50.0 * (i * n)) elif n <= 2.6e-182: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.16e-175) tmp = Float64(Float64(n * 100.0) + Float64(50.0 * Float64(i * n))); elseif (n <= 2.6e-182) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -1.16e-175) tmp = (n * 100.0) + (50.0 * (i * n)); elseif (n <= 2.6e-182) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -1.16e-175], N[(N[(n * 100.0), $MachinePrecision] + N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.6e-182], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.16 \cdot 10^{-175}:\\
\;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\
\mathbf{elif}\;n \leq 2.6 \cdot 10^{-182}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -1.16000000000000002e-175Initial program 27.7%
Taylor expanded in n around inf 42.1%
*-commutative42.1%
associate-/l*42.1%
expm1-define84.0%
Simplified84.0%
Taylor expanded in i around 0 50.1%
if -1.16000000000000002e-175 < n < 2.60000000000000006e-182Initial program 66.9%
div-sub66.9%
clear-num55.9%
div-inv55.9%
cancel-sign-sub-inv55.9%
div-inv55.9%
clear-num61.1%
Applied egg-rr61.1%
Taylor expanded in i around 0 85.8%
distribute-rgt1-in85.8%
metadata-eval85.8%
mul0-lft85.8%
div085.8%
Simplified85.8%
if 2.60000000000000006e-182 < n Initial program 15.6%
Taylor expanded in n around inf 31.4%
*-commutative31.4%
associate-/l*31.4%
expm1-define83.9%
Simplified83.9%
Taylor expanded in i around 0 64.1%
associate-*r*64.1%
distribute-rgt-out64.1%
Applied egg-rr64.1%
Final simplification61.3%
(FPCore (i n) :precision binary64 (if (or (<= n -2.5e-189) (not (<= n 2e-181))) (* n 100.0) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -2.5e-189) || !(n <= 2e-181)) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-2.5d-189)) .or. (.not. (n <= 2d-181))) then
tmp = n * 100.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -2.5e-189) || !(n <= 2e-181)) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2.5e-189) or not (n <= 2e-181): tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -2.5e-189) || !(n <= 2e-181)) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -2.5e-189) || ~((n <= 2e-181))) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -2.5e-189], N[Not[LessEqual[n, 2e-181]], $MachinePrecision]], N[(n * 100.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.5 \cdot 10^{-189} \lor \neg \left(n \leq 2 \cdot 10^{-181}\right):\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -2.4999999999999999e-189 or 2.00000000000000009e-181 < n Initial program 21.5%
Taylor expanded in i around 0 52.1%
*-commutative52.1%
Simplified52.1%
if -2.4999999999999999e-189 < n < 2.00000000000000009e-181Initial program 66.9%
div-sub66.9%
clear-num55.9%
div-inv55.9%
cancel-sign-sub-inv55.9%
div-inv55.9%
clear-num61.1%
Applied egg-rr61.1%
Taylor expanded in i around 0 85.8%
distribute-rgt1-in85.8%
metadata-eval85.8%
mul0-lft85.8%
div085.8%
Simplified85.8%
Final simplification57.0%
(FPCore (i n) :precision binary64 (* n -100.0))
double code(double i, double n) {
return n * -100.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n * (-100.0d0)
end function
public static double code(double i, double n) {
return n * -100.0;
}
def code(i, n): return n * -100.0
function code(i, n) return Float64(n * -100.0) end
function tmp = code(i, n) tmp = n * -100.0; end
code[i_, n_] := N[(n * -100.0), $MachinePrecision]
\begin{array}{l}
\\
n \cdot -100
\end{array}
Initial program 28.1%
associate-*r/28.1%
sub-neg28.1%
distribute-lft-in28.1%
metadata-eval28.1%
metadata-eval28.1%
Simplified28.1%
Taylor expanded in i around 0 16.3%
*-commutative16.3%
Simplified16.3%
frac-2neg16.3%
div-inv16.2%
+-commutative16.2%
associate-+l+41.4%
metadata-eval41.4%
distribute-neg-frac241.4%
clear-num40.3%
add-sqr-sqrt19.4%
sqrt-unprod32.1%
sqr-neg32.1%
sqrt-unprod4.5%
add-sqr-sqrt8.5%
Applied egg-rr8.5%
*-commutative8.5%
+-rgt-identity8.5%
distribute-rgt-neg-in8.5%
metadata-eval8.5%
Simplified8.5%
Taylor expanded in n around 0 2.3%
Final simplification2.3%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 28.1%
div-sub28.1%
clear-num25.6%
div-inv26.3%
cancel-sign-sub-inv26.3%
div-inv26.3%
clear-num26.5%
Applied egg-rr26.5%
Taylor expanded in i around 0 19.1%
distribute-rgt1-in19.1%
metadata-eval19.1%
mul0-lft19.1%
div019.1%
Simplified19.1%
Final simplification19.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t\_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t\_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2024053
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:alt
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))