
(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 (if (<= (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n)) INFINITY) (* n (* 100.0 (/ (expm1 (* n (log1p (/ i n)))) i))) (* n 100.0)))
double code(double i, double n) {
double tmp;
if (((pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= ((double) INFINITY)) {
tmp = n * (100.0 * (expm1((n * log1p((i / n)))) / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (((Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= Double.POSITIVE_INFINITY) {
tmp = n * (100.0 * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if ((math.pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= math.inf: tmp = n * (100.0 * (math.expm1((n * math.log1p((i / n)))) / i)) else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if (Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) <= Inf) tmp = Float64(n * Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := If[LessEqual[N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], Infinity], N[(n * N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\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)) < +inf.0Initial program 35.0%
associate-*r/35.0%
sub-neg35.0%
distribute-rgt-in35.0%
metadata-eval35.0%
metadata-eval35.0%
Simplified35.0%
metadata-eval35.0%
metadata-eval35.0%
distribute-rgt-in35.0%
sub-neg35.0%
associate-*r/35.0%
associate-/r/34.5%
associate-*r*34.5%
add-exp-log34.5%
expm1-define34.5%
log-pow39.0%
log1p-define95.1%
Applied egg-rr95.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 i around 0 72.7%
*-commutative72.7%
Simplified72.7%
Final simplification91.1%
(FPCore (i n) :precision binary64 (if (<= (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n)) INFINITY) (* 100.0 (* n (/ (expm1 (* n (log1p (/ i n)))) i))) (* n 100.0)))
double code(double i, double n) {
double tmp;
if (((pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= ((double) INFINITY)) {
tmp = 100.0 * (n * (expm1((n * log1p((i / n)))) / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (((Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * (n * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if ((math.pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= math.inf: tmp = 100.0 * (n * (math.expm1((n * math.log1p((i / n)))) / i)) else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if (Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) <= Inf) tmp = Float64(100.0 * Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := If[LessEqual[N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], Infinity], 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], N[(n * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\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)) < +inf.0Initial program 35.0%
associate-/r/34.5%
add-exp-log34.5%
expm1-define34.5%
log-pow39.0%
log1p-define95.0%
Applied egg-rr95.0%
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 i around 0 72.7%
*-commutative72.7%
Simplified72.7%
Final simplification91.1%
(FPCore (i n) :precision binary64 (if (or (<= n -5.8e-245) (not (<= n 3.5e-52))) (* n (/ (* 100.0 (expm1 i)) i)) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -5.8e-245) || !(n <= 3.5e-52)) {
tmp = n * ((100.0 * expm1(i)) / i);
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -5.8e-245) || !(n <= 3.5e-52)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -5.8e-245) or not (n <= 3.5e-52): tmp = n * ((100.0 * math.expm1(i)) / i) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -5.8e-245) || !(n <= 3.5e-52)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -5.8e-245], N[Not[LessEqual[n, 3.5e-52]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.8 \cdot 10^{-245} \lor \neg \left(n \leq 3.5 \cdot 10^{-52}\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -5.7999999999999999e-245Initial program 24.1%
associate-/r/24.4%
associate-*r*24.4%
*-commutative24.4%
associate-*r/24.4%
sub-neg24.4%
distribute-lft-in24.4%
metadata-eval24.4%
metadata-eval24.4%
metadata-eval24.4%
fma-define24.4%
metadata-eval24.4%
Simplified24.4%
Taylor expanded in n around inf 37.2%
sub-neg37.2%
metadata-eval37.2%
metadata-eval37.2%
distribute-lft-in37.2%
metadata-eval37.2%
sub-neg37.2%
expm1-define84.8%
Simplified84.8%
if -5.7999999999999999e-245 < n < 3.5e-52Initial program 50.9%
associate-*r/50.9%
sub-neg50.9%
distribute-rgt-in50.9%
metadata-eval50.9%
metadata-eval50.9%
Simplified50.9%
Taylor expanded in i around 0 72.9%
if 3.5e-52 < n Initial program 19.7%
associate-*r/19.7%
sub-neg19.7%
distribute-rgt-in19.7%
metadata-eval19.7%
metadata-eval19.7%
Simplified19.7%
metadata-eval19.7%
metadata-eval19.7%
distribute-rgt-in19.7%
sub-neg19.7%
associate-*r/19.7%
associate-/r/20.0%
associate-*r*20.0%
add-exp-log20.0%
expm1-define20.0%
log-pow16.4%
log1p-define77.2%
Applied egg-rr77.2%
Taylor expanded in n around inf 42.5%
associate-*r/42.5%
expm1-define96.3%
Simplified96.3%
Final simplification85.8%
(FPCore (i n) :precision binary64 (if (or (<= n -2e-244) (not (<= n 3.5e-52))) (* n (/ (* 100.0 (expm1 i)) i)) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -2e-244) || !(n <= 3.5e-52)) {
tmp = n * ((100.0 * expm1(i)) / i);
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -2e-244) || !(n <= 3.5e-52)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2e-244) or not (n <= 3.5e-52): tmp = n * ((100.0 * math.expm1(i)) / i) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -2e-244) || !(n <= 3.5e-52)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2e-244], N[Not[LessEqual[n, 3.5e-52]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2 \cdot 10^{-244} \lor \neg \left(n \leq 3.5 \cdot 10^{-52}\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.9999999999999999e-244 or 3.5e-52 < n Initial program 22.3%
associate-/r/22.5%
associate-*r*22.5%
*-commutative22.5%
associate-*r/22.5%
sub-neg22.5%
distribute-lft-in22.5%
metadata-eval22.5%
metadata-eval22.5%
metadata-eval22.5%
fma-define22.5%
metadata-eval22.5%
Simplified22.5%
Taylor expanded in n around inf 39.4%
sub-neg39.4%
metadata-eval39.4%
metadata-eval39.4%
distribute-lft-in39.4%
metadata-eval39.4%
sub-neg39.4%
expm1-define89.6%
Simplified89.6%
if -1.9999999999999999e-244 < n < 3.5e-52Initial program 50.9%
associate-*r/50.9%
sub-neg50.9%
distribute-rgt-in50.9%
metadata-eval50.9%
metadata-eval50.9%
Simplified50.9%
Taylor expanded in i around 0 72.9%
Final simplification85.8%
(FPCore (i n)
:precision binary64
(if (<= i -2.2e-54)
(* 100.0 (/ (expm1 i) (/ i n)))
(if (or (<= i -4.1e-199) (not (<= i 1.02e-162)))
(*
(/ 100.0 i)
(*
i
(+
n
(*
i
(+
(* n 0.5)
(*
i
(+ (* 0.041666666666666664 (* i n)) (* n 0.16666666666666666))))))))
(+ (* n 100.0) (* 100.0 (* i (* n (+ 0.5 (* 0.5 (/ -1.0 n))))))))))
double code(double i, double n) {
double tmp;
if (i <= -2.2e-54) {
tmp = 100.0 * (expm1(i) / (i / n));
} else if ((i <= -4.1e-199) || !(i <= 1.02e-162)) {
tmp = (100.0 / i) * (i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))))));
} else {
tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= -2.2e-54) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else if ((i <= -4.1e-199) || !(i <= 1.02e-162)) {
tmp = (100.0 / i) * (i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))))));
} else {
tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.2e-54: tmp = 100.0 * (math.expm1(i) / (i / n)) elif (i <= -4.1e-199) or not (i <= 1.02e-162): tmp = (100.0 / i) * (i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))))) else: tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n)))))) return tmp
function code(i, n) tmp = 0.0 if (i <= -2.2e-54) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); elseif ((i <= -4.1e-199) || !(i <= 1.02e-162)) tmp = Float64(Float64(100.0 / i) * Float64(i * Float64(n + Float64(i * Float64(Float64(n * 0.5) + Float64(i * Float64(Float64(0.041666666666666664 * Float64(i * n)) + Float64(n * 0.16666666666666666)))))))); else tmp = Float64(Float64(n * 100.0) + Float64(100.0 * Float64(i * Float64(n * Float64(0.5 + Float64(0.5 * Float64(-1.0 / n))))))); end return tmp end
code[i_, n_] := If[LessEqual[i, -2.2e-54], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[i, -4.1e-199], N[Not[LessEqual[i, 1.02e-162]], $MachinePrecision]], N[(N[(100.0 / i), $MachinePrecision] * 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]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] + N[(100.0 * N[(i * N[(n * N[(0.5 + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2.2 \cdot 10^{-54}:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq -4.1 \cdot 10^{-199} \lor \neg \left(i \leq 1.02 \cdot 10^{-162}\right):\\
\;\;\;\;\frac{100}{i} \cdot \left(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)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 + 0.5 \cdot \frac{-1}{n}\right)\right)\right)\\
\end{array}
\end{array}
if i < -2.2e-54Initial program 46.1%
Taylor expanded in n around inf 71.2%
expm1-define79.2%
Simplified79.2%
if -2.2e-54 < i < -4.10000000000000022e-199 or 1.01999999999999998e-162 < i Initial program 31.7%
Taylor expanded in n around inf 36.7%
expm1-define57.8%
Simplified57.8%
clear-num57.7%
un-div-inv57.7%
associate-/l/71.2%
Applied egg-rr71.2%
/-rgt-identity71.2%
associate-/r/71.2%
associate-/r/71.2%
associate-/r/71.3%
/-rgt-identity71.3%
*-commutative71.3%
Simplified71.3%
Taylor expanded in i around 0 68.7%
if -4.10000000000000022e-199 < i < 1.01999999999999998e-162Initial program 4.1%
Taylor expanded in i around 0 95.9%
Final simplification78.1%
(FPCore (i n)
:precision binary64
(if (<= i -7.5e-47)
(* 100.0 (* (expm1 i) (/ n i)))
(if (or (<= i -8e-200) (not (<= i 2.6e-165)))
(*
(/ 100.0 i)
(*
i
(+
n
(*
i
(+
(* n 0.5)
(*
i
(+ (* 0.041666666666666664 (* i n)) (* n 0.16666666666666666))))))))
(+ (* n 100.0) (* 100.0 (* i (* n (+ 0.5 (* 0.5 (/ -1.0 n))))))))))
double code(double i, double n) {
double tmp;
if (i <= -7.5e-47) {
tmp = 100.0 * (expm1(i) * (n / i));
} else if ((i <= -8e-200) || !(i <= 2.6e-165)) {
tmp = (100.0 / i) * (i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))))));
} else {
tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= -7.5e-47) {
tmp = 100.0 * (Math.expm1(i) * (n / i));
} else if ((i <= -8e-200) || !(i <= 2.6e-165)) {
tmp = (100.0 / i) * (i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))))));
} else {
tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n))))));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -7.5e-47: tmp = 100.0 * (math.expm1(i) * (n / i)) elif (i <= -8e-200) or not (i <= 2.6e-165): tmp = (100.0 / i) * (i * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))))) else: tmp = (n * 100.0) + (100.0 * (i * (n * (0.5 + (0.5 * (-1.0 / n)))))) return tmp
function code(i, n) tmp = 0.0 if (i <= -7.5e-47) tmp = Float64(100.0 * Float64(expm1(i) * Float64(n / i))); elseif ((i <= -8e-200) || !(i <= 2.6e-165)) tmp = Float64(Float64(100.0 / i) * Float64(i * Float64(n + Float64(i * Float64(Float64(n * 0.5) + Float64(i * Float64(Float64(0.041666666666666664 * Float64(i * n)) + Float64(n * 0.16666666666666666)))))))); else tmp = Float64(Float64(n * 100.0) + Float64(100.0 * Float64(i * Float64(n * Float64(0.5 + Float64(0.5 * Float64(-1.0 / n))))))); end return tmp end
code[i_, n_] := If[LessEqual[i, -7.5e-47], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[i, -8e-200], N[Not[LessEqual[i, 2.6e-165]], $MachinePrecision]], N[(N[(100.0 / i), $MachinePrecision] * 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]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] + N[(100.0 * N[(i * N[(n * N[(0.5 + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -7.5 \cdot 10^{-47}:\\
\;\;\;\;100 \cdot \left(\mathsf{expm1}\left(i\right) \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;i \leq -8 \cdot 10^{-200} \lor \neg \left(i \leq 2.6 \cdot 10^{-165}\right):\\
\;\;\;\;\frac{100}{i} \cdot \left(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)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + 100 \cdot \left(i \cdot \left(n \cdot \left(0.5 + 0.5 \cdot \frac{-1}{n}\right)\right)\right)\\
\end{array}
\end{array}
if i < -7.49999999999999969e-47Initial program 46.1%
associate-/r/44.6%
add-exp-log44.6%
expm1-define44.6%
log-pow49.4%
log1p-define93.6%
Applied egg-rr93.6%
Taylor expanded in n around inf 69.9%
expm1-define77.8%
associate-*l/77.8%
Simplified77.8%
if -7.49999999999999969e-47 < i < -7.9999999999999999e-200 or 2.60000000000000007e-165 < i Initial program 31.7%
Taylor expanded in n around inf 36.7%
expm1-define57.8%
Simplified57.8%
clear-num57.7%
un-div-inv57.7%
associate-/l/71.2%
Applied egg-rr71.2%
/-rgt-identity71.2%
associate-/r/71.2%
associate-/r/71.2%
associate-/r/71.3%
/-rgt-identity71.3%
*-commutative71.3%
Simplified71.3%
Taylor expanded in i around 0 68.7%
if -7.9999999999999999e-200 < i < 2.60000000000000007e-165Initial program 4.1%
Taylor expanded in i around 0 95.9%
Final simplification77.7%
(FPCore (i n)
:precision binary64
(let* ((t_0
(+
n
(*
i
(+
(* n 0.5)
(*
i
(+
(* 0.041666666666666664 (* i n))
(* n 0.16666666666666666))))))))
(if (<= n -1.08e-148)
(* 100.0 t_0)
(if (<= n 3.5e-52) (/ 0.0 (/ i n)) (* (/ 100.0 i) (* i t_0))))))
double code(double i, double n) {
double t_0 = n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))));
double tmp;
if (n <= -1.08e-148) {
tmp = 100.0 * t_0;
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (100.0 / i) * (i * 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 + (i * ((n * 0.5d0) + (i * ((0.041666666666666664d0 * (i * n)) + (n * 0.16666666666666666d0)))))
if (n <= (-1.08d-148)) then
tmp = 100.0d0 * t_0
else if (n <= 3.5d-52) then
tmp = 0.0d0 / (i / n)
else
tmp = (100.0d0 / i) * (i * t_0)
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))));
double tmp;
if (n <= -1.08e-148) {
tmp = 100.0 * t_0;
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (100.0 / i) * (i * t_0);
}
return tmp;
}
def code(i, n): t_0 = n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))) tmp = 0 if n <= -1.08e-148: tmp = 100.0 * t_0 elif n <= 3.5e-52: tmp = 0.0 / (i / n) else: tmp = (100.0 / i) * (i * t_0) return tmp
function code(i, n) t_0 = Float64(n + Float64(i * Float64(Float64(n * 0.5) + Float64(i * Float64(Float64(0.041666666666666664 * Float64(i * n)) + Float64(n * 0.16666666666666666)))))) tmp = 0.0 if (n <= -1.08e-148) tmp = Float64(100.0 * t_0); elseif (n <= 3.5e-52) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(Float64(100.0 / i) * Float64(i * t_0)); end return tmp end
function tmp_2 = code(i, n) t_0 = n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))); tmp = 0.0; if (n <= -1.08e-148) tmp = 100.0 * t_0; elseif (n <= 3.5e-52) tmp = 0.0 / (i / n); else tmp = (100.0 / i) * (i * t_0); end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = 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]}, If[LessEqual[n, -1.08e-148], N[(100.0 * t$95$0), $MachinePrecision], If[LessEqual[n, 3.5e-52], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(N[(100.0 / i), $MachinePrecision] * N[(i * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 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)\\
\mathbf{if}\;n \leq -1.08 \cdot 10^{-148}:\\
\;\;\;\;100 \cdot t\_0\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100}{i} \cdot \left(i \cdot t\_0\right)\\
\end{array}
\end{array}
if n < -1.08000000000000006e-148Initial program 20.6%
Taylor expanded in n around inf 36.6%
expm1-define71.8%
Simplified71.8%
Taylor expanded in i around 0 59.1%
if -1.08000000000000006e-148 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
if 3.5e-52 < n Initial program 19.7%
Taylor expanded in n around inf 42.1%
expm1-define78.2%
Simplified78.2%
clear-num78.1%
un-div-inv78.1%
associate-/l/96.0%
Applied egg-rr96.0%
/-rgt-identity96.0%
associate-/r/96.0%
associate-/r/95.9%
associate-/r/96.0%
/-rgt-identity96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in i around 0 85.5%
Final simplification70.8%
(FPCore (i n)
:precision binary64
(if (<= n -8.5e-149)
(*
100.0
(+
n
(*
i
(+
(* n 0.5)
(* i (+ (* 0.041666666666666664 (* i n)) (* n 0.16666666666666666)))))))
(if (<= n 3.5e-52)
(/ 0.0 (/ i n))
(+
(* n 100.0)
(*
i
(* n (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667))))))))))
double code(double i, double n) {
double tmp;
if (n <= -8.5e-149) {
tmp = 100.0 * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (n * (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 <= (-8.5d-149)) then
tmp = 100.0d0 * (n + (i * ((n * 0.5d0) + (i * ((0.041666666666666664d0 * (i * n)) + (n * 0.16666666666666666d0))))))
else if (n <= 3.5d-52) then
tmp = 0.0d0 / (i / n)
else
tmp = (n * 100.0d0) + (i * (n * (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 <= -8.5e-149) {
tmp = 100.0 * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666))))));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (n * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -8.5e-149: tmp = 100.0 * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))))) elif n <= 3.5e-52: tmp = 0.0 / (i / n) else: tmp = (n * 100.0) + (i * (n * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if (n <= -8.5e-149) tmp = Float64(100.0 * Float64(n + Float64(i * Float64(Float64(n * 0.5) + Float64(i * Float64(Float64(0.041666666666666664 * Float64(i * n)) + Float64(n * 0.16666666666666666))))))); elseif (n <= 3.5e-52) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(Float64(n * 100.0) + Float64(i * Float64(n * 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 <= -8.5e-149) tmp = 100.0 * (n + (i * ((n * 0.5) + (i * ((0.041666666666666664 * (i * n)) + (n * 0.16666666666666666)))))); elseif (n <= 3.5e-52) tmp = 0.0 / (i / n); else tmp = (n * 100.0) + (i * (n * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -8.5e-149], N[(100.0 * 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], If[LessEqual[n, 3.5e-52], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] + N[(i * N[(n * 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 -8.5 \cdot 10^{-149}:\\
\;\;\;\;100 \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)\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + i \cdot \left(n \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\end{array}
\end{array}
if n < -8.5000000000000006e-149Initial program 20.6%
Taylor expanded in n around inf 36.6%
expm1-define71.8%
Simplified71.8%
Taylor expanded in i around 0 59.1%
if -8.5000000000000006e-149 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
if 3.5e-52 < n Initial program 19.7%
associate-*r/19.7%
sub-neg19.7%
distribute-rgt-in19.7%
metadata-eval19.7%
metadata-eval19.7%
Simplified19.7%
Taylor expanded in n around inf 42.0%
Taylor expanded in i around 0 83.6%
Taylor expanded in n around 0 83.6%
Final simplification70.1%
(FPCore (i n)
:precision binary64
(if (<= n -9.5e-149)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 3.5e-52)
(/ 0.0 (/ i n))
(+
(* n 100.0)
(*
i
(* n (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667))))))))))
double code(double i, double n) {
double tmp;
if (n <= -9.5e-149) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (n * (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 <= (-9.5d-149)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 3.5d-52) then
tmp = 0.0d0 / (i / n)
else
tmp = (n * 100.0d0) + (i * (n * (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 <= -9.5e-149) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (n * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -9.5e-149: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 3.5e-52: tmp = 0.0 / (i / n) else: tmp = (n * 100.0) + (i * (n * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if (n <= -9.5e-149) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 3.5e-52) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(Float64(n * 100.0) + Float64(i * Float64(n * 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 <= -9.5e-149) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 3.5e-52) tmp = 0.0 / (i / n); else tmp = (n * 100.0) + (i * (n * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -9.5e-149], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.5e-52], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] + N[(i * N[(n * 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 -9.5 \cdot 10^{-149}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + i \cdot \left(n \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\end{array}
\end{array}
if n < -9.50000000000000034e-149Initial program 20.6%
associate-*r/20.6%
sub-neg20.6%
distribute-rgt-in20.7%
metadata-eval20.7%
metadata-eval20.7%
Simplified20.7%
Taylor expanded in n around inf 36.6%
Taylor expanded in i around 0 58.0%
Taylor expanded in n around 0 59.1%
if -9.50000000000000034e-149 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
if 3.5e-52 < n Initial program 19.7%
associate-*r/19.7%
sub-neg19.7%
distribute-rgt-in19.7%
metadata-eval19.7%
metadata-eval19.7%
Simplified19.7%
Taylor expanded in n around inf 42.0%
Taylor expanded in i around 0 83.6%
Taylor expanded in n around 0 83.6%
Final simplification70.1%
(FPCore (i n)
:precision binary64
(if (<= n -9.8e-149)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 3.5e-52)
(/ 0.0 (/ i n))
(+ (* n 100.0) (* i (+ (* (* i n) 16.666666666666668) (* n 50.0)))))))
double code(double i, double n) {
double tmp;
if (n <= -9.8e-149) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (((i * n) * 16.666666666666668) + (n * 50.0)));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-9.8d-149)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 3.5d-52) then
tmp = 0.0d0 / (i / n)
else
tmp = (n * 100.0d0) + (i * (((i * n) * 16.666666666666668d0) + (n * 50.0d0)))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -9.8e-149) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (((i * n) * 16.666666666666668) + (n * 50.0)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -9.8e-149: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 3.5e-52: tmp = 0.0 / (i / n) else: tmp = (n * 100.0) + (i * (((i * n) * 16.666666666666668) + (n * 50.0))) return tmp
function code(i, n) tmp = 0.0 if (n <= -9.8e-149) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 3.5e-52) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(Float64(n * 100.0) + Float64(i * Float64(Float64(Float64(i * n) * 16.666666666666668) + Float64(n * 50.0)))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -9.8e-149) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 3.5e-52) tmp = 0.0 / (i / n); else tmp = (n * 100.0) + (i * (((i * n) * 16.666666666666668) + (n * 50.0))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -9.8e-149], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.5e-52], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] + N[(i * N[(N[(N[(i * n), $MachinePrecision] * 16.666666666666668), $MachinePrecision] + N[(n * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.8 \cdot 10^{-149}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + i \cdot \left(\left(i \cdot n\right) \cdot 16.666666666666668 + n \cdot 50\right)\\
\end{array}
\end{array}
if n < -9.8000000000000008e-149Initial program 20.6%
associate-*r/20.6%
sub-neg20.6%
distribute-rgt-in20.7%
metadata-eval20.7%
metadata-eval20.7%
Simplified20.7%
Taylor expanded in n around inf 36.6%
Taylor expanded in i around 0 58.0%
Taylor expanded in n around 0 59.1%
if -9.8000000000000008e-149 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
if 3.5e-52 < n Initial program 19.7%
associate-*r/19.7%
sub-neg19.7%
distribute-rgt-in19.7%
metadata-eval19.7%
metadata-eval19.7%
Simplified19.7%
Taylor expanded in n around inf 42.0%
Taylor expanded in i around 0 80.5%
Final simplification69.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 50.0 (* i 16.666666666666668))))
(if (<= n -4e-148)
(* n (+ 100.0 (* i t_0)))
(if (<= n 3.5e-52) (/ 0.0 (/ i n)) (+ (* n 100.0) (* i (* n t_0)))))))
double code(double i, double n) {
double t_0 = 50.0 + (i * 16.666666666666668);
double tmp;
if (n <= -4e-148) {
tmp = n * (100.0 + (i * t_0));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (n * 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 = 50.0d0 + (i * 16.666666666666668d0)
if (n <= (-4d-148)) then
tmp = n * (100.0d0 + (i * t_0))
else if (n <= 3.5d-52) then
tmp = 0.0d0 / (i / n)
else
tmp = (n * 100.0d0) + (i * (n * t_0))
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = 50.0 + (i * 16.666666666666668);
double tmp;
if (n <= -4e-148) {
tmp = n * (100.0 + (i * t_0));
} else if (n <= 3.5e-52) {
tmp = 0.0 / (i / n);
} else {
tmp = (n * 100.0) + (i * (n * t_0));
}
return tmp;
}
def code(i, n): t_0 = 50.0 + (i * 16.666666666666668) tmp = 0 if n <= -4e-148: tmp = n * (100.0 + (i * t_0)) elif n <= 3.5e-52: tmp = 0.0 / (i / n) else: tmp = (n * 100.0) + (i * (n * t_0)) return tmp
function code(i, n) t_0 = Float64(50.0 + Float64(i * 16.666666666666668)) tmp = 0.0 if (n <= -4e-148) tmp = Float64(n * Float64(100.0 + Float64(i * t_0))); elseif (n <= 3.5e-52) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(Float64(n * 100.0) + Float64(i * Float64(n * t_0))); end return tmp end
function tmp_2 = code(i, n) t_0 = 50.0 + (i * 16.666666666666668); tmp = 0.0; if (n <= -4e-148) tmp = n * (100.0 + (i * t_0)); elseif (n <= 3.5e-52) tmp = 0.0 / (i / n); else tmp = (n * 100.0) + (i * (n * t_0)); end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -4e-148], N[(n * N[(100.0 + N[(i * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.5e-52], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] + N[(i * N[(n * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 50 + i \cdot 16.666666666666668\\
\mathbf{if}\;n \leq -4 \cdot 10^{-148}:\\
\;\;\;\;n \cdot \left(100 + i \cdot t\_0\right)\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + i \cdot \left(n \cdot t\_0\right)\\
\end{array}
\end{array}
if n < -3.99999999999999974e-148Initial program 20.6%
associate-*r/20.6%
sub-neg20.6%
distribute-rgt-in20.7%
metadata-eval20.7%
metadata-eval20.7%
Simplified20.7%
Taylor expanded in n around inf 36.6%
Taylor expanded in i around 0 58.0%
Taylor expanded in n around 0 59.1%
if -3.99999999999999974e-148 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
if 3.5e-52 < n Initial program 19.7%
associate-*r/19.7%
sub-neg19.7%
distribute-rgt-in19.7%
metadata-eval19.7%
metadata-eval19.7%
Simplified19.7%
Taylor expanded in n around inf 42.0%
Taylor expanded in i around 0 80.5%
associate-*r*80.5%
distribute-rgt-out80.5%
*-commutative80.5%
Applied egg-rr80.5%
Final simplification69.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.85e-148) (not (<= n 3.5e-52))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.85e-148) || !(n <= 3.5e-52)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 0.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 ((n <= (-1.85d-148)) .or. (.not. (n <= 3.5d-52))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else
tmp = 0.0d0 / (i / n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.85e-148) || !(n <= 3.5e-52)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.85e-148) or not (n <= 3.5e-52): tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.85e-148) || !(n <= 3.5e-52)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.85e-148) || ~((n <= 3.5e-52))) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); else tmp = 0.0 / (i / n); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.85e-148], N[Not[LessEqual[n, 3.5e-52]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.85 \cdot 10^{-148} \lor \neg \left(n \leq 3.5 \cdot 10^{-52}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.85000000000000017e-148 or 3.5e-52 < n Initial program 20.2%
associate-*r/20.2%
sub-neg20.2%
distribute-rgt-in20.2%
metadata-eval20.2%
metadata-eval20.2%
Simplified20.2%
Taylor expanded in n around inf 39.1%
Taylor expanded in i around 0 68.0%
Taylor expanded in n around 0 68.6%
if -1.85000000000000017e-148 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
Final simplification69.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.22e-147) (not (<= n 3.5e-52))) (* n (+ 100.0 (* i 50.0))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.22e-147) || !(n <= 3.5e-52)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.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 ((n <= (-1.22d-147)) .or. (.not. (n <= 3.5d-52))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 0.0d0 / (i / n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.22e-147) || !(n <= 3.5e-52)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.22e-147) or not (n <= 3.5e-52): tmp = n * (100.0 + (i * 50.0)) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.22e-147) || !(n <= 3.5e-52)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.22e-147) || ~((n <= 3.5e-52))) tmp = n * (100.0 + (i * 50.0)); else tmp = 0.0 / (i / n); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.22e-147], N[Not[LessEqual[n, 3.5e-52]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.22 \cdot 10^{-147} \lor \neg \left(n \leq 3.5 \cdot 10^{-52}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.21999999999999995e-147 or 3.5e-52 < n Initial program 20.2%
associate-*r/20.2%
sub-neg20.2%
distribute-rgt-in20.2%
metadata-eval20.2%
metadata-eval20.2%
Simplified20.2%
Taylor expanded in n around inf 39.1%
Taylor expanded in i around 0 68.0%
Taylor expanded in i around 0 65.8%
+-commutative65.8%
associate-*r*65.8%
distribute-rgt-out65.8%
*-commutative65.8%
Simplified65.8%
if -1.21999999999999995e-147 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
Final simplification67.1%
(FPCore (i n) :precision binary64 (if (or (<= n -8.5e-149) (not (<= n 3.5e-52))) (* n (+ 100.0 (* i 50.0))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -8.5e-149) || !(n <= 3.5e-52)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-8.5d-149)) .or. (.not. (n <= 3.5d-52))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -8.5e-149) || !(n <= 3.5e-52)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -8.5e-149) or not (n <= 3.5e-52): tmp = n * (100.0 + (i * 50.0)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -8.5e-149) || !(n <= 3.5e-52)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -8.5e-149) || ~((n <= 3.5e-52))) tmp = n * (100.0 + (i * 50.0)); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -8.5e-149], N[Not[LessEqual[n, 3.5e-52]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.5 \cdot 10^{-149} \lor \neg \left(n \leq 3.5 \cdot 10^{-52}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -8.5000000000000006e-149 or 3.5e-52 < n Initial program 20.2%
associate-*r/20.2%
sub-neg20.2%
distribute-rgt-in20.2%
metadata-eval20.2%
metadata-eval20.2%
Simplified20.2%
Taylor expanded in n around inf 39.1%
Taylor expanded in i around 0 68.0%
Taylor expanded in i around 0 65.8%
+-commutative65.8%
associate-*r*65.8%
distribute-rgt-out65.8%
*-commutative65.8%
Simplified65.8%
if -8.5000000000000006e-149 < n < 3.5e-52Initial program 51.9%
associate-*r/51.9%
sub-neg51.9%
distribute-rgt-in51.9%
metadata-eval51.9%
metadata-eval51.9%
Simplified51.9%
Taylor expanded in i around 0 70.5%
Taylor expanded in i around 0 70.5%
Final simplification67.1%
(FPCore (i n) :precision binary64 (if (or (<= n -8.6e-149) (not (<= n 2.4e-83))) (* n 100.0) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -8.6e-149) || !(n <= 2.4e-83)) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-8.6d-149)) .or. (.not. (n <= 2.4d-83))) then
tmp = n * 100.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -8.6e-149) || !(n <= 2.4e-83)) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -8.6e-149) or not (n <= 2.4e-83): tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -8.6e-149) || !(n <= 2.4e-83)) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -8.6e-149) || ~((n <= 2.4e-83))) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -8.6e-149], N[Not[LessEqual[n, 2.4e-83]], $MachinePrecision]], N[(n * 100.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.6 \cdot 10^{-149} \lor \neg \left(n \leq 2.4 \cdot 10^{-83}\right):\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -8.60000000000000073e-149 or 2.4000000000000001e-83 < n Initial program 20.4%
Taylor expanded in i around 0 55.8%
*-commutative55.8%
Simplified55.8%
if -8.60000000000000073e-149 < n < 2.4000000000000001e-83Initial program 53.3%
associate-*r/53.3%
sub-neg53.3%
distribute-rgt-in53.3%
metadata-eval53.3%
metadata-eval53.3%
Simplified53.3%
Taylor expanded in i around 0 73.0%
Taylor expanded in i around 0 73.0%
Final simplification60.2%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 28.9%
associate-*r/28.9%
sub-neg28.9%
distribute-rgt-in28.9%
metadata-eval28.9%
metadata-eval28.9%
Simplified28.9%
Taylor expanded in i around 0 21.3%
Taylor expanded in i around 0 21.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 2024107
(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))))