
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 0.0)
(* n (* 100.0 (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_1 INFINITY) (* n (/ (+ (* t_0 100.0) -100.0) i)) (* n 100.0)))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = n * (100.0 * (expm1((n * log1p((i / n)))) / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = n * (100.0 * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= 0.0: tmp = n * (100.0 * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_1 <= math.inf: tmp = n * (((t_0 * 100.0) + -100.0) / i) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(n * Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_1 <= Inf) tmp = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(n * N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t\_0 \cdot 100 + -100}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 28.1%
associate-*r/28.1%
sub-neg28.1%
distribute-rgt-in28.0%
metadata-eval28.0%
metadata-eval28.0%
Simplified28.0%
metadata-eval28.0%
metadata-eval28.0%
distribute-rgt-in28.1%
sub-neg28.1%
associate-*r/28.1%
associate-/r/28.1%
associate-*r*28.1%
add-exp-log28.1%
expm1-define28.1%
log-pow38.4%
log1p-define99.1%
Applied egg-rr99.1%
if 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.8%
associate-/r/99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r/99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
fma-undefine99.8%
*-commutative99.8%
Applied egg-rr99.8%
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.8%
associate-*r*1.8%
*-commutative1.8%
associate-*r/1.8%
sub-neg1.8%
distribute-lft-in1.8%
metadata-eval1.8%
metadata-eval1.8%
metadata-eval1.8%
fma-define1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 82.7%
*-commutative82.7%
Simplified82.7%
Final simplification96.0%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 0.0)
(* 100.0 (* n (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_1 INFINITY) (* n (/ (+ (* t_0 100.0) -100.0) i)) (* n 100.0)))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (n * (expm1((n * log1p((i / n)))) / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (n * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= 0.0: tmp = 100.0 * (n * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_1 <= math.inf: tmp = n * (((t_0 * 100.0) + -100.0) / i) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(100.0 * Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_1 <= Inf) tmp = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t\_0 \cdot 100 + -100}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 28.1%
associate-/r/28.1%
add-exp-log28.1%
expm1-define28.1%
log-pow38.3%
log1p-define98.9%
Applied egg-rr98.9%
if 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.8%
associate-/r/99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r/99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
fma-undefine99.8%
*-commutative99.8%
Applied egg-rr99.8%
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.8%
associate-*r*1.8%
*-commutative1.8%
associate-*r/1.8%
sub-neg1.8%
distribute-lft-in1.8%
metadata-eval1.8%
metadata-eval1.8%
metadata-eval1.8%
fma-define1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 82.7%
*-commutative82.7%
Simplified82.7%
Final simplification95.9%
(FPCore (i n) :precision binary64 (if (or (<= n -5.4e-138) (not (<= n 6.5e-161))) (* n (* 100.0 (/ (expm1 i) i))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -5.4e-138) || !(n <= 6.5e-161)) {
tmp = n * (100.0 * (expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -5.4e-138) || !(n <= 6.5e-161)) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -5.4e-138) or not (n <= 6.5e-161): tmp = n * (100.0 * (math.expm1(i) / i)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -5.4e-138) || !(n <= 6.5e-161)) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -5.4e-138], N[Not[LessEqual[n, 6.5e-161]], $MachinePrecision]], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.4 \cdot 10^{-138} \lor \neg \left(n \leq 6.5 \cdot 10^{-161}\right):\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -5.40000000000000057e-138 or 6.50000000000000008e-161 < n Initial program 24.2%
associate-/r/24.5%
associate-*r*24.5%
*-commutative24.5%
associate-*r/24.6%
sub-neg24.6%
distribute-lft-in24.5%
metadata-eval24.5%
metadata-eval24.5%
metadata-eval24.5%
fma-define24.6%
metadata-eval24.6%
Simplified24.6%
Taylor expanded in n around inf 35.7%
associate-/l*35.8%
sub-neg35.8%
metadata-eval35.8%
metadata-eval35.8%
distribute-lft-in35.8%
metadata-eval35.8%
sub-neg35.8%
associate-*r/35.8%
*-commutative35.8%
expm1-define84.1%
Simplified84.1%
if -5.40000000000000057e-138 < n < 6.50000000000000008e-161Initial program 57.9%
associate-*r/57.9%
sub-neg57.9%
distribute-rgt-in57.9%
metadata-eval57.9%
metadata-eval57.9%
Simplified57.9%
Taylor expanded in i around 0 74.6%
Taylor expanded in i around 0 74.6%
Final simplification82.6%
(FPCore (i n) :precision binary64 (if (or (<= n -5.8e-138) (not (<= n 3.6e-161))) (* n (* (expm1 i) (/ 100.0 i))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -5.8e-138) || !(n <= 3.6e-161)) {
tmp = n * (expm1(i) * (100.0 / i));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -5.8e-138) || !(n <= 3.6e-161)) {
tmp = n * (Math.expm1(i) * (100.0 / i));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -5.8e-138) or not (n <= 3.6e-161): tmp = n * (math.expm1(i) * (100.0 / i)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -5.8e-138) || !(n <= 3.6e-161)) tmp = Float64(n * Float64(expm1(i) * Float64(100.0 / i))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -5.8e-138], N[Not[LessEqual[n, 3.6e-161]], $MachinePrecision]], N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] * N[(100.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.8 \cdot 10^{-138} \lor \neg \left(n \leq 3.6 \cdot 10^{-161}\right):\\
\;\;\;\;n \cdot \left(\mathsf{expm1}\left(i\right) \cdot \frac{100}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -5.79999999999999946e-138 or 3.60000000000000018e-161 < n Initial program 24.2%
associate-/r/24.5%
associate-*r*24.5%
*-commutative24.5%
associate-*r/24.6%
sub-neg24.6%
distribute-lft-in24.5%
metadata-eval24.5%
metadata-eval24.5%
metadata-eval24.5%
fma-define24.6%
metadata-eval24.6%
Simplified24.6%
Taylor expanded in n around inf 35.8%
sub-neg35.8%
metadata-eval35.8%
metadata-eval35.8%
distribute-lft-in35.8%
metadata-eval35.8%
sub-neg35.8%
expm1-define84.1%
Simplified84.1%
*-commutative84.1%
associate-/l*84.1%
Applied egg-rr84.1%
if -5.79999999999999946e-138 < n < 3.60000000000000018e-161Initial program 57.9%
associate-*r/57.9%
sub-neg57.9%
distribute-rgt-in57.9%
metadata-eval57.9%
metadata-eval57.9%
Simplified57.9%
Taylor expanded in i around 0 74.6%
Taylor expanded in i around 0 74.6%
Final simplification82.5%
(FPCore (i n)
:precision binary64
(if (or (<= i -0.00029) (not (<= i 9.8e-8)))
(* 100.0 (/ (expm1 i) (/ i n)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))))
double code(double i, double n) {
double tmp;
if ((i <= -0.00029) || !(i <= 9.8e-8)) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -0.00029) || !(i <= 9.8e-8)) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -0.00029) or not (i <= 9.8e-8): tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if ((i <= -0.00029) || !(i <= 9.8e-8)) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -0.00029], N[Not[LessEqual[i, 9.8e-8]], $MachinePrecision]], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -0.00029 \lor \neg \left(i \leq 9.8 \cdot 10^{-8}\right):\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\end{array}
\end{array}
if i < -2.9e-4 or 9.8000000000000004e-8 < i Initial program 51.2%
Taylor expanded in n around inf 62.9%
expm1-define62.9%
Simplified62.9%
if -2.9e-4 < i < 9.8000000000000004e-8Initial program 8.9%
associate-/r/9.5%
associate-*r*9.5%
*-commutative9.5%
associate-*r/9.5%
sub-neg9.5%
distribute-lft-in9.5%
metadata-eval9.5%
metadata-eval9.5%
metadata-eval9.5%
fma-define9.5%
metadata-eval9.5%
Simplified9.5%
Taylor expanded in n around inf 10.7%
associate-/l*10.7%
sub-neg10.7%
metadata-eval10.7%
metadata-eval10.7%
distribute-lft-in10.7%
metadata-eval10.7%
sub-neg10.7%
associate-*r/10.7%
*-commutative10.7%
expm1-define88.3%
Simplified88.3%
Taylor expanded in i around 0 88.3%
*-commutative88.3%
Simplified88.3%
Final simplification75.8%
(FPCore (i n)
:precision binary64
(if (<= n -8.4e-138)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 2.25e-194)
0.0
(if (<= n 2.45)
(* 100.0 (/ i (/ i n)))
(/
(*
n
(*
i
(+
100.0
(*
i
(+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667))))))))
i)))))
double code(double i, double n) {
double tmp;
if (n <= -8.4e-138) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 2.25e-194) {
tmp = 0.0;
} else if (n <= 2.45) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * (i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))))) / i;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-8.4d-138)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 2.25d-194) then
tmp = 0.0d0
else if (n <= 2.45d0) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = (n * (i * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0)))))))) / i
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -8.4e-138) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 2.25e-194) {
tmp = 0.0;
} else if (n <= 2.45) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * (i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))))) / i;
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -8.4e-138: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 2.25e-194: tmp = 0.0 elif n <= 2.45: tmp = 100.0 * (i / (i / n)) else: tmp = (n * (i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))))) / i return tmp
function code(i, n) tmp = 0.0 if (n <= -8.4e-138) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 2.25e-194) tmp = 0.0; elseif (n <= 2.45) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(Float64(n * Float64(i * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667)))))))) / i); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -8.4e-138) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 2.25e-194) tmp = 0.0; elseif (n <= 2.45) tmp = 100.0 * (i / (i / n)); else tmp = (n * (i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))))) / i; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -8.4e-138], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.25e-194], 0.0, If[LessEqual[n, 2.45], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * N[(i * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.4 \cdot 10^{-138}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 2.25 \cdot 10^{-194}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 2.45:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot \left(i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\right)}{i}\\
\end{array}
\end{array}
if n < -8.39999999999999943e-138Initial program 31.3%
associate-/r/31.6%
associate-*r*31.6%
*-commutative31.6%
associate-*r/31.7%
sub-neg31.7%
distribute-lft-in31.6%
metadata-eval31.6%
metadata-eval31.6%
metadata-eval31.6%
fma-define31.7%
metadata-eval31.7%
Simplified31.7%
Taylor expanded in n around inf 38.6%
associate-/l*38.6%
sub-neg38.6%
metadata-eval38.6%
metadata-eval38.6%
distribute-lft-in38.6%
metadata-eval38.6%
sub-neg38.6%
associate-*r/38.6%
*-commutative38.6%
expm1-define81.4%
Simplified81.4%
Taylor expanded in i around 0 56.7%
*-commutative56.7%
Simplified56.7%
if -8.39999999999999943e-138 < n < 2.2499999999999999e-194Initial program 66.1%
associate-*r/66.1%
sub-neg66.1%
distribute-rgt-in66.1%
metadata-eval66.1%
metadata-eval66.1%
Simplified66.1%
Taylor expanded in i around 0 77.5%
Taylor expanded in i around 0 77.5%
if 2.2499999999999999e-194 < n < 2.4500000000000002Initial program 15.1%
Taylor expanded in i around 0 65.8%
if 2.4500000000000002 < n Initial program 17.6%
associate-/r/18.2%
associate-*r*18.2%
*-commutative18.2%
associate-*r/18.2%
sub-neg18.2%
distribute-lft-in18.2%
metadata-eval18.2%
metadata-eval18.2%
metadata-eval18.2%
fma-define18.2%
metadata-eval18.2%
Simplified18.2%
Taylor expanded in n around inf 45.7%
associate-/l*45.8%
sub-neg45.8%
metadata-eval45.8%
metadata-eval45.8%
distribute-lft-in45.9%
metadata-eval45.9%
sub-neg45.9%
associate-*r/45.9%
*-commutative45.9%
expm1-define99.9%
Simplified99.9%
*-commutative99.9%
associate-/l*99.9%
associate-*r/99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in i around 0 80.1%
*-commutative80.1%
Simplified80.1%
(FPCore (i n)
:precision binary64
(if (<= n -2.65e-137)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 3.45e-161)
0.0
(*
n
(/
(*
i
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))
i)))))
double code(double i, double n) {
double tmp;
if (n <= -2.65e-137) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.45e-161) {
tmp = 0.0;
} else {
tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-2.65d-137)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 3.45d-161) then
tmp = 0.0d0
else
tmp = n * ((i * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -2.65e-137) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 3.45e-161) {
tmp = 0.0;
} else {
tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2.65e-137: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 3.45e-161: tmp = 0.0 else: tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= -2.65e-137) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 3.45e-161) tmp = 0.0; else tmp = Float64(n * Float64(Float64(i * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))) / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -2.65e-137) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 3.45e-161) tmp = 0.0; else tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2.65e-137], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.45e-161], 0.0, N[(n * N[(N[(i * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.65 \cdot 10^{-137}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 3.45 \cdot 10^{-161}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)}{i}\\
\end{array}
\end{array}
if n < -2.65000000000000019e-137Initial program 31.3%
associate-/r/31.6%
associate-*r*31.6%
*-commutative31.6%
associate-*r/31.7%
sub-neg31.7%
distribute-lft-in31.6%
metadata-eval31.6%
metadata-eval31.6%
metadata-eval31.6%
fma-define31.7%
metadata-eval31.7%
Simplified31.7%
Taylor expanded in n around inf 38.6%
associate-/l*38.6%
sub-neg38.6%
metadata-eval38.6%
metadata-eval38.6%
distribute-lft-in38.6%
metadata-eval38.6%
sub-neg38.6%
associate-*r/38.6%
*-commutative38.6%
expm1-define81.4%
Simplified81.4%
Taylor expanded in i around 0 56.7%
*-commutative56.7%
Simplified56.7%
if -2.65000000000000019e-137 < n < 3.45000000000000001e-161Initial program 57.9%
associate-*r/57.9%
sub-neg57.9%
distribute-rgt-in57.9%
metadata-eval57.9%
metadata-eval57.9%
Simplified57.9%
Taylor expanded in i around 0 74.6%
Taylor expanded in i around 0 74.6%
if 3.45000000000000001e-161 < n Initial program 16.7%
associate-/r/17.2%
associate-*r*17.2%
*-commutative17.2%
associate-*r/17.2%
sub-neg17.2%
distribute-lft-in17.2%
metadata-eval17.2%
metadata-eval17.2%
metadata-eval17.2%
fma-define17.2%
metadata-eval17.2%
Simplified17.2%
Taylor expanded in n around inf 32.8%
sub-neg32.8%
metadata-eval32.8%
metadata-eval32.8%
distribute-lft-in32.9%
metadata-eval32.9%
sub-neg32.9%
expm1-define86.9%
Simplified86.9%
Taylor expanded in i around 0 71.6%
*-commutative71.6%
Simplified71.6%
(FPCore (i n)
:precision binary64
(if (<= i -1.52)
0.0
(if (<= i 900000.0)
(* n (+ 100.0 (* i 50.0)))
(if (<= i 1.9e+50)
(* 100.0 (/ i (+ (+ 1.0 (/ i n)) -1.0)))
(* n (* 16.666666666666668 (* i i)))))))
double code(double i, double n) {
double tmp;
if (i <= -1.52) {
tmp = 0.0;
} else if (i <= 900000.0) {
tmp = n * (100.0 + (i * 50.0));
} else if (i <= 1.9e+50) {
tmp = 100.0 * (i / ((1.0 + (i / n)) + -1.0));
} else {
tmp = n * (16.666666666666668 * (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 <= (-1.52d0)) then
tmp = 0.0d0
else if (i <= 900000.0d0) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (i <= 1.9d+50) then
tmp = 100.0d0 * (i / ((1.0d0 + (i / n)) + (-1.0d0)))
else
tmp = n * (16.666666666666668d0 * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -1.52) {
tmp = 0.0;
} else if (i <= 900000.0) {
tmp = n * (100.0 + (i * 50.0));
} else if (i <= 1.9e+50) {
tmp = 100.0 * (i / ((1.0 + (i / n)) + -1.0));
} else {
tmp = n * (16.666666666666668 * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.52: tmp = 0.0 elif i <= 900000.0: tmp = n * (100.0 + (i * 50.0)) elif i <= 1.9e+50: tmp = 100.0 * (i / ((1.0 + (i / n)) + -1.0)) else: tmp = n * (16.666666666666668 * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= -1.52) tmp = 0.0; elseif (i <= 900000.0) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (i <= 1.9e+50) tmp = Float64(100.0 * Float64(i / Float64(Float64(1.0 + Float64(i / n)) + -1.0))); else tmp = Float64(n * Float64(16.666666666666668 * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -1.52) tmp = 0.0; elseif (i <= 900000.0) tmp = n * (100.0 + (i * 50.0)); elseif (i <= 1.9e+50) tmp = 100.0 * (i / ((1.0 + (i / n)) + -1.0)); else tmp = n * (16.666666666666668 * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.52], 0.0, If[LessEqual[i, 900000.0], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1.9e+50], N[(100.0 * N[(i / N[(N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(16.666666666666668 * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.52:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 900000:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;i \leq 1.9 \cdot 10^{+50}:\\
\;\;\;\;100 \cdot \frac{i}{\left(1 + \frac{i}{n}\right) + -1}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(16.666666666666668 \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < -1.52Initial program 60.7%
associate-*r/60.8%
sub-neg60.8%
distribute-rgt-in60.6%
metadata-eval60.6%
metadata-eval60.6%
Simplified60.6%
Taylor expanded in i around 0 35.7%
Taylor expanded in i around 0 35.7%
if -1.52 < i < 9e5Initial program 9.4%
associate-/r/9.9%
associate-*r*9.9%
*-commutative9.9%
associate-*r/9.9%
sub-neg9.9%
distribute-lft-in9.9%
metadata-eval9.9%
metadata-eval9.9%
metadata-eval9.9%
fma-define9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in n around inf 13.2%
associate-/l*13.3%
sub-neg13.3%
metadata-eval13.3%
metadata-eval13.3%
distribute-lft-in13.3%
metadata-eval13.3%
sub-neg13.3%
associate-*r/13.3%
*-commutative13.3%
expm1-define88.0%
Simplified88.0%
Taylor expanded in i around 0 85.3%
+-commutative85.3%
associate-*r*85.3%
distribute-rgt-in85.3%
*-commutative85.3%
Simplified85.3%
if 9e5 < i < 1.89999999999999994e50Initial program 2.7%
Taylor expanded in i around 0 5.2%
expm1-log1p-u5.2%
log1p-define57.5%
expm1-undefine57.5%
add-exp-log57.5%
Applied egg-rr57.5%
if 1.89999999999999994e50 < i Initial program 52.5%
associate-/r/52.7%
associate-*r*52.7%
*-commutative52.7%
associate-*r/52.7%
sub-neg52.7%
distribute-lft-in52.7%
metadata-eval52.7%
metadata-eval52.7%
metadata-eval52.7%
fma-define52.7%
metadata-eval52.7%
Simplified52.7%
Taylor expanded in n around inf 49.8%
associate-/l*49.8%
sub-neg49.8%
metadata-eval49.8%
metadata-eval49.8%
distribute-lft-in49.8%
metadata-eval49.8%
sub-neg49.8%
associate-*r/49.8%
*-commutative49.8%
expm1-define49.8%
Simplified49.8%
Taylor expanded in i around 0 43.6%
*-commutative43.6%
Simplified43.6%
Taylor expanded in i around inf 43.6%
associate-*r*43.6%
*-commutative43.6%
Simplified43.6%
unpow243.6%
Applied egg-rr43.6%
Final simplification64.4%
(FPCore (i n) :precision binary64 (if (or (<= n -6.5e-138) (not (<= n 8.8e-161))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -6.5e-138) || !(n <= 8.8e-161)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} 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 <= (-6.5d-138)) .or. (.not. (n <= 8.8d-161))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -6.5e-138) || !(n <= 8.8e-161)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -6.5e-138) or not (n <= 8.8e-161): tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -6.5e-138) || !(n <= 8.8e-161)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -6.5e-138) || ~((n <= 8.8e-161))) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -6.5e-138], N[Not[LessEqual[n, 8.8e-161]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.5 \cdot 10^{-138} \lor \neg \left(n \leq 8.8 \cdot 10^{-161}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -6.4999999999999999e-138 or 8.80000000000000009e-161 < n Initial program 24.2%
associate-/r/24.5%
associate-*r*24.5%
*-commutative24.5%
associate-*r/24.6%
sub-neg24.6%
distribute-lft-in24.5%
metadata-eval24.5%
metadata-eval24.5%
metadata-eval24.5%
fma-define24.6%
metadata-eval24.6%
Simplified24.6%
Taylor expanded in n around inf 35.7%
associate-/l*35.8%
sub-neg35.8%
metadata-eval35.8%
metadata-eval35.8%
distribute-lft-in35.8%
metadata-eval35.8%
sub-neg35.8%
associate-*r/35.8%
*-commutative35.8%
expm1-define84.1%
Simplified84.1%
Taylor expanded in i around 0 63.7%
*-commutative63.7%
Simplified63.7%
if -6.4999999999999999e-138 < n < 8.80000000000000009e-161Initial program 57.9%
associate-*r/57.9%
sub-neg57.9%
distribute-rgt-in57.9%
metadata-eval57.9%
metadata-eval57.9%
Simplified57.9%
Taylor expanded in i around 0 74.6%
Taylor expanded in i around 0 74.6%
Final simplification65.5%
(FPCore (i n)
:precision binary64
(if (<= i -1.35)
0.0
(if (<= i 2.5e-5)
(* n (+ 100.0 (* i 50.0)))
(* n (* 16.666666666666668 (* i i))))))
double code(double i, double n) {
double tmp;
if (i <= -1.35) {
tmp = 0.0;
} else if (i <= 2.5e-5) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = n * (16.666666666666668 * (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 <= (-1.35d0)) then
tmp = 0.0d0
else if (i <= 2.5d-5) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = n * (16.666666666666668d0 * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -1.35) {
tmp = 0.0;
} else if (i <= 2.5e-5) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = n * (16.666666666666668 * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.35: tmp = 0.0 elif i <= 2.5e-5: tmp = n * (100.0 + (i * 50.0)) else: tmp = n * (16.666666666666668 * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= -1.35) tmp = 0.0; elseif (i <= 2.5e-5) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = Float64(n * Float64(16.666666666666668 * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -1.35) tmp = 0.0; elseif (i <= 2.5e-5) tmp = n * (100.0 + (i * 50.0)); else tmp = n * (16.666666666666668 * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.35], 0.0, If[LessEqual[i, 2.5e-5], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(16.666666666666668 * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.35:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 2.5 \cdot 10^{-5}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(16.666666666666668 \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < -1.3500000000000001Initial program 60.7%
associate-*r/60.8%
sub-neg60.8%
distribute-rgt-in60.6%
metadata-eval60.6%
metadata-eval60.6%
Simplified60.6%
Taylor expanded in i around 0 35.7%
Taylor expanded in i around 0 35.7%
if -1.3500000000000001 < i < 2.50000000000000012e-5Initial program 8.8%
associate-/r/9.4%
associate-*r*9.4%
*-commutative9.4%
associate-*r/9.4%
sub-neg9.4%
distribute-lft-in9.4%
metadata-eval9.4%
metadata-eval9.4%
metadata-eval9.4%
fma-define9.4%
metadata-eval9.4%
Simplified9.4%
Taylor expanded in n around inf 12.0%
associate-/l*12.0%
sub-neg12.0%
metadata-eval12.0%
metadata-eval12.0%
distribute-lft-in12.0%
metadata-eval12.0%
sub-neg12.0%
associate-*r/12.1%
*-commutative12.1%
expm1-define88.5%
Simplified88.5%
Taylor expanded in i around 0 87.1%
+-commutative87.1%
associate-*r*87.1%
distribute-rgt-in87.1%
*-commutative87.1%
Simplified87.1%
if 2.50000000000000012e-5 < i Initial program 45.4%
associate-/r/45.6%
associate-*r*45.6%
*-commutative45.6%
associate-*r/45.6%
sub-neg45.6%
distribute-lft-in45.6%
metadata-eval45.6%
metadata-eval45.6%
metadata-eval45.6%
fma-define45.6%
metadata-eval45.6%
Simplified45.6%
Taylor expanded in n around inf 52.8%
associate-/l*52.8%
sub-neg52.8%
metadata-eval52.8%
metadata-eval52.8%
distribute-lft-in52.8%
metadata-eval52.8%
sub-neg52.8%
associate-*r/52.8%
*-commutative52.8%
expm1-define52.8%
Simplified52.8%
Taylor expanded in i around 0 37.2%
*-commutative37.2%
Simplified37.2%
Taylor expanded in i around inf 37.3%
associate-*r*37.3%
*-commutative37.3%
Simplified37.3%
unpow237.3%
Applied egg-rr37.3%
(FPCore (i n) :precision binary64 (if (<= i -21000.0) 0.0 (if (<= i 2.5e-5) (* n 100.0) (* n (* 16.666666666666668 (* i i))))))
double code(double i, double n) {
double tmp;
if (i <= -21000.0) {
tmp = 0.0;
} else if (i <= 2.5e-5) {
tmp = n * 100.0;
} else {
tmp = n * (16.666666666666668 * (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 <= (-21000.0d0)) then
tmp = 0.0d0
else if (i <= 2.5d-5) then
tmp = n * 100.0d0
else
tmp = n * (16.666666666666668d0 * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -21000.0) {
tmp = 0.0;
} else if (i <= 2.5e-5) {
tmp = n * 100.0;
} else {
tmp = n * (16.666666666666668 * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -21000.0: tmp = 0.0 elif i <= 2.5e-5: tmp = n * 100.0 else: tmp = n * (16.666666666666668 * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= -21000.0) tmp = 0.0; elseif (i <= 2.5e-5) tmp = Float64(n * 100.0); else tmp = Float64(n * Float64(16.666666666666668 * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -21000.0) tmp = 0.0; elseif (i <= 2.5e-5) tmp = n * 100.0; else tmp = n * (16.666666666666668 * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -21000.0], 0.0, If[LessEqual[i, 2.5e-5], N[(n * 100.0), $MachinePrecision], N[(n * N[(16.666666666666668 * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -21000:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 2.5 \cdot 10^{-5}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(16.666666666666668 \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < -21000Initial program 61.9%
associate-*r/61.9%
sub-neg61.9%
distribute-rgt-in61.8%
metadata-eval61.8%
metadata-eval61.8%
Simplified61.8%
Taylor expanded in i around 0 36.3%
Taylor expanded in i around 0 36.3%
if -21000 < i < 2.50000000000000012e-5Initial program 8.7%
associate-/r/9.3%
associate-*r*9.3%
*-commutative9.3%
associate-*r/9.3%
sub-neg9.3%
distribute-lft-in9.3%
metadata-eval9.3%
metadata-eval9.3%
metadata-eval9.3%
fma-define9.3%
metadata-eval9.3%
Simplified9.3%
Taylor expanded in i around 0 86.0%
*-commutative86.0%
Simplified86.0%
if 2.50000000000000012e-5 < i Initial program 45.4%
associate-/r/45.6%
associate-*r*45.6%
*-commutative45.6%
associate-*r/45.6%
sub-neg45.6%
distribute-lft-in45.6%
metadata-eval45.6%
metadata-eval45.6%
metadata-eval45.6%
fma-define45.6%
metadata-eval45.6%
Simplified45.6%
Taylor expanded in n around inf 52.8%
associate-/l*52.8%
sub-neg52.8%
metadata-eval52.8%
metadata-eval52.8%
distribute-lft-in52.8%
metadata-eval52.8%
sub-neg52.8%
associate-*r/52.8%
*-commutative52.8%
expm1-define52.8%
Simplified52.8%
Taylor expanded in i around 0 37.2%
*-commutative37.2%
Simplified37.2%
Taylor expanded in i around inf 37.3%
associate-*r*37.3%
*-commutative37.3%
Simplified37.3%
unpow237.3%
Applied egg-rr37.3%
(FPCore (i n) :precision binary64 (if (<= i -26000.0) 0.0 (if (<= i 2.5e-5) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -26000.0) {
tmp = 0.0;
} else if (i <= 2.5e-5) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-26000.0d0)) then
tmp = 0.0d0
else if (i <= 2.5d-5) then
tmp = n * 100.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -26000.0) {
tmp = 0.0;
} else if (i <= 2.5e-5) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -26000.0: tmp = 0.0 elif i <= 2.5e-5: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -26000.0) tmp = 0.0; elseif (i <= 2.5e-5) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -26000.0) tmp = 0.0; elseif (i <= 2.5e-5) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -26000.0], 0.0, If[LessEqual[i, 2.5e-5], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -26000:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 2.5 \cdot 10^{-5}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -26000 or 2.50000000000000012e-5 < i Initial program 52.4%
associate-*r/52.3%
sub-neg52.3%
distribute-rgt-in52.3%
metadata-eval52.3%
metadata-eval52.3%
Simplified52.3%
Taylor expanded in i around 0 28.3%
Taylor expanded in i around 0 28.3%
if -26000 < i < 2.50000000000000012e-5Initial program 8.7%
associate-/r/9.3%
associate-*r*9.3%
*-commutative9.3%
associate-*r/9.3%
sub-neg9.3%
distribute-lft-in9.3%
metadata-eval9.3%
metadata-eval9.3%
metadata-eval9.3%
fma-define9.3%
metadata-eval9.3%
Simplified9.3%
Taylor expanded in i around 0 86.0%
*-commutative86.0%
Simplified86.0%
(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 29.7%
associate-*r/29.7%
sub-neg29.7%
distribute-rgt-in29.7%
metadata-eval29.7%
metadata-eval29.7%
Simplified29.7%
Taylor expanded in i around 0 18.2%
Taylor expanded in i around 0 18.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 2024165
(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))))