
(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 0.0)
(* 100.0 (* n (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_1 INFINITY) (* n (/ (+ (* t_0 100.0) -100.0) i)) (* n 100.0)))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (n * (expm1((n * log1p((i / n)))) / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (n * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= 0.0: tmp = 100.0 * (n * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_1 <= math.inf: tmp = n * (((t_0 * 100.0) + -100.0) / i) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(100.0 * Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_1 <= Inf) tmp = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t_0 \cdot 100 + -100}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 25.2%
div-inv25.2%
associate-/r/24.8%
associate-*l*24.8%
div-inv24.8%
pow-to-exp23.8%
expm1-def33.5%
*-commutative33.5%
log1p-udef98.0%
Applied egg-rr98.0%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.4%
associate-/r/99.4%
associate-*r*99.5%
*-commutative99.5%
associate-*r/99.5%
sub-neg99.5%
distribute-lft-in99.9%
fma-def99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
fma-udef99.9%
*-commutative99.9%
Applied egg-rr99.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 83.3%
*-commutative83.3%
Simplified83.3%
Final simplification95.6%
(FPCore (i n) :precision binary64 (if (or (<= i -1.15e-9) (not (<= i 1.9e-29))) (* (expm1 i) (* n (/ 100.0 i))) (* (* n 100.0) (+ 1.0 (* i 0.5)))))
double code(double i, double n) {
double tmp;
if ((i <= -1.15e-9) || !(i <= 1.9e-29)) {
tmp = expm1(i) * (n * (100.0 / i));
} else {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -1.15e-9) || !(i <= 1.9e-29)) {
tmp = Math.expm1(i) * (n * (100.0 / i));
} else {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -1.15e-9) or not (i <= 1.9e-29): tmp = math.expm1(i) * (n * (100.0 / i)) else: tmp = (n * 100.0) * (1.0 + (i * 0.5)) return tmp
function code(i, n) tmp = 0.0 if ((i <= -1.15e-9) || !(i <= 1.9e-29)) tmp = Float64(expm1(i) * Float64(n * Float64(100.0 / i))); else tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5))); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -1.15e-9], N[Not[LessEqual[i, 1.9e-29]], $MachinePrecision]], N[(N[(Exp[i] - 1), $MachinePrecision] * N[(n * N[(100.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.15 \cdot 10^{-9} \lor \neg \left(i \leq 1.9 \cdot 10^{-29}\right):\\
\;\;\;\;\mathsf{expm1}\left(i\right) \cdot \left(n \cdot \frac{100}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\end{array}
\end{array}
if i < -1.15e-9 or 1.89999999999999988e-29 < i Initial program 45.1%
clear-num44.7%
un-div-inv44.8%
pow-to-exp34.4%
expm1-def39.9%
*-commutative39.9%
log1p-udef82.0%
Applied egg-rr82.0%
associate-/r/83.1%
Simplified83.1%
associate-/r/82.5%
Applied egg-rr82.5%
Taylor expanded in n around inf 66.0%
if -1.15e-9 < i < 1.89999999999999988e-29Initial program 9.1%
*-commutative9.1%
associate-/r/9.7%
associate-*l*9.7%
sub-neg9.7%
metadata-eval9.7%
Simplified9.7%
Taylor expanded in n around inf 9.9%
expm1-def85.8%
Simplified85.8%
Taylor expanded in i around 0 85.9%
*-commutative85.9%
Simplified85.9%
Final simplification76.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.15e-206) (not (<= n 8.5e-118))) (* 100.0 (/ n (/ i (expm1 i)))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.15e-206) || !(n <= 8.5e-118)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.15e-206) || !(n <= 8.5e-118)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.15e-206) or not (n <= 8.5e-118): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.15e-206) || !(n <= 8.5e-118)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.15e-206], N[Not[LessEqual[n, 8.5e-118]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.15 \cdot 10^{-206} \lor \neg \left(n \leq 8.5 \cdot 10^{-118}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.15e-206 or 8.50000000000000087e-118 < n Initial program 20.9%
Taylor expanded in n around inf 36.8%
*-commutative36.8%
associate-/l*36.8%
expm1-def86.9%
Simplified86.9%
if -1.15e-206 < n < 8.50000000000000087e-118Initial program 56.2%
*-commutative56.2%
associate-/r/55.8%
associate-*l*55.8%
sub-neg55.8%
metadata-eval55.8%
Simplified55.8%
Taylor expanded in i around 0 72.9%
Taylor expanded in i around 0 72.9%
Final simplification84.6%
(FPCore (i n)
:precision binary64
(if (<= i -1e-9)
(* (expm1 i) (/ 100.0 (/ i n)))
(if (<= i 1.9e-29)
(* (* n 100.0) (+ 1.0 (* i 0.5)))
(* (expm1 i) (* n (/ 100.0 i))))))
double code(double i, double n) {
double tmp;
if (i <= -1e-9) {
tmp = expm1(i) * (100.0 / (i / n));
} else if (i <= 1.9e-29) {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
} else {
tmp = expm1(i) * (n * (100.0 / i));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= -1e-9) {
tmp = Math.expm1(i) * (100.0 / (i / n));
} else if (i <= 1.9e-29) {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
} else {
tmp = Math.expm1(i) * (n * (100.0 / i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1e-9: tmp = math.expm1(i) * (100.0 / (i / n)) elif i <= 1.9e-29: tmp = (n * 100.0) * (1.0 + (i * 0.5)) else: tmp = math.expm1(i) * (n * (100.0 / i)) return tmp
function code(i, n) tmp = 0.0 if (i <= -1e-9) tmp = Float64(expm1(i) * Float64(100.0 / Float64(i / n))); elseif (i <= 1.9e-29) tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5))); else tmp = Float64(expm1(i) * Float64(n * Float64(100.0 / i))); end return tmp end
code[i_, n_] := If[LessEqual[i, -1e-9], N[(N[(Exp[i] - 1), $MachinePrecision] * N[(100.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1.9e-29], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Exp[i] - 1), $MachinePrecision] * N[(n * N[(100.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{expm1}\left(i\right) \cdot \frac{100}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 1.9 \cdot 10^{-29}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(i\right) \cdot \left(n \cdot \frac{100}{i}\right)\\
\end{array}
\end{array}
if i < -1.00000000000000006e-9Initial program 47.2%
clear-num47.2%
un-div-inv47.2%
pow-to-exp43.7%
expm1-def53.7%
*-commutative53.7%
log1p-udef94.7%
Applied egg-rr94.7%
associate-/r/96.2%
Simplified96.2%
Taylor expanded in n around inf 76.8%
if -1.00000000000000006e-9 < i < 1.89999999999999988e-29Initial program 9.1%
*-commutative9.1%
associate-/r/9.7%
associate-*l*9.7%
sub-neg9.7%
metadata-eval9.7%
Simplified9.7%
Taylor expanded in n around inf 9.9%
expm1-def85.8%
Simplified85.8%
Taylor expanded in i around 0 85.9%
*-commutative85.9%
Simplified85.9%
if 1.89999999999999988e-29 < i Initial program 43.3%
clear-num42.7%
un-div-inv42.7%
pow-to-exp26.6%
expm1-def28.4%
*-commutative28.4%
log1p-udef71.3%
Applied egg-rr71.3%
associate-/r/72.0%
Simplified72.0%
associate-/r/72.0%
Applied egg-rr72.0%
Taylor expanded in n around inf 57.8%
Final simplification76.4%
(FPCore (i n) :precision binary64 (if (<= n -2.5e-211) (* (* n 100.0) (/ (expm1 i) i)) (if (<= n 8.5e-118) 0.0 (* 100.0 (/ n (/ i (expm1 i)))))))
double code(double i, double n) {
double tmp;
if (n <= -2.5e-211) {
tmp = (n * 100.0) * (expm1(i) / i);
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = 100.0 * (n / (i / expm1(i)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -2.5e-211) {
tmp = (n * 100.0) * (Math.expm1(i) / i);
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = 100.0 * (n / (i / Math.expm1(i)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2.5e-211: tmp = (n * 100.0) * (math.expm1(i) / i) elif n <= 8.5e-118: tmp = 0.0 else: tmp = 100.0 * (n / (i / math.expm1(i))) return tmp
function code(i, n) tmp = 0.0 if (n <= -2.5e-211) tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i)); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); end return tmp end
code[i_, n_] := If[LessEqual[n, -2.5e-211], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.5e-118], 0.0, N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.5 \cdot 10^{-211}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\
\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\end{array}
\end{array}
if n < -2.5000000000000001e-211Initial program 28.3%
*-commutative28.3%
associate-/r/28.2%
associate-*l*28.2%
sub-neg28.2%
metadata-eval28.2%
Simplified28.2%
Taylor expanded in n around inf 36.2%
expm1-def79.8%
Simplified79.8%
if -2.5000000000000001e-211 < n < 8.50000000000000087e-118Initial program 56.2%
*-commutative56.2%
associate-/r/55.8%
associate-*l*55.8%
sub-neg55.8%
metadata-eval55.8%
Simplified55.8%
Taylor expanded in i around 0 72.9%
Taylor expanded in i around 0 72.9%
if 8.50000000000000087e-118 < n Initial program 12.6%
Taylor expanded in n around inf 37.6%
*-commutative37.6%
associate-/l*37.6%
expm1-def95.0%
Simplified95.0%
Final simplification84.6%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ (* n (+ i (* i (* i 0.5)))) i))))
(if (<= n -7.5e+82)
t_0
(if (<= n -5.1e-210)
(* 100.0 (/ i (/ i n)))
(if (<= n 3.4e-107) 0.0 t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * ((n * (i + (i * (i * 0.5)))) / i);
double tmp;
if (n <= -7.5e+82) {
tmp = t_0;
} else if (n <= -5.1e-210) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 3.4e-107) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 100.0d0 * ((n * (i + (i * (i * 0.5d0)))) / i)
if (n <= (-7.5d+82)) then
tmp = t_0
else if (n <= (-5.1d-210)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 3.4d-107) then
tmp = 0.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = 100.0 * ((n * (i + (i * (i * 0.5)))) / i);
double tmp;
if (n <= -7.5e+82) {
tmp = t_0;
} else if (n <= -5.1e-210) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 3.4e-107) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * ((n * (i + (i * (i * 0.5)))) / i) tmp = 0 if n <= -7.5e+82: tmp = t_0 elif n <= -5.1e-210: tmp = 100.0 * (i / (i / n)) elif n <= 3.4e-107: tmp = 0.0 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(Float64(n * Float64(i + Float64(i * Float64(i * 0.5)))) / i)) tmp = 0.0 if (n <= -7.5e+82) tmp = t_0; elseif (n <= -5.1e-210) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 3.4e-107) tmp = 0.0; else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = 100.0 * ((n * (i + (i * (i * 0.5)))) / i); tmp = 0.0; if (n <= -7.5e+82) tmp = t_0; elseif (n <= -5.1e-210) tmp = 100.0 * (i / (i / n)); elseif (n <= 3.4e-107) tmp = 0.0; else tmp = t_0; end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(N[(n * N[(i + N[(i * N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -7.5e+82], t$95$0, If[LessEqual[n, -5.1e-210], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.4e-107], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n \cdot \left(i + i \cdot \left(i \cdot 0.5\right)\right)}{i}\\
\mathbf{if}\;n \leq -7.5 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -5.1 \cdot 10^{-210}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 3.4 \cdot 10^{-107}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -7.4999999999999999e82 or 3.39999999999999994e-107 < n Initial program 15.3%
Taylor expanded in i around 0 46.5%
unpow246.5%
associate-*r/46.5%
metadata-eval46.5%
Simplified46.5%
Taylor expanded in n around inf 68.5%
unpow268.5%
*-commutative68.5%
associate-*l*68.5%
Simplified68.5%
if -7.4999999999999999e82 < n < -5.09999999999999995e-210Initial program 36.5%
Taylor expanded in i around 0 58.5%
if -5.09999999999999995e-210 < n < 3.39999999999999994e-107Initial program 56.2%
*-commutative56.2%
associate-/r/55.8%
associate-*l*55.8%
sub-neg55.8%
metadata-eval55.8%
Simplified55.8%
Taylor expanded in i around 0 72.9%
Taylor expanded in i around 0 72.9%
Final simplification67.1%
(FPCore (i n)
:precision binary64
(if (<= n -6.2e+82)
(* n (+ 100.0 (* i 50.0)))
(if (<= n -1.15e-206)
(* 100.0 (/ i (/ i n)))
(if (<= n 8.5e-118) 0.0 (* 100.0 (+ n (* 0.5 (* i n))))))))
double code(double i, double n) {
double tmp;
if (n <= -6.2e+82) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= -1.15e-206) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = 100.0 * (n + (0.5 * (i * n)));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-6.2d+82)) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (n <= (-1.15d-206)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 8.5d-118) then
tmp = 0.0d0
else
tmp = 100.0d0 * (n + (0.5d0 * (i * n)))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -6.2e+82) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= -1.15e-206) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = 100.0 * (n + (0.5 * (i * n)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -6.2e+82: tmp = n * (100.0 + (i * 50.0)) elif n <= -1.15e-206: tmp = 100.0 * (i / (i / n)) elif n <= 8.5e-118: tmp = 0.0 else: tmp = 100.0 * (n + (0.5 * (i * n))) return tmp
function code(i, n) tmp = 0.0 if (n <= -6.2e+82) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (n <= -1.15e-206) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = Float64(100.0 * Float64(n + Float64(0.5 * Float64(i * n)))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -6.2e+82) tmp = n * (100.0 + (i * 50.0)); elseif (n <= -1.15e-206) tmp = 100.0 * (i / (i / n)); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = 100.0 * (n + (0.5 * (i * n))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -6.2e+82], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -1.15e-206], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.5e-118], 0.0, N[(100.0 * N[(n + N[(0.5 * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.2 \cdot 10^{+82}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;n \leq -1.15 \cdot 10^{-206}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + 0.5 \cdot \left(i \cdot n\right)\right)\\
\end{array}
\end{array}
if n < -6.20000000000000065e82Initial program 20.3%
*-commutative20.3%
associate-/r/20.9%
associate-*l*20.9%
sub-neg20.9%
metadata-eval20.9%
Simplified20.9%
Taylor expanded in n around inf 44.8%
expm1-def89.4%
Simplified89.4%
Taylor expanded in i around 0 55.3%
associate-*r*55.3%
distribute-rgt-out55.3%
Simplified55.3%
if -6.20000000000000065e82 < n < -1.15e-206Initial program 36.5%
Taylor expanded in i around 0 58.5%
if -1.15e-206 < n < 8.50000000000000087e-118Initial program 56.2%
*-commutative56.2%
associate-/r/55.8%
associate-*l*55.8%
sub-neg55.8%
metadata-eval55.8%
Simplified55.8%
Taylor expanded in i around 0 72.9%
Taylor expanded in i around 0 72.9%
if 8.50000000000000087e-118 < n Initial program 12.6%
div-inv12.5%
associate-/r/12.5%
associate-*l*13.0%
div-inv13.0%
pow-to-exp11.0%
expm1-def12.1%
*-commutative12.1%
log1p-udef76.8%
Applied egg-rr76.8%
Taylor expanded in i around 0 74.9%
Taylor expanded in i around 0 72.2%
*-commutative72.2%
Simplified72.2%
Final simplification65.5%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* (* n 100.0) (+ 1.0 (* i 0.5)))))
(if (<= n -9e+82)
t_0
(if (<= n -3.8e-209)
(* 100.0 (/ i (/ i n)))
(if (<= n 8.5e-118) 0.0 t_0)))))
double code(double i, double n) {
double t_0 = (n * 100.0) * (1.0 + (i * 0.5));
double tmp;
if (n <= -9e+82) {
tmp = t_0;
} else if (n <= -3.8e-209) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
if (n <= (-9d+82)) then
tmp = t_0
else if (n <= (-3.8d-209)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 8.5d-118) then
tmp = 0.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = (n * 100.0) * (1.0 + (i * 0.5));
double tmp;
if (n <= -9e+82) {
tmp = t_0;
} else if (n <= -3.8e-209) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = (n * 100.0) * (1.0 + (i * 0.5)) tmp = 0 if n <= -9e+82: tmp = t_0 elif n <= -3.8e-209: tmp = 100.0 * (i / (i / n)) elif n <= 8.5e-118: tmp = 0.0 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5))) tmp = 0.0 if (n <= -9e+82) tmp = t_0; elseif (n <= -3.8e-209) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = (n * 100.0) * (1.0 + (i * 0.5)); tmp = 0.0; if (n <= -9e+82) tmp = t_0; elseif (n <= -3.8e-209) tmp = 100.0 * (i / (i / n)); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = t_0; end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -9e+82], t$95$0, If[LessEqual[n, -3.8e-209], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.5e-118], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\mathbf{if}\;n \leq -9 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -3.8 \cdot 10^{-209}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -8.9999999999999993e82 or 8.50000000000000087e-118 < n Initial program 15.3%
*-commutative15.3%
associate-/r/15.8%
associate-*l*15.8%
sub-neg15.8%
metadata-eval15.8%
Simplified15.8%
Taylor expanded in n around inf 39.6%
expm1-def92.4%
Simplified92.4%
Taylor expanded in i around 0 66.1%
*-commutative66.1%
Simplified66.1%
if -8.9999999999999993e82 < n < -3.7999999999999999e-209Initial program 36.5%
Taylor expanded in i around 0 58.5%
if -3.7999999999999999e-209 < n < 8.50000000000000087e-118Initial program 56.2%
*-commutative56.2%
associate-/r/55.8%
associate-*l*55.8%
sub-neg55.8%
metadata-eval55.8%
Simplified55.8%
Taylor expanded in i around 0 72.9%
Taylor expanded in i around 0 72.9%
Final simplification65.5%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (+ 100.0 (* i 50.0)))))
(if (<= n -6.2e+82)
t_0
(if (<= n -2.05e-209)
(* 100.0 (/ i (/ i n)))
(if (<= n 8.5e-118) 0.0 t_0)))))
double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double tmp;
if (n <= -6.2e+82) {
tmp = t_0;
} else if (n <= -2.05e-209) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = n * (100.0d0 + (i * 50.0d0))
if (n <= (-6.2d+82)) then
tmp = t_0
else if (n <= (-2.05d-209)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 8.5d-118) then
tmp = 0.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double tmp;
if (n <= -6.2e+82) {
tmp = t_0;
} else if (n <= -2.05e-209) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = n * (100.0 + (i * 50.0)) tmp = 0 if n <= -6.2e+82: tmp = t_0 elif n <= -2.05e-209: tmp = 100.0 * (i / (i / n)) elif n <= 8.5e-118: tmp = 0.0 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(n * Float64(100.0 + Float64(i * 50.0))) tmp = 0.0 if (n <= -6.2e+82) tmp = t_0; elseif (n <= -2.05e-209) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = n * (100.0 + (i * 50.0)); tmp = 0.0; if (n <= -6.2e+82) tmp = t_0; elseif (n <= -2.05e-209) tmp = 100.0 * (i / (i / n)); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = t_0; end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -6.2e+82], t$95$0, If[LessEqual[n, -2.05e-209], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.5e-118], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{if}\;n \leq -6.2 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -2.05 \cdot 10^{-209}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -6.20000000000000065e82 or 8.50000000000000087e-118 < n Initial program 15.3%
*-commutative15.3%
associate-/r/15.8%
associate-*l*15.8%
sub-neg15.8%
metadata-eval15.8%
Simplified15.8%
Taylor expanded in n around inf 39.6%
expm1-def92.4%
Simplified92.4%
Taylor expanded in i around 0 66.1%
associate-*r*66.1%
distribute-rgt-out66.1%
Simplified66.1%
if -6.20000000000000065e82 < n < -2.04999999999999989e-209Initial program 36.5%
Taylor expanded in i around 0 58.5%
if -2.04999999999999989e-209 < n < 8.50000000000000087e-118Initial program 56.2%
*-commutative56.2%
associate-/r/55.8%
associate-*l*55.8%
sub-neg55.8%
metadata-eval55.8%
Simplified55.8%
Taylor expanded in i around 0 72.9%
Taylor expanded in i around 0 72.9%
Final simplification65.5%
(FPCore (i n) :precision binary64 (if (<= i -6.2e+30) 0.0 (if (<= i 10500.0) (* n 100.0) (if (<= i 5.6e+61) 0.0 (* 50.0 (* i n))))))
double code(double i, double n) {
double tmp;
if (i <= -6.2e+30) {
tmp = 0.0;
} else if (i <= 10500.0) {
tmp = n * 100.0;
} else if (i <= 5.6e+61) {
tmp = 0.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-6.2d+30)) then
tmp = 0.0d0
else if (i <= 10500.0d0) then
tmp = n * 100.0d0
else if (i <= 5.6d+61) then
tmp = 0.0d0
else
tmp = 50.0d0 * (i * n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -6.2e+30) {
tmp = 0.0;
} else if (i <= 10500.0) {
tmp = n * 100.0;
} else if (i <= 5.6e+61) {
tmp = 0.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -6.2e+30: tmp = 0.0 elif i <= 10500.0: tmp = n * 100.0 elif i <= 5.6e+61: tmp = 0.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= -6.2e+30) tmp = 0.0; elseif (i <= 10500.0) tmp = Float64(n * 100.0); elseif (i <= 5.6e+61) tmp = 0.0; else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -6.2e+30) tmp = 0.0; elseif (i <= 10500.0) tmp = n * 100.0; elseif (i <= 5.6e+61) tmp = 0.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -6.2e+30], 0.0, If[LessEqual[i, 10500.0], N[(n * 100.0), $MachinePrecision], If[LessEqual[i, 5.6e+61], 0.0, N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -6.2 \cdot 10^{+30}:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 10500:\\
\;\;\;\;n \cdot 100\\
\mathbf{elif}\;i \leq 5.6 \cdot 10^{+61}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < -6.1999999999999995e30 or 10500 < i < 5.6000000000000003e61Initial program 50.3%
*-commutative50.3%
associate-/r/49.3%
associate-*l*49.3%
sub-neg49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in i around 0 32.1%
Taylor expanded in i around 0 32.1%
if -6.1999999999999995e30 < i < 10500Initial program 9.8%
Taylor expanded in i around 0 80.2%
*-commutative80.2%
Simplified80.2%
if 5.6000000000000003e61 < i Initial program 48.0%
*-commutative48.0%
associate-/r/48.2%
associate-*l*48.2%
sub-neg48.2%
metadata-eval48.2%
Simplified48.2%
Taylor expanded in n around inf 53.0%
expm1-def53.0%
Simplified53.0%
Taylor expanded in i around 0 35.9%
Taylor expanded in i around inf 35.9%
Final simplification60.3%
(FPCore (i n) :precision binary64 (if (<= n -9.6e-104) (* n 100.0) (if (<= n 8.5e-118) 0.0 (* n 100.0))))
double code(double i, double n) {
double tmp;
if (n <= -9.6e-104) {
tmp = n * 100.0;
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = n * 100.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-9.6d-104)) then
tmp = n * 100.0d0
else if (n <= 8.5d-118) then
tmp = 0.0d0
else
tmp = n * 100.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -9.6e-104) {
tmp = n * 100.0;
} else if (n <= 8.5e-118) {
tmp = 0.0;
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -9.6e-104: tmp = n * 100.0 elif n <= 8.5e-118: tmp = 0.0 else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if (n <= -9.6e-104) tmp = Float64(n * 100.0); elseif (n <= 8.5e-118) tmp = 0.0; else tmp = Float64(n * 100.0); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -9.6e-104) tmp = n * 100.0; elseif (n <= 8.5e-118) tmp = 0.0; else tmp = n * 100.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -9.6e-104], N[(n * 100.0), $MachinePrecision], If[LessEqual[n, 8.5e-118], 0.0, N[(n * 100.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.6 \cdot 10^{-104}:\\
\;\;\;\;n \cdot 100\\
\mathbf{elif}\;n \leq 8.5 \cdot 10^{-118}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if n < -9.6000000000000003e-104 or 8.50000000000000087e-118 < n Initial program 18.7%
Taylor expanded in i around 0 56.4%
*-commutative56.4%
Simplified56.4%
if -9.6000000000000003e-104 < n < 8.50000000000000087e-118Initial program 53.2%
*-commutative53.2%
associate-/r/52.9%
associate-*l*52.9%
sub-neg52.9%
metadata-eval52.9%
Simplified52.9%
Taylor expanded in i around 0 65.0%
Taylor expanded in i around 0 65.0%
Final simplification58.4%
(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 26.7%
*-commutative26.7%
associate-/r/26.7%
associate-*l*26.7%
sub-neg26.7%
metadata-eval26.7%
Simplified26.7%
Taylor expanded in i around 0 17.9%
Taylor expanded in i around 0 18.0%
Final simplification18.0%
(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 2023277
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))