
(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 11 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 1e-202)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY)
(* n (/ (+ (* t_0 100.0) -100.0) i))
(* 100.0 (/ (* i n) i))))))
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 <= 1e-202) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = 100.0 * ((i * n) / i);
}
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 <= 1e-202) {
tmp = 100.0 * (Math.expm1((n * Math.log1p((i / n)))) / (i / n));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = 100.0 * ((i * n) / i);
}
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 <= 1e-202: tmp = 100.0 * (math.expm1((n * math.log1p((i / n)))) / (i / n)) elif t_1 <= math.inf: tmp = n * (((t_0 * 100.0) + -100.0) / i) else: tmp = 100.0 * ((i * n) / i) 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 <= 1e-202) tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_1 <= Inf) tmp = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i)); else tmp = Float64(100.0 * Float64(Float64(i * n) / i)); 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, 1e-202], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $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[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 10^{-202}:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t\_0 \cdot 100 + -100}{i}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 1e-202Initial program 25.7%
sub-neg25.7%
metadata-eval25.7%
Applied egg-rr25.7%
metadata-eval25.7%
sub-neg25.7%
exp-to-pow24.5%
log1p-undefine50.3%
*-commutative50.3%
expm1-undefine98.7%
Simplified98.7%
if 1e-202 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 98.7%
associate-/r/98.9%
associate-*r*98.8%
*-commutative98.8%
associate-*r/98.9%
sub-neg98.9%
distribute-lft-in99.1%
metadata-eval99.1%
metadata-eval99.1%
metadata-eval99.1%
fma-define98.9%
metadata-eval98.9%
Simplified98.9%
fma-undefine99.1%
*-commutative99.1%
Applied egg-rr99.1%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-define85.7%
Simplified85.7%
associate-*r/85.7%
Applied egg-rr85.7%
Taylor expanded in i around 0 86.3%
*-commutative86.3%
Simplified86.3%
Final simplification96.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.4e-206) (not (<= n 1.02e-157))) (* 100.0 (* n (/ (expm1 i) i))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.4e-206) || !(n <= 1.02e-157)) {
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 <= -1.4e-206) || !(n <= 1.02e-157)) {
tmp = 100.0 * (n * (Math.expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.4e-206) or not (n <= 1.02e-157): tmp = 100.0 * (n * (math.expm1(i) / i)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.4e-206) || !(n <= 1.02e-157)) 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, -1.4e-206], N[Not[LessEqual[n, 1.02e-157]], $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 -1.4 \cdot 10^{-206} \lor \neg \left(n \leq 1.02 \cdot 10^{-157}\right):\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.4000000000000001e-206 or 1.0200000000000001e-157 < n Initial program 23.7%
Taylor expanded in n around inf 35.7%
*-commutative35.7%
associate-/l*35.7%
expm1-define83.3%
Simplified83.3%
if -1.4000000000000001e-206 < n < 1.0200000000000001e-157Initial program 49.3%
associate-*r/49.3%
sub-neg49.3%
distribute-rgt-in49.3%
metadata-eval49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in i around 0 69.3%
Taylor expanded in i around 0 69.3%
Final simplification81.6%
(FPCore (i n) :precision binary64 (if (or (<= n -1.5e-206) (not (<= n 1.28e-157))) (* n (* 100.0 (/ (expm1 i) i))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.5e-206) || !(n <= 1.28e-157)) {
tmp = n * (100.0 * (expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.5e-206) || !(n <= 1.28e-157)) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.5e-206) or not (n <= 1.28e-157): tmp = n * (100.0 * (math.expm1(i) / i)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.5e-206) || !(n <= 1.28e-157)) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.5e-206], N[Not[LessEqual[n, 1.28e-157]], $MachinePrecision]], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.5 \cdot 10^{-206} \lor \neg \left(n \leq 1.28 \cdot 10^{-157}\right):\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.5000000000000001e-206 or 1.27999999999999999e-157 < n Initial program 23.7%
associate-/r/24.2%
associate-*r*24.2%
*-commutative24.2%
associate-*r/24.2%
sub-neg24.2%
distribute-lft-in24.2%
metadata-eval24.2%
metadata-eval24.2%
metadata-eval24.2%
fma-define24.2%
metadata-eval24.2%
Simplified24.2%
Taylor expanded in n around inf 35.7%
sub-neg35.7%
metadata-eval35.7%
metadata-eval35.7%
distribute-lft-in35.7%
metadata-eval35.7%
sub-neg35.7%
associate-*r/35.7%
*-commutative35.7%
expm1-define83.2%
Simplified83.2%
if -1.5000000000000001e-206 < n < 1.27999999999999999e-157Initial program 49.3%
associate-*r/49.3%
sub-neg49.3%
distribute-rgt-in49.3%
metadata-eval49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in i around 0 69.3%
Taylor expanded in i around 0 69.3%
Final simplification81.6%
(FPCore (i n) :precision binary64 (if (<= n -2.55e-199) (/ (/ n 0.01) (/ i (expm1 i))) (if (<= n 1.25e-156) 0.0 (* 100.0 (* n (/ (expm1 i) i))))))
double code(double i, double n) {
double tmp;
if (n <= -2.55e-199) {
tmp = (n / 0.01) / (i / expm1(i));
} else if (n <= 1.25e-156) {
tmp = 0.0;
} else {
tmp = 100.0 * (n * (expm1(i) / i));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -2.55e-199) {
tmp = (n / 0.01) / (i / Math.expm1(i));
} else if (n <= 1.25e-156) {
tmp = 0.0;
} else {
tmp = 100.0 * (n * (Math.expm1(i) / i));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2.55e-199: tmp = (n / 0.01) / (i / math.expm1(i)) elif n <= 1.25e-156: tmp = 0.0 else: tmp = 100.0 * (n * (math.expm1(i) / i)) return tmp
function code(i, n) tmp = 0.0 if (n <= -2.55e-199) tmp = Float64(Float64(n / 0.01) / Float64(i / expm1(i))); elseif (n <= 1.25e-156) tmp = 0.0; else tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i))); end return tmp end
code[i_, n_] := If[LessEqual[n, -2.55e-199], N[(N[(n / 0.01), $MachinePrecision] / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.25e-156], 0.0, N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.55 \cdot 10^{-199}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{elif}\;n \leq 1.25 \cdot 10^{-156}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\end{array}
\end{array}
if n < -2.54999999999999993e-199Initial program 27.4%
Taylor expanded in n around inf 34.8%
*-commutative34.8%
associate-/l*34.8%
expm1-define79.4%
Simplified79.4%
associate-*l*79.3%
associate-*l/79.3%
*-commutative79.3%
clear-num79.2%
un-div-inv79.3%
*-un-lft-identity79.3%
times-frac79.4%
metadata-eval79.4%
Applied egg-rr79.4%
associate-/r*79.4%
Simplified79.4%
if -2.54999999999999993e-199 < n < 1.25000000000000002e-156Initial program 49.3%
associate-*r/49.3%
sub-neg49.3%
distribute-rgt-in49.3%
metadata-eval49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in i around 0 69.3%
Taylor expanded in i around 0 69.3%
if 1.25000000000000002e-156 < n Initial program 19.5%
Taylor expanded in n around inf 36.8%
*-commutative36.8%
associate-/l*36.8%
expm1-define87.8%
Simplified87.8%
Final simplification81.7%
(FPCore (i n)
:precision binary64
(if (<= i -1.5e-84)
(* 100.0 (/ (expm1 i) (/ i n)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))))
double code(double i, double n) {
double tmp;
if (i <= -1.5e-84) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= -1.5e-84) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.5e-84: tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if (i <= -1.5e-84) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); end return tmp end
code[i_, n_] := If[LessEqual[i, -1.5e-84], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.5 \cdot 10^{-84}:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\end{array}
\end{array}
if i < -1.5000000000000001e-84Initial program 43.2%
Taylor expanded in n around inf 71.9%
expm1-define73.1%
Simplified73.1%
if -1.5000000000000001e-84 < i Initial program 21.0%
associate-/r/21.6%
associate-*r*21.6%
*-commutative21.6%
associate-*r/21.6%
sub-neg21.6%
distribute-lft-in21.6%
metadata-eval21.6%
metadata-eval21.6%
metadata-eval21.6%
fma-define21.6%
metadata-eval21.6%
Simplified21.6%
Taylor expanded in n around inf 22.4%
sub-neg22.4%
metadata-eval22.4%
metadata-eval22.4%
distribute-lft-in22.4%
metadata-eval22.4%
sub-neg22.4%
expm1-define77.6%
Simplified77.6%
Taylor expanded in i around 0 76.5%
*-commutative76.5%
Simplified76.5%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ i (/ i n)))))
(if (<= n -15.5)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n -5e-205)
t_0
(if (<= n 3.8e-174)
0.0
(if (<= n 0.72)
t_0
(*
100.0
(/
(*
i
(+
n
(*
i
(+
(* n 0.5)
(*
i
(+
(* 0.041666666666666664 (* i n))
(* n 0.16666666666666666)))))))
i))))))))
double code(double i, double n) {
double t_0 = 100.0 * (i / (i / n));
double tmp;
if (n <= -15.5) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= -5e-205) {
tmp = t_0;
} else if (n <= 3.8e-174) {
tmp = 0.0;
} else if (n <= 0.72) {
tmp = t_0;
} else {
tmp = 100.0 * ((i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))))) / i);
}
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 * (i / (i / n))
if (n <= (-15.5d0)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= (-5d-205)) then
tmp = t_0
else if (n <= 3.8d-174) then
tmp = 0.0d0
else if (n <= 0.72d0) then
tmp = t_0
else
tmp = 100.0d0 * ((i * (n + (i * ((n * 0.5d0) + (i * ((0.041666666666666664d0 * (i * n)) + (n * 0.16666666666666666d0))))))) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = 100.0 * (i / (i / n));
double tmp;
if (n <= -15.5) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= -5e-205) {
tmp = t_0;
} else if (n <= 3.8e-174) {
tmp = 0.0;
} else if (n <= 0.72) {
tmp = t_0;
} else {
tmp = 100.0 * ((i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))))) / i);
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (i / (i / n)) tmp = 0 if n <= -15.5: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= -5e-205: tmp = t_0 elif n <= 3.8e-174: tmp = 0.0 elif n <= 0.72: tmp = t_0 else: tmp = 100.0 * ((i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))))) / i) return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(i / Float64(i / n))) tmp = 0.0 if (n <= -15.5) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= -5e-205) tmp = t_0; elseif (n <= 3.8e-174) tmp = 0.0; elseif (n <= 0.72) tmp = t_0; else tmp = Float64(100.0 * Float64(Float64(i * Float64(n + Float64(i * Float64(Float64(n * 0.5) + Float64(i * Float64(Float64(0.041666666666666664 * Float64(i * n)) + Float64(n * 0.16666666666666666))))))) / i)); end return tmp end
function tmp_2 = code(i, n) t_0 = 100.0 * (i / (i / n)); tmp = 0.0; if (n <= -15.5) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= -5e-205) tmp = t_0; elseif (n <= 3.8e-174) tmp = 0.0; elseif (n <= 0.72) tmp = t_0; else tmp = 100.0 * ((i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))))) / i); end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -15.5], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -5e-205], t$95$0, If[LessEqual[n, 3.8e-174], 0.0, If[LessEqual[n, 0.72], t$95$0, N[(100.0 * N[(N[(i * N[(n + N[(i * N[(N[(n * 0.5), $MachinePrecision] + N[(i * N[(N[(0.041666666666666664 * N[(i * n), $MachinePrecision]), $MachinePrecision] + N[(n * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{if}\;n \leq -15.5:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq -5 \cdot 10^{-205}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 3.8 \cdot 10^{-174}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 0.72:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i \cdot \left(n + i \cdot \left(n \cdot 0.5 + i \cdot \left(0.041666666666666664 \cdot \left(i \cdot n\right) + n \cdot 0.16666666666666666\right)\right)\right)}{i}\\
\end{array}
\end{array}
if n < -15.5Initial program 29.3%
associate-/r/29.9%
associate-*r*29.9%
*-commutative29.9%
associate-*r/30.0%
sub-neg30.0%
distribute-lft-in30.0%
metadata-eval30.0%
metadata-eval30.0%
metadata-eval30.0%
fma-define30.0%
metadata-eval30.0%
Simplified30.0%
Taylor expanded in n around inf 46.1%
sub-neg46.1%
metadata-eval46.1%
metadata-eval46.1%
distribute-lft-in46.1%
metadata-eval46.1%
sub-neg46.1%
expm1-define87.4%
Simplified87.4%
Taylor expanded in i around 0 58.6%
*-commutative58.6%
Simplified58.6%
if -15.5 < n < -5.00000000000000001e-205 or 3.80000000000000021e-174 < n < 0.71999999999999997Initial program 22.0%
Taylor expanded in i around 0 67.4%
if -5.00000000000000001e-205 < n < 3.80000000000000021e-174Initial program 52.6%
associate-*r/52.6%
sub-neg52.6%
distribute-rgt-in52.6%
metadata-eval52.6%
metadata-eval52.6%
Simplified52.6%
Taylor expanded in i around 0 70.5%
Taylor expanded in i around 0 70.5%
if 0.71999999999999997 < n Initial program 19.3%
Taylor expanded in n around inf 49.1%
*-commutative49.1%
associate-/l*49.1%
expm1-define97.4%
Simplified97.4%
associate-*r/97.4%
Applied egg-rr97.4%
Taylor expanded in i around 0 81.3%
Final simplification69.3%
(FPCore (i n)
:precision binary64
(if (<= n -60.0)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n -2e-206)
(* 100.0 (/ i (/ i n)))
(if (<= n 1.2e-157)
0.0
(*
n
(+
100.0
(*
i
(+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))))))
double code(double i, double n) {
double tmp;
if (n <= -60.0) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= -2e-206) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 1.2e-157) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-60.0d0)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= (-2d-206)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 1.2d-157) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -60.0) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= -2e-206) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 1.2e-157) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -60.0: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= -2e-206: tmp = 100.0 * (i / (i / n)) elif n <= 1.2e-157: tmp = 0.0 else: tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if (n <= -60.0) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= -2e-206) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 1.2e-157) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -60.0) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= -2e-206) tmp = 100.0 * (i / (i / n)); elseif (n <= 1.2e-157) tmp = 0.0; else tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -60.0], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -2e-206], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.2e-157], 0.0, N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -60:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq -2 \cdot 10^{-206}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 1.2 \cdot 10^{-157}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\end{array}
\end{array}
if n < -60Initial program 29.3%
associate-/r/29.9%
associate-*r*29.9%
*-commutative29.9%
associate-*r/30.0%
sub-neg30.0%
distribute-lft-in30.0%
metadata-eval30.0%
metadata-eval30.0%
metadata-eval30.0%
fma-define30.0%
metadata-eval30.0%
Simplified30.0%
Taylor expanded in n around inf 46.1%
sub-neg46.1%
metadata-eval46.1%
metadata-eval46.1%
distribute-lft-in46.1%
metadata-eval46.1%
sub-neg46.1%
expm1-define87.4%
Simplified87.4%
Taylor expanded in i around 0 58.6%
*-commutative58.6%
Simplified58.6%
if -60 < n < -2.00000000000000006e-206Initial program 24.2%
Taylor expanded in i around 0 64.7%
if -2.00000000000000006e-206 < n < 1.2e-157Initial program 49.3%
associate-*r/49.3%
sub-neg49.3%
distribute-rgt-in49.3%
metadata-eval49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in i around 0 69.3%
Taylor expanded in i around 0 69.3%
if 1.2e-157 < n Initial program 19.5%
associate-/r/20.0%
associate-*r*20.0%
*-commutative20.0%
associate-*r/20.0%
sub-neg20.0%
distribute-lft-in20.0%
metadata-eval20.0%
metadata-eval20.0%
metadata-eval20.0%
fma-define20.0%
metadata-eval20.0%
Simplified20.0%
Taylor expanded in n around inf 36.8%
sub-neg36.8%
metadata-eval36.8%
metadata-eval36.8%
distribute-lft-in36.8%
metadata-eval36.8%
sub-neg36.8%
expm1-define87.6%
Simplified87.6%
Taylor expanded in i around 0 75.2%
*-commutative75.2%
Simplified75.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))))
(if (<= n -15.0)
t_0
(if (<= n -5.6e-206)
(* 100.0 (/ i (/ i n)))
(if (<= n 3.8e-156) 0.0 t_0)))))
double code(double i, double n) {
double t_0 = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
double tmp;
if (n <= -15.0) {
tmp = t_0;
} else if (n <= -5.6e-206) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 3.8e-156) {
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 + (i * 16.666666666666668d0))))
if (n <= (-15.0d0)) then
tmp = t_0
else if (n <= (-5.6d-206)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 3.8d-156) 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 + (i * 16.666666666666668))));
double tmp;
if (n <= -15.0) {
tmp = t_0;
} else if (n <= -5.6e-206) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 3.8e-156) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) tmp = 0 if n <= -15.0: tmp = t_0 elif n <= -5.6e-206: tmp = 100.0 * (i / (i / n)) elif n <= 3.8e-156: tmp = 0.0 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))) tmp = 0.0 if (n <= -15.0) tmp = t_0; elseif (n <= -5.6e-206) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 3.8e-156) 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 + (i * 16.666666666666668)))); tmp = 0.0; if (n <= -15.0) tmp = t_0; elseif (n <= -5.6e-206) tmp = 100.0 * (i / (i / n)); elseif (n <= 3.8e-156) 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 * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -15.0], t$95$0, If[LessEqual[n, -5.6e-206], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.8e-156], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{if}\;n \leq -15:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -5.6 \cdot 10^{-206}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 3.8 \cdot 10^{-156}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -15 or 3.80000000000000008e-156 < n Initial program 23.6%
associate-/r/24.2%
associate-*r*24.2%
*-commutative24.2%
associate-*r/24.2%
sub-neg24.2%
distribute-lft-in24.2%
metadata-eval24.2%
metadata-eval24.2%
metadata-eval24.2%
fma-define24.2%
metadata-eval24.2%
Simplified24.2%
Taylor expanded in n around inf 40.7%
sub-neg40.7%
metadata-eval40.7%
metadata-eval40.7%
distribute-lft-in40.7%
metadata-eval40.7%
sub-neg40.7%
expm1-define87.5%
Simplified87.5%
Taylor expanded in i around 0 66.3%
*-commutative66.3%
Simplified66.3%
if -15 < n < -5.6000000000000003e-206Initial program 24.2%
Taylor expanded in i around 0 64.7%
if -5.6000000000000003e-206 < n < 3.80000000000000008e-156Initial program 49.3%
associate-*r/49.3%
sub-neg49.3%
distribute-rgt-in49.3%
metadata-eval49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in i around 0 69.3%
Taylor expanded in i around 0 69.3%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (+ 100.0 (* i 50.0)))))
(if (<= n -9.5e+19)
t_0
(if (<= n -4.8e-202)
(* 100.0 (/ i (/ i n)))
(if (<= n 2.2e-157) 0.0 t_0)))))
double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double tmp;
if (n <= -9.5e+19) {
tmp = t_0;
} else if (n <= -4.8e-202) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 2.2e-157) {
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 <= (-9.5d+19)) then
tmp = t_0
else if (n <= (-4.8d-202)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 2.2d-157) 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 <= -9.5e+19) {
tmp = t_0;
} else if (n <= -4.8e-202) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 2.2e-157) {
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 <= -9.5e+19: tmp = t_0 elif n <= -4.8e-202: tmp = 100.0 * (i / (i / n)) elif n <= 2.2e-157: 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 <= -9.5e+19) tmp = t_0; elseif (n <= -4.8e-202) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 2.2e-157) 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 <= -9.5e+19) tmp = t_0; elseif (n <= -4.8e-202) tmp = 100.0 * (i / (i / n)); elseif (n <= 2.2e-157) 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, -9.5e+19], t$95$0, If[LessEqual[n, -4.8e-202], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.2e-157], 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 -9.5 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -4.8 \cdot 10^{-202}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 2.2 \cdot 10^{-157}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -9.5e19 or 2.2000000000000001e-157 < n Initial program 22.1%
associate-/r/22.6%
associate-*r*22.6%
*-commutative22.6%
associate-*r/22.6%
sub-neg22.6%
distribute-lft-in22.7%
metadata-eval22.7%
metadata-eval22.7%
metadata-eval22.7%
fma-define22.6%
metadata-eval22.6%
Simplified22.6%
Taylor expanded in n around inf 39.6%
sub-neg39.6%
metadata-eval39.6%
metadata-eval39.6%
distribute-lft-in39.6%
metadata-eval39.6%
sub-neg39.6%
expm1-define87.5%
Simplified87.5%
Taylor expanded in i around 0 61.7%
*-commutative61.7%
Simplified61.7%
if -9.5e19 < n < -4.8000000000000002e-202Initial program 29.7%
Taylor expanded in i around 0 60.7%
if -4.8000000000000002e-202 < n < 2.2000000000000001e-157Initial program 49.3%
associate-*r/49.3%
sub-neg49.3%
distribute-rgt-in49.3%
metadata-eval49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in i around 0 69.3%
Taylor expanded in i around 0 69.3%
(FPCore (i n) :precision binary64 (if (<= i -1.65e+68) 0.0 (if (<= i 5.8e-16) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -1.65e+68) {
tmp = 0.0;
} else if (i <= 5.8e-16) {
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 (i <= (-1.65d+68)) then
tmp = 0.0d0
else if (i <= 5.8d-16) 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 (i <= -1.65e+68) {
tmp = 0.0;
} else if (i <= 5.8e-16) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.65e+68: tmp = 0.0 elif i <= 5.8e-16: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -1.65e+68) tmp = 0.0; elseif (i <= 5.8e-16) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -1.65e+68) tmp = 0.0; elseif (i <= 5.8e-16) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.65e+68], 0.0, If[LessEqual[i, 5.8e-16], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.65 \cdot 10^{+68}:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 5.8 \cdot 10^{-16}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -1.65e68 or 5.7999999999999996e-16 < i Initial program 52.2%
associate-*r/52.2%
sub-neg52.2%
distribute-rgt-in52.2%
metadata-eval52.2%
metadata-eval52.2%
Simplified52.2%
Taylor expanded in i around 0 25.8%
Taylor expanded in i around 0 25.8%
if -1.65e68 < i < 5.7999999999999996e-16Initial program 7.2%
Taylor expanded in i around 0 80.4%
*-commutative80.4%
Simplified80.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%
associate-*r/26.7%
sub-neg26.7%
distribute-rgt-in26.7%
metadata-eval26.7%
metadata-eval26.7%
Simplified26.7%
Taylor expanded in i around 0 14.9%
Taylor expanded in i around 0 15.3%
(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 2024087
(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))))