
(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)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY)
(/ (* n (fma t_0 100.0 -100.0)) 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 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (n * fma(t_0, 100.0, -100.0)) / 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(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_1 <= Inf) tmp = Float64(Float64(n * fma(t_0, 100.0, -100.0)) / 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[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(n * N[(t$95$0 * 100.0 + -100.0), $MachinePrecision]), $MachinePrecision] / i), $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{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{n \cdot \mathsf{fma}\left(t\_0, 100, -100\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0Initial program 25.4%
sub-neg25.4%
metadata-eval25.4%
Applied egg-rr25.4%
metadata-eval25.4%
sub-neg25.4%
exp-to-pow23.7%
log1p-undefine39.2%
*-commutative39.2%
expm1-undefine98.0%
Simplified98.0%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 99.6%
associate-*r/99.6%
sub-neg99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
metadata-eval99.6%
associate-/r/99.4%
*-commutative99.4%
fma-undefine99.4%
*-commutative99.4%
associate-*r/99.7%
fma-undefine99.7%
*-commutative99.7%
fma-define99.7%
Applied egg-rr99.7%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-define85.6%
Simplified85.6%
associate-*l*85.6%
associate-*l/85.4%
*-commutative85.4%
clear-num85.4%
un-div-inv85.2%
*-un-lft-identity85.2%
times-frac85.4%
metadata-eval85.4%
Applied egg-rr85.4%
associate-/r*85.4%
Simplified85.4%
Taylor expanded in i around 0 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in n around 0 99.9%
Final simplification98.6%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n))
(t_1 (/ (+ t_0 -1.0) (/ i n)))
(t_2 (* 100.0 (- (* t_0 (/ n i)) (/ n i)))))
(if (<= t_1 -2e-174)
t_2
(if (<= t_1 0.0)
(/ (* n 100.0) (/ i (expm1 i)))
(if (<= t_1 INFINITY) t_2 (* 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 t_2 = 100.0 * ((t_0 * (n / i)) - (n / i));
double tmp;
if (t_1 <= -2e-174) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (n * 100.0) / (i / expm1(i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_2;
} 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 t_2 = 100.0 * ((t_0 * (n / i)) - (n / i));
double tmp;
if (t_1 <= -2e-174) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (n * 100.0) / (i / Math.expm1(i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} 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) t_2 = 100.0 * ((t_0 * (n / i)) - (n / i)) tmp = 0 if t_1 <= -2e-174: tmp = t_2 elif t_1 <= 0.0: tmp = (n * 100.0) / (i / math.expm1(i)) elif t_1 <= math.inf: tmp = t_2 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)) t_2 = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i))) tmp = 0.0 if (t_1 <= -2e-174) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(n * 100.0) / Float64(i / expm1(i))); elseif (t_1 <= Inf) tmp = t_2; 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]}, Block[{t$95$2 = N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-174], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(n * 100.0), $MachinePrecision] / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$2, 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}}\\
t_2 := 100 \cdot \left(t\_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-174}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -2e-174 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 99.4%
div-sub99.6%
clear-num99.5%
sub-neg99.5%
div-inv99.5%
clear-num99.5%
Applied egg-rr99.5%
sub-neg99.5%
Simplified99.5%
if -2e-174 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0Initial program 16.5%
Taylor expanded in n around inf 30.8%
*-commutative30.8%
associate-/l*30.7%
expm1-define79.6%
Simplified79.6%
associate-*l*79.6%
associate-*l/79.5%
*-commutative79.5%
clear-num79.5%
un-div-inv79.4%
*-un-lft-identity79.4%
times-frac79.5%
metadata-eval79.5%
Applied egg-rr79.5%
associate-/r*79.5%
Simplified79.5%
div-inv79.6%
metadata-eval79.6%
Applied egg-rr79.6%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-define85.6%
Simplified85.6%
associate-*l*85.6%
associate-*l/85.4%
*-commutative85.4%
clear-num85.4%
un-div-inv85.2%
*-un-lft-identity85.2%
times-frac85.4%
metadata-eval85.4%
Applied egg-rr85.4%
associate-/r*85.4%
Simplified85.4%
Taylor expanded in i around 0 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in n around 0 99.9%
Final simplification87.3%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))) (t_1 (* t_0 100.0)))
(if (<= t_0 -2e-174)
t_1
(if (<= t_0 0.0)
(/ (* n 100.0) (/ i (expm1 i)))
(if (<= t_0 INFINITY) t_1 (* 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 t_1 = t_0 * 100.0;
double tmp;
if (t_0 <= -2e-174) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = (n * 100.0) / (i / expm1(i));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_1;
} 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 t_1 = t_0 * 100.0;
double tmp;
if (t_0 <= -2e-174) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = (n * 100.0) / (i / Math.expm1(i));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} 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) t_1 = t_0 * 100.0 tmp = 0 if t_0 <= -2e-174: tmp = t_1 elif t_0 <= 0.0: tmp = (n * 100.0) / (i / math.expm1(i)) elif t_0 <= math.inf: tmp = t_1 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)) t_1 = Float64(t_0 * 100.0) tmp = 0.0 if (t_0 <= -2e-174) tmp = t_1; elseif (t_0 <= 0.0) tmp = Float64(Float64(n * 100.0) / Float64(i / expm1(i))); elseif (t_0 <= Inf) tmp = t_1; 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]}, Block[{t$95$1 = N[(t$95$0 * 100.0), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-174], t$95$1, If[LessEqual[t$95$0, 0.0], N[(N[(n * 100.0), $MachinePrecision] / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$1, 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}}\\
t_1 := t\_0 \cdot 100\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-174}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -2e-174 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 99.4%
if -2e-174 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0Initial program 16.5%
Taylor expanded in n around inf 30.8%
*-commutative30.8%
associate-/l*30.7%
expm1-define79.6%
Simplified79.6%
associate-*l*79.6%
associate-*l/79.5%
*-commutative79.5%
clear-num79.5%
un-div-inv79.4%
*-un-lft-identity79.4%
times-frac79.5%
metadata-eval79.5%
Applied egg-rr79.5%
associate-/r*79.5%
Simplified79.5%
div-inv79.6%
metadata-eval79.6%
Applied egg-rr79.6%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-define85.6%
Simplified85.6%
associate-*l*85.6%
associate-*l/85.4%
*-commutative85.4%
clear-num85.4%
un-div-inv85.2%
*-un-lft-identity85.2%
times-frac85.4%
metadata-eval85.4%
Applied egg-rr85.4%
associate-/r*85.4%
Simplified85.4%
Taylor expanded in i around 0 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in n around 0 99.9%
Final simplification87.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)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY)
(* 100.0 (- (* t_0 (/ n i)) (/ 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 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 * (n / i)) - (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 * (Math.expm1((n * Math.log1p((i / n)))) / (i / n));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 * (n / i)) - (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 * (math.expm1((n * math.log1p((i / n)))) / (i / n)) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 * (n / i)) - (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(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - 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[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $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[(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{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t\_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0Initial program 25.4%
sub-neg25.4%
metadata-eval25.4%
Applied egg-rr25.4%
metadata-eval25.4%
sub-neg25.4%
exp-to-pow23.7%
log1p-undefine39.2%
*-commutative39.2%
expm1-undefine98.0%
Simplified98.0%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 99.6%
div-sub99.8%
clear-num99.7%
sub-neg99.7%
div-inv99.7%
clear-num99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-define85.6%
Simplified85.6%
associate-*l*85.6%
associate-*l/85.4%
*-commutative85.4%
clear-num85.4%
un-div-inv85.2%
*-un-lft-identity85.2%
times-frac85.4%
metadata-eval85.4%
Applied egg-rr85.4%
associate-/r*85.4%
Simplified85.4%
Taylor expanded in i around 0 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in n around 0 99.9%
Final simplification98.6%
(FPCore (i n) :precision binary64 (if (or (<= n -4.8e-27) (not (<= n 1.5))) (* n (/ (* 100.0 (expm1 i)) i)) (/ (/ n 0.01) (+ 1.0 (* i (- (* i 0.08333333333333333) 0.5))))))
double code(double i, double n) {
double tmp;
if ((n <= -4.8e-27) || !(n <= 1.5)) {
tmp = n * ((100.0 * expm1(i)) / i);
} else {
tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -4.8e-27) || !(n <= 1.5)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5)));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -4.8e-27) or not (n <= 1.5): tmp = n * ((100.0 * math.expm1(i)) / i) else: tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5))) return tmp
function code(i, n) tmp = 0.0 if ((n <= -4.8e-27) || !(n <= 1.5)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = Float64(Float64(n / 0.01) / Float64(1.0 + Float64(i * Float64(Float64(i * 0.08333333333333333) - 0.5)))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -4.8e-27], N[Not[LessEqual[n, 1.5]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(N[(n / 0.01), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(i * 0.08333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -4.8 \cdot 10^{-27} \lor \neg \left(n \leq 1.5\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot \left(i \cdot 0.08333333333333333 - 0.5\right)}\\
\end{array}
\end{array}
if n < -4.80000000000000004e-27 or 1.5 < n Initial program 31.6%
associate-/r/32.0%
associate-*r*32.0%
*-commutative32.0%
associate-*r/32.0%
sub-neg32.0%
distribute-lft-in32.0%
metadata-eval32.0%
metadata-eval32.0%
metadata-eval32.0%
fma-define32.0%
metadata-eval32.0%
Simplified32.0%
Taylor expanded in n around inf 36.4%
sub-neg36.4%
metadata-eval36.4%
metadata-eval36.4%
distribute-lft-in36.5%
metadata-eval36.5%
sub-neg36.5%
expm1-define86.1%
Simplified86.1%
if -4.80000000000000004e-27 < n < 1.5Initial program 26.2%
Taylor expanded in n around inf 20.0%
*-commutative20.0%
associate-/l*20.0%
expm1-define59.0%
Simplified59.0%
associate-*l*59.0%
associate-*l/58.9%
*-commutative58.9%
clear-num58.9%
un-div-inv58.8%
*-un-lft-identity58.8%
times-frac58.8%
metadata-eval58.8%
Applied egg-rr58.8%
associate-/r*58.8%
Simplified58.8%
Taylor expanded in i around 0 69.6%
Final simplification80.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.5e-43) (not (<= n 1.7))) (* 100.0 (* n (/ (expm1 i) i))) (/ (/ n 0.01) (+ 1.0 (* i (- (* i 0.08333333333333333) 0.5))))))
double code(double i, double n) {
double tmp;
if ((n <= -1.5e-43) || !(n <= 1.7)) {
tmp = 100.0 * (n * (expm1(i) / i));
} else {
tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.5e-43) || !(n <= 1.7)) {
tmp = 100.0 * (n * (Math.expm1(i) / i));
} else {
tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5)));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.5e-43) or not (n <= 1.7): tmp = 100.0 * (n * (math.expm1(i) / i)) else: tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5))) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.5e-43) || !(n <= 1.7)) tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i))); else tmp = Float64(Float64(n / 0.01) / Float64(1.0 + Float64(i * Float64(Float64(i * 0.08333333333333333) - 0.5)))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.5e-43], N[Not[LessEqual[n, 1.7]], $MachinePrecision]], N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n / 0.01), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(i * 0.08333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.5 \cdot 10^{-43} \lor \neg \left(n \leq 1.7\right):\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot \left(i \cdot 0.08333333333333333 - 0.5\right)}\\
\end{array}
\end{array}
if n < -1.50000000000000002e-43 or 1.69999999999999996 < n Initial program 31.2%
Taylor expanded in n around inf 36.1%
*-commutative36.1%
associate-/l*36.1%
expm1-define86.4%
Simplified86.4%
if -1.50000000000000002e-43 < n < 1.69999999999999996Initial program 26.7%
Taylor expanded in n around inf 20.3%
*-commutative20.3%
associate-/l*20.3%
expm1-define58.1%
Simplified58.1%
associate-*l*58.1%
associate-*l/58.0%
*-commutative58.0%
clear-num58.0%
un-div-inv57.9%
*-un-lft-identity57.9%
times-frac58.0%
metadata-eval58.0%
Applied egg-rr58.0%
associate-/r*58.0%
Simplified58.0%
Taylor expanded in i around 0 69.0%
Final simplification80.2%
(FPCore (i n)
:precision binary64
(if (<= n -3.25e-43)
(/ (* n 100.0) (/ i (expm1 i)))
(if (<= n 1.55)
(/ (/ n 0.01) (+ 1.0 (* i (- (* i 0.08333333333333333) 0.5))))
(* 100.0 (* n (/ (expm1 i) i))))))
double code(double i, double n) {
double tmp;
if (n <= -3.25e-43) {
tmp = (n * 100.0) / (i / expm1(i));
} else if (n <= 1.55) {
tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5)));
} else {
tmp = 100.0 * (n * (expm1(i) / i));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -3.25e-43) {
tmp = (n * 100.0) / (i / Math.expm1(i));
} else if (n <= 1.55) {
tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5)));
} else {
tmp = 100.0 * (n * (Math.expm1(i) / i));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.25e-43: tmp = (n * 100.0) / (i / math.expm1(i)) elif n <= 1.55: tmp = (n / 0.01) / (1.0 + (i * ((i * 0.08333333333333333) - 0.5))) else: tmp = 100.0 * (n * (math.expm1(i) / i)) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.25e-43) tmp = Float64(Float64(n * 100.0) / Float64(i / expm1(i))); elseif (n <= 1.55) tmp = Float64(Float64(n / 0.01) / Float64(1.0 + Float64(i * Float64(Float64(i * 0.08333333333333333) - 0.5)))); else tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i))); end return tmp end
code[i_, n_] := If[LessEqual[n, -3.25e-43], N[(N[(n * 100.0), $MachinePrecision] / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.55], N[(N[(n / 0.01), $MachinePrecision] / N[(1.0 + N[(i * N[(N[(i * 0.08333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.25 \cdot 10^{-43}:\\
\;\;\;\;\frac{n \cdot 100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{elif}\;n \leq 1.55:\\
\;\;\;\;\frac{\frac{n}{0.01}}{1 + i \cdot \left(i \cdot 0.08333333333333333 - 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\end{array}
\end{array}
if n < -3.25e-43Initial program 35.6%
Taylor expanded in n around inf 30.9%
*-commutative30.9%
associate-/l*30.8%
expm1-define79.6%
Simplified79.6%
associate-*l*79.6%
associate-*l/79.5%
*-commutative79.5%
clear-num79.5%
un-div-inv79.5%
*-un-lft-identity79.5%
times-frac79.5%
metadata-eval79.5%
Applied egg-rr79.5%
associate-/r*79.5%
Simplified79.5%
div-inv79.6%
metadata-eval79.6%
Applied egg-rr79.6%
if -3.25e-43 < n < 1.55000000000000004Initial program 26.7%
Taylor expanded in n around inf 20.3%
*-commutative20.3%
associate-/l*20.3%
expm1-define58.1%
Simplified58.1%
associate-*l*58.1%
associate-*l/58.0%
*-commutative58.0%
clear-num58.0%
un-div-inv57.9%
*-un-lft-identity57.9%
times-frac58.0%
metadata-eval58.0%
Applied egg-rr58.0%
associate-/r*58.0%
Simplified58.0%
Taylor expanded in i around 0 69.0%
if 1.55000000000000004 < n Initial program 25.4%
Taylor expanded in n around inf 43.2%
*-commutative43.2%
associate-/l*43.2%
expm1-define95.6%
Simplified95.6%
Final simplification80.2%
(FPCore (i n)
:precision binary64
(if (<= i -0.00029)
(* 100.0 (* (/ n i) (expm1 i)))
(*
n
(/
(*
i
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))
i))))
double code(double i, double n) {
double tmp;
if (i <= -0.00029) {
tmp = 100.0 * ((n / i) * expm1(i));
} else {
tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= -0.00029) {
tmp = 100.0 * ((n / i) * Math.expm1(i));
} else {
tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -0.00029: tmp = 100.0 * ((n / i) * math.expm1(i)) else: tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i) return tmp
function code(i, n) tmp = 0.0 if (i <= -0.00029) tmp = Float64(100.0 * Float64(Float64(n / i) * expm1(i))); else tmp = Float64(n * Float64(Float64(i * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))) / i)); end return tmp end
code[i_, n_] := If[LessEqual[i, -0.00029], N[(100.0 * N[(N[(n / i), $MachinePrecision] * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(N[(i * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -0.00029:\\
\;\;\;\;100 \cdot \left(\frac{n}{i} \cdot \mathsf{expm1}\left(i\right)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)}{i}\\
\end{array}
\end{array}
if i < -2.9e-4Initial program 64.5%
Taylor expanded in n around inf 73.1%
*-commutative73.1%
associate-/l*73.0%
expm1-define73.0%
Simplified73.0%
associate-*l*72.9%
associate-*l/73.1%
*-commutative73.1%
clear-num72.9%
un-div-inv73.0%
*-un-lft-identity73.0%
times-frac73.0%
metadata-eval73.0%
Applied egg-rr73.0%
associate-/r*73.1%
Simplified73.1%
Taylor expanded in n around 0 73.1%
expm1-define73.1%
*-commutative73.1%
associate-/l*73.1%
Simplified73.1%
if -2.9e-4 < i Initial program 20.7%
associate-/r/21.2%
associate-*r*21.2%
*-commutative21.2%
associate-*r/21.2%
sub-neg21.2%
distribute-lft-in21.2%
metadata-eval21.2%
metadata-eval21.2%
metadata-eval21.2%
fma-define21.2%
metadata-eval21.2%
Simplified21.2%
Taylor expanded in n around inf 19.5%
sub-neg19.5%
metadata-eval19.5%
metadata-eval19.5%
distribute-lft-in19.6%
metadata-eval19.6%
sub-neg19.6%
expm1-define77.0%
Simplified77.0%
Taylor expanded in i around 0 76.1%
*-commutative76.1%
Simplified76.1%
Final simplification75.5%
(FPCore (i n)
:precision binary64
(if (<= n 0.116)
(* 100.0 (/ n (+ 1.0 (* i -0.5))))
(*
n
(/
(*
i
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))
i))))
double code(double i, double n) {
double tmp;
if (n <= 0.116) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 0.116d0) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else
tmp = n * ((i * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 0.116) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 0.116: tmp = 100.0 * (n / (1.0 + (i * -0.5))) else: tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= 0.116) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); else tmp = Float64(n * Float64(Float64(i * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))) / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 0.116) tmp = 100.0 * (n / (1.0 + (i * -0.5))); else tmp = n * ((i * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))))) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 0.116], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(N[(i * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.116:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{i \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)}{i}\\
\end{array}
\end{array}
if n < 0.116000000000000006Initial program 31.2%
Taylor expanded in n around inf 25.7%
*-commutative25.7%
associate-/l*25.7%
expm1-define69.0%
Simplified69.0%
associate-*l*69.0%
associate-*l/69.0%
*-commutative69.0%
clear-num69.0%
un-div-inv68.9%
*-un-lft-identity68.9%
times-frac68.9%
metadata-eval68.9%
Applied egg-rr68.9%
associate-/r*69.0%
Simplified69.0%
Taylor expanded in i around 0 62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in n around 0 62.6%
if 0.116000000000000006 < n Initial program 25.4%
associate-/r/25.9%
associate-*r*25.9%
*-commutative25.9%
associate-*r/25.9%
sub-neg25.9%
distribute-lft-in25.9%
metadata-eval25.9%
metadata-eval25.9%
metadata-eval25.9%
fma-define25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in n around inf 43.0%
sub-neg43.0%
metadata-eval43.0%
metadata-eval43.0%
distribute-lft-in43.2%
metadata-eval43.2%
sub-neg43.2%
expm1-define95.5%
Simplified95.5%
Taylor expanded in i around 0 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification69.1%
(FPCore (i n)
:precision binary64
(if (<= n 0.0037)
(* 100.0 (/ n (+ 1.0 (* i -0.5))))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))))
double code(double i, double n) {
double tmp;
if (n <= 0.0037) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 0.0037d0) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 0.0037) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 0.0037: tmp = 100.0 * (n / (1.0 + (i * -0.5))) else: tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if (n <= 0.0037) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 0.0037) tmp = 100.0 * (n / (1.0 + (i * -0.5))); else tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 0.0037], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.0037:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\end{array}
\end{array}
if n < 0.0037000000000000002Initial program 31.2%
Taylor expanded in n around inf 25.7%
*-commutative25.7%
associate-/l*25.7%
expm1-define69.0%
Simplified69.0%
associate-*l*69.0%
associate-*l/69.0%
*-commutative69.0%
clear-num69.0%
un-div-inv68.9%
*-un-lft-identity68.9%
times-frac68.9%
metadata-eval68.9%
Applied egg-rr68.9%
associate-/r*69.0%
Simplified69.0%
Taylor expanded in i around 0 62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in n around 0 62.6%
if 0.0037000000000000002 < n Initial program 25.4%
associate-/r/25.9%
associate-*r*25.9%
*-commutative25.9%
associate-*r/25.9%
sub-neg25.9%
distribute-lft-in25.9%
metadata-eval25.9%
metadata-eval25.9%
metadata-eval25.9%
fma-define25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in n around inf 43.0%
sub-neg43.0%
metadata-eval43.0%
metadata-eval43.0%
distribute-lft-in43.2%
metadata-eval43.2%
sub-neg43.2%
expm1-define95.5%
Simplified95.5%
Taylor expanded in i around 0 85.2%
*-commutative85.2%
Simplified85.2%
Final simplification68.8%
(FPCore (i n) :precision binary64 (if (<= n 5.5e+18) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))))
double code(double i, double n) {
double tmp;
if (n <= 5.5e+18) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 5.5d+18) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 5.5e+18) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 5.5e+18: tmp = 100.0 * (n / (1.0 + (i * -0.5))) else: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) return tmp
function code(i, n) tmp = 0.0 if (n <= 5.5e+18) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 5.5e+18) tmp = 100.0 * (n / (1.0 + (i * -0.5))); else tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 5.5e+18], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 5.5 \cdot 10^{+18}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\end{array}
\end{array}
if n < 5.5e18Initial program 31.9%
Taylor expanded in n around inf 26.0%
*-commutative26.0%
associate-/l*26.0%
expm1-define69.5%
Simplified69.5%
associate-*l*69.5%
associate-*l/69.4%
*-commutative69.4%
clear-num69.5%
un-div-inv69.4%
*-un-lft-identity69.4%
times-frac69.4%
metadata-eval69.4%
Applied egg-rr69.4%
associate-/r*69.4%
Simplified69.4%
Taylor expanded in i around 0 62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in n around 0 62.3%
if 5.5e18 < n Initial program 22.9%
associate-/r/23.5%
associate-*r*23.5%
*-commutative23.5%
associate-*r/23.5%
sub-neg23.5%
distribute-lft-in23.5%
metadata-eval23.5%
metadata-eval23.5%
metadata-eval23.5%
fma-define23.5%
metadata-eval23.5%
Simplified23.5%
Taylor expanded in n around inf 43.8%
sub-neg43.8%
metadata-eval43.8%
metadata-eval43.8%
distribute-lft-in44.0%
metadata-eval44.0%
sub-neg44.0%
expm1-define96.7%
Simplified96.7%
Taylor expanded in i around 0 81.2%
*-commutative81.2%
Simplified81.2%
Final simplification67.0%
(FPCore (i n) :precision binary64 (if (or (<= i -2.0) (not (<= i 7.5e+35))) (* (/ n i) -200.0) (* n 100.0)))
double code(double i, double n) {
double tmp;
if ((i <= -2.0) || !(i <= 7.5e+35)) {
tmp = (n / i) * -200.0;
} else {
tmp = n * 100.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)) .or. (.not. (i <= 7.5d+35))) then
tmp = (n / i) * (-200.0d0)
else
tmp = n * 100.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((i <= -2.0) || !(i <= 7.5e+35)) {
tmp = (n / i) * -200.0;
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -2.0) or not (i <= 7.5e+35): tmp = (n / i) * -200.0 else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if ((i <= -2.0) || !(i <= 7.5e+35)) tmp = Float64(Float64(n / i) * -200.0); else tmp = Float64(n * 100.0); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((i <= -2.0) || ~((i <= 7.5e+35))) tmp = (n / i) * -200.0; else tmp = n * 100.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[i, -2.0], N[Not[LessEqual[i, 7.5e+35]], $MachinePrecision]], N[(N[(n / i), $MachinePrecision] * -200.0), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2 \lor \neg \left(i \leq 7.5 \cdot 10^{+35}\right):\\
\;\;\;\;\frac{n}{i} \cdot -200\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if i < -2 or 7.4999999999999999e35 < i Initial program 63.7%
Taylor expanded in n around inf 59.3%
*-commutative59.3%
associate-/l*59.2%
expm1-define59.2%
Simplified59.2%
associate-*l*59.2%
associate-*l/59.3%
*-commutative59.3%
clear-num59.2%
un-div-inv59.2%
*-un-lft-identity59.2%
times-frac59.2%
metadata-eval59.2%
Applied egg-rr59.2%
associate-/r*59.3%
Simplified59.3%
Taylor expanded in i around 0 25.4%
*-commutative25.4%
Simplified25.4%
Taylor expanded in i around inf 25.4%
if -2 < i < 7.4999999999999999e35Initial program 7.8%
Taylor expanded in i around 0 83.3%
*-commutative83.3%
Simplified83.3%
Final simplification60.7%
(FPCore (i n) :precision binary64 (if (<= n 3.1e+18) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (n <= 3.1e+18) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 3.1d+18) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 3.1e+18) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 3.1e+18: tmp = 100.0 * (n / (1.0 + (i * -0.5))) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= 3.1e+18) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 3.1e+18) tmp = 100.0 * (n / (1.0 + (i * -0.5))); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 3.1e+18], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.1 \cdot 10^{+18}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < 3.1e18Initial program 31.9%
Taylor expanded in n around inf 26.0%
*-commutative26.0%
associate-/l*26.0%
expm1-define69.5%
Simplified69.5%
associate-*l*69.5%
associate-*l/69.4%
*-commutative69.4%
clear-num69.5%
un-div-inv69.4%
*-un-lft-identity69.4%
times-frac69.4%
metadata-eval69.4%
Applied egg-rr69.4%
associate-/r*69.4%
Simplified69.4%
Taylor expanded in i around 0 62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in n around 0 62.3%
if 3.1e18 < n Initial program 22.9%
Taylor expanded in n around inf 44.0%
*-commutative44.0%
associate-/l*44.0%
expm1-define96.7%
Simplified96.7%
Taylor expanded in i around 0 80.6%
associate-*r*80.6%
distribute-rgt-out80.6%
+-commutative80.6%
*-commutative80.6%
Simplified80.6%
Final simplification66.9%
(FPCore (i n) :precision binary64 (if (<= i -2.5e+19) 0.0 (if (<= i 1.7e+33) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -2.5e+19) {
tmp = 0.0;
} else if (i <= 1.7e+33) {
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.5d+19)) then
tmp = 0.0d0
else if (i <= 1.7d+33) 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.5e+19) {
tmp = 0.0;
} else if (i <= 1.7e+33) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.5e+19: tmp = 0.0 elif i <= 1.7e+33: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -2.5e+19) tmp = 0.0; elseif (i <= 1.7e+33) 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.5e+19) tmp = 0.0; elseif (i <= 1.7e+33) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.5e+19], 0.0, If[LessEqual[i, 1.7e+33], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2.5 \cdot 10^{+19}:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{+33}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -2.5e19 or 1.7e33 < i Initial program 64.6%
associate-*r/64.5%
sub-neg64.5%
distribute-rgt-in64.5%
metadata-eval64.5%
metadata-eval64.5%
Simplified64.5%
Taylor expanded in i around 0 24.2%
Taylor expanded in i around 0 24.2%
if -2.5e19 < i < 1.7e33Initial program 8.3%
Taylor expanded in i around 0 82.0%
*-commutative82.0%
Simplified82.0%
Final simplification60.1%
(FPCore (i n) :precision binary64 (if (<= i -1.6) (* (/ n i) -200.0) (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (i <= -1.6) {
tmp = (n / i) * -200.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 (i <= (-1.6d0)) then
tmp = (n / i) * (-200.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 (i <= -1.6) {
tmp = (n / i) * -200.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.6: tmp = (n / i) * -200.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (i <= -1.6) tmp = Float64(Float64(n / i) * -200.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 (i <= -1.6) tmp = (n / i) * -200.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.6], N[(N[(n / i), $MachinePrecision] * -200.0), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.6:\\
\;\;\;\;\frac{n}{i} \cdot -200\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if i < -1.6000000000000001Initial program 66.8%
Taylor expanded in n around inf 74.0%
*-commutative74.0%
associate-/l*73.8%
expm1-define73.8%
Simplified73.8%
associate-*l*73.7%
associate-*l/74.0%
*-commutative74.0%
clear-num73.8%
un-div-inv73.8%
*-un-lft-identity73.8%
times-frac73.8%
metadata-eval73.8%
Applied egg-rr73.8%
associate-/r*73.9%
Simplified73.9%
Taylor expanded in i around 0 30.1%
*-commutative30.1%
Simplified30.1%
Taylor expanded in i around inf 30.1%
if -1.6000000000000001 < i Initial program 20.6%
Taylor expanded in n around inf 20.0%
*-commutative20.0%
associate-/l*20.0%
expm1-define76.9%
Simplified76.9%
Taylor expanded in i around 0 73.1%
associate-*r*73.1%
distribute-rgt-out73.1%
+-commutative73.1%
*-commutative73.1%
Simplified73.1%
Final simplification64.7%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 29.6%
associate-*r/29.6%
sub-neg29.6%
distribute-rgt-in29.6%
metadata-eval29.6%
metadata-eval29.6%
Simplified29.6%
Taylor expanded in i around 0 13.2%
Taylor expanded in i around 0 13.5%
Final simplification13.5%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t\_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t\_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2024071
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:alt
(* 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))))