
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 0.0)
(/ (expm1 (* n (log1p (/ i n)))) (/ (* i 0.01) n))
(if (<= t_1 INFINITY) (/ (fma 100.0 t_0 -100.0) (/ i n)) (* 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 = expm1((n * log1p((i / n)))) / ((i * 0.01) / n);
} else if (t_1 <= ((double) INFINITY)) {
tmp = fma(100.0, t_0, -100.0) / (i / n);
} 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(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(Float64(i * 0.01) / n)); elseif (t_1 <= Inf) tmp = Float64(fma(100.0, t_0, -100.0) / Float64(i / n)); 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[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(N[(i * 0.01), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(100.0 * t$95$0 + -100.0), $MachinePrecision] / N[(i / n), $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:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i \cdot 0.01}{n}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, t_0, -100\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 27.7%
*-commutative27.7%
associate-/r/26.8%
sub-neg26.8%
metadata-eval26.8%
associate-*r*26.8%
metadata-eval26.8%
sub-neg26.8%
associate-*l/26.8%
associate-/l*27.7%
add-exp-log27.7%
expm1-def27.7%
log-pow35.8%
log1p-udef97.3%
Applied egg-rr97.3%
Taylor expanded in i around 0 97.7%
associate-*r/97.7%
Simplified97.7%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.1%
associate-*r/98.4%
sub-neg98.4%
distribute-lft-in98.4%
metadata-eval98.4%
metadata-eval98.4%
metadata-eval98.4%
fma-def98.4%
metadata-eval98.4%
Simplified98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 80.0%
*-commutative80.0%
Simplified80.0%
Final simplification94.6%
(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)
(* (expm1 (* n (log1p (/ i n)))) (* 100.0 (/ n i)))
(if (<= t_1 INFINITY)
(* 100.0 (- (* t_0 (/ n i)) (/ n 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 = expm1((n * log1p((i / n)))) * (100.0 * (n / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / 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 = Math.expm1((n * Math.log1p((i / n)))) * (100.0 * (n / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / 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 = math.expm1((n * math.log1p((i / n)))) * (100.0 * (n / i)) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 * (n / i)) - (n / 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(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(100.0 * Float64(n / i))); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / 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[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(100.0 * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $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:\\
\;\;\;\;\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \left(100 \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 27.7%
*-commutative27.7%
associate-/r/26.8%
sub-neg26.8%
metadata-eval26.8%
associate-*r*26.8%
metadata-eval26.8%
sub-neg26.8%
associate-*l/26.8%
associate-/l*27.7%
add-exp-log27.7%
expm1-def27.7%
log-pow35.8%
log1p-udef97.3%
Applied egg-rr97.3%
expm1-log1p-u75.6%
expm1-udef43.1%
div-inv42.3%
clear-num42.3%
associate-/l*42.8%
Applied egg-rr42.8%
expm1-def74.3%
expm1-log1p96.1%
associate-/r/96.1%
Simplified96.1%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.1%
div-sub98.2%
clear-num98.4%
sub-neg98.4%
div-inv98.4%
clear-num98.4%
Applied egg-rr98.4%
sub-neg98.4%
Simplified98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 80.0%
*-commutative80.0%
Simplified80.0%
Final simplification93.4%
(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)
(* 100.0 (- (* t_0 (/ n i)) (/ n 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 = 100.0 * ((t_0 * (n / i)) - (n / 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 = 100.0 * ((t_0 * (n / i)) - (n / 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 = 100.0 * ((t_0 * (n / i)) - (n / 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(Float64(n * 100.0) * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i)); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / 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), $MachinePrecision] * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $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:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 27.7%
*-commutative27.7%
associate-/r/26.8%
associate-*l*26.8%
sub-neg26.8%
metadata-eval26.8%
Simplified26.8%
expm1-log1p-u25.7%
expm1-udef20.9%
metadata-eval20.9%
sub-neg20.9%
add-exp-log20.9%
expm1-def20.9%
log-pow22.3%
log1p-udef72.8%
Applied egg-rr72.8%
expm1-def96.6%
expm1-log1p96.6%
Simplified96.6%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.1%
div-sub98.2%
clear-num98.4%
sub-neg98.4%
div-inv98.4%
clear-num98.4%
Applied egg-rr98.4%
sub-neg98.4%
Simplified98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 80.0%
*-commutative80.0%
Simplified80.0%
Final simplification93.8%
(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)
(/ (expm1 (* n (log1p (/ i n)))) (/ i (* n 100.0)))
(if (<= t_1 INFINITY)
(* 100.0 (- (* t_0 (/ n i)) (/ n 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 = expm1((n * log1p((i / n)))) / (i / (n * 100.0));
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / 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 = Math.expm1((n * Math.log1p((i / n)))) / (i / (n * 100.0));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / 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 = math.expm1((n * math.log1p((i / n)))) / (i / (n * 100.0)) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 * (n / i)) - (n / 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(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / Float64(n * 100.0))); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / 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[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / N[(n * 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $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:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n \cdot 100}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 27.7%
*-commutative27.7%
associate-/r/26.8%
sub-neg26.8%
metadata-eval26.8%
associate-*r*26.8%
metadata-eval26.8%
sub-neg26.8%
associate-*l/26.8%
associate-/l*27.7%
add-exp-log27.7%
expm1-def27.7%
log-pow35.8%
log1p-udef97.3%
Applied egg-rr97.3%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.1%
div-sub98.2%
clear-num98.4%
sub-neg98.4%
div-inv98.4%
clear-num98.4%
Applied egg-rr98.4%
sub-neg98.4%
Simplified98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 80.0%
*-commutative80.0%
Simplified80.0%
Final simplification94.3%
(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)
(/ (expm1 (* n (log1p (/ i n)))) (/ (* i 0.01) n))
(if (<= t_1 INFINITY)
(* 100.0 (- (* t_0 (/ n i)) (/ n 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 = expm1((n * log1p((i / n)))) / ((i * 0.01) / n);
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / 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 = Math.expm1((n * Math.log1p((i / n)))) / ((i * 0.01) / n);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / 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 = math.expm1((n * math.log1p((i / n)))) / ((i * 0.01) / n) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 * (n / i)) - (n / 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(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(Float64(i * 0.01) / n)); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / 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[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(N[(i * 0.01), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $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:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i \cdot 0.01}{n}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 27.7%
*-commutative27.7%
associate-/r/26.8%
sub-neg26.8%
metadata-eval26.8%
associate-*r*26.8%
metadata-eval26.8%
sub-neg26.8%
associate-*l/26.8%
associate-/l*27.7%
add-exp-log27.7%
expm1-def27.7%
log-pow35.8%
log1p-udef97.3%
Applied egg-rr97.3%
Taylor expanded in i around 0 97.7%
associate-*r/97.7%
Simplified97.7%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.1%
div-sub98.2%
clear-num98.4%
sub-neg98.4%
div-inv98.4%
clear-num98.4%
Applied egg-rr98.4%
sub-neg98.4%
Simplified98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 80.0%
*-commutative80.0%
Simplified80.0%
Final simplification94.6%
(FPCore (i n) :precision binary64 (if (or (<= i -1.3e-64) (not (<= i 4.8e-100))) (* 100.0 (/ (expm1 i) (/ i n))) (* n (+ 100.0 (* 100.0 (* i (- 0.5 (/ 0.5 n))))))))
double code(double i, double n) {
double tmp;
if ((i <= -1.3e-64) || !(i <= 4.8e-100)) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n)))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -1.3e-64) || !(i <= 4.8e-100)) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n)))));
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -1.3e-64) or not (i <= 4.8e-100): tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n))))) return tmp
function code(i, n) tmp = 0.0 if ((i <= -1.3e-64) || !(i <= 4.8e-100)) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(n * Float64(100.0 + Float64(100.0 * Float64(i * Float64(0.5 - Float64(0.5 / n)))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -1.3e-64], N[Not[LessEqual[i, 4.8e-100]], $MachinePrecision]], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(100.0 * N[(i * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.3 \cdot 10^{-64} \lor \neg \left(i \leq 4.8 \cdot 10^{-100}\right):\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\
\end{array}
\end{array}
if i < -1.3e-64 or 4.8000000000000005e-100 < i Initial program 45.9%
Taylor expanded in n around inf 56.6%
expm1-def67.0%
Simplified67.0%
if -1.3e-64 < i < 4.8000000000000005e-100Initial program 7.6%
associate-/r/8.3%
associate-*r*8.3%
*-commutative8.3%
associate-*r/8.3%
sub-neg8.3%
distribute-lft-in8.3%
metadata-eval8.3%
metadata-eval8.3%
metadata-eval8.3%
fma-def8.3%
metadata-eval8.3%
Simplified8.3%
Taylor expanded in i around 0 89.5%
associate-*r/89.5%
metadata-eval89.5%
Simplified89.5%
Final simplification76.6%
(FPCore (i n) :precision binary64 (if (or (<= n -7.4e-138) (not (<= n 1.7e-159))) (* n (/ (* 100.0 (expm1 i)) i)) (* (* n 100.0) (/ 0.0 i))))
double code(double i, double n) {
double tmp;
if ((n <= -7.4e-138) || !(n <= 1.7e-159)) {
tmp = n * ((100.0 * expm1(i)) / i);
} else {
tmp = (n * 100.0) * (0.0 / i);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -7.4e-138) || !(n <= 1.7e-159)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = (n * 100.0) * (0.0 / i);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -7.4e-138) or not (n <= 1.7e-159): tmp = n * ((100.0 * math.expm1(i)) / i) else: tmp = (n * 100.0) * (0.0 / i) return tmp
function code(i, n) tmp = 0.0 if ((n <= -7.4e-138) || !(n <= 1.7e-159)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -7.4e-138], N[Not[LessEqual[n, 1.7e-159]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -7.4 \cdot 10^{-138} \lor \neg \left(n \leq 1.7 \cdot 10^{-159}\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\
\end{array}
\end{array}
if n < -7.39999999999999981e-138 or 1.69999999999999992e-159 < n Initial program 23.0%
associate-/r/23.0%
associate-*r*23.0%
*-commutative23.0%
associate-*r/23.1%
sub-neg23.1%
distribute-lft-in23.1%
metadata-eval23.1%
metadata-eval23.1%
metadata-eval23.1%
fma-def23.1%
metadata-eval23.1%
Simplified23.1%
fma-udef23.1%
*-commutative23.1%
Applied egg-rr23.1%
Taylor expanded in n around inf 35.9%
sub-neg35.9%
metadata-eval35.9%
metadata-eval35.9%
distribute-lft-in35.9%
metadata-eval35.9%
sub-neg35.9%
expm1-def86.7%
Simplified86.7%
if -7.39999999999999981e-138 < n < 1.69999999999999992e-159Initial program 56.3%
*-commutative56.3%
associate-/r/54.4%
associate-*l*54.4%
sub-neg54.4%
metadata-eval54.4%
Simplified54.4%
Taylor expanded in i around 0 73.9%
Final simplification84.1%
(FPCore (i n)
:precision binary64
(if (<= n -6.6e-138)
(* (* n 100.0) (/ (expm1 i) i))
(if (<= n 1.8e-161)
(* (* n 100.0) (/ 0.0 i))
(* n (/ (* 100.0 (expm1 i)) i)))))
double code(double i, double n) {
double tmp;
if (n <= -6.6e-138) {
tmp = (n * 100.0) * (expm1(i) / i);
} else if (n <= 1.8e-161) {
tmp = (n * 100.0) * (0.0 / i);
} else {
tmp = n * ((100.0 * expm1(i)) / i);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -6.6e-138) {
tmp = (n * 100.0) * (Math.expm1(i) / i);
} else if (n <= 1.8e-161) {
tmp = (n * 100.0) * (0.0 / i);
} else {
tmp = n * ((100.0 * Math.expm1(i)) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -6.6e-138: tmp = (n * 100.0) * (math.expm1(i) / i) elif n <= 1.8e-161: tmp = (n * 100.0) * (0.0 / i) else: tmp = n * ((100.0 * math.expm1(i)) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= -6.6e-138) tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i)); elseif (n <= 1.8e-161) tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i)); else tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); end return tmp end
code[i_, n_] := If[LessEqual[n, -6.6e-138], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.8e-161], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.6 \cdot 10^{-138}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\
\mathbf{elif}\;n \leq 1.8 \cdot 10^{-161}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\end{array}
\end{array}
if n < -6.59999999999999964e-138Initial program 25.0%
*-commutative25.0%
associate-/r/24.8%
associate-*l*24.8%
sub-neg24.8%
metadata-eval24.8%
Simplified24.8%
Taylor expanded in n around inf 36.9%
expm1-def84.0%
Simplified84.0%
if -6.59999999999999964e-138 < n < 1.80000000000000009e-161Initial program 56.3%
*-commutative56.3%
associate-/r/54.4%
associate-*l*54.4%
sub-neg54.4%
metadata-eval54.4%
Simplified54.4%
Taylor expanded in i around 0 73.9%
if 1.80000000000000009e-161 < n Initial program 20.9%
associate-/r/21.3%
associate-*r*21.3%
*-commutative21.3%
associate-*r/21.3%
sub-neg21.3%
distribute-lft-in21.3%
metadata-eval21.3%
metadata-eval21.3%
metadata-eval21.3%
fma-def21.3%
metadata-eval21.3%
Simplified21.3%
fma-udef21.3%
*-commutative21.3%
Applied egg-rr21.3%
Taylor expanded in n around inf 34.8%
sub-neg34.8%
metadata-eval34.8%
metadata-eval34.8%
distribute-lft-in34.8%
metadata-eval34.8%
sub-neg34.8%
expm1-def89.5%
Simplified89.5%
Final simplification84.2%
(FPCore (i n)
:precision binary64
(if (<= n -6.5e+102)
(* n (+ 100.0 (* i 50.0)))
(if (<= n 2.15e-44)
(* 100.0 (/ 1.0 (/ (/ i n) i)))
(* 100.0 (/ (* i n) i)))))
double code(double i, double n) {
double tmp;
if (n <= -6.5e+102) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 2.15e-44) {
tmp = 100.0 * (1.0 / ((i / n) / i));
} else {
tmp = 100.0 * ((i * n) / i);
}
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+102)) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (n <= 2.15d-44) then
tmp = 100.0d0 * (1.0d0 / ((i / n) / i))
else
tmp = 100.0d0 * ((i * n) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -6.5e+102) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 2.15e-44) {
tmp = 100.0 * (1.0 / ((i / n) / i));
} else {
tmp = 100.0 * ((i * n) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -6.5e+102: tmp = n * (100.0 + (i * 50.0)) elif n <= 2.15e-44: tmp = 100.0 * (1.0 / ((i / n) / i)) else: tmp = 100.0 * ((i * n) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= -6.5e+102) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (n <= 2.15e-44) tmp = Float64(100.0 * Float64(1.0 / Float64(Float64(i / n) / i))); else tmp = Float64(100.0 * Float64(Float64(i * n) / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -6.5e+102) tmp = n * (100.0 + (i * 50.0)); elseif (n <= 2.15e-44) tmp = 100.0 * (1.0 / ((i / n) / i)); else tmp = 100.0 * ((i * n) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -6.5e+102], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.15e-44], N[(100.0 * N[(1.0 / N[(N[(i / n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.5 \cdot 10^{+102}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;n \leq 2.15 \cdot 10^{-44}:\\
\;\;\;\;100 \cdot \frac{1}{\frac{\frac{i}{n}}{i}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\end{array}
\end{array}
if n < -6.5000000000000004e102Initial program 19.9%
associate-/r/20.5%
associate-*r*20.5%
*-commutative20.5%
associate-*r/20.5%
sub-neg20.5%
distribute-lft-in20.5%
metadata-eval20.5%
metadata-eval20.5%
metadata-eval20.5%
fma-def20.5%
metadata-eval20.5%
Simplified20.5%
fma-udef20.5%
*-commutative20.5%
Applied egg-rr20.5%
Taylor expanded in n around inf 44.5%
sub-neg44.5%
metadata-eval44.5%
metadata-eval44.5%
distribute-lft-in44.5%
metadata-eval44.5%
sub-neg44.5%
expm1-def91.1%
Simplified91.1%
Taylor expanded in i around 0 58.8%
if -6.5000000000000004e102 < n < 2.15000000000000007e-44Initial program 39.5%
Taylor expanded in i around 0 29.4%
+-commutative29.4%
Simplified29.4%
div-inv29.4%
associate--l+57.8%
metadata-eval57.8%
+-rgt-identity57.8%
clear-num55.3%
*-commutative55.3%
Applied egg-rr55.3%
*-commutative55.3%
frac-2neg55.3%
distribute-frac-neg55.3%
clear-num57.8%
distribute-rgt-neg-in57.8%
distribute-lft-neg-out57.8%
un-div-inv57.9%
clear-num57.8%
add-sqr-sqrt29.2%
sqrt-unprod29.3%
sqr-neg29.3%
sqrt-unprod10.1%
add-sqr-sqrt21.1%
add-sqr-sqrt11.0%
sqrt-unprod16.1%
sqr-neg16.1%
sqrt-unprod28.4%
add-sqr-sqrt57.8%
Applied egg-rr57.8%
if 2.15000000000000007e-44 < n Initial program 22.7%
Taylor expanded in i around 0 3.3%
+-commutative3.3%
Simplified3.3%
div-inv3.3%
associate--l+34.0%
metadata-eval34.0%
+-rgt-identity34.0%
clear-num34.1%
*-commutative34.1%
Applied egg-rr34.1%
associate-*l/67.9%
Applied egg-rr67.9%
Final simplification61.3%
(FPCore (i n) :precision binary64 (if (or (<= n -6.5e+102) (not (<= n 2.15e-44))) (* 100.0 (/ (* i n) i)) (* 100.0 (* i (/ n i)))))
double code(double i, double n) {
double tmp;
if ((n <= -6.5e+102) || !(n <= 2.15e-44)) {
tmp = 100.0 * ((i * n) / i);
} else {
tmp = 100.0 * (i * (n / i));
}
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+102)) .or. (.not. (n <= 2.15d-44))) then
tmp = 100.0d0 * ((i * n) / i)
else
tmp = 100.0d0 * (i * (n / i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -6.5e+102) || !(n <= 2.15e-44)) {
tmp = 100.0 * ((i * n) / i);
} else {
tmp = 100.0 * (i * (n / i));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -6.5e+102) or not (n <= 2.15e-44): tmp = 100.0 * ((i * n) / i) else: tmp = 100.0 * (i * (n / i)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -6.5e+102) || !(n <= 2.15e-44)) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); else tmp = Float64(100.0 * Float64(i * Float64(n / i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -6.5e+102) || ~((n <= 2.15e-44))) tmp = 100.0 * ((i * n) / i); else tmp = 100.0 * (i * (n / i)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -6.5e+102], N[Not[LessEqual[n, 2.15e-44]], $MachinePrecision]], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.5 \cdot 10^{+102} \lor \neg \left(n \leq 2.15 \cdot 10^{-44}\right):\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\end{array}
\end{array}
if n < -6.5000000000000004e102 or 2.15000000000000007e-44 < n Initial program 21.5%
Taylor expanded in i around 0 4.5%
+-commutative4.5%
Simplified4.5%
div-inv4.5%
associate--l+29.1%
metadata-eval29.1%
+-rgt-identity29.1%
clear-num29.2%
*-commutative29.2%
Applied egg-rr29.2%
associate-*l/64.2%
Applied egg-rr64.2%
if -6.5000000000000004e102 < n < 2.15000000000000007e-44Initial program 39.5%
Taylor expanded in i around 0 29.4%
+-commutative29.4%
Simplified29.4%
div-inv29.4%
associate--l+57.8%
metadata-eval57.8%
+-rgt-identity57.8%
clear-num55.3%
*-commutative55.3%
Applied egg-rr55.3%
Final simplification60.2%
(FPCore (i n) :precision binary64 (if (or (<= n -4.6e-105) (not (<= n 6.6e-161))) (* n (+ 100.0 (* i 50.0))) (* (* n 100.0) (/ 0.0 i))))
double code(double i, double n) {
double tmp;
if ((n <= -4.6e-105) || !(n <= 6.6e-161)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = (n * 100.0) * (0.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 <= (-4.6d-105)) .or. (.not. (n <= 6.6d-161))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = (n * 100.0d0) * (0.0d0 / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -4.6e-105) || !(n <= 6.6e-161)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = (n * 100.0) * (0.0 / i);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -4.6e-105) or not (n <= 6.6e-161): tmp = n * (100.0 + (i * 50.0)) else: tmp = (n * 100.0) * (0.0 / i) return tmp
function code(i, n) tmp = 0.0 if ((n <= -4.6e-105) || !(n <= 6.6e-161)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -4.6e-105) || ~((n <= 6.6e-161))) tmp = n * (100.0 + (i * 50.0)); else tmp = (n * 100.0) * (0.0 / i); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -4.6e-105], N[Not[LessEqual[n, 6.6e-161]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -4.6 \cdot 10^{-105} \lor \neg \left(n \leq 6.6 \cdot 10^{-161}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\
\end{array}
\end{array}
if n < -4.6000000000000002e-105 or 6.5999999999999997e-161 < n Initial program 22.6%
associate-/r/22.6%
associate-*r*22.7%
*-commutative22.7%
associate-*r/22.7%
sub-neg22.7%
distribute-lft-in22.7%
metadata-eval22.7%
metadata-eval22.7%
metadata-eval22.7%
fma-def22.7%
metadata-eval22.7%
Simplified22.7%
fma-udef22.7%
*-commutative22.7%
Applied egg-rr22.7%
Taylor expanded in n around inf 35.9%
sub-neg35.9%
metadata-eval35.9%
metadata-eval35.9%
distribute-lft-in35.9%
metadata-eval35.9%
sub-neg35.9%
expm1-def87.4%
Simplified87.4%
Taylor expanded in i around 0 62.3%
if -4.6000000000000002e-105 < n < 6.5999999999999997e-161Initial program 54.1%
*-commutative54.1%
associate-/r/52.5%
associate-*l*52.5%
sub-neg52.5%
metadata-eval52.5%
Simplified52.5%
Taylor expanded in i around 0 69.9%
Final simplification64.0%
(FPCore (i n) :precision binary64 (if (<= n -6.5e+102) (* n (+ 100.0 (* i 50.0))) (if (<= n 2e-44) (* 100.0 (* i (/ n i))) (* 100.0 (/ (* i n) i)))))
double code(double i, double n) {
double tmp;
if (n <= -6.5e+102) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 2e-44) {
tmp = 100.0 * (i * (n / i));
} else {
tmp = 100.0 * ((i * n) / i);
}
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+102)) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (n <= 2d-44) then
tmp = 100.0d0 * (i * (n / i))
else
tmp = 100.0d0 * ((i * n) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -6.5e+102) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 2e-44) {
tmp = 100.0 * (i * (n / i));
} else {
tmp = 100.0 * ((i * n) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -6.5e+102: tmp = n * (100.0 + (i * 50.0)) elif n <= 2e-44: tmp = 100.0 * (i * (n / i)) else: tmp = 100.0 * ((i * n) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= -6.5e+102) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (n <= 2e-44) tmp = Float64(100.0 * Float64(i * Float64(n / i))); else tmp = Float64(100.0 * Float64(Float64(i * n) / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -6.5e+102) tmp = n * (100.0 + (i * 50.0)); elseif (n <= 2e-44) tmp = 100.0 * (i * (n / i)); else tmp = 100.0 * ((i * n) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -6.5e+102], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2e-44], N[(100.0 * N[(i * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.5 \cdot 10^{+102}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;n \leq 2 \cdot 10^{-44}:\\
\;\;\;\;100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\end{array}
\end{array}
if n < -6.5000000000000004e102Initial program 19.9%
associate-/r/20.5%
associate-*r*20.5%
*-commutative20.5%
associate-*r/20.5%
sub-neg20.5%
distribute-lft-in20.5%
metadata-eval20.5%
metadata-eval20.5%
metadata-eval20.5%
fma-def20.5%
metadata-eval20.5%
Simplified20.5%
fma-udef20.5%
*-commutative20.5%
Applied egg-rr20.5%
Taylor expanded in n around inf 44.5%
sub-neg44.5%
metadata-eval44.5%
metadata-eval44.5%
distribute-lft-in44.5%
metadata-eval44.5%
sub-neg44.5%
expm1-def91.1%
Simplified91.1%
Taylor expanded in i around 0 58.8%
if -6.5000000000000004e102 < n < 1.99999999999999991e-44Initial program 39.5%
Taylor expanded in i around 0 29.4%
+-commutative29.4%
Simplified29.4%
div-inv29.4%
associate--l+57.8%
metadata-eval57.8%
+-rgt-identity57.8%
clear-num55.3%
*-commutative55.3%
Applied egg-rr55.3%
if 1.99999999999999991e-44 < n Initial program 22.7%
Taylor expanded in i around 0 3.3%
+-commutative3.3%
Simplified3.3%
div-inv3.3%
associate--l+34.0%
metadata-eval34.0%
+-rgt-identity34.0%
clear-num34.1%
*-commutative34.1%
Applied egg-rr34.1%
associate-*l/67.9%
Applied egg-rr67.9%
Final simplification60.2%
(FPCore (i n) :precision binary64 (if (<= n -6.5e+102) (* n (+ 100.0 (* i 50.0))) (if (<= n 2.15e-44) (/ (* i 100.0) (/ i n)) (* 100.0 (/ (* i n) i)))))
double code(double i, double n) {
double tmp;
if (n <= -6.5e+102) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 2.15e-44) {
tmp = (i * 100.0) / (i / n);
} else {
tmp = 100.0 * ((i * n) / i);
}
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+102)) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (n <= 2.15d-44) then
tmp = (i * 100.0d0) / (i / n)
else
tmp = 100.0d0 * ((i * n) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -6.5e+102) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 2.15e-44) {
tmp = (i * 100.0) / (i / n);
} else {
tmp = 100.0 * ((i * n) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -6.5e+102: tmp = n * (100.0 + (i * 50.0)) elif n <= 2.15e-44: tmp = (i * 100.0) / (i / n) else: tmp = 100.0 * ((i * n) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= -6.5e+102) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (n <= 2.15e-44) tmp = Float64(Float64(i * 100.0) / Float64(i / n)); else tmp = Float64(100.0 * Float64(Float64(i * n) / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -6.5e+102) tmp = n * (100.0 + (i * 50.0)); elseif (n <= 2.15e-44) tmp = (i * 100.0) / (i / n); else tmp = 100.0 * ((i * n) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -6.5e+102], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.15e-44], N[(N[(i * 100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.5 \cdot 10^{+102}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;n \leq 2.15 \cdot 10^{-44}:\\
\;\;\;\;\frac{i \cdot 100}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\end{array}
\end{array}
if n < -6.5000000000000004e102Initial program 19.9%
associate-/r/20.5%
associate-*r*20.5%
*-commutative20.5%
associate-*r/20.5%
sub-neg20.5%
distribute-lft-in20.5%
metadata-eval20.5%
metadata-eval20.5%
metadata-eval20.5%
fma-def20.5%
metadata-eval20.5%
Simplified20.5%
fma-udef20.5%
*-commutative20.5%
Applied egg-rr20.5%
Taylor expanded in n around inf 44.5%
sub-neg44.5%
metadata-eval44.5%
metadata-eval44.5%
distribute-lft-in44.5%
metadata-eval44.5%
sub-neg44.5%
expm1-def91.1%
Simplified91.1%
Taylor expanded in i around 0 58.8%
if -6.5000000000000004e102 < n < 2.15000000000000007e-44Initial program 39.5%
associate-*r/39.6%
sub-neg39.6%
distribute-lft-in39.6%
metadata-eval39.6%
metadata-eval39.6%
metadata-eval39.6%
fma-def39.6%
metadata-eval39.6%
Simplified39.6%
Taylor expanded in i around 0 57.7%
*-commutative57.7%
Simplified57.7%
if 2.15000000000000007e-44 < n Initial program 22.7%
Taylor expanded in i around 0 3.3%
+-commutative3.3%
Simplified3.3%
div-inv3.3%
associate--l+34.0%
metadata-eval34.0%
+-rgt-identity34.0%
clear-num34.1%
*-commutative34.1%
Applied egg-rr34.1%
associate-*l/67.9%
Applied egg-rr67.9%
Final simplification61.3%
(FPCore (i n) :precision binary64 (if (<= i -1.35e+96) (* (/ n i) 200.0) (if (<= i 3.9e+52) (* n 100.0) (* 50.0 (* i n)))))
double code(double i, double n) {
double tmp;
if (i <= -1.35e+96) {
tmp = (n / i) * 200.0;
} else if (i <= 3.9e+52) {
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 <= (-1.35d+96)) then
tmp = (n / i) * 200.0d0
else if (i <= 3.9d+52) 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 <= -1.35e+96) {
tmp = (n / i) * 200.0;
} else if (i <= 3.9e+52) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.35e+96: tmp = (n / i) * 200.0 elif i <= 3.9e+52: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= -1.35e+96) tmp = Float64(Float64(n / i) * 200.0); elseif (i <= 3.9e+52) 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 <= -1.35e+96) tmp = (n / i) * 200.0; elseif (i <= 3.9e+52) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.35e+96], N[(N[(n / i), $MachinePrecision] * 200.0), $MachinePrecision], If[LessEqual[i, 3.9e+52], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.35 \cdot 10^{+96}:\\
\;\;\;\;\frac{n}{i} \cdot 200\\
\mathbf{elif}\;i \leq 3.9 \cdot 10^{+52}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < -1.35000000000000011e96Initial program 72.8%
div-sub72.8%
clear-num68.4%
sub-neg68.4%
div-inv68.4%
clear-num68.2%
Applied egg-rr68.2%
sub-neg68.2%
Simplified68.2%
sub-neg68.2%
distribute-neg-frac68.2%
remove-double-neg68.2%
frac-2neg68.2%
clear-num73.1%
clear-num68.2%
add-sqr-sqrt68.8%
sqrt-unprod46.6%
sqr-neg46.6%
sqrt-unprod0.0%
add-sqr-sqrt33.4%
*-un-lft-identity33.4%
distribute-rgt-out33.4%
+-commutative33.4%
Applied egg-rr33.4%
Taylor expanded in n around 0 27.9%
if -1.35000000000000011e96 < i < 3.9e52Initial program 14.5%
Taylor expanded in i around 0 69.0%
*-commutative69.0%
Simplified69.0%
if 3.9e52 < i Initial program 53.7%
*-commutative53.7%
associate-/r/54.0%
associate-*l*54.1%
sub-neg54.1%
metadata-eval54.1%
Simplified54.1%
Taylor expanded in n around inf 51.8%
expm1-def51.8%
Simplified51.8%
Taylor expanded in i around 0 34.1%
*-commutative34.1%
Simplified34.1%
Taylor expanded in i around inf 34.1%
Final simplification57.1%
(FPCore (i n) :precision binary64 (if (<= i 3.9e+52) (* n 100.0) (* 50.0 (* i n))))
double code(double i, double n) {
double tmp;
if (i <= 3.9e+52) {
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 <= 3.9d+52) 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 <= 3.9e+52) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 3.9e+52: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= 3.9e+52) 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 <= 3.9e+52) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 3.9e+52], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 3.9 \cdot 10^{+52}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < 3.9e52Initial program 24.5%
Taylor expanded in i around 0 58.0%
*-commutative58.0%
Simplified58.0%
if 3.9e52 < i Initial program 53.7%
*-commutative53.7%
associate-/r/54.0%
associate-*l*54.1%
sub-neg54.1%
metadata-eval54.1%
Simplified54.1%
Taylor expanded in n around inf 51.8%
expm1-def51.8%
Simplified51.8%
Taylor expanded in i around 0 34.1%
*-commutative34.1%
Simplified34.1%
Taylor expanded in i around inf 34.1%
Final simplification53.8%
(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.6%
Taylor expanded in i around 0 48.7%
*-commutative48.7%
Simplified48.7%
Final simplification48.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 2024020
(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))))