
(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 12 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 (- INFINITY))
(* t_1 100.0)
(if (<= t_1 0.0)
(/ (* 100.0 (expm1 (* n (log1p (/ i n))))) (/ i n))
(if (<= t_1 INFINITY)
(* n (/ (+ (* t_0 100.0) -100.0) i))
(/ (* n 100.0) (+ 1.0 (* i (+ (/ 0.5 n) -0.5)))))))))
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 <= -((double) INFINITY)) {
tmp = t_1 * 100.0;
} else if (t_1 <= 0.0) {
tmp = (100.0 * expm1((n * log1p((i / n))))) / (i / n);
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
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 <= -Double.POSITIVE_INFINITY) {
tmp = t_1 * 100.0;
} 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 = n * (((t_0 * 100.0) + -100.0) / i);
} else {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
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 <= -math.inf: tmp = t_1 * 100.0 elif t_1 <= 0.0: tmp = (100.0 * math.expm1((n * math.log1p((i / n))))) / (i / n) elif t_1 <= math.inf: tmp = n * (((t_0 * 100.0) + -100.0) / i) else: tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5))) 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 <= Float64(-Inf)) tmp = Float64(t_1 * 100.0); elseif (t_1 <= 0.0) tmp = Float64(Float64(100.0 * expm1(Float64(n * log1p(Float64(i / n))))) / Float64(i / n)); elseif (t_1 <= Inf) tmp = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i)); else tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(Float64(0.5 / n) + -0.5)))); 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, (-Infinity)], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(100.0 * N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(i / n), $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[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_1 \cdot 100\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t_0 \cdot 100 + -100}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -inf.0Initial program 100.0%
if -inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 27.3%
associate-*r/27.3%
sub-neg27.3%
distribute-lft-in27.2%
fma-def27.3%
metadata-eval27.3%
metadata-eval27.3%
Simplified27.3%
fma-udef27.2%
metadata-eval27.2%
distribute-lft-in27.3%
metadata-eval27.3%
sub-neg27.3%
*-commutative27.3%
add-exp-log27.3%
expm1-def27.3%
log-pow41.6%
log1p-udef99.6%
Applied egg-rr99.6%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
associate-/r/99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
fma-udef99.9%
*-commutative99.9%
Applied egg-rr99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
*-commutative0.0%
associate-/r/1.8%
sub-neg1.8%
metadata-eval1.8%
associate-*r*1.8%
*-commutative1.8%
clear-num1.8%
un-div-inv1.8%
metadata-eval1.8%
sub-neg1.8%
add-exp-log1.8%
expm1-def1.8%
log-pow1.8%
log1p-udef1.8%
Applied egg-rr1.8%
Taylor expanded in i around 0 99.9%
sub-neg99.9%
associate-*r/99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.7%
(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 -5e-48)
(* t_1 100.0)
(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) (+ 1.0 (* i (+ (/ 0.5 n) -0.5)))))))))
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 <= -5e-48) {
tmp = t_1 * 100.0;
} else 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) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
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 <= -5e-48) {
tmp = t_1 * 100.0;
} else 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) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
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 <= -5e-48: tmp = t_1 * 100.0 elif 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) / (1.0 + (i * ((0.5 / n) + -0.5))) 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 <= -5e-48) tmp = Float64(t_1 * 100.0); elseif (t_1 <= 0.0) tmp = Float64(n * Float64(Float64(100.0 * 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(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(Float64(0.5 / n) + -0.5)))); 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, -5e-48], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(n * N[(N[(100.0 * N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / i), $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[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-48}:\\
\;\;\;\;t_1 \cdot 100\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{t_0 \cdot 100 + -100}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -4.9999999999999999e-48Initial program 100.0%
if -4.9999999999999999e-48 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 26.4%
associate-/r/25.9%
associate-*r*25.9%
*-commutative25.9%
associate-*r/25.9%
sub-neg25.9%
distribute-lft-in25.8%
fma-def25.9%
metadata-eval25.9%
metadata-eval25.9%
Simplified25.9%
fma-udef26.3%
metadata-eval26.3%
distribute-lft-in26.4%
metadata-eval26.4%
sub-neg26.4%
*-commutative26.4%
add-exp-log26.4%
expm1-def26.4%
log-pow40.9%
log1p-udef99.6%
Applied egg-rr98.7%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
associate-/r/99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
fma-udef99.9%
*-commutative99.9%
Applied egg-rr99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
*-commutative0.0%
associate-/r/1.8%
sub-neg1.8%
metadata-eval1.8%
associate-*r*1.8%
*-commutative1.8%
clear-num1.8%
un-div-inv1.8%
metadata-eval1.8%
sub-neg1.8%
add-exp-log1.8%
expm1-def1.8%
log-pow1.8%
log1p-udef1.8%
Applied egg-rr1.8%
Taylor expanded in i around 0 99.9%
sub-neg99.9%
associate-*r/99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (i n) :precision binary64 (if (or (<= n -4.2e-5) (not (<= n 2.7e-22))) (* n (/ (* 100.0 (expm1 i)) i)) (/ (* n 100.0) (+ 1.0 (* i (+ (/ 0.5 n) -0.5))))))
double code(double i, double n) {
double tmp;
if ((n <= -4.2e-5) || !(n <= 2.7e-22)) {
tmp = n * ((100.0 * expm1(i)) / i);
} else {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -4.2e-5) || !(n <= 2.7e-22)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -4.2e-5) or not (n <= 2.7e-22): tmp = n * ((100.0 * math.expm1(i)) / i) else: tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5))) return tmp
function code(i, n) tmp = 0.0 if ((n <= -4.2e-5) || !(n <= 2.7e-22)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(Float64(0.5 / n) + -0.5)))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -4.2e-5], N[Not[LessEqual[n, 2.7e-22]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -4.2 \cdot 10^{-5} \lor \neg \left(n \leq 2.7 \cdot 10^{-22}\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if n < -4.19999999999999977e-5 or 2.7000000000000002e-22 < n Initial program 29.8%
associate-/r/30.3%
associate-*r*30.3%
*-commutative30.3%
associate-*r/30.3%
sub-neg30.3%
distribute-lft-in30.3%
fma-def30.3%
metadata-eval30.3%
metadata-eval30.3%
Simplified30.3%
fma-udef29.9%
metadata-eval29.9%
distribute-lft-in29.9%
metadata-eval29.9%
sub-neg29.9%
*-commutative29.9%
add-exp-log29.9%
expm1-def29.9%
log-pow18.9%
log1p-udef66.7%
Applied egg-rr66.6%
Taylor expanded in n around inf 44.2%
*-commutative44.2%
expm1-def88.4%
associate-*l/88.3%
Simplified88.3%
if -4.19999999999999977e-5 < n < 2.7000000000000002e-22Initial program 37.3%
*-commutative37.3%
associate-/r/36.5%
sub-neg36.5%
metadata-eval36.5%
associate-*r*36.5%
*-commutative36.5%
clear-num36.5%
un-div-inv36.5%
metadata-eval36.5%
sub-neg36.5%
add-exp-log36.5%
expm1-def36.5%
log-pow63.4%
log1p-udef88.2%
Applied egg-rr88.2%
Taylor expanded in i around 0 74.3%
sub-neg74.3%
associate-*r/74.3%
metadata-eval74.3%
metadata-eval74.3%
Simplified74.3%
Final simplification83.2%
(FPCore (i n) :precision binary64 (if (or (<= n -2.9e-5) (not (<= n 2.7e-22))) (* 100.0 (/ n (/ i (expm1 i)))) (/ (* n 100.0) (+ 1.0 (* i (+ (/ 0.5 n) -0.5))))))
double code(double i, double n) {
double tmp;
if ((n <= -2.9e-5) || !(n <= 2.7e-22)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -2.9e-5) || !(n <= 2.7e-22)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2.9e-5) or not (n <= 2.7e-22): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5))) return tmp
function code(i, n) tmp = 0.0 if ((n <= -2.9e-5) || !(n <= 2.7e-22)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(Float64(0.5 / n) + -0.5)))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2.9e-5], N[Not[LessEqual[n, 2.7e-22]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.9 \cdot 10^{-5} \lor \neg \left(n \leq 2.7 \cdot 10^{-22}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if n < -2.9e-5 or 2.7000000000000002e-22 < n Initial program 29.8%
Taylor expanded in n around inf 44.2%
*-commutative44.2%
associate-/l*44.2%
expm1-def88.4%
Simplified88.4%
if -2.9e-5 < n < 2.7000000000000002e-22Initial program 37.3%
*-commutative37.3%
associate-/r/36.5%
sub-neg36.5%
metadata-eval36.5%
associate-*r*36.5%
*-commutative36.5%
clear-num36.5%
un-div-inv36.5%
metadata-eval36.5%
sub-neg36.5%
add-exp-log36.5%
expm1-def36.5%
log-pow63.4%
log1p-udef88.2%
Applied egg-rr88.2%
Taylor expanded in i around 0 74.3%
sub-neg74.3%
associate-*r/74.3%
metadata-eval74.3%
metadata-eval74.3%
Simplified74.3%
Final simplification83.3%
(FPCore (i n) :precision binary64 (if (<= n 2.7e-22) (/ (* n 100.0) (+ 1.0 (* i (+ (/ 0.5 n) -0.5)))) (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (n <= 2.7e-22) {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
} 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 <= 2.7d-22) then
tmp = (n * 100.0d0) / (1.0d0 + (i * ((0.5d0 / n) + (-0.5d0))))
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 <= 2.7e-22) {
tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5)));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 2.7e-22: tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5))) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= 2.7e-22) tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(Float64(0.5 / n) + -0.5)))); 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 <= 2.7e-22) tmp = (n * 100.0) / (1.0 + (i * ((0.5 / n) + -0.5))); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 2.7e-22], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 2.7 \cdot 10^{-22}:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < 2.7000000000000002e-22Initial program 35.3%
*-commutative35.3%
associate-/r/35.1%
sub-neg35.1%
metadata-eval35.1%
associate-*r*35.1%
*-commutative35.1%
clear-num35.1%
un-div-inv35.1%
metadata-eval35.1%
sub-neg35.1%
add-exp-log35.1%
expm1-def35.1%
log-pow42.1%
log1p-udef76.3%
Applied egg-rr76.3%
Taylor expanded in i around 0 64.2%
sub-neg64.2%
associate-*r/64.2%
metadata-eval64.2%
metadata-eval64.2%
Simplified64.2%
if 2.7000000000000002e-22 < n Initial program 27.0%
associate-*r/27.0%
sub-neg27.0%
distribute-lft-in27.0%
fma-def27.0%
metadata-eval27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in n around inf 45.5%
Taylor expanded in i around 0 68.8%
metadata-eval68.8%
associate-/r/68.7%
+-commutative68.7%
associate-/r/68.8%
metadata-eval68.8%
fma-def68.9%
*-commutative68.9%
*-commutative68.9%
Simplified68.9%
Taylor expanded in n around 0 68.9%
distribute-lft-in68.8%
*-commutative68.8%
distribute-lft-in68.9%
Simplified68.9%
Final simplification65.7%
(FPCore (i n) :precision binary64 (if (or (<= n -50000000000.0) (not (<= n 2.7e-22))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -50000000000.0) || !(n <= 2.7e-22)) {
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 <= (-50000000000.0d0)) .or. (.not. (n <= 2.7d-22))) 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 <= -50000000000.0) || !(n <= 2.7e-22)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -50000000000.0) or not (n <= 2.7e-22): 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 <= -50000000000.0) || !(n <= 2.7e-22)) 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 <= -50000000000.0) || ~((n <= 2.7e-22))) 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, -50000000000.0], N[Not[LessEqual[n, 2.7e-22]], $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 -50000000000 \lor \neg \left(n \leq 2.7 \cdot 10^{-22}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -5e10 or 2.7000000000000002e-22 < n Initial program 29.3%
associate-*r/29.4%
sub-neg29.4%
distribute-lft-in29.4%
fma-def29.4%
metadata-eval29.4%
metadata-eval29.4%
Simplified29.4%
Taylor expanded in n around inf 44.1%
Taylor expanded in i around 0 58.9%
metadata-eval58.9%
associate-/r/58.7%
+-commutative58.7%
associate-/r/58.9%
metadata-eval58.9%
fma-def58.9%
*-commutative58.9%
*-commutative58.9%
Simplified58.9%
Taylor expanded in n around 0 58.9%
distribute-lft-in58.9%
*-commutative58.9%
distribute-lft-in58.9%
Simplified58.9%
if -5e10 < n < 2.7000000000000002e-22Initial program 37.8%
Taylor expanded in i around 0 52.7%
Final simplification56.5%
(FPCore (i n) :precision binary64 (if (<= n -1.25e-201) (/ n (+ 0.01 (* i -0.005))) (if (<= n 6.4e-94) (/ 0.0 (/ i n)) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -1.25e-201) {
tmp = n / (0.01 + (i * -0.005));
} else if (n <= 6.4e-94) {
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.25d-201)) then
tmp = n / (0.01d0 + (i * (-0.005d0)))
else if (n <= 6.4d-94) 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.25e-201) {
tmp = n / (0.01 + (i * -0.005));
} else if (n <= 6.4e-94) {
tmp = 0.0 / (i / n);
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.25e-201: tmp = n / (0.01 + (i * -0.005)) elif n <= 6.4e-94: 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.25e-201) tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); elseif (n <= 6.4e-94) 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.25e-201) tmp = n / (0.01 + (i * -0.005)); elseif (n <= 6.4e-94) 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.25e-201], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6.4e-94], 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.25 \cdot 10^{-201}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{elif}\;n \leq 6.4 \cdot 10^{-94}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -1.25e-201Initial program 31.9%
associate-/r/32.2%
associate-*r*32.2%
*-commutative32.2%
associate-*r/32.2%
sub-neg32.2%
distribute-lft-in32.1%
fma-def32.2%
metadata-eval32.2%
metadata-eval32.2%
Simplified32.2%
Taylor expanded in n around inf 33.1%
associate-/l*33.8%
*-commutative33.8%
fma-neg33.9%
metadata-eval33.9%
Simplified33.9%
Taylor expanded in i around 0 53.3%
*-commutative53.3%
Simplified53.3%
if -1.25e-201 < n < 6.39999999999999993e-94Initial program 46.6%
associate-*r/46.6%
sub-neg46.6%
distribute-lft-in46.6%
fma-def46.6%
metadata-eval46.6%
metadata-eval46.6%
Simplified46.6%
Taylor expanded in n around inf 32.5%
Taylor expanded in i around 0 66.6%
if 6.39999999999999993e-94 < n Initial program 25.9%
associate-*r/25.9%
sub-neg25.9%
distribute-lft-in25.9%
fma-def25.9%
metadata-eval25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in n around inf 41.4%
Taylor expanded in i around 0 68.8%
metadata-eval68.8%
associate-/r/68.6%
+-commutative68.6%
associate-/r/68.8%
metadata-eval68.8%
fma-def68.8%
*-commutative68.8%
*-commutative68.8%
Simplified68.8%
Taylor expanded in n around 0 68.8%
distribute-lft-in68.8%
*-commutative68.8%
distribute-lft-in68.8%
Simplified68.8%
Final simplification61.6%
(FPCore (i n) :precision binary64 (if (<= i -5e+47) (* 100.0 (/ i (/ i n))) (if (<= i 5.8e+106) (* n 100.0) (* 50.0 (* i n)))))
double code(double i, double n) {
double tmp;
if (i <= -5e+47) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 5.8e+106) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-5d+47)) then
tmp = 100.0d0 * (i / (i / n))
else if (i <= 5.8d+106) then
tmp = n * 100.0d0
else
tmp = 50.0d0 * (i * n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -5e+47) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 5.8e+106) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -5e+47: tmp = 100.0 * (i / (i / n)) elif i <= 5.8e+106: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= -5e+47) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (i <= 5.8e+106) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -5e+47) tmp = 100.0 * (i / (i / n)); elseif (i <= 5.8e+106) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -5e+47], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 5.8e+106], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -5 \cdot 10^{+47}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 5.8 \cdot 10^{+106}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < -5.00000000000000022e47Initial program 62.5%
Taylor expanded in i around 0 24.0%
if -5.00000000000000022e47 < i < 5.8000000000000004e106Initial program 11.7%
Taylor expanded in i around 0 67.3%
*-commutative67.3%
Simplified67.3%
if 5.8000000000000004e106 < i Initial program 65.8%
associate-*r/65.9%
sub-neg65.9%
distribute-lft-in65.9%
fma-def65.9%
metadata-eval65.9%
metadata-eval65.9%
Simplified65.9%
Taylor expanded in n around inf 51.4%
Taylor expanded in i around 0 36.7%
metadata-eval36.7%
associate-/r/36.7%
+-commutative36.7%
associate-/r/36.7%
metadata-eval36.7%
fma-def36.7%
*-commutative36.7%
*-commutative36.7%
Simplified36.7%
fma-udef36.7%
*-commutative36.7%
*-commutative36.7%
associate-*l*36.7%
Applied egg-rr36.7%
Taylor expanded in i around inf 36.7%
Final simplification52.5%
(FPCore (i n) :precision binary64 (if (<= n 4.9e-40) (/ n (+ 0.01 (* i -0.005))) (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (n <= 4.9e-40) {
tmp = n / (0.01 + (i * -0.005));
} 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 <= 4.9d-40) then
tmp = n / (0.01d0 + (i * (-0.005d0)))
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 <= 4.9e-40) {
tmp = n / (0.01 + (i * -0.005));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 4.9e-40: tmp = n / (0.01 + (i * -0.005)) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= 4.9e-40) tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); 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 <= 4.9e-40) tmp = n / (0.01 + (i * -0.005)); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 4.9e-40], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 4.9 \cdot 10^{-40}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < 4.8999999999999997e-40Initial program 36.1%
associate-/r/35.9%
associate-*r*35.8%
*-commutative35.8%
associate-*r/35.9%
sub-neg35.9%
distribute-lft-in35.8%
fma-def35.9%
metadata-eval35.9%
metadata-eval35.9%
Simplified35.9%
Taylor expanded in n around inf 31.6%
associate-/l*32.1%
*-commutative32.1%
fma-neg32.1%
metadata-eval32.1%
Simplified32.1%
Taylor expanded in i around 0 51.6%
*-commutative51.6%
Simplified51.6%
if 4.8999999999999997e-40 < n Initial program 25.9%
associate-*r/25.9%
sub-neg25.9%
distribute-lft-in25.9%
fma-def25.9%
metadata-eval25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in n around inf 43.6%
Taylor expanded in i around 0 69.2%
metadata-eval69.2%
associate-/r/69.0%
+-commutative69.0%
associate-/r/69.2%
metadata-eval69.2%
fma-def69.3%
*-commutative69.3%
*-commutative69.3%
Simplified69.3%
Taylor expanded in n around 0 69.2%
distribute-lft-in69.2%
*-commutative69.2%
distribute-lft-in69.2%
Simplified69.2%
Final simplification57.8%
(FPCore (i n) :precision binary64 (if (<= i 5.8e+106) (* n 100.0) (* 50.0 (* i n))))
double code(double i, double n) {
double tmp;
if (i <= 5.8e+106) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 5.8d+106) then
tmp = n * 100.0d0
else
tmp = 50.0d0 * (i * n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 5.8e+106) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 5.8e+106: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= 5.8e+106) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 5.8e+106) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 5.8e+106], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 5.8 \cdot 10^{+106}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < 5.8000000000000004e106Initial program 24.7%
Taylor expanded in i around 0 51.3%
*-commutative51.3%
Simplified51.3%
if 5.8000000000000004e106 < i Initial program 65.8%
associate-*r/65.9%
sub-neg65.9%
distribute-lft-in65.9%
fma-def65.9%
metadata-eval65.9%
metadata-eval65.9%
Simplified65.9%
Taylor expanded in n around inf 51.4%
Taylor expanded in i around 0 36.7%
metadata-eval36.7%
associate-/r/36.7%
+-commutative36.7%
associate-/r/36.7%
metadata-eval36.7%
fma-def36.7%
*-commutative36.7%
*-commutative36.7%
Simplified36.7%
fma-udef36.7%
*-commutative36.7%
*-commutative36.7%
associate-*l*36.7%
Applied egg-rr36.7%
Taylor expanded in i around inf 36.7%
Final simplification48.5%
(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 32.5%
*-commutative32.5%
associate-/r/32.6%
associate-*l*32.6%
sub-neg32.6%
metadata-eval32.6%
Simplified32.6%
Taylor expanded in i around 0 48.2%
associate-*r/48.2%
metadata-eval48.2%
Simplified48.2%
Taylor expanded in n around 0 2.7%
*-commutative2.7%
Simplified2.7%
Final simplification2.7%
(FPCore (i n) :precision binary64 (* n 100.0))
double code(double i, double n) {
return n * 100.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n * 100.0d0
end function
public static double code(double i, double n) {
return n * 100.0;
}
def code(i, n): return n * 100.0
function code(i, n) return Float64(n * 100.0) end
function tmp = code(i, n) tmp = n * 100.0; end
code[i_, n_] := N[(n * 100.0), $MachinePrecision]
\begin{array}{l}
\\
n \cdot 100
\end{array}
Initial program 32.5%
Taylor expanded in i around 0 42.3%
*-commutative42.3%
Simplified42.3%
Final simplification42.3%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2023333
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:herbie-target
(* 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))))