
(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 15 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)))
(t_2 (/ (+ (* t_0 100.0) -100.0) (/ i n))))
(if (<= t_1 -2000000000000.0)
t_2
(if (<= t_1 0.0)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY) t_2 (* n 100.0))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double t_2 = ((t_0 * 100.0) + -100.0) / (i / n);
double tmp;
if (t_1 <= -2000000000000.0) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double t_2 = ((t_0 * 100.0) + -100.0) / (i / n);
double tmp;
if (t_1 <= -2000000000000.0) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = 100.0 * (Math.expm1((n * Math.log1p((i / n)))) / (i / n));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) t_2 = ((t_0 * 100.0) + -100.0) / (i / n) tmp = 0 if t_1 <= -2000000000000.0: tmp = t_2 elif t_1 <= 0.0: tmp = 100.0 * (math.expm1((n * math.log1p((i / n)))) / (i / n)) elif t_1 <= math.inf: tmp = t_2 else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) t_2 = Float64(Float64(Float64(t_0 * 100.0) + -100.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -2000000000000.0) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_1 <= Inf) tmp = t_2; else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2000000000000.0], t$95$2, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$2, N[(n * 100.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
t_2 := \frac{t\_0 \cdot 100 + -100}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq -2000000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_2\\
\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)) < -2e12 or 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 99.6%
associate-*r/99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
if -2e12 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 24.8%
sub-neg24.8%
metadata-eval24.8%
Applied egg-rr24.8%
metadata-eval24.8%
sub-neg24.8%
exp-to-pow24.8%
log1p-undefine43.5%
*-commutative43.5%
expm1-undefine99.7%
Simplified99.7%
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%
associate-/r/1.9%
associate-*r*1.9%
*-commutative1.9%
associate-*r/1.9%
sub-neg1.9%
distribute-lft-in1.9%
metadata-eval1.9%
metadata-eval1.9%
metadata-eval1.9%
fma-define1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in i around 0 79.8%
*-commutative79.8%
Simplified79.8%
Final simplification96.8%
(FPCore (i n) :precision binary64 (if (or (<= n -2e-245) (not (<= n 1.8e-170))) (* (* n 100.0) (/ (expm1 i) i)) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -2e-245) || !(n <= 1.8e-170)) {
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-245) || !(n <= 1.8e-170)) {
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-245) or not (n <= 1.8e-170): 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-245) || !(n <= 1.8e-170)) tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i)); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2e-245], N[Not[LessEqual[n, 1.8e-170]], $MachinePrecision]], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $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^{-245} \lor \neg \left(n \leq 1.8 \cdot 10^{-170}\right):\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.9999999999999999e-245 or 1.8000000000000002e-170 < n Initial program 25.6%
associate-/r/25.8%
associate-*r*25.8%
*-commutative25.8%
associate-*r/25.9%
sub-neg25.9%
distribute-lft-in25.8%
metadata-eval25.8%
metadata-eval25.8%
metadata-eval25.8%
fma-define25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in n around inf 31.3%
sub-neg31.3%
metadata-eval31.3%
metadata-eval31.3%
distribute-lft-in31.3%
metadata-eval31.3%
sub-neg31.3%
expm1-define78.4%
Simplified78.4%
associate-*r/72.4%
Applied egg-rr72.4%
associate-/l*78.4%
associate-*r/78.5%
associate-*r*78.5%
*-commutative78.5%
Simplified78.5%
if -1.9999999999999999e-245 < n < 1.8000000000000002e-170Initial program 58.3%
associate-*r/58.3%
sub-neg58.3%
distribute-rgt-in58.3%
metadata-eval58.3%
metadata-eval58.3%
Simplified58.3%
Taylor expanded in i around 0 69.2%
+-commutative69.2%
Simplified69.2%
Taylor expanded in i around 0 81.7%
Final simplification78.9%
(FPCore (i n) :precision binary64 (if (or (<= n -1.22e-250) (not (<= n 2.6e-170))) (* n (/ (* 100.0 (expm1 i)) i)) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.22e-250) || !(n <= 2.6e-170)) {
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 <= -1.22e-250) || !(n <= 2.6e-170)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.22e-250) or not (n <= 2.6e-170): 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 <= -1.22e-250) || !(n <= 2.6e-170)) 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, -1.22e-250], N[Not[LessEqual[n, 2.6e-170]], $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 -1.22 \cdot 10^{-250} \lor \neg \left(n \leq 2.6 \cdot 10^{-170}\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.2200000000000001e-250 or 2.6000000000000001e-170 < n Initial program 25.6%
associate-/r/25.8%
associate-*r*25.8%
*-commutative25.8%
associate-*r/25.9%
sub-neg25.9%
distribute-lft-in25.8%
metadata-eval25.8%
metadata-eval25.8%
metadata-eval25.8%
fma-define25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in n around inf 31.3%
sub-neg31.3%
metadata-eval31.3%
metadata-eval31.3%
distribute-lft-in31.3%
metadata-eval31.3%
sub-neg31.3%
expm1-define78.4%
Simplified78.4%
if -1.2200000000000001e-250 < n < 2.6000000000000001e-170Initial program 58.3%
associate-*r/58.3%
sub-neg58.3%
distribute-rgt-in58.3%
metadata-eval58.3%
metadata-eval58.3%
Simplified58.3%
Taylor expanded in i around 0 69.2%
+-commutative69.2%
Simplified69.2%
Taylor expanded in i around 0 81.7%
Final simplification78.8%
(FPCore (i n) :precision binary64 (if (or (<= i -3e-57) (not (<= i 6.6e-38))) (* 100.0 (/ (expm1 i) (/ i n))) (* 100.0 (+ n (* (* i n) (- 0.5 (/ 0.5 n)))))))
double code(double i, double n) {
double tmp;
if ((i <= -3e-57) || !(i <= 6.6e-38)) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -3e-57) || !(i <= 6.6e-38)) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n))));
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -3e-57) or not (i <= 6.6e-38): tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n)))) return tmp
function code(i, n) tmp = 0.0 if ((i <= -3e-57) || !(i <= 6.6e-38)) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(100.0 * Float64(n + Float64(Float64(i * n) * Float64(0.5 - Float64(0.5 / n))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -3e-57], N[Not[LessEqual[i, 6.6e-38]], $MachinePrecision]], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n + N[(N[(i * n), $MachinePrecision] * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -3 \cdot 10^{-57} \lor \neg \left(i \leq 6.6 \cdot 10^{-38}\right):\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + \left(i \cdot n\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if i < -3.00000000000000001e-57 or 6.6000000000000005e-38 < i Initial program 48.1%
Taylor expanded in n around inf 54.4%
expm1-define60.0%
Simplified60.0%
if -3.00000000000000001e-57 < i < 6.6000000000000005e-38Initial program 9.9%
Taylor expanded in i around 0 84.2%
associate-*r*84.3%
*-commutative84.3%
associate-*r/84.3%
metadata-eval84.3%
Simplified84.3%
Final simplification71.9%
(FPCore (i n)
:precision binary64
(if (or (<= n -8.2e-108) (not (<= n 3.8e-170)))
(+
(* n 100.0)
(*
i
(+
(* n 50.0)
(* i (+ (* (* i n) 4.166666666666667) (* n 16.666666666666668))))))
(/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -8.2e-108) || !(n <= 3.8e-170)) {
tmp = (n * 100.0) + (i * ((n * 50.0) + (i * (((i * n) * 4.166666666666667) + (n * 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 <= (-8.2d-108)) .or. (.not. (n <= 3.8d-170))) then
tmp = (n * 100.0d0) + (i * ((n * 50.0d0) + (i * (((i * n) * 4.166666666666667d0) + (n * 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 <= -8.2e-108) || !(n <= 3.8e-170)) {
tmp = (n * 100.0) + (i * ((n * 50.0) + (i * (((i * n) * 4.166666666666667) + (n * 16.666666666666668)))));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -8.2e-108) or not (n <= 3.8e-170): tmp = (n * 100.0) + (i * ((n * 50.0) + (i * (((i * n) * 4.166666666666667) + (n * 16.666666666666668))))) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -8.2e-108) || !(n <= 3.8e-170)) tmp = Float64(Float64(n * 100.0) + Float64(i * Float64(Float64(n * 50.0) + Float64(i * Float64(Float64(Float64(i * n) * 4.166666666666667) + Float64(n * 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 <= -8.2e-108) || ~((n <= 3.8e-170))) tmp = (n * 100.0) + (i * ((n * 50.0) + (i * (((i * n) * 4.166666666666667) + (n * 16.666666666666668))))); else tmp = 0.0 / (i / n); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -8.2e-108], N[Not[LessEqual[n, 3.8e-170]], $MachinePrecision]], N[(N[(n * 100.0), $MachinePrecision] + N[(i * N[(N[(n * 50.0), $MachinePrecision] + N[(i * N[(N[(N[(i * n), $MachinePrecision] * 4.166666666666667), $MachinePrecision] + N[(n * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.2 \cdot 10^{-108} \lor \neg \left(n \leq 3.8 \cdot 10^{-170}\right):\\
\;\;\;\;n \cdot 100 + i \cdot \left(n \cdot 50 + i \cdot \left(\left(i \cdot n\right) \cdot 4.166666666666667 + n \cdot 16.666666666666668\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -8.20000000000000074e-108 or 3.7999999999999998e-170 < n Initial program 24.0%
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 n around inf 31.0%
sub-neg31.0%
metadata-eval31.0%
metadata-eval31.0%
distribute-lft-in31.1%
metadata-eval31.1%
sub-neg31.1%
expm1-define79.9%
Simplified79.9%
Taylor expanded in i around 0 62.1%
if -8.20000000000000074e-108 < n < 3.7999999999999998e-170Initial program 53.4%
associate-*r/53.4%
sub-neg53.4%
distribute-rgt-in53.4%
metadata-eval53.4%
metadata-eval53.4%
Simplified53.4%
Taylor expanded in i around 0 56.3%
+-commutative56.3%
Simplified56.3%
Taylor expanded in i around 0 68.3%
Final simplification63.2%
(FPCore (i n)
:precision binary64
(if (or (<= n -1.45e-108) (not (<= n 6.5e-170)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))
(/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.45e-108) || !(n <= 6.5e-170)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} 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.45d-108)) .or. (.not. (n <= 6.5d-170))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
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.45e-108) || !(n <= 6.5e-170)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.45e-108) or not (n <= 6.5e-170): tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.45e-108) || !(n <= 6.5e-170)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.45e-108) || ~((n <= 6.5e-170))) tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); else tmp = 0.0 / (i / n); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.45e-108], N[Not[LessEqual[n, 6.5e-170]], $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[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.45 \cdot 10^{-108} \lor \neg \left(n \leq 6.5 \cdot 10^{-170}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.45e-108 or 6.50000000000000035e-170 < n Initial program 24.0%
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 n around inf 31.0%
sub-neg31.0%
metadata-eval31.0%
metadata-eval31.0%
distribute-lft-in31.1%
metadata-eval31.1%
sub-neg31.1%
expm1-define79.9%
Simplified79.9%
Taylor expanded in i around 0 62.1%
*-commutative62.1%
Simplified62.1%
if -1.45e-108 < n < 6.50000000000000035e-170Initial program 53.4%
associate-*r/53.4%
sub-neg53.4%
distribute-rgt-in53.4%
metadata-eval53.4%
metadata-eval53.4%
Simplified53.4%
Taylor expanded in i around 0 56.3%
+-commutative56.3%
Simplified56.3%
Taylor expanded in i around 0 68.3%
Final simplification63.2%
(FPCore (i n) :precision binary64 (if (or (<= n -1.4e-108) (not (<= n 6.2e-170))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.4e-108) || !(n <= 6.2e-170)) {
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.4d-108)) .or. (.not. (n <= 6.2d-170))) 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.4e-108) || !(n <= 6.2e-170)) {
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.4e-108) or not (n <= 6.2e-170): 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.4e-108) || !(n <= 6.2e-170)) 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.4e-108) || ~((n <= 6.2e-170))) 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.4e-108], N[Not[LessEqual[n, 6.2e-170]], $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.4 \cdot 10^{-108} \lor \neg \left(n \leq 6.2 \cdot 10^{-170}\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.4e-108 or 6.19999999999999971e-170 < n Initial program 24.0%
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 n around inf 31.0%
sub-neg31.0%
metadata-eval31.0%
metadata-eval31.0%
distribute-lft-in31.1%
metadata-eval31.1%
sub-neg31.1%
expm1-define79.9%
Simplified79.9%
Taylor expanded in i around 0 59.2%
*-commutative59.2%
Simplified59.2%
if -1.4e-108 < n < 6.19999999999999971e-170Initial program 53.4%
associate-*r/53.4%
sub-neg53.4%
distribute-rgt-in53.4%
metadata-eval53.4%
metadata-eval53.4%
Simplified53.4%
Taylor expanded in i around 0 56.3%
+-commutative56.3%
Simplified56.3%
Taylor expanded in i around 0 68.3%
Final simplification60.9%
(FPCore (i n)
:precision binary64
(if (<= n -1.4e-108)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 3.9e-170)
(/ 0.0 (/ i n))
(* n (/ (* i (+ 100.0 (* i 50.0))) i)))))
double code(double i, double n) {
double tmp;
if (n <= -1.4e-108) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.9e-170) {
tmp = 0.0 / (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 <= (-1.4d-108)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 3.9d-170) then
tmp = 0.0d0 / (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 <= -1.4e-108) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.9e-170) {
tmp = 0.0 / (i / n);
} else {
tmp = n * ((i * (100.0 + (i * 50.0))) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.4e-108: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 3.9e-170: tmp = 0.0 / (i / n) else: tmp = n * ((i * (100.0 + (i * 50.0))) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.4e-108) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 3.9e-170) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(n * Float64(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 <= -1.4e-108) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 3.9e-170) tmp = 0.0 / (i / n); else tmp = n * ((i * (100.0 + (i * 50.0))) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -1.4e-108], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.9e-170], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(N[(i * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.4 \cdot 10^{-108}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 3.9 \cdot 10^{-170}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot 50\right)}{i}\\
\end{array}
\end{array}
if n < -1.4e-108Initial program 32.2%
associate-/r/32.4%
associate-*r*32.4%
*-commutative32.4%
associate-*r/32.5%
sub-neg32.5%
distribute-lft-in32.3%
metadata-eval32.3%
metadata-eval32.3%
metadata-eval32.3%
fma-define32.5%
metadata-eval32.5%
Simplified32.5%
Taylor expanded in n around inf 32.5%
sub-neg32.5%
metadata-eval32.5%
metadata-eval32.5%
distribute-lft-in32.5%
metadata-eval32.5%
sub-neg32.5%
expm1-define78.1%
Simplified78.1%
Taylor expanded in i around 0 53.4%
*-commutative53.4%
Simplified53.4%
if -1.4e-108 < n < 3.90000000000000021e-170Initial program 53.4%
associate-*r/53.4%
sub-neg53.4%
distribute-rgt-in53.4%
metadata-eval53.4%
metadata-eval53.4%
Simplified53.4%
Taylor expanded in i around 0 56.3%
+-commutative56.3%
Simplified56.3%
Taylor expanded in i around 0 68.3%
if 3.90000000000000021e-170 < n Initial program 15.5%
associate-/r/15.8%
associate-*r*15.8%
*-commutative15.8%
associate-*r/15.8%
sub-neg15.8%
distribute-lft-in15.8%
metadata-eval15.8%
metadata-eval15.8%
metadata-eval15.8%
fma-define15.8%
metadata-eval15.8%
Simplified15.8%
Taylor expanded in n around inf 29.5%
sub-neg29.5%
metadata-eval29.5%
metadata-eval29.5%
distribute-lft-in29.5%
metadata-eval29.5%
sub-neg29.5%
expm1-define81.7%
Simplified81.7%
Taylor expanded in i around 0 66.0%
*-commutative66.0%
Simplified66.0%
Final simplification61.2%
(FPCore (i n) :precision binary64 (if (or (<= n -1.4e-108) (not (<= n 4.9e-170))) (* n (+ 100.0 (* i 50.0))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.4e-108) || !(n <= 4.9e-170)) {
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.4d-108)) .or. (.not. (n <= 4.9d-170))) 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.4e-108) || !(n <= 4.9e-170)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.4e-108) or not (n <= 4.9e-170): 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.4e-108) || !(n <= 4.9e-170)) 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.4e-108) || ~((n <= 4.9e-170))) 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.4e-108], N[Not[LessEqual[n, 4.9e-170]], $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.4 \cdot 10^{-108} \lor \neg \left(n \leq 4.9 \cdot 10^{-170}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.4e-108 or 4.8999999999999996e-170 < n Initial program 24.0%
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 n around inf 31.0%
sub-neg31.0%
metadata-eval31.0%
metadata-eval31.0%
distribute-lft-in31.1%
metadata-eval31.1%
sub-neg31.1%
expm1-define79.9%
Simplified79.9%
Taylor expanded in i around 0 57.0%
*-commutative57.0%
Simplified57.0%
if -1.4e-108 < n < 4.8999999999999996e-170Initial program 53.4%
associate-*r/53.4%
sub-neg53.4%
distribute-rgt-in53.4%
metadata-eval53.4%
metadata-eval53.4%
Simplified53.4%
Taylor expanded in i around 0 56.3%
+-commutative56.3%
Simplified56.3%
Taylor expanded in i around 0 68.3%
Final simplification59.0%
(FPCore (i n) :precision binary64 (if (or (<= n -6.8e+35) (not (<= n 1.2e-33))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -6.8e+35) || !(n <= 1.2e-33)) {
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 <= (-6.8d+35)) .or. (.not. (n <= 1.2d-33))) 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 <= -6.8e+35) || !(n <= 1.2e-33)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -6.8e+35) or not (n <= 1.2e-33): 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 <= -6.8e+35) || !(n <= 1.2e-33)) 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 <= -6.8e+35) || ~((n <= 1.2e-33))) 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, -6.8e+35], N[Not[LessEqual[n, 1.2e-33]], $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 -6.8 \cdot 10^{+35} \lor \neg \left(n \leq 1.2 \cdot 10^{-33}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -6.8000000000000002e35 or 1.2e-33 < n Initial program 26.0%
associate-/r/26.4%
associate-*r*26.4%
*-commutative26.4%
associate-*r/26.5%
sub-neg26.5%
distribute-lft-in26.5%
metadata-eval26.5%
metadata-eval26.5%
metadata-eval26.5%
fma-define26.5%
metadata-eval26.5%
Simplified26.5%
Taylor expanded in n around inf 39.1%
sub-neg39.1%
metadata-eval39.1%
metadata-eval39.1%
distribute-lft-in39.1%
metadata-eval39.1%
sub-neg39.1%
expm1-define88.5%
Simplified88.5%
Taylor expanded in i around 0 59.3%
*-commutative59.3%
Simplified59.3%
if -6.8000000000000002e35 < n < 1.2e-33Initial program 34.1%
Taylor expanded in i around 0 52.9%
Final simplification56.6%
(FPCore (i n) :precision binary64 (if (<= n -1.4e-108) (* (* n 100.0) (+ 1.0 (* i 0.5))) (if (<= n 4.2e-170) (/ 0.0 (/ i n)) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -1.4e-108) {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
} else if (n <= 4.2e-170) {
tmp = 0.0 / (i / n);
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-1.4d-108)) then
tmp = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
else if (n <= 4.2d-170) then
tmp = 0.0d0 / (i / n)
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -1.4e-108) {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
} else if (n <= 4.2e-170) {
tmp = 0.0 / (i / n);
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.4e-108: tmp = (n * 100.0) * (1.0 + (i * 0.5)) elif n <= 4.2e-170: tmp = 0.0 / (i / n) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.4e-108) tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5))); elseif (n <= 4.2e-170) tmp = Float64(0.0 / Float64(i / n)); else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -1.4e-108) tmp = (n * 100.0) * (1.0 + (i * 0.5)); elseif (n <= 4.2e-170) tmp = 0.0 / (i / n); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -1.4e-108], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.2e-170], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.4 \cdot 10^{-108}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\mathbf{elif}\;n \leq 4.2 \cdot 10^{-170}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -1.4e-108Initial program 32.2%
Taylor expanded in i around 0 50.9%
associate-*r*50.9%
*-commutative50.9%
associate-*r/50.9%
metadata-eval50.9%
Simplified50.9%
Taylor expanded in n around inf 50.8%
associate-*r*50.8%
*-commutative50.8%
Simplified50.8%
if -1.4e-108 < n < 4.2000000000000001e-170Initial program 53.4%
associate-*r/53.4%
sub-neg53.4%
distribute-rgt-in53.4%
metadata-eval53.4%
metadata-eval53.4%
Simplified53.4%
Taylor expanded in i around 0 56.3%
+-commutative56.3%
Simplified56.3%
Taylor expanded in i around 0 68.3%
if 4.2000000000000001e-170 < n Initial program 15.5%
associate-/r/15.8%
associate-*r*15.8%
*-commutative15.8%
associate-*r/15.8%
sub-neg15.8%
distribute-lft-in15.8%
metadata-eval15.8%
metadata-eval15.8%
metadata-eval15.8%
fma-define15.8%
metadata-eval15.8%
Simplified15.8%
Taylor expanded in n around inf 29.5%
sub-neg29.5%
metadata-eval29.5%
metadata-eval29.5%
distribute-lft-in29.5%
metadata-eval29.5%
sub-neg29.5%
expm1-define81.7%
Simplified81.7%
Taylor expanded in i around 0 63.5%
*-commutative63.5%
Simplified63.5%
Final simplification59.0%
(FPCore (i n)
:precision binary64
(if (<= i -3.1e-57)
(* 100.0 (/ i (/ i n)))
(if (<= i 0.65)
(* 100.0 (+ n (* i -0.5)))
(* 16.666666666666668 (* n (* i i))))))
double code(double i, double n) {
double tmp;
if (i <= -3.1e-57) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 0.65) {
tmp = 100.0 * (n + (i * -0.5));
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-3.1d-57)) then
tmp = 100.0d0 * (i / (i / n))
else if (i <= 0.65d0) then
tmp = 100.0d0 * (n + (i * (-0.5d0)))
else
tmp = 16.666666666666668d0 * (n * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -3.1e-57) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 0.65) {
tmp = 100.0 * (n + (i * -0.5));
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -3.1e-57: tmp = 100.0 * (i / (i / n)) elif i <= 0.65: tmp = 100.0 * (n + (i * -0.5)) else: tmp = 16.666666666666668 * (n * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= -3.1e-57) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (i <= 0.65) tmp = Float64(100.0 * Float64(n + Float64(i * -0.5))); else tmp = Float64(16.666666666666668 * Float64(n * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -3.1e-57) tmp = 100.0 * (i / (i / n)); elseif (i <= 0.65) tmp = 100.0 * (n + (i * -0.5)); else tmp = 16.666666666666668 * (n * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -3.1e-57], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 0.65], N[(100.0 * N[(n + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(16.666666666666668 * N[(n * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -3.1 \cdot 10^{-57}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 0.65:\\
\;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < -3.09999999999999976e-57Initial program 56.6%
Taylor expanded in i around 0 24.5%
if -3.09999999999999976e-57 < i < 0.650000000000000022Initial program 10.1%
Taylor expanded in i around 0 82.3%
associate-*r*82.4%
*-commutative82.4%
associate-*r/82.4%
metadata-eval82.4%
Simplified82.4%
Taylor expanded in n around 0 82.1%
*-commutative82.1%
Simplified82.1%
if 0.650000000000000022 < i Initial program 44.9%
associate-/r/45.1%
associate-*r*45.1%
*-commutative45.1%
associate-*r/45.2%
sub-neg45.2%
distribute-lft-in45.2%
metadata-eval45.2%
metadata-eval45.2%
metadata-eval45.2%
fma-define45.2%
metadata-eval45.2%
Simplified45.2%
Taylor expanded in n around inf 45.7%
sub-neg45.7%
metadata-eval45.7%
metadata-eval45.7%
distribute-lft-in45.7%
metadata-eval45.7%
sub-neg45.7%
expm1-define45.7%
Simplified45.7%
Taylor expanded in i around 0 26.9%
*-commutative26.9%
Simplified26.9%
Taylor expanded in i around inf 26.8%
unpow226.8%
Applied egg-rr26.8%
Final simplification55.4%
(FPCore (i n) :precision binary64 (if (<= i 6.8e+53) (* n 100.0) (* 16.666666666666668 (* n (* i i)))))
double code(double i, double n) {
double tmp;
if (i <= 6.8e+53) {
tmp = n * 100.0;
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 6.8d+53) then
tmp = n * 100.0d0
else
tmp = 16.666666666666668d0 * (n * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 6.8e+53) {
tmp = n * 100.0;
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 6.8e+53: tmp = n * 100.0 else: tmp = 16.666666666666668 * (n * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= 6.8e+53) tmp = Float64(n * 100.0); else tmp = Float64(16.666666666666668 * Float64(n * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 6.8e+53) tmp = n * 100.0; else tmp = 16.666666666666668 * (n * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 6.8e+53], N[(n * 100.0), $MachinePrecision], N[(16.666666666666668 * N[(n * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 6.8 \cdot 10^{+53}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < 6.79999999999999995e53Initial program 24.5%
associate-/r/24.7%
associate-*r*24.8%
*-commutative24.8%
associate-*r/24.8%
sub-neg24.8%
distribute-lft-in24.7%
metadata-eval24.7%
metadata-eval24.7%
metadata-eval24.7%
fma-define24.8%
metadata-eval24.8%
Simplified24.8%
Taylor expanded in i around 0 55.6%
*-commutative55.6%
Simplified55.6%
if 6.79999999999999995e53 < i Initial program 55.4%
associate-/r/55.6%
associate-*r*55.5%
*-commutative55.5%
associate-*r/55.7%
sub-neg55.7%
distribute-lft-in55.7%
metadata-eval55.7%
metadata-eval55.7%
metadata-eval55.7%
fma-define55.7%
metadata-eval55.7%
Simplified55.7%
Taylor expanded in n around inf 39.8%
sub-neg39.8%
metadata-eval39.8%
metadata-eval39.8%
distribute-lft-in39.8%
metadata-eval39.8%
sub-neg39.8%
expm1-define39.8%
Simplified39.8%
Taylor expanded in i around 0 33.3%
*-commutative33.3%
Simplified33.3%
Taylor expanded in i around inf 33.3%
unpow233.3%
Applied egg-rr33.3%
Final simplification52.0%
(FPCore (i n) :precision binary64 (* n 100.0))
double code(double i, double n) {
return n * 100.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n * 100.0d0
end function
public static double code(double i, double n) {
return n * 100.0;
}
def code(i, n): return n * 100.0
function code(i, n) return Float64(n * 100.0) end
function tmp = code(i, n) tmp = n * 100.0; end
code[i_, n_] := N[(n * 100.0), $MachinePrecision]
\begin{array}{l}
\\
n \cdot 100
\end{array}
Initial program 29.4%
associate-/r/29.7%
associate-*r*29.7%
*-commutative29.7%
associate-*r/29.7%
sub-neg29.7%
distribute-lft-in29.7%
metadata-eval29.7%
metadata-eval29.7%
metadata-eval29.7%
fma-define29.7%
metadata-eval29.7%
Simplified29.7%
Taylor expanded in i around 0 47.4%
*-commutative47.4%
Simplified47.4%
(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 29.4%
Taylor expanded in i around 0 49.9%
associate-*r*49.9%
*-commutative49.9%
associate-*r/49.9%
metadata-eval49.9%
Simplified49.9%
Taylor expanded in n around 0 2.7%
*-commutative2.7%
Simplified2.7%
(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 2024133
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:alt
(! :herbie-platform default (let ((lnbase (if (== (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) (* 100 (/ (- (exp (* n lnbase)) 1) (/ i n)))))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))