
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 5e-289)
(/ 1.0 (/ (/ i n) (* (expm1 (* n (log1p (/ 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 <= 5e-289) {
tmp = 1.0 / ((i / n) / (expm1((n * log1p((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 <= 5e-289) {
tmp = 1.0 / ((i / n) / (Math.expm1((n * Math.log1p((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 <= 5e-289: tmp = 1.0 / ((i / n) / (math.expm1((n * math.log1p((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 <= 5e-289) tmp = Float64(1.0 / Float64(Float64(i / n) / Float64(expm1(Float64(n * log1p(Float64(i / 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, 5e-289], N[(1.0 / N[(N[(i / n), $MachinePrecision] / N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * 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 5 \cdot 10^{-289}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{n}}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \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)) < 5.00000000000000029e-289Initial program 27.3%
associate-*r/27.3%
clear-num27.3%
*-commutative27.3%
add-exp-log27.3%
expm1-def27.3%
log-pow36.5%
log1p-udef97.3%
Applied egg-rr97.3%
if 5.00000000000000029e-289 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
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-def86.2%
Simplified86.2%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification98.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 0.0)
(* 100.0 (/ n (/ i (expm1 i))))
(if (<= t_1 INFINITY)
(- (* 100.0 (* t_0 (/ n i))) (* 100.0 (/ n i)))
(* 100.0 (/ n (+ 1.0 (* i -0.5))))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (n / (i / expm1(i)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (100.0 * (t_0 * (n / i))) - (100.0 * (n / i));
} 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);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (100.0 * (t_0 * (n / i))) - (100.0 * (n / i));
} 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) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= 0.0: tmp = 100.0 * (n / (i / math.expm1(i))) elif t_1 <= math.inf: tmp = (100.0 * (t_0 * (n / i))) - (100.0 * (n / i)) else: tmp = 100.0 * (n / (1.0 + (i * -0.5))) return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); elseif (t_1 <= Inf) tmp = Float64(Float64(100.0 * Float64(t_0 * Float64(n / i))) - Float64(100.0 * Float64(n / i))); 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[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(100.0 * N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(100.0 * N[(n / i), $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}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t_0 \cdot \frac{n}{i}\right) - 100 \cdot \frac{n}{i}\\
\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%
Taylor expanded in n around inf 40.5%
*-commutative40.5%
associate-/l*40.5%
expm1-def75.8%
Simplified75.8%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.4%
div-sub99.3%
clear-num99.3%
sub-neg99.3%
div-inv99.3%
clear-num99.3%
Applied egg-rr99.3%
+-commutative99.3%
*-rgt-identity99.3%
distribute-rgt-neg-in99.3%
metadata-eval99.3%
*-commutative99.3%
distribute-lft-out99.3%
Simplified99.3%
distribute-rgt-in99.3%
distribute-rgt-in99.5%
mul-1-neg99.5%
Applied egg-rr99.5%
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-def86.2%
Simplified86.2%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification82.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 0.0)
(* 100.0 (/ n (/ i (expm1 i))))
(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 = 100.0 * (n / (i / expm1(i)));
} 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 = 100.0 * (n / (i / Math.expm1(i)));
} 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 = 100.0 * (n / (i / math.expm1(i))) 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(100.0 * Float64(n / Float64(i / expm1(i)))); 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[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $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:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\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%
Taylor expanded in n around inf 40.5%
*-commutative40.5%
associate-/l*40.5%
expm1-def75.8%
Simplified75.8%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.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 n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-def86.2%
Simplified86.2%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification82.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 5e-289)
(* 100.0 (* (expm1 (* n (log1p (/ i n)))) (/ n i)))
(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 <= 5e-289) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) * (n / i));
} 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 <= 5e-289) {
tmp = 100.0 * (Math.expm1((n * Math.log1p((i / n)))) * (n / i));
} 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 <= 5e-289: tmp = 100.0 * (math.expm1((n * math.log1p((i / n)))) * (n / i)) 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 <= 5e-289) tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(n / i))); 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, 5e-289], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(n / i), $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 5 \cdot 10^{-289}:\\
\;\;\;\;100 \cdot \left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n}{i}\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)) < 5.00000000000000029e-289Initial program 27.3%
clear-num27.3%
associate-/r/27.2%
clear-num27.2%
add-exp-log27.2%
expm1-def27.2%
log-pow37.0%
log1p-udef96.5%
Applied egg-rr96.5%
if 5.00000000000000029e-289 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
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-def86.2%
Simplified86.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 5e-289)
(* n (* (expm1 (* n (log1p (/ i n)))) (/ 100.0 i)))
(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 <= 5e-289) {
tmp = n * (expm1((n * log1p((i / n)))) * (100.0 / i));
} 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 <= 5e-289) {
tmp = n * (Math.expm1((n * Math.log1p((i / n)))) * (100.0 / i));
} 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 <= 5e-289: tmp = n * (math.expm1((n * math.log1p((i / n)))) * (100.0 / i)) 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 <= 5e-289) tmp = Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(100.0 / i))); 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, 5e-289], N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(100.0 / i), $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 5 \cdot 10^{-289}:\\
\;\;\;\;n \cdot \left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{100}{i}\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)) < 5.00000000000000029e-289Initial program 27.3%
associate-/r/27.3%
associate-*r*27.3%
*-commutative27.3%
associate-*r/27.3%
sub-neg27.3%
distribute-lft-in27.3%
metadata-eval27.3%
metadata-eval27.3%
metadata-eval27.3%
fma-def27.3%
metadata-eval27.3%
Simplified27.3%
expm1-log1p-u25.6%
expm1-udef20.2%
fma-udef20.2%
metadata-eval20.2%
metadata-eval20.2%
distribute-lft-in20.2%
sub-neg20.2%
*-commutative20.2%
add-exp-log20.2%
expm1-def20.2%
log-pow22.2%
log1p-udef71.4%
Applied egg-rr71.4%
expm1-def96.2%
expm1-log1p96.9%
*-rgt-identity96.9%
associate-*r/96.8%
associate-*l*96.8%
associate-*r/96.9%
metadata-eval96.9%
Simplified96.9%
if 5.00000000000000029e-289 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
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-def86.2%
Simplified86.2%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification97.8%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ n (/ i (expm1 i)))))
(t_1 (* 100.0 (/ n (+ 1.0 (* (pow i 2.0) 0.08333333333333333))))))
(if (<= n -1.35e-15)
t_0
(if (<= n -1.22e-175)
t_1
(if (<= n 5.2e-172) 0.0 (if (<= n 1.55) t_1 t_0))))))
double code(double i, double n) {
double t_0 = 100.0 * (n / (i / expm1(i)));
double t_1 = 100.0 * (n / (1.0 + (pow(i, 2.0) * 0.08333333333333333)));
double tmp;
if (n <= -1.35e-15) {
tmp = t_0;
} else if (n <= -1.22e-175) {
tmp = t_1;
} else if (n <= 5.2e-172) {
tmp = 0.0;
} else if (n <= 1.55) {
tmp = t_1;
} 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 t_1 = 100.0 * (n / (1.0 + (Math.pow(i, 2.0) * 0.08333333333333333)));
double tmp;
if (n <= -1.35e-15) {
tmp = t_0;
} else if (n <= -1.22e-175) {
tmp = t_1;
} else if (n <= 5.2e-172) {
tmp = 0.0;
} else if (n <= 1.55) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (n / (i / math.expm1(i))) t_1 = 100.0 * (n / (1.0 + (math.pow(i, 2.0) * 0.08333333333333333))) tmp = 0 if n <= -1.35e-15: tmp = t_0 elif n <= -1.22e-175: tmp = t_1 elif n <= 5.2e-172: tmp = 0.0 elif n <= 1.55: tmp = t_1 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(n / Float64(i / expm1(i)))) t_1 = Float64(100.0 * Float64(n / Float64(1.0 + Float64((i ^ 2.0) * 0.08333333333333333)))) tmp = 0.0 if (n <= -1.35e-15) tmp = t_0; elseif (n <= -1.22e-175) tmp = t_1; elseif (n <= 5.2e-172) tmp = 0.0; elseif (n <= 1.55) tmp = t_1; 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]}, Block[{t$95$1 = N[(100.0 * N[(n / N[(1.0 + N[(N[Power[i, 2.0], $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.35e-15], t$95$0, If[LessEqual[n, -1.22e-175], t$95$1, If[LessEqual[n, 5.2e-172], 0.0, If[LessEqual[n, 1.55], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
t_1 := 100 \cdot \frac{n}{1 + {i}^{2} \cdot 0.08333333333333333}\\
\mathbf{if}\;n \leq -1.35 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -1.22 \cdot 10^{-175}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq 5.2 \cdot 10^{-172}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 1.55:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -1.35000000000000005e-15 or 1.55000000000000004 < n Initial program 22.7%
Taylor expanded in n around inf 41.8%
*-commutative41.8%
associate-/l*41.8%
expm1-def91.9%
Simplified91.9%
if -1.35000000000000005e-15 < n < -1.2200000000000001e-175 or 5.1999999999999996e-172 < n < 1.55000000000000004Initial program 21.9%
Taylor expanded in n around inf 9.0%
*-commutative9.0%
associate-/l*9.0%
expm1-def57.2%
Simplified57.2%
Taylor expanded in i around 0 72.6%
Taylor expanded in i around inf 72.6%
*-commutative72.6%
Simplified72.6%
if -1.2200000000000001e-175 < n < 5.1999999999999996e-172Initial program 67.4%
Taylor expanded in i around 0 79.2%
Taylor expanded in i around 0 79.2%
Final simplification85.5%
(FPCore (i n) :precision binary64 (if (or (<= i -4e-14) (not (<= i 1.8e-7))) (* 100.0 (/ (expm1 i) (/ i n))) (* n 100.0)))
double code(double i, double n) {
double tmp;
if ((i <= -4e-14) || !(i <= 1.8e-7)) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -4e-14) || !(i <= 1.8e-7)) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -4e-14) or not (i <= 1.8e-7): tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if ((i <= -4e-14) || !(i <= 1.8e-7)) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -4e-14], N[Not[LessEqual[i, 1.8e-7]], $MachinePrecision]], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -4 \cdot 10^{-14} \lor \neg \left(i \leq 1.8 \cdot 10^{-7}\right):\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if i < -4e-14 or 1.79999999999999997e-7 < i Initial program 51.3%
Taylor expanded in n around inf 62.4%
expm1-def63.3%
Simplified63.3%
if -4e-14 < i < 1.79999999999999997e-7Initial program 7.1%
Taylor expanded in i around 0 87.5%
*-commutative87.5%
Simplified87.5%
Final simplification75.8%
(FPCore (i n) :precision binary64 (if (or (<= i -4.4e-15) (not (<= i 1.8e-7))) (* (expm1 i) (* 100.0 (/ n i))) (* n 100.0)))
double code(double i, double n) {
double tmp;
if ((i <= -4.4e-15) || !(i <= 1.8e-7)) {
tmp = expm1(i) * (100.0 * (n / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -4.4e-15) || !(i <= 1.8e-7)) {
tmp = Math.expm1(i) * (100.0 * (n / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -4.4e-15) or not (i <= 1.8e-7): tmp = math.expm1(i) * (100.0 * (n / i)) else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if ((i <= -4.4e-15) || !(i <= 1.8e-7)) tmp = Float64(expm1(i) * Float64(100.0 * Float64(n / i))); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -4.4e-15], N[Not[LessEqual[i, 1.8e-7]], $MachinePrecision]], N[(N[(Exp[i] - 1), $MachinePrecision] * N[(100.0 * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -4.4 \cdot 10^{-15} \lor \neg \left(i \leq 1.8 \cdot 10^{-7}\right):\\
\;\;\;\;\mathsf{expm1}\left(i\right) \cdot \left(100 \cdot \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if i < -4.39999999999999971e-15 or 1.79999999999999997e-7 < i Initial program 51.3%
Taylor expanded in n around inf 62.5%
*-commutative62.5%
associate-/l*62.5%
expm1-def63.4%
Simplified63.4%
Taylor expanded in n around 0 62.5%
metadata-eval62.5%
expm1-def63.4%
associate-/l*63.4%
times-frac63.4%
*-commutative63.4%
*-lft-identity63.4%
associate-/r/63.3%
*-commutative63.3%
associate-*r/63.3%
Simplified63.3%
if -4.39999999999999971e-15 < i < 1.79999999999999997e-7Initial program 7.1%
Taylor expanded in i around 0 87.5%
*-commutative87.5%
Simplified87.5%
Final simplification75.8%
(FPCore (i n) :precision binary64 (if (or (<= n -1.22e-175) (not (<= n 8.5e-128))) (* 100.0 (/ n (/ i (expm1 i)))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.22e-175) || !(n <= 8.5e-128)) {
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.22e-175) || !(n <= 8.5e-128)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.22e-175) or not (n <= 8.5e-128): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.22e-175) || !(n <= 8.5e-128)) 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.22e-175], N[Not[LessEqual[n, 8.5e-128]], $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.22 \cdot 10^{-175} \lor \neg \left(n \leq 8.5 \cdot 10^{-128}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.2200000000000001e-175 or 8.4999999999999996e-128 < n Initial program 22.7%
Taylor expanded in n around inf 33.7%
*-commutative33.7%
associate-/l*33.7%
expm1-def84.3%
Simplified84.3%
if -1.2200000000000001e-175 < n < 8.4999999999999996e-128Initial program 57.9%
Taylor expanded in i around 0 72.2%
Taylor expanded in i around 0 72.2%
Final simplification82.3%
(FPCore (i n) :precision binary64 (if (<= i -3.2e-22) 0.0 (if (<= i 0.76) (* n 100.0) (if (<= i 3.5e+125) 0.0 (* 50.0 (* i n))))))
double code(double i, double n) {
double tmp;
if (i <= -3.2e-22) {
tmp = 0.0;
} else if (i <= 0.76) {
tmp = n * 100.0;
} else if (i <= 3.5e+125) {
tmp = 0.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.2d-22)) then
tmp = 0.0d0
else if (i <= 0.76d0) then
tmp = n * 100.0d0
else if (i <= 3.5d+125) then
tmp = 0.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.2e-22) {
tmp = 0.0;
} else if (i <= 0.76) {
tmp = n * 100.0;
} else if (i <= 3.5e+125) {
tmp = 0.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -3.2e-22: tmp = 0.0 elif i <= 0.76: tmp = n * 100.0 elif i <= 3.5e+125: tmp = 0.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= -3.2e-22) tmp = 0.0; elseif (i <= 0.76) tmp = Float64(n * 100.0); elseif (i <= 3.5e+125) tmp = 0.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.2e-22) tmp = 0.0; elseif (i <= 0.76) tmp = n * 100.0; elseif (i <= 3.5e+125) tmp = 0.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -3.2e-22], 0.0, If[LessEqual[i, 0.76], N[(n * 100.0), $MachinePrecision], If[LessEqual[i, 3.5e+125], 0.0, N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -3.2 \cdot 10^{-22}:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 0.76:\\
\;\;\;\;n \cdot 100\\
\mathbf{elif}\;i \leq 3.5 \cdot 10^{+125}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < -3.19999999999999987e-22 or 0.76000000000000001 < i < 3.50000000000000011e125Initial program 52.2%
Taylor expanded in i around 0 34.2%
Taylor expanded in i around 0 34.2%
if -3.19999999999999987e-22 < i < 0.76000000000000001Initial program 6.3%
Taylor expanded in i around 0 87.8%
*-commutative87.8%
Simplified87.8%
if 3.50000000000000011e125 < i Initial program 51.6%
Taylor expanded in i around 0 49.9%
associate-*r*49.9%
associate-*r/49.9%
metadata-eval49.9%
Simplified49.9%
Taylor expanded in n around inf 50.1%
associate-*r*50.1%
*-commutative50.1%
Simplified50.1%
Taylor expanded in i around inf 50.1%
Final simplification64.4%
(FPCore (i n) :precision binary64 (if (or (<= n -5e-88) (not (<= n 1.05e-128))) (* n (+ 100.0 (* i 50.0))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -5e-88) || !(n <= 1.05e-128)) {
tmp = n * (100.0 + (i * 50.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 ((n <= (-5d-88)) .or. (.not. (n <= 1.05d-128))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -5e-88) || !(n <= 1.05e-128)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -5e-88) or not (n <= 1.05e-128): tmp = n * (100.0 + (i * 50.0)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -5e-88) || !(n <= 1.05e-128)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -5e-88) || ~((n <= 1.05e-128))) tmp = n * (100.0 + (i * 50.0)); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -5e-88], N[Not[LessEqual[n, 1.05e-128]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5 \cdot 10^{-88} \lor \neg \left(n \leq 1.05 \cdot 10^{-128}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -5.00000000000000009e-88 or 1.0500000000000001e-128 < n Initial program 20.7%
Taylor expanded in n around inf 34.4%
*-commutative34.4%
associate-/l*34.4%
expm1-def85.9%
Simplified85.9%
Taylor expanded in i around 0 65.2%
+-commutative65.2%
associate-*r*65.2%
distribute-rgt-out65.2%
Simplified65.2%
if -5.00000000000000009e-88 < n < 1.0500000000000001e-128Initial program 55.6%
Taylor expanded in i around 0 66.1%
Taylor expanded in i around 0 66.1%
Final simplification65.4%
(FPCore (i n) :precision binary64 (if (<= n -2.3e-175) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) (if (<= n 1.06e-128) 0.0 (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -2.3e-175) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 1.06e-128) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-2.3d-175)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 1.06d-128) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -2.3e-175) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 1.06e-128) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2.3e-175: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 1.06e-128: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -2.3e-175) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 1.06e-128) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -2.3e-175) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 1.06e-128) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2.3e-175], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.06e-128], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.3 \cdot 10^{-175}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 1.06 \cdot 10^{-128}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -2.3e-175Initial program 26.6%
Taylor expanded in n around inf 34.2%
*-commutative34.2%
associate-/l*34.2%
expm1-def81.0%
Simplified81.0%
Taylor expanded in i around 0 58.7%
*-commutative58.7%
Simplified58.7%
if -2.3e-175 < n < 1.05999999999999995e-128Initial program 57.9%
Taylor expanded in i around 0 72.2%
Taylor expanded in i around 0 72.2%
if 1.05999999999999995e-128 < n Initial program 19.0%
Taylor expanded in n around inf 33.2%
*-commutative33.2%
associate-/l*33.2%
expm1-def87.5%
Simplified87.5%
Taylor expanded in i around 0 72.7%
+-commutative72.7%
associate-*r*72.7%
distribute-rgt-out72.7%
Simplified72.7%
Final simplification66.9%
(FPCore (i n) :precision binary64 (if (<= n -1.22e-175) (/ (* n 100.0) (+ 1.0 (* i -0.5))) (if (<= n 1.05e-128) 0.0 (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -1.22e-175) {
tmp = (n * 100.0) / (1.0 + (i * -0.5));
} else if (n <= 1.05e-128) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-1.22d-175)) then
tmp = (n * 100.0d0) / (1.0d0 + (i * (-0.5d0)))
else if (n <= 1.05d-128) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -1.22e-175) {
tmp = (n * 100.0) / (1.0 + (i * -0.5));
} else if (n <= 1.05e-128) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.22e-175: tmp = (n * 100.0) / (1.0 + (i * -0.5)) elif n <= 1.05e-128: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.22e-175) tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * -0.5))); elseif (n <= 1.05e-128) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -1.22e-175) tmp = (n * 100.0) / (1.0 + (i * -0.5)); elseif (n <= 1.05e-128) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -1.22e-175], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.05e-128], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.22 \cdot 10^{-175}:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-128}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -1.2200000000000001e-175Initial program 26.6%
Taylor expanded in n around inf 34.2%
*-commutative34.2%
associate-/l*34.2%
expm1-def81.0%
Simplified81.0%
associate-*l/80.9%
Applied egg-rr80.9%
Taylor expanded in i around 0 58.7%
*-commutative58.7%
Simplified58.7%
if -1.2200000000000001e-175 < n < 1.0500000000000001e-128Initial program 57.9%
Taylor expanded in i around 0 72.2%
Taylor expanded in i around 0 72.2%
if 1.0500000000000001e-128 < n Initial program 19.0%
Taylor expanded in n around inf 33.2%
*-commutative33.2%
associate-/l*33.2%
expm1-def87.5%
Simplified87.5%
Taylor expanded in i around 0 72.7%
+-commutative72.7%
associate-*r*72.7%
distribute-rgt-out72.7%
Simplified72.7%
Final simplification66.9%
(FPCore (i n) :precision binary64 (if (<= i -3.2e-22) 0.0 (if (<= i 0.47) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -3.2e-22) {
tmp = 0.0;
} else if (i <= 0.47) {
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 <= (-3.2d-22)) then
tmp = 0.0d0
else if (i <= 0.47d0) 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 <= -3.2e-22) {
tmp = 0.0;
} else if (i <= 0.47) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -3.2e-22: tmp = 0.0 elif i <= 0.47: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -3.2e-22) tmp = 0.0; elseif (i <= 0.47) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -3.2e-22) tmp = 0.0; elseif (i <= 0.47) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -3.2e-22], 0.0, If[LessEqual[i, 0.47], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -3.2 \cdot 10^{-22}:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 0.47:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -3.19999999999999987e-22 or 0.46999999999999997 < i Initial program 52.0%
Taylor expanded in i around 0 29.3%
Taylor expanded in i around 0 29.3%
if -3.19999999999999987e-22 < i < 0.46999999999999997Initial program 6.3%
Taylor expanded in i around 0 87.8%
*-commutative87.8%
Simplified87.8%
Final simplification59.4%
(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.5%
Taylor expanded in i around 0 17.5%
Taylor expanded in i around 0 17.8%
Final simplification17.8%
(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 2023322
(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))))