
(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) -1.0) (/ i n))))
(if (<= t_0 0.0)
(/ (* n 100.0) (/ i (expm1 (* n (log1p (/ i n))))))
(if (<= t_0 INFINITY) (* t_0 100.0) (* 100.0 (/ n (+ 1.0 (* i -0.5))))))))
double code(double i, double n) {
double t_0 = (pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = (n * 100.0) / (i / expm1((n * log1p((i / n)))));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = (Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = (n * 100.0) / (i / Math.expm1((n * Math.log1p((i / n)))));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
def code(i, n): t_0 = (math.pow((1.0 + (i / n)), n) + -1.0) / (i / n) tmp = 0 if t_0 <= 0.0: tmp = (n * 100.0) / (i / math.expm1((n * math.log1p((i / n))))) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = 100.0 * (n / (1.0 + (i * -0.5))) return tmp
function code(i, n) t_0 = Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(n * 100.0) / Float64(i / expm1(Float64(n * log1p(Float64(i / n)))))); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(n * 100.0), $MachinePrecision] / N[(i / N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 26.9%
*-commutative26.9%
associate-/r/26.7%
sub-neg26.7%
metadata-eval26.7%
associate-*r*26.7%
*-commutative26.7%
clear-num26.7%
un-div-inv26.7%
metadata-eval26.7%
sub-neg26.7%
pow-to-exp26.1%
expm1-def36.0%
add-log-exp26.1%
pow-to-exp26.7%
log-pow36.0%
log1p-udef96.7%
Applied egg-rr96.7%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-def88.2%
Simplified88.2%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.5%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 0.0)
(/ (expm1 (* n (log1p (/ i n)))) (/ i (* n 100.0)))
(if (<= t_0 INFINITY) (* t_0 100.0) (* 100.0 (/ n (+ 1.0 (* i -0.5))))))))
double code(double i, double n) {
double t_0 = (pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = expm1((n * log1p((i / n)))) / (i / (n * 100.0));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = (Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.expm1((n * Math.log1p((i / n)))) / (i / (n * 100.0));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
def code(i, n): t_0 = (math.pow((1.0 + (i / n)), n) + -1.0) / (i / n) tmp = 0 if t_0 <= 0.0: tmp = math.expm1((n * math.log1p((i / n)))) / (i / (n * 100.0)) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = 100.0 * (n / (1.0 + (i * -0.5))) return tmp
function code(i, n) t_0 = Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / Float64(n * 100.0))); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 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$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n \cdot 100}}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 26.9%
*-commutative26.9%
associate-/r/26.7%
sub-neg26.7%
metadata-eval26.7%
associate-*r*26.7%
metadata-eval26.7%
sub-neg26.7%
associate-*l/26.7%
associate-/l*26.9%
Applied egg-rr96.3%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-def88.2%
Simplified88.2%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 0.0)
(/ (expm1 (* n (log1p (/ i n)))) (/ (/ i 100.0) n))
(if (<= t_0 INFINITY) (* t_0 100.0) (* 100.0 (/ n (+ 1.0 (* i -0.5))))))))
double code(double i, double n) {
double t_0 = (pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = expm1((n * log1p((i / n)))) / ((i / 100.0) / n);
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = (Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.expm1((n * Math.log1p((i / n)))) / ((i / 100.0) / n);
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
def code(i, n): t_0 = (math.pow((1.0 + (i / n)), n) + -1.0) / (i / n) tmp = 0 if t_0 <= 0.0: tmp = math.expm1((n * math.log1p((i / n)))) / ((i / 100.0) / n) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = 100.0 * (n / (1.0 + (i * -0.5))) return tmp
function code(i, n) t_0 = Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(Float64(i / 100.0) / n)); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(N[(i / 100.0), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{\frac{i}{100}}{n}}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 26.9%
*-commutative26.9%
associate-/r/26.7%
sub-neg26.7%
metadata-eval26.7%
associate-*r*26.7%
metadata-eval26.7%
sub-neg26.7%
associate-*l/26.7%
associate-/l*26.9%
Applied egg-rr96.3%
*-un-lft-identity96.3%
times-frac96.5%
Applied egg-rr96.5%
associate-*l/96.6%
*-lft-identity96.6%
Simplified96.6%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-def88.2%
Simplified88.2%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.4%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
(if (<= n -4.3e-120)
t_0
(if (<= n 5.1e-144)
(/ 1.0 (/ (+ (* n (* i -0.005)) (* n 0.01)) (* n n)))
(if (<= n 1.25e-98) (* 100.0 (/ (* n n) (/ i (log (/ i n))))) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (n / (i / expm1(i)));
double tmp;
if (n <= -4.3e-120) {
tmp = t_0;
} else if (n <= 5.1e-144) {
tmp = 1.0 / (((n * (i * -0.005)) + (n * 0.01)) / (n * n));
} else if (n <= 1.25e-98) {
tmp = 100.0 * ((n * n) / (i / log((i / n))));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (n / (i / Math.expm1(i)));
double tmp;
if (n <= -4.3e-120) {
tmp = t_0;
} else if (n <= 5.1e-144) {
tmp = 1.0 / (((n * (i * -0.005)) + (n * 0.01)) / (n * n));
} else if (n <= 1.25e-98) {
tmp = 100.0 * ((n * n) / (i / Math.log((i / n))));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (n / (i / math.expm1(i))) tmp = 0 if n <= -4.3e-120: tmp = t_0 elif n <= 5.1e-144: tmp = 1.0 / (((n * (i * -0.005)) + (n * 0.01)) / (n * n)) elif n <= 1.25e-98: tmp = 100.0 * ((n * n) / (i / math.log((i / n)))) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(n / Float64(i / expm1(i)))) tmp = 0.0 if (n <= -4.3e-120) tmp = t_0; elseif (n <= 5.1e-144) tmp = Float64(1.0 / Float64(Float64(Float64(n * Float64(i * -0.005)) + Float64(n * 0.01)) / Float64(n * n))); elseif (n <= 1.25e-98) tmp = Float64(100.0 * Float64(Float64(n * n) / Float64(i / log(Float64(i / n))))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -4.3e-120], t$95$0, If[LessEqual[n, 5.1e-144], N[(1.0 / N[(N[(N[(n * N[(i * -0.005), $MachinePrecision]), $MachinePrecision] + N[(n * 0.01), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.25e-98], N[(100.0 * N[(N[(n * n), $MachinePrecision] / N[(i / N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{if}\;n \leq -4.3 \cdot 10^{-120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 5.1 \cdot 10^{-144}:\\
\;\;\;\;\frac{1}{\frac{n \cdot \left(i \cdot -0.005\right) + n \cdot 0.01}{n \cdot n}}\\
\mathbf{elif}\;n \leq 1.25 \cdot 10^{-98}:\\
\;\;\;\;100 \cdot \frac{n \cdot n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -4.29999999999999982e-120 or 1.25000000000000005e-98 < n Initial program 20.5%
Taylor expanded in n around inf 35.6%
*-commutative35.6%
associate-/l*35.6%
expm1-def91.2%
Simplified91.2%
if -4.29999999999999982e-120 < n < 5.1e-144Initial program 55.6%
Taylor expanded in n around inf 39.9%
*-commutative39.9%
associate-/l*39.9%
expm1-def45.9%
Simplified45.9%
associate-*l/45.9%
clear-num46.8%
Applied egg-rr46.8%
associate-/l/31.5%
*-commutative31.5%
associate-*r*31.5%
*-commutative31.5%
associate-*r*31.5%
*-commutative31.5%
associate-*l*31.5%
Simplified31.5%
Taylor expanded in i around 0 54.9%
associate-*r/54.9%
un-div-inv55.0%
frac-add66.1%
*-commutative66.1%
Applied egg-rr66.1%
if 5.1e-144 < n < 1.25000000000000005e-98Initial program 46.4%
*-commutative46.4%
associate-/r/46.4%
sub-neg46.4%
metadata-eval46.4%
associate-*r*46.4%
metadata-eval46.4%
sub-neg46.4%
associate-*l/46.4%
associate-/l*46.4%
Applied egg-rr99.4%
Taylor expanded in n around 0 99.3%
associate-/l*99.6%
unpow299.6%
mul-1-neg99.6%
unsub-neg99.6%
log-div99.8%
Simplified99.8%
Final simplification86.5%
(FPCore (i n) :precision binary64 (if (or (<= i -4.2e-13) (not (<= i 20000000000000.0))) (* 100.0 (/ (expm1 i) (/ i n))) (* 100.0 (/ n (+ 1.0 (* i -0.5))))))
double code(double i, double n) {
double tmp;
if ((i <= -4.2e-13) || !(i <= 20000000000000.0)) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -4.2e-13) || !(i <= 20000000000000.0)) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -4.2e-13) or not (i <= 20000000000000.0): tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = 100.0 * (n / (1.0 + (i * -0.5))) return tmp
function code(i, n) tmp = 0.0 if ((i <= -4.2e-13) || !(i <= 20000000000000.0)) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -4.2e-13], N[Not[LessEqual[i, 20000000000000.0]], $MachinePrecision]], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -4.2 \cdot 10^{-13} \lor \neg \left(i \leq 20000000000000\right):\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if i < -4.19999999999999977e-13 or 2e13 < i Initial program 53.1%
Taylor expanded in n around inf 71.7%
expm1-def71.7%
Simplified71.7%
if -4.19999999999999977e-13 < i < 2e13Initial program 9.4%
Taylor expanded in n around inf 8.5%
*-commutative8.5%
associate-/l*8.5%
expm1-def86.1%
Simplified86.1%
Taylor expanded in i around 0 86.1%
*-commutative86.1%
Simplified86.1%
Final simplification80.0%
(FPCore (i n) :precision binary64 (if (or (<= n -1.85e-132) (not (<= n 2.2e-82))) (* 100.0 (/ n (/ i (expm1 i)))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.85e-132) || !(n <= 2.2e-82)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.85e-132) || !(n <= 2.2e-82)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.85e-132) or not (n <= 2.2e-82): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.85e-132) || !(n <= 2.2e-82)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.85e-132], N[Not[LessEqual[n, 2.2e-82]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.85 \cdot 10^{-132} \lor \neg \left(n \leq 2.2 \cdot 10^{-82}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.8500000000000001e-132 or 2.19999999999999986e-82 < n Initial program 20.6%
Taylor expanded in n around inf 35.8%
*-commutative35.8%
associate-/l*35.8%
expm1-def91.7%
Simplified91.7%
if -1.8500000000000001e-132 < n < 2.19999999999999986e-82Initial program 53.6%
*-commutative53.6%
associate-/r/52.9%
associate-*l*52.9%
sub-neg52.9%
metadata-eval52.9%
Simplified52.9%
Taylor expanded in i around 0 62.1%
Taylor expanded in i around 0 62.1%
Final simplification84.9%
(FPCore (i n) :precision binary64 (if (or (<= n -8.2e-94) (not (<= n 2.05e-81))) (* 100.0 (+ n (* n (+ (* i 0.5) (* 0.16666666666666666 (* i i)))))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -8.2e-94) || !(n <= 2.05e-81)) {
tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i)))));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-8.2d-94)) .or. (.not. (n <= 2.05d-81))) then
tmp = 100.0d0 * (n + (n * ((i * 0.5d0) + (0.16666666666666666d0 * (i * i)))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -8.2e-94) || !(n <= 2.05e-81)) {
tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i)))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -8.2e-94) or not (n <= 2.05e-81): tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i))))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -8.2e-94) || !(n <= 2.05e-81)) tmp = Float64(100.0 * Float64(n + Float64(n * Float64(Float64(i * 0.5) + Float64(0.16666666666666666 * Float64(i * i)))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -8.2e-94) || ~((n <= 2.05e-81))) tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i))))); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -8.2e-94], N[Not[LessEqual[n, 2.05e-81]], $MachinePrecision]], N[(100.0 * N[(n + N[(n * N[(N[(i * 0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.2 \cdot 10^{-94} \lor \neg \left(n \leq 2.05 \cdot 10^{-81}\right):\\
\;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5 + 0.16666666666666666 \cdot \left(i \cdot i\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -8.20000000000000001e-94 or 2.04999999999999992e-81 < n Initial program 20.0%
Taylor expanded in n around inf 35.7%
expm1-def72.6%
Simplified72.6%
Taylor expanded in i around 0 69.9%
+-commutative69.9%
associate-*r*69.9%
associate-*r*69.9%
distribute-rgt-out70.2%
*-commutative70.2%
unpow270.2%
Simplified70.2%
if -8.20000000000000001e-94 < n < 2.04999999999999992e-81Initial program 52.8%
*-commutative52.8%
associate-/r/52.2%
associate-*l*52.2%
sub-neg52.2%
metadata-eval52.2%
Simplified52.2%
Taylor expanded in i around 0 60.6%
Taylor expanded in i around 0 60.6%
Final simplification67.8%
(FPCore (i n) :precision binary64 (if (or (<= n -9e+132) (not (<= n 1.5e-170))) (* 100.0 (+ n (* n (+ (* i 0.5) (* 0.16666666666666666 (* i i)))))) (/ 1.0 (/ (+ (* n (* i -0.005)) (* n 0.01)) (* n n)))))
double code(double i, double n) {
double tmp;
if ((n <= -9e+132) || !(n <= 1.5e-170)) {
tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i)))));
} else {
tmp = 1.0 / (((n * (i * -0.005)) + (n * 0.01)) / (n * n));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-9d+132)) .or. (.not. (n <= 1.5d-170))) then
tmp = 100.0d0 * (n + (n * ((i * 0.5d0) + (0.16666666666666666d0 * (i * i)))))
else
tmp = 1.0d0 / (((n * (i * (-0.005d0))) + (n * 0.01d0)) / (n * n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -9e+132) || !(n <= 1.5e-170)) {
tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i)))));
} else {
tmp = 1.0 / (((n * (i * -0.005)) + (n * 0.01)) / (n * n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -9e+132) or not (n <= 1.5e-170): tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i))))) else: tmp = 1.0 / (((n * (i * -0.005)) + (n * 0.01)) / (n * n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -9e+132) || !(n <= 1.5e-170)) tmp = Float64(100.0 * Float64(n + Float64(n * Float64(Float64(i * 0.5) + Float64(0.16666666666666666 * Float64(i * i)))))); else tmp = Float64(1.0 / Float64(Float64(Float64(n * Float64(i * -0.005)) + Float64(n * 0.01)) / Float64(n * n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -9e+132) || ~((n <= 1.5e-170))) tmp = 100.0 * (n + (n * ((i * 0.5) + (0.16666666666666666 * (i * i))))); else tmp = 1.0 / (((n * (i * -0.005)) + (n * 0.01)) / (n * n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -9e+132], N[Not[LessEqual[n, 1.5e-170]], $MachinePrecision]], N[(100.0 * N[(n + N[(n * N[(N[(i * 0.5), $MachinePrecision] + N[(0.16666666666666666 * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(n * N[(i * -0.005), $MachinePrecision]), $MachinePrecision] + N[(n * 0.01), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9 \cdot 10^{+132} \lor \neg \left(n \leq 1.5 \cdot 10^{-170}\right):\\
\;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5 + 0.16666666666666666 \cdot \left(i \cdot i\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{n \cdot \left(i \cdot -0.005\right) + n \cdot 0.01}{n \cdot n}}\\
\end{array}
\end{array}
if n < -8.99999999999999944e132 or 1.50000000000000007e-170 < n Initial program 19.5%
Taylor expanded in n around inf 36.4%
expm1-def65.4%
Simplified65.4%
Taylor expanded in i around 0 69.3%
+-commutative69.3%
associate-*r*69.3%
associate-*r*69.3%
distribute-rgt-out69.6%
*-commutative69.6%
unpow269.6%
Simplified69.6%
if -8.99999999999999944e132 < n < 1.50000000000000007e-170Initial program 40.4%
Taylor expanded in n around inf 33.8%
*-commutative33.8%
associate-/l*33.8%
expm1-def66.0%
Simplified66.0%
associate-*l/66.0%
clear-num66.4%
Applied egg-rr66.4%
associate-/l/58.1%
*-commutative58.1%
associate-*r*58.0%
*-commutative58.0%
associate-*r*58.0%
*-commutative58.0%
associate-*l*58.1%
Simplified58.1%
Taylor expanded in i around 0 60.2%
associate-*r/60.2%
un-div-inv60.3%
frac-add66.6%
*-commutative66.6%
Applied egg-rr66.6%
Final simplification68.3%
(FPCore (i n) :precision binary64 (if (<= i -2.0) (/ -200.0 (/ i n)) (if (<= i 1.7e-21) (* n 100.0) (* 16.666666666666668 (* n (* i i))))))
double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = -200.0 / (i / n);
} else if (i <= 1.7e-21) {
tmp = n * 100.0;
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-2.0d0)) then
tmp = (-200.0d0) / (i / n)
else if (i <= 1.7d-21) then
tmp = n * 100.0d0
else
tmp = 16.666666666666668d0 * (n * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = -200.0 / (i / n);
} else if (i <= 1.7e-21) {
tmp = n * 100.0;
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.0: tmp = -200.0 / (i / n) elif i <= 1.7e-21: tmp = n * 100.0 else: tmp = 16.666666666666668 * (n * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= -2.0) tmp = Float64(-200.0 / Float64(i / n)); elseif (i <= 1.7e-21) tmp = Float64(n * 100.0); else tmp = Float64(16.666666666666668 * Float64(n * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2.0) tmp = -200.0 / (i / n); elseif (i <= 1.7e-21) tmp = n * 100.0; else tmp = 16.666666666666668 * (n * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.0], N[(-200.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1.7e-21], N[(n * 100.0), $MachinePrecision], N[(16.666666666666668 * N[(n * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;\frac{-200}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{-21}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < -2Initial program 59.9%
Taylor expanded in n around inf 78.8%
*-commutative78.8%
associate-/l*78.8%
expm1-def78.8%
Simplified78.8%
Taylor expanded in i around 0 33.1%
*-commutative33.1%
Simplified33.1%
Taylor expanded in i around inf 33.1%
clear-num34.0%
un-div-inv34.0%
Applied egg-rr34.0%
if -2 < i < 1.7e-21Initial program 7.5%
Taylor expanded in i around 0 87.9%
*-commutative87.9%
Simplified87.9%
if 1.7e-21 < i Initial program 49.1%
Taylor expanded in n around inf 60.9%
expm1-def59.3%
Simplified59.3%
Taylor expanded in i around 0 39.0%
+-commutative39.0%
associate-*r*39.0%
associate-*r*39.0%
distribute-rgt-out39.0%
*-commutative39.0%
unpow239.0%
Simplified39.0%
Taylor expanded in i around inf 39.1%
unpow239.1%
*-commutative39.1%
Simplified39.1%
Final simplification65.2%
(FPCore (i n) :precision binary64 (if (<= i 1.7e-21) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) (* 16.666666666666668 (* n (* i i)))))
double code(double i, double n) {
double tmp;
if (i <= 1.7e-21) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 1.7d-21) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else
tmp = 16.666666666666668d0 * (n * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 1.7e-21) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 1.7e-21: tmp = 100.0 * (n / (1.0 + (i * -0.5))) else: tmp = 16.666666666666668 * (n * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= 1.7e-21) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); else tmp = Float64(16.666666666666668 * Float64(n * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 1.7e-21) tmp = 100.0 * (n / (1.0 + (i * -0.5))); else tmp = 16.666666666666668 * (n * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 1.7e-21], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(16.666666666666668 * N[(n * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 1.7 \cdot 10^{-21}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < 1.7e-21Initial program 22.0%
Taylor expanded in n around inf 28.1%
*-commutative28.1%
associate-/l*28.1%
expm1-def85.8%
Simplified85.8%
Taylor expanded in i around 0 72.7%
*-commutative72.7%
Simplified72.7%
if 1.7e-21 < i Initial program 49.1%
Taylor expanded in n around inf 60.9%
expm1-def59.3%
Simplified59.3%
Taylor expanded in i around 0 39.0%
+-commutative39.0%
associate-*r*39.0%
associate-*r*39.0%
distribute-rgt-out39.0%
*-commutative39.0%
unpow239.0%
Simplified39.0%
Taylor expanded in i around inf 39.1%
unpow239.1%
*-commutative39.1%
Simplified39.1%
Final simplification65.1%
(FPCore (i n) :precision binary64 (if (<= i 1.7e-21) (/ 100.0 (/ (+ 1.0 (* i -0.5)) n)) (* 16.666666666666668 (* n (* i i)))))
double code(double i, double n) {
double tmp;
if (i <= 1.7e-21) {
tmp = 100.0 / ((1.0 + (i * -0.5)) / n);
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 1.7d-21) then
tmp = 100.0d0 / ((1.0d0 + (i * (-0.5d0))) / n)
else
tmp = 16.666666666666668d0 * (n * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 1.7e-21) {
tmp = 100.0 / ((1.0 + (i * -0.5)) / n);
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 1.7e-21: tmp = 100.0 / ((1.0 + (i * -0.5)) / n) else: tmp = 16.666666666666668 * (n * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= 1.7e-21) tmp = Float64(100.0 / Float64(Float64(1.0 + Float64(i * -0.5)) / n)); else tmp = Float64(16.666666666666668 * Float64(n * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 1.7e-21) tmp = 100.0 / ((1.0 + (i * -0.5)) / n); else tmp = 16.666666666666668 * (n * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 1.7e-21], N[(100.0 / N[(N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(16.666666666666668 * N[(n * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 1.7 \cdot 10^{-21}:\\
\;\;\;\;\frac{100}{\frac{1 + i \cdot -0.5}{n}}\\
\mathbf{else}:\\
\;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < 1.7e-21Initial program 22.0%
Taylor expanded in n around inf 28.1%
*-commutative28.1%
associate-/l*28.1%
expm1-def85.8%
Simplified85.8%
*-commutative85.8%
clear-num85.9%
un-div-inv85.8%
Applied egg-rr85.8%
Taylor expanded in i around 0 72.7%
*-commutative72.7%
Simplified72.7%
if 1.7e-21 < i Initial program 49.1%
Taylor expanded in n around inf 60.9%
expm1-def59.3%
Simplified59.3%
Taylor expanded in i around 0 39.0%
+-commutative39.0%
associate-*r*39.0%
associate-*r*39.0%
distribute-rgt-out39.0%
*-commutative39.0%
unpow239.0%
Simplified39.0%
Taylor expanded in i around inf 39.1%
unpow239.1%
*-commutative39.1%
Simplified39.1%
Final simplification65.1%
(FPCore (i n) :precision binary64 (if (<= i 1.7e-21) (/ n (+ (* i -0.005) 0.01)) (* 16.666666666666668 (* n (* i i)))))
double code(double i, double n) {
double tmp;
if (i <= 1.7e-21) {
tmp = n / ((i * -0.005) + 0.01);
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 1.7d-21) then
tmp = n / ((i * (-0.005d0)) + 0.01d0)
else
tmp = 16.666666666666668d0 * (n * (i * i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 1.7e-21) {
tmp = n / ((i * -0.005) + 0.01);
} else {
tmp = 16.666666666666668 * (n * (i * i));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 1.7e-21: tmp = n / ((i * -0.005) + 0.01) else: tmp = 16.666666666666668 * (n * (i * i)) return tmp
function code(i, n) tmp = 0.0 if (i <= 1.7e-21) tmp = Float64(n / Float64(Float64(i * -0.005) + 0.01)); else tmp = Float64(16.666666666666668 * Float64(n * Float64(i * i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 1.7e-21) tmp = n / ((i * -0.005) + 0.01); else tmp = 16.666666666666668 * (n * (i * i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 1.7e-21], N[(n / N[(N[(i * -0.005), $MachinePrecision] + 0.01), $MachinePrecision]), $MachinePrecision], N[(16.666666666666668 * N[(n * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 1.7 \cdot 10^{-21}:\\
\;\;\;\;\frac{n}{i \cdot -0.005 + 0.01}\\
\mathbf{else}:\\
\;\;\;\;16.666666666666668 \cdot \left(n \cdot \left(i \cdot i\right)\right)\\
\end{array}
\end{array}
if i < 1.7e-21Initial program 22.0%
Taylor expanded in n around inf 28.1%
*-commutative28.1%
associate-/l*28.1%
expm1-def85.8%
Simplified85.8%
associate-*l/85.3%
clear-num85.4%
Applied egg-rr85.4%
associate-/l/79.0%
*-commutative79.0%
associate-*r*78.8%
*-commutative78.8%
associate-*r*78.8%
*-commutative78.8%
associate-*l*79.0%
Simplified79.0%
Taylor expanded in i around 0 72.6%
Taylor expanded in n around 0 72.6%
*-commutative72.6%
Simplified72.6%
if 1.7e-21 < i Initial program 49.1%
Taylor expanded in n around inf 60.9%
expm1-def59.3%
Simplified59.3%
Taylor expanded in i around 0 39.0%
+-commutative39.0%
associate-*r*39.0%
associate-*r*39.0%
distribute-rgt-out39.0%
*-commutative39.0%
unpow239.0%
Simplified39.0%
Taylor expanded in i around inf 39.1%
unpow239.1%
*-commutative39.1%
Simplified39.1%
Final simplification65.0%
(FPCore (i n) :precision binary64 (if (<= i -350.0) 0.0 (if (<= i 1.7e-21) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -350.0) {
tmp = 0.0;
} else if (i <= 1.7e-21) {
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 <= (-350.0d0)) then
tmp = 0.0d0
else if (i <= 1.7d-21) 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 <= -350.0) {
tmp = 0.0;
} else if (i <= 1.7e-21) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -350.0: tmp = 0.0 elif i <= 1.7e-21: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -350.0) tmp = 0.0; elseif (i <= 1.7e-21) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -350.0) tmp = 0.0; elseif (i <= 1.7e-21) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -350.0], 0.0, If[LessEqual[i, 1.7e-21], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -350:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{-21}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -350 or 1.7e-21 < i Initial program 54.9%
*-commutative54.9%
associate-/r/54.6%
associate-*l*54.5%
sub-neg54.5%
metadata-eval54.5%
Simplified54.5%
Taylor expanded in i around 0 29.2%
Taylor expanded in i around 0 29.2%
if -350 < i < 1.7e-21Initial program 7.4%
Taylor expanded in i around 0 87.4%
*-commutative87.4%
Simplified87.4%
Final simplification61.9%
(FPCore (i n) :precision binary64 (if (<= i -2.0) (* -200.0 (/ n i)) (if (<= i 1.7e-21) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = -200.0 * (n / i);
} else if (i <= 1.7e-21) {
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 <= (-2.0d0)) then
tmp = (-200.0d0) * (n / i)
else if (i <= 1.7d-21) 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 <= -2.0) {
tmp = -200.0 * (n / i);
} else if (i <= 1.7e-21) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.0: tmp = -200.0 * (n / i) elif i <= 1.7e-21: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -2.0) tmp = Float64(-200.0 * Float64(n / i)); elseif (i <= 1.7e-21) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2.0) tmp = -200.0 * (n / i); elseif (i <= 1.7e-21) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.0], N[(-200.0 * N[(n / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1.7e-21], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;-200 \cdot \frac{n}{i}\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{-21}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -2Initial program 59.9%
Taylor expanded in n around inf 78.8%
*-commutative78.8%
associate-/l*78.8%
expm1-def78.8%
Simplified78.8%
Taylor expanded in i around 0 33.1%
*-commutative33.1%
Simplified33.1%
Taylor expanded in i around inf 33.1%
if -2 < i < 1.7e-21Initial program 7.5%
Taylor expanded in i around 0 87.9%
*-commutative87.9%
Simplified87.9%
if 1.7e-21 < i Initial program 49.1%
*-commutative49.1%
associate-/r/49.2%
associate-*l*49.2%
sub-neg49.2%
metadata-eval49.2%
Simplified49.2%
Taylor expanded in i around 0 25.9%
Taylor expanded in i around 0 25.9%
Final simplification62.1%
(FPCore (i n) :precision binary64 (if (<= i -2.0) (/ -200.0 (/ i n)) (if (<= i 1.7e-21) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = -200.0 / (i / n);
} else if (i <= 1.7e-21) {
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 <= (-2.0d0)) then
tmp = (-200.0d0) / (i / n)
else if (i <= 1.7d-21) 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 <= -2.0) {
tmp = -200.0 / (i / n);
} else if (i <= 1.7e-21) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.0: tmp = -200.0 / (i / n) elif i <= 1.7e-21: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -2.0) tmp = Float64(-200.0 / Float64(i / n)); elseif (i <= 1.7e-21) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2.0) tmp = -200.0 / (i / n); elseif (i <= 1.7e-21) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.0], N[(-200.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1.7e-21], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;\frac{-200}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{-21}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -2Initial program 59.9%
Taylor expanded in n around inf 78.8%
*-commutative78.8%
associate-/l*78.8%
expm1-def78.8%
Simplified78.8%
Taylor expanded in i around 0 33.1%
*-commutative33.1%
Simplified33.1%
Taylor expanded in i around inf 33.1%
clear-num34.0%
un-div-inv34.0%
Applied egg-rr34.0%
if -2 < i < 1.7e-21Initial program 7.5%
Taylor expanded in i around 0 87.9%
*-commutative87.9%
Simplified87.9%
if 1.7e-21 < i Initial program 49.1%
*-commutative49.1%
associate-/r/49.2%
associate-*l*49.2%
sub-neg49.2%
metadata-eval49.2%
Simplified49.2%
Taylor expanded in i around 0 25.9%
Taylor expanded in i around 0 25.9%
Final simplification62.3%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 28.2%
*-commutative28.2%
associate-/r/28.3%
associate-*l*28.3%
sub-neg28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in i around 0 17.2%
Taylor expanded in i around 0 17.2%
Final simplification17.2%
(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 2023283
(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))))