
(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 16 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)
(* n (/ (* (expm1 (* n (log1p (/ i n)))) 100.0) i))
(if (<= t_1 1e-19)
(/ (+ (* t_0 100.0) -100.0) (/ i n))
(* n (* 100.0 (/ (expm1 i) 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 <= 0.0) {
tmp = n * ((expm1((n * log1p((i / n)))) * 100.0) / i);
} else if (t_1 <= 1e-19) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * (100.0 * (expm1(i) / 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 <= 0.0) {
tmp = n * ((Math.expm1((n * Math.log1p((i / n)))) * 100.0) / i);
} else if (t_1 <= 1e-19) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * (100.0 * (Math.expm1(i) / 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 <= 0.0: tmp = n * ((math.expm1((n * math.log1p((i / n)))) * 100.0) / i) elif t_1 <= 1e-19: tmp = ((t_0 * 100.0) + -100.0) / (i / n) else: tmp = n * (100.0 * (math.expm1(i) / 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 <= 0.0) tmp = Float64(n * Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) * 100.0) / i)); elseif (t_1 <= 1e-19) tmp = Float64(Float64(Float64(t_0 * 100.0) + -100.0) / Float64(i / n)); else tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / 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, 0.0], N[(n * N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * 100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-19], N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot 100}{i}\\
\mathbf{elif}\;t\_1 \leq 10^{-19}:\\
\;\;\;\;\frac{t\_0 \cdot 100 + -100}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\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)) < 0.0Initial program 23.2%
associate-/r/22.7%
associate-*r*22.7%
*-commutative22.7%
associate-*r/22.7%
sub-neg22.7%
distribute-lft-in22.7%
metadata-eval22.7%
metadata-eval22.7%
metadata-eval22.7%
fma-define22.7%
metadata-eval22.7%
Simplified22.7%
fma-undefine22.7%
metadata-eval22.7%
metadata-eval22.7%
distribute-lft-in22.7%
sub-neg22.7%
*-commutative22.7%
add-exp-log22.7%
expm1-define22.7%
log-pow28.3%
log1p-define94.9%
Applied egg-rr94.9%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 9.9999999999999998e-20Initial program 93.3%
associate-*r/93.7%
sub-neg93.7%
distribute-rgt-in93.8%
metadata-eval93.8%
metadata-eval93.8%
Simplified93.8%
if 9.9999999999999998e-20 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 16.7%
associate-/r/18.1%
associate-*r*18.1%
*-commutative18.1%
associate-*r/18.1%
sub-neg18.1%
distribute-lft-in18.1%
metadata-eval18.1%
metadata-eval18.1%
metadata-eval18.1%
fma-define18.1%
metadata-eval18.1%
Simplified18.1%
Taylor expanded in n around inf 31.6%
div-sub31.6%
associate-*r/33.0%
metadata-eval33.0%
associate-*r/31.6%
distribute-lft-out--31.6%
div-sub31.6%
*-commutative31.6%
expm1-define83.6%
Simplified83.6%
Final simplification92.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 0.0)
(* 100.0 (* n (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_1 1e-19)
(/ (+ (* t_0 100.0) -100.0) (/ i n))
(* n (* 100.0 (/ (expm1 i) 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 <= 0.0) {
tmp = 100.0 * (n * (expm1((n * log1p((i / n)))) / i));
} else if (t_1 <= 1e-19) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * (100.0 * (expm1(i) / 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 <= 0.0) {
tmp = 100.0 * (n * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_1 <= 1e-19) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else {
tmp = n * (100.0 * (Math.expm1(i) / 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 <= 0.0: tmp = 100.0 * (n * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_1 <= 1e-19: tmp = ((t_0 * 100.0) + -100.0) / (i / n) else: tmp = n * (100.0 * (math.expm1(i) / 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 <= 0.0) tmp = Float64(100.0 * Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_1 <= 1e-19) tmp = Float64(Float64(Float64(t_0 * 100.0) + -100.0) / Float64(i / n)); else tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / 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, 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, 1e-19], N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\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 10^{-19}:\\
\;\;\;\;\frac{t\_0 \cdot 100 + -100}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\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)) < 0.0Initial program 23.2%
associate-/r/22.7%
add-exp-log22.7%
expm1-define22.7%
log-pow28.2%
log1p-define94.8%
Applied egg-rr94.8%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 9.9999999999999998e-20Initial program 93.3%
associate-*r/93.7%
sub-neg93.7%
distribute-rgt-in93.8%
metadata-eval93.8%
metadata-eval93.8%
Simplified93.8%
if 9.9999999999999998e-20 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 16.7%
associate-/r/18.1%
associate-*r*18.1%
*-commutative18.1%
associate-*r/18.1%
sub-neg18.1%
distribute-lft-in18.1%
metadata-eval18.1%
metadata-eval18.1%
metadata-eval18.1%
fma-define18.1%
metadata-eval18.1%
Simplified18.1%
Taylor expanded in n around inf 31.6%
div-sub31.6%
associate-*r/33.0%
metadata-eval33.0%
associate-*r/31.6%
distribute-lft-out--31.6%
div-sub31.6%
*-commutative31.6%
expm1-define83.6%
Simplified83.6%
Final simplification91.8%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ (expm1 i) (/ i n)))))
(if (<= i -1.7e-6)
t_0
(if (<= i 2.5e-43)
(*
n
(+
100.0
(*
i
(*
100.0
(+
(-
(* i 0.16666666666666666)
(/ (+ (* (/ i n) -0.3333333333333333) (* i 0.5)) n))
(- 0.5 (/ 0.5 n)))))))
(if (<= i 1.7e+145)
t_0
(if (<= i 2.7e+217) (/ 0.0 (/ i n)) (/ (* 100.0 (* i n)) i)))))))
double code(double i, double n) {
double t_0 = 100.0 * (expm1(i) / (i / n));
double tmp;
if (i <= -1.7e-6) {
tmp = t_0;
} else if (i <= 2.5e-43) {
tmp = n * (100.0 + (i * (100.0 * (((i * 0.16666666666666666) - ((((i / n) * -0.3333333333333333) + (i * 0.5)) / n)) + (0.5 - (0.5 / n))))));
} else if (i <= 1.7e+145) {
tmp = t_0;
} else if (i <= 2.7e+217) {
tmp = 0.0 / (i / n);
} else {
tmp = (100.0 * (i * n)) / i;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (Math.expm1(i) / (i / n));
double tmp;
if (i <= -1.7e-6) {
tmp = t_0;
} else if (i <= 2.5e-43) {
tmp = n * (100.0 + (i * (100.0 * (((i * 0.16666666666666666) - ((((i / n) * -0.3333333333333333) + (i * 0.5)) / n)) + (0.5 - (0.5 / n))))));
} else if (i <= 1.7e+145) {
tmp = t_0;
} else if (i <= 2.7e+217) {
tmp = 0.0 / (i / n);
} else {
tmp = (100.0 * (i * n)) / i;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (math.expm1(i) / (i / n)) tmp = 0 if i <= -1.7e-6: tmp = t_0 elif i <= 2.5e-43: tmp = n * (100.0 + (i * (100.0 * (((i * 0.16666666666666666) - ((((i / n) * -0.3333333333333333) + (i * 0.5)) / n)) + (0.5 - (0.5 / n)))))) elif i <= 1.7e+145: tmp = t_0 elif i <= 2.7e+217: tmp = 0.0 / (i / n) else: tmp = (100.0 * (i * n)) / i return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(expm1(i) / Float64(i / n))) tmp = 0.0 if (i <= -1.7e-6) tmp = t_0; elseif (i <= 2.5e-43) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(100.0 * Float64(Float64(Float64(i * 0.16666666666666666) - Float64(Float64(Float64(Float64(i / n) * -0.3333333333333333) + Float64(i * 0.5)) / n)) + Float64(0.5 - Float64(0.5 / n))))))); elseif (i <= 1.7e+145) tmp = t_0; elseif (i <= 2.7e+217) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(Float64(100.0 * Float64(i * n)) / i); 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, -1.7e-6], t$95$0, If[LessEqual[i, 2.5e-43], N[(n * N[(100.0 + N[(i * N[(100.0 * N[(N[(N[(i * 0.16666666666666666), $MachinePrecision] - N[(N[(N[(N[(i / n), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + N[(i * 0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1.7e+145], t$95$0, If[LessEqual[i, 2.7e+217], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(N[(100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{if}\;i \leq -1.7 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;i \leq 2.5 \cdot 10^{-43}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(100 \cdot \left(\left(i \cdot 0.16666666666666666 - \frac{\frac{i}{n} \cdot -0.3333333333333333 + i \cdot 0.5}{n}\right) + \left(0.5 - \frac{0.5}{n}\right)\right)\right)\right)\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{+145}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;i \leq 2.7 \cdot 10^{+217}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\
\end{array}
\end{array}
if i < -1.70000000000000003e-6 or 2.50000000000000009e-43 < i < 1.7e145Initial program 35.3%
Taylor expanded in n around inf 73.8%
expm1-define77.9%
Simplified77.9%
if -1.70000000000000003e-6 < i < 2.50000000000000009e-43Initial program 4.9%
associate-/r/5.5%
associate-*r*5.5%
*-commutative5.5%
associate-*r/5.5%
sub-neg5.5%
distribute-lft-in5.5%
metadata-eval5.5%
metadata-eval5.5%
metadata-eval5.5%
fma-define5.5%
metadata-eval5.5%
Simplified5.5%
Taylor expanded in i around 0 87.3%
distribute-lft-out87.3%
associate--l+87.3%
associate-*r/87.4%
metadata-eval87.4%
associate-*r/87.4%
metadata-eval87.4%
associate-*r/87.4%
metadata-eval87.4%
Simplified87.4%
Taylor expanded in n around -inf 93.7%
if 1.7e145 < i < 2.70000000000000003e217Initial program 53.1%
associate-*r/53.2%
sub-neg53.2%
distribute-rgt-in53.2%
metadata-eval53.2%
metadata-eval53.2%
Simplified53.2%
Taylor expanded in i around 0 67.6%
if 2.70000000000000003e217 < i Initial program 67.4%
associate-/r/67.4%
associate-*r*67.5%
*-commutative67.5%
associate-*r/67.5%
sub-neg67.5%
distribute-lft-in67.5%
metadata-eval67.5%
metadata-eval67.5%
metadata-eval67.5%
fma-define67.5%
metadata-eval67.5%
Simplified67.5%
Taylor expanded in n around inf 48.0%
div-sub48.0%
associate-*r/48.0%
metadata-eval48.0%
associate-*r/48.0%
distribute-lft-out--48.0%
div-sub48.0%
*-commutative48.0%
expm1-define48.0%
Simplified48.0%
associate-*l/48.0%
associate-*r/48.0%
Applied egg-rr48.0%
Taylor expanded in i around 0 49.0%
*-commutative49.0%
Simplified49.0%
Final simplification82.7%
(FPCore (i n) :precision binary64 (if (<= i 4e+128) (* n (* 100.0 (/ (expm1 i) i))) (* (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n)) 100.0)))
double code(double i, double n) {
double tmp;
if (i <= 4e+128) {
tmp = n * (100.0 * (expm1(i) / i));
} else {
tmp = ((pow((1.0 + (i / n)), n) + -1.0) / (i / n)) * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= 4e+128) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else {
tmp = ((Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n)) * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 4e+128: tmp = n * (100.0 * (math.expm1(i) / i)) else: tmp = ((math.pow((1.0 + (i / n)), n) + -1.0) / (i / n)) * 100.0 return tmp
function code(i, n) tmp = 0.0 if (i <= 4e+128) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); else tmp = Float64(Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) * 100.0); end return tmp end
code[i_, n_] := If[LessEqual[i, 4e+128], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision] * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 4 \cdot 10^{+128}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \cdot 100\\
\end{array}
\end{array}
if i < 4.0000000000000003e128Initial program 17.6%
associate-/r/17.6%
associate-*r*17.6%
*-commutative17.6%
associate-*r/17.6%
sub-neg17.6%
distribute-lft-in17.6%
metadata-eval17.6%
metadata-eval17.6%
metadata-eval17.6%
fma-define17.6%
metadata-eval17.6%
Simplified17.6%
Taylor expanded in n around inf 36.9%
div-sub37.7%
associate-*r/37.6%
metadata-eval37.6%
associate-*r/37.4%
distribute-lft-out--37.7%
div-sub36.9%
*-commutative36.9%
expm1-define86.9%
Simplified86.9%
if 4.0000000000000003e128 < i Initial program 61.1%
Final simplification83.0%
(FPCore (i n) :precision binary64 (if (<= i 3.8e+127) (* n (* 100.0 (/ (expm1 i) i))) (* n (/ (+ (* (pow (+ 1.0 (/ i n)) n) 100.0) -100.0) i))))
double code(double i, double n) {
double tmp;
if (i <= 3.8e+127) {
tmp = n * (100.0 * (expm1(i) / i));
} else {
tmp = n * (((pow((1.0 + (i / n)), n) * 100.0) + -100.0) / i);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= 3.8e+127) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else {
tmp = n * (((Math.pow((1.0 + (i / n)), n) * 100.0) + -100.0) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 3.8e+127: tmp = n * (100.0 * (math.expm1(i) / i)) else: tmp = n * (((math.pow((1.0 + (i / n)), n) * 100.0) + -100.0) / i) return tmp
function code(i, n) tmp = 0.0 if (i <= 3.8e+127) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); else tmp = Float64(n * Float64(Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) * 100.0) + -100.0) / i)); end return tmp end
code[i_, n_] := If[LessEqual[i, 3.8e+127], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 3.8 \cdot 10^{+127}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + -100}{i}\\
\end{array}
\end{array}
if i < 3.7999999999999998e127Initial program 17.6%
associate-/r/17.6%
associate-*r*17.6%
*-commutative17.6%
associate-*r/17.6%
sub-neg17.6%
distribute-lft-in17.6%
metadata-eval17.6%
metadata-eval17.6%
metadata-eval17.6%
fma-define17.6%
metadata-eval17.6%
Simplified17.6%
Taylor expanded in n around inf 36.9%
div-sub37.7%
associate-*r/37.6%
metadata-eval37.6%
associate-*r/37.4%
distribute-lft-out--37.7%
div-sub36.9%
*-commutative36.9%
expm1-define86.9%
Simplified86.9%
if 3.7999999999999998e127 < i Initial program 61.1%
associate-/r/61.4%
associate-*r*61.5%
*-commutative61.5%
associate-*r/61.5%
sub-neg61.5%
distribute-lft-in61.5%
metadata-eval61.5%
metadata-eval61.5%
metadata-eval61.5%
fma-define61.5%
metadata-eval61.5%
Simplified61.5%
fma-undefine61.5%
*-commutative61.5%
Applied egg-rr61.5%
Final simplification83.0%
(FPCore (i n) :precision binary64 (if (or (<= n -9.2e-68) (not (<= n 1.75e-11))) (* n (* 100.0 (/ (expm1 i) i))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -9.2e-68) || !(n <= 1.75e-11)) {
tmp = n * (100.0 * (expm1(i) / i));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -9.2e-68) || !(n <= 1.75e-11)) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -9.2e-68) or not (n <= 1.75e-11): tmp = n * (100.0 * (math.expm1(i) / i)) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -9.2e-68) || !(n <= 1.75e-11)) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); else tmp = Float64(100.0 * Float64(i / Float64(i / n))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -9.2e-68], N[Not[LessEqual[n, 1.75e-11]], $MachinePrecision]], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.2 \cdot 10^{-68} \lor \neg \left(n \leq 1.75 \cdot 10^{-11}\right):\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -9.19999999999999987e-68 or 1.7500000000000001e-11 < n Initial program 22.5%
associate-/r/22.9%
associate-*r*22.9%
*-commutative22.9%
associate-*r/22.9%
sub-neg22.9%
distribute-lft-in22.9%
metadata-eval22.9%
metadata-eval22.9%
metadata-eval22.9%
fma-define22.9%
metadata-eval22.9%
Simplified22.9%
Taylor expanded in n around inf 41.6%
div-sub42.7%
associate-*r/42.6%
metadata-eval42.6%
associate-*r/42.3%
distribute-lft-out--42.7%
div-sub41.7%
*-commutative41.7%
expm1-define88.9%
Simplified88.9%
if -9.19999999999999987e-68 < n < 1.7500000000000001e-11Initial program 27.9%
Taylor expanded in i around 0 72.8%
Final simplification83.8%
(FPCore (i n)
:precision binary64
(if (<= n -1e-65)
(* n (/ (* 100.0 (expm1 i)) i))
(if (<= n 1.75e-11)
(* 100.0 (/ i (/ i n)))
(* n (* 100.0 (/ (expm1 i) i))))))
double code(double i, double n) {
double tmp;
if (n <= -1e-65) {
tmp = n * ((100.0 * expm1(i)) / i);
} else if (n <= 1.75e-11) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 * (expm1(i) / i));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -1e-65) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else if (n <= 1.75e-11) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 * (Math.expm1(i) / i));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1e-65: tmp = n * ((100.0 * math.expm1(i)) / i) elif n <= 1.75e-11: tmp = 100.0 * (i / (i / n)) else: tmp = n * (100.0 * (math.expm1(i) / i)) return tmp
function code(i, n) tmp = 0.0 if (n <= -1e-65) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); elseif (n <= 1.75e-11) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); end return tmp end
code[i_, n_] := If[LessEqual[n, -1e-65], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.75e-11], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1 \cdot 10^{-65}:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{elif}\;n \leq 1.75 \cdot 10^{-11}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\end{array}
\end{array}
if n < -9.99999999999999923e-66Initial program 26.7%
associate-/r/26.9%
associate-*r*27.0%
*-commutative27.0%
associate-*r/27.0%
sub-neg27.0%
distribute-lft-in27.0%
metadata-eval27.0%
metadata-eval27.0%
metadata-eval27.0%
fma-define27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in n around inf 38.1%
div-sub39.4%
associate-*r/39.1%
metadata-eval39.1%
associate-*r/38.6%
distribute-lft-out--38.6%
div-sub38.1%
*-commutative38.1%
expm1-define82.0%
Simplified82.0%
associate-*l/82.0%
Applied egg-rr82.0%
if -9.99999999999999923e-66 < n < 1.7500000000000001e-11Initial program 27.9%
Taylor expanded in i around 0 72.8%
if 1.7500000000000001e-11 < n Initial program 18.0%
associate-/r/18.5%
associate-*r*18.5%
*-commutative18.5%
associate-*r/18.5%
sub-neg18.5%
distribute-lft-in18.5%
metadata-eval18.5%
metadata-eval18.5%
metadata-eval18.5%
fma-define18.5%
metadata-eval18.5%
Simplified18.5%
Taylor expanded in n around inf 45.6%
div-sub46.3%
associate-*r/46.5%
metadata-eval46.5%
associate-*r/46.3%
distribute-lft-out--47.1%
div-sub45.6%
*-commutative45.6%
expm1-define96.3%
Simplified96.3%
Final simplification83.8%
(FPCore (i n) :precision binary64 (if (<= i 6e+135) (* n (* 100.0 (/ (expm1 i) i))) (* i (/ (fma i 50.0 100.0) (/ i n)))))
double code(double i, double n) {
double tmp;
if (i <= 6e+135) {
tmp = n * (100.0 * (expm1(i) / i));
} else {
tmp = i * (fma(i, 50.0, 100.0) / (i / n));
}
return tmp;
}
function code(i, n) tmp = 0.0 if (i <= 6e+135) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); else tmp = Float64(i * Float64(fma(i, 50.0, 100.0) / Float64(i / n))); end return tmp end
code[i_, n_] := If[LessEqual[i, 6e+135], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * N[(N[(i * 50.0 + 100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 6 \cdot 10^{+135}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;i \cdot \frac{\mathsf{fma}\left(i, 50, 100\right)}{\frac{i}{n}}\\
\end{array}
\end{array}
if i < 6.0000000000000001e135Initial program 18.0%
associate-/r/18.0%
associate-*r*18.0%
*-commutative18.0%
associate-*r/18.0%
sub-neg18.0%
distribute-lft-in18.0%
metadata-eval18.0%
metadata-eval18.0%
metadata-eval18.0%
fma-define18.0%
metadata-eval18.0%
Simplified18.0%
Taylor expanded in n around inf 37.2%
div-sub38.0%
associate-*r/37.8%
metadata-eval37.8%
associate-*r/37.6%
distribute-lft-out--38.0%
div-sub37.2%
*-commutative37.2%
expm1-define86.9%
Simplified86.9%
if 6.0000000000000001e135 < i Initial program 60.1%
associate-*r/60.2%
sub-neg60.2%
distribute-rgt-in60.2%
metadata-eval60.2%
metadata-eval60.2%
Simplified60.2%
Taylor expanded in n around inf 32.0%
Taylor expanded in i around 0 34.7%
*-commutative34.7%
Simplified34.7%
associate-/l*58.7%
+-commutative58.7%
fma-define58.7%
Applied egg-rr58.7%
Final simplification82.8%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ i (/ i n)))))
(if (<= i -2e+66)
t_0
(if (<= i 1.7e+18)
(* n 100.0)
(if (or (<= i 1.7e+145) (not (<= i 2.5e+217))) (* 50.0 (* i n)) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (i / (i / n));
double tmp;
if (i <= -2e+66) {
tmp = t_0;
} else if (i <= 1.7e+18) {
tmp = n * 100.0;
} else if ((i <= 1.7e+145) || !(i <= 2.5e+217)) {
tmp = 50.0 * (i * n);
} 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 * (i / (i / n))
if (i <= (-2d+66)) then
tmp = t_0
else if (i <= 1.7d+18) then
tmp = n * 100.0d0
else if ((i <= 1.7d+145) .or. (.not. (i <= 2.5d+217))) then
tmp = 50.0d0 * (i * n)
else
tmp = t_0
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 (i <= -2e+66) {
tmp = t_0;
} else if (i <= 1.7e+18) {
tmp = n * 100.0;
} else if ((i <= 1.7e+145) || !(i <= 2.5e+217)) {
tmp = 50.0 * (i * n);
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (i / (i / n)) tmp = 0 if i <= -2e+66: tmp = t_0 elif i <= 1.7e+18: tmp = n * 100.0 elif (i <= 1.7e+145) or not (i <= 2.5e+217): tmp = 50.0 * (i * n) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(i / Float64(i / n))) tmp = 0.0 if (i <= -2e+66) tmp = t_0; elseif (i <= 1.7e+18) tmp = Float64(n * 100.0); elseif ((i <= 1.7e+145) || !(i <= 2.5e+217)) tmp = Float64(50.0 * Float64(i * n)); else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = 100.0 * (i / (i / n)); tmp = 0.0; if (i <= -2e+66) tmp = t_0; elseif (i <= 1.7e+18) tmp = n * 100.0; elseif ((i <= 1.7e+145) || ~((i <= 2.5e+217))) tmp = 50.0 * (i * n); else tmp = t_0; 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[i, -2e+66], t$95$0, If[LessEqual[i, 1.7e+18], N[(n * 100.0), $MachinePrecision], If[Or[LessEqual[i, 1.7e+145], N[Not[LessEqual[i, 2.5e+217]], $MachinePrecision]], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{if}\;i \leq -2 \cdot 10^{+66}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{+18}:\\
\;\;\;\;n \cdot 100\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{+145} \lor \neg \left(i \leq 2.5 \cdot 10^{+217}\right):\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if i < -1.99999999999999989e66 or 1.7e145 < i < 2.50000000000000021e217Initial program 47.2%
Taylor expanded in i around 0 41.6%
if -1.99999999999999989e66 < i < 1.7e18Initial program 9.2%
Taylor expanded in i around 0 80.3%
*-commutative80.3%
Simplified80.3%
if 1.7e18 < i < 1.7e145 or 2.50000000000000021e217 < i Initial program 41.9%
associate-*r/42.0%
sub-neg42.0%
distribute-rgt-in42.0%
metadata-eval42.0%
metadata-eval42.0%
Simplified42.0%
Taylor expanded in n around inf 66.3%
Taylor expanded in i around 0 39.0%
*-commutative39.0%
Simplified39.0%
Taylor expanded in i around inf 39.2%
*-commutative39.2%
Simplified39.2%
Final simplification63.5%
(FPCore (i n)
:precision binary64
(if (or (<= n -3.5e+30) (not (<= n 1.35e-11)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))
(* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -3.5e+30) || !(n <= 1.35e-11)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} else {
tmp = 100.0 * (i / (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 <= (-3.5d+30)) .or. (.not. (n <= 1.35d-11))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
else
tmp = 100.0d0 * (i / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -3.5e+30) || !(n <= 1.35e-11)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -3.5e+30) or not (n <= 1.35e-11): tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -3.5e+30) || !(n <= 1.35e-11)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); else tmp = Float64(100.0 * Float64(i / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -3.5e+30) || ~((n <= 1.35e-11))) tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -3.5e+30], N[Not[LessEqual[n, 1.35e-11]], $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], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.5 \cdot 10^{+30} \lor \neg \left(n \leq 1.35 \cdot 10^{-11}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -3.50000000000000021e30 or 1.35000000000000002e-11 < n Initial program 22.0%
associate-/r/22.4%
associate-*r*22.4%
*-commutative22.4%
associate-*r/22.4%
sub-neg22.4%
distribute-lft-in22.4%
metadata-eval22.4%
metadata-eval22.4%
metadata-eval22.4%
fma-define22.4%
metadata-eval22.4%
Simplified22.4%
Taylor expanded in n around inf 44.4%
div-sub45.6%
associate-*r/45.6%
metadata-eval45.6%
associate-*r/45.2%
distribute-lft-out--45.6%
div-sub44.5%
*-commutative44.5%
expm1-define92.1%
Simplified92.1%
Taylor expanded in i around 0 74.3%
*-commutative74.3%
Simplified74.3%
if -3.50000000000000021e30 < n < 1.35000000000000002e-11Initial program 27.6%
Taylor expanded in i around 0 67.4%
Final simplification71.5%
(FPCore (i n) :precision binary64 (if (or (<= n -4.2e+33) (not (<= n 1.75e-11))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -4.2e+33) || !(n <= 1.75e-11)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 100.0 * (i / (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 <= (-4.2d+33)) .or. (.not. (n <= 1.75d-11))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else
tmp = 100.0d0 * (i / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -4.2e+33) || !(n <= 1.75e-11)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -4.2e+33) or not (n <= 1.75e-11): tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -4.2e+33) || !(n <= 1.75e-11)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); else tmp = Float64(100.0 * Float64(i / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -4.2e+33) || ~((n <= 1.75e-11))) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -4.2e+33], N[Not[LessEqual[n, 1.75e-11]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -4.2 \cdot 10^{+33} \lor \neg \left(n \leq 1.75 \cdot 10^{-11}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -4.2000000000000001e33 or 1.7500000000000001e-11 < n Initial program 22.0%
associate-/r/22.4%
associate-*r*22.4%
*-commutative22.4%
associate-*r/22.4%
sub-neg22.4%
distribute-lft-in22.4%
metadata-eval22.4%
metadata-eval22.4%
metadata-eval22.4%
fma-define22.4%
metadata-eval22.4%
Simplified22.4%
Taylor expanded in n around inf 44.4%
div-sub45.6%
associate-*r/45.6%
metadata-eval45.6%
associate-*r/45.2%
distribute-lft-out--45.6%
div-sub44.5%
*-commutative44.5%
expm1-define92.1%
Simplified92.1%
Taylor expanded in i around 0 71.2%
*-commutative71.2%
Simplified71.2%
if -4.2000000000000001e33 < n < 1.7500000000000001e-11Initial program 27.6%
Taylor expanded in i around 0 67.4%
Final simplification69.7%
(FPCore (i n)
:precision binary64
(if (<= n -2.2e+31)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 1.75)
(* 100.0 (/ i (/ i n)))
(/ (* n (* i (+ 100.0 (* i 50.0)))) i))))
double code(double i, double n) {
double tmp;
if (n <= -2.2e+31) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 1.75) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * (i * (100.0 + (i * 50.0)))) / i;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-2.2d+31)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 1.75d0) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = (n * (i * (100.0d0 + (i * 50.0d0)))) / i
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -2.2e+31) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 1.75) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * (i * (100.0 + (i * 50.0)))) / i;
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2.2e+31: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 1.75: tmp = 100.0 * (i / (i / n)) else: tmp = (n * (i * (100.0 + (i * 50.0)))) / i return tmp
function code(i, n) tmp = 0.0 if (n <= -2.2e+31) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 1.75) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(Float64(n * Float64(i * Float64(100.0 + Float64(i * 50.0)))) / i); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -2.2e+31) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 1.75) tmp = 100.0 * (i / (i / n)); else tmp = (n * (i * (100.0 + (i * 50.0)))) / i; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2.2e+31], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.75], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * N[(i * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.2 \cdot 10^{+31}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 1.75:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot \left(i \cdot \left(100 + i \cdot 50\right)\right)}{i}\\
\end{array}
\end{array}
if n < -2.2000000000000001e31Initial program 26.7%
associate-/r/27.0%
associate-*r*27.1%
*-commutative27.1%
associate-*r/27.1%
sub-neg27.1%
distribute-lft-in27.1%
metadata-eval27.1%
metadata-eval27.1%
metadata-eval27.1%
fma-define27.1%
metadata-eval27.1%
Simplified27.1%
Taylor expanded in n around inf 43.1%
div-sub44.8%
associate-*r/44.5%
metadata-eval44.5%
associate-*r/43.8%
distribute-lft-out--43.8%
div-sub43.2%
*-commutative43.2%
expm1-define87.0%
Simplified87.0%
Taylor expanded in i around 0 62.7%
*-commutative62.7%
Simplified62.7%
if -2.2000000000000001e31 < n < 1.75Initial program 27.2%
Taylor expanded in i around 0 68.0%
if 1.75 < n Initial program 18.3%
associate-/r/18.9%
associate-*r*18.9%
*-commutative18.9%
associate-*r/18.9%
sub-neg18.9%
distribute-lft-in18.9%
metadata-eval18.9%
metadata-eval18.9%
metadata-eval18.9%
fma-define18.9%
metadata-eval18.9%
Simplified18.9%
Taylor expanded in n around inf 46.6%
div-sub47.3%
associate-*r/47.5%
metadata-eval47.5%
associate-*r/47.4%
distribute-lft-out--48.2%
div-sub46.7%
*-commutative46.7%
expm1-define96.3%
Simplified96.3%
associate-*l/96.2%
associate-*r/92.6%
Applied egg-rr92.6%
Taylor expanded in i around 0 80.2%
Final simplification70.4%
(FPCore (i n) :precision binary64 (if (or (<= n -1.65e+31) (not (<= n 1.06e-11))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -1.65e+31) || !(n <= 1.06e-11)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (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 <= (-1.65d+31)) .or. (.not. (n <= 1.06d-11))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 100.0d0 * (i / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.65e+31) || !(n <= 1.06e-11)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.65e+31) or not (n <= 1.06e-11): tmp = n * (100.0 + (i * 50.0)) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.65e+31) || !(n <= 1.06e-11)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = Float64(100.0 * Float64(i / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.65e+31) || ~((n <= 1.06e-11))) tmp = n * (100.0 + (i * 50.0)); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.65e+31], N[Not[LessEqual[n, 1.06e-11]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.65 \cdot 10^{+31} \lor \neg \left(n \leq 1.06 \cdot 10^{-11}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.64999999999999996e31 or 1.05999999999999993e-11 < n Initial program 22.0%
associate-/r/22.4%
associate-*r*22.4%
*-commutative22.4%
associate-*r/22.4%
sub-neg22.4%
distribute-lft-in22.4%
metadata-eval22.4%
metadata-eval22.4%
metadata-eval22.4%
fma-define22.4%
metadata-eval22.4%
Simplified22.4%
Taylor expanded in n around inf 44.4%
div-sub45.6%
associate-*r/45.6%
metadata-eval45.6%
associate-*r/45.2%
distribute-lft-out--45.6%
div-sub44.5%
*-commutative44.5%
expm1-define92.1%
Simplified92.1%
Taylor expanded in i around 0 63.8%
+-commutative63.8%
associate-*r*63.8%
distribute-rgt-in63.8%
*-commutative63.8%
Simplified63.8%
if -1.64999999999999996e31 < n < 1.05999999999999993e-11Initial program 27.6%
Taylor expanded in i around 0 67.4%
Final simplification65.2%
(FPCore (i n) :precision binary64 (if (<= i 2.8e+19) (* n 100.0) (* 50.0 (* i n))))
double code(double i, double n) {
double tmp;
if (i <= 2.8e+19) {
tmp = n * 100.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 <= 2.8d+19) then
tmp = n * 100.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 <= 2.8e+19) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 2.8e+19: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= 2.8e+19) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 2.8e+19) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 2.8e+19], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 2.8 \cdot 10^{+19}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < 2.8e19Initial program 17.7%
Taylor expanded in i around 0 62.4%
*-commutative62.4%
Simplified62.4%
if 2.8e19 < i Initial program 44.6%
associate-*r/44.7%
sub-neg44.7%
distribute-rgt-in44.7%
metadata-eval44.7%
metadata-eval44.7%
Simplified44.7%
Taylor expanded in n around inf 53.6%
Taylor expanded in i around 0 34.5%
*-commutative34.5%
Simplified34.5%
Taylor expanded in i around inf 30.4%
*-commutative30.4%
Simplified30.4%
Final simplification54.6%
(FPCore (i n) :precision binary64 (* i -50.0))
double code(double i, double n) {
return i * -50.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = i * (-50.0d0)
end function
public static double code(double i, double n) {
return i * -50.0;
}
def code(i, n): return i * -50.0
function code(i, n) return Float64(i * -50.0) end
function tmp = code(i, n) tmp = i * -50.0; end
code[i_, n_] := N[(i * -50.0), $MachinePrecision]
\begin{array}{l}
\\
i \cdot -50
\end{array}
Initial program 24.2%
associate-/r/24.3%
associate-*r*24.3%
*-commutative24.3%
associate-*r/24.3%
sub-neg24.3%
distribute-lft-in24.3%
metadata-eval24.3%
metadata-eval24.3%
metadata-eval24.3%
fma-define24.3%
metadata-eval24.3%
Simplified24.3%
Taylor expanded in i around 0 54.7%
*-commutative54.7%
associate-*r/54.7%
metadata-eval54.7%
Simplified54.7%
Taylor expanded in n around 0 2.7%
*-commutative2.7%
Simplified2.7%
Final simplification2.7%
(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 24.2%
Taylor expanded in i around 0 48.5%
*-commutative48.5%
Simplified48.5%
Final simplification48.5%
(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 2024067
(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))))