
(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 11 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 -2e-191)
(/ (* n (fma t_0 100.0 -100.0)) i)
(if (<= t_1 5e-191)
(* n (/ 100.0 (/ i (expm1 (* n (log1p (/ i n)))))))
(if (<= t_1 INFINITY)
(* n (* 100.0 (+ (/ t_0 i) (/ -1.0 i))))
(* n (/ 1.0 (+ 0.01 (* (* i 0.01) (+ (/ 0.5 n) -0.5))))))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -2e-191) {
tmp = (n * fma(t_0, 100.0, -100.0)) / i;
} else if (t_1 <= 5e-191) {
tmp = n * (100.0 / (i / expm1((n * log1p((i / n))))));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (100.0 * ((t_0 / i) + (-1.0 / i)));
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -2e-191) tmp = Float64(Float64(n * fma(t_0, 100.0, -100.0)) / i); elseif (t_1 <= 5e-191) tmp = Float64(n * Float64(100.0 / Float64(i / expm1(Float64(n * log1p(Float64(i / n))))))); elseif (t_1 <= Inf) tmp = Float64(n * Float64(100.0 * Float64(Float64(t_0 / i) + Float64(-1.0 / i)))); else tmp = Float64(n * Float64(1.0 / Float64(0.01 + Float64(Float64(i * 0.01) * Float64(Float64(0.5 / n) + -0.5))))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-191], N[(N[(n * N[(t$95$0 * 100.0 + -100.0), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[t$95$1, 5e-191], N[(n * N[(100.0 / N[(i / N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(100.0 * N[(N[(t$95$0 / i), $MachinePrecision] + N[(-1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(1.0 / N[(0.01 + N[(N[(i * 0.01), $MachinePrecision] * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $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 -2 \cdot 10^{-191}:\\
\;\;\;\;\frac{n \cdot \mathsf{fma}\left(t_0, 100, -100\right)}{i}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-191}:\\
\;\;\;\;n \cdot \frac{100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \left(100 \cdot \left(\frac{t_0}{i} + \frac{-1}{i}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{1}{0.01 + \left(i \cdot 0.01\right) \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -2e-191Initial program 99.6%
associate-/r/99.6%
associate-*r*99.7%
*-commutative99.7%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
fma-udef99.9%
*-commutative99.9%
Applied egg-rr99.9%
associate-*r/100.0%
fma-def100.0%
+-commutative100.0%
Applied egg-rr100.0%
if -2e-191 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 5.0000000000000001e-191Initial program 15.8%
associate-/r/15.7%
associate-*r*15.7%
*-commutative15.7%
associate-*r/15.7%
sub-neg15.7%
distribute-lft-in15.7%
fma-def15.7%
metadata-eval15.7%
metadata-eval15.7%
Simplified15.7%
clear-num15.7%
inv-pow15.7%
fma-udef15.7%
metadata-eval15.7%
metadata-eval15.7%
distribute-lft-in15.7%
sub-neg15.7%
*-commutative15.7%
pow-to-exp15.7%
expm1-def32.1%
add-log-exp15.7%
pow-to-exp15.7%
log-pow32.1%
log1p-udef98.1%
Applied egg-rr98.1%
unpow-198.1%
*-commutative98.1%
Simplified98.1%
clear-num98.1%
*-un-lft-identity98.1%
times-frac98.2%
metadata-eval98.2%
Applied egg-rr98.2%
clear-num98.1%
un-div-inv98.2%
Applied egg-rr98.2%
if 5.0000000000000001e-191 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.3%
associate-/r/98.2%
associate-*r*98.3%
*-commutative98.3%
associate-*r/98.3%
sub-neg98.3%
distribute-lft-in98.2%
fma-def98.3%
metadata-eval98.3%
metadata-eval98.3%
Simplified98.3%
clear-num98.3%
inv-pow98.3%
fma-udef98.2%
metadata-eval98.2%
metadata-eval98.2%
distribute-lft-in98.3%
sub-neg98.3%
*-commutative98.3%
pow-to-exp66.8%
expm1-def68.4%
add-log-exp66.8%
pow-to-exp98.3%
log-pow68.4%
log1p-udef68.4%
Applied egg-rr68.4%
unpow-168.4%
*-commutative68.4%
Simplified68.4%
clear-num68.3%
*-un-lft-identity68.3%
times-frac68.2%
metadata-eval68.2%
Applied egg-rr68.2%
expm1-udef66.8%
div-sub66.9%
*-commutative66.9%
log1p-udef66.9%
exp-to-pow98.4%
Applied egg-rr98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.8%
associate-*r*1.8%
*-commutative1.8%
associate-*r/1.8%
sub-neg1.8%
distribute-lft-in1.8%
fma-def1.8%
metadata-eval1.8%
metadata-eval1.8%
Simplified1.8%
clear-num1.8%
inv-pow1.8%
fma-udef1.8%
metadata-eval1.8%
metadata-eval1.8%
distribute-lft-in1.8%
sub-neg1.8%
*-commutative1.8%
pow-to-exp1.8%
expm1-def1.8%
add-log-exp1.8%
pow-to-exp1.8%
log-pow1.8%
log1p-udef1.8%
Applied egg-rr1.8%
unpow-11.8%
*-commutative1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
associate-*r/99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.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))))
(if (<= t_1 -5e-42)
(* n (/ (+ -100.0 (* t_0 100.0)) i))
(if (<= t_1 5e-191)
(* n (* 100.0 (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_1 INFINITY)
(* n (* 100.0 (+ (/ t_0 i) (/ -1.0 i))))
(* n (/ 1.0 (+ 0.01 (* (* i 0.01) (+ (/ 0.5 n) -0.5))))))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -5e-42) {
tmp = n * ((-100.0 + (t_0 * 100.0)) / i);
} else if (t_1 <= 5e-191) {
tmp = n * (100.0 * (expm1((n * log1p((i / n)))) / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (100.0 * ((t_0 / i) + (-1.0 / i)));
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -5e-42) {
tmp = n * ((-100.0 + (t_0 * 100.0)) / i);
} else if (t_1 <= 5e-191) {
tmp = n * (100.0 * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = n * (100.0 * ((t_0 / i) + (-1.0 / i)));
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= -5e-42: tmp = n * ((-100.0 + (t_0 * 100.0)) / i) elif t_1 <= 5e-191: tmp = n * (100.0 * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_1 <= math.inf: tmp = n * (100.0 * ((t_0 / i) + (-1.0 / i))) else: tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))) return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -5e-42) tmp = Float64(n * Float64(Float64(-100.0 + Float64(t_0 * 100.0)) / i)); elseif (t_1 <= 5e-191) tmp = Float64(n * Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_1 <= Inf) tmp = Float64(n * Float64(100.0 * Float64(Float64(t_0 / i) + Float64(-1.0 / i)))); else tmp = Float64(n * Float64(1.0 / Float64(0.01 + Float64(Float64(i * 0.01) * Float64(Float64(0.5 / n) + -0.5))))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-42], N[(n * N[(N[(-100.0 + N[(t$95$0 * 100.0), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-191], N[(n * N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(100.0 * N[(N[(t$95$0 / i), $MachinePrecision] + N[(-1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(1.0 / N[(0.01 + N[(N[(i * 0.01), $MachinePrecision] * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-42}:\\
\;\;\;\;n \cdot \frac{-100 + t_0 \cdot 100}{i}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-191}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;n \cdot \left(100 \cdot \left(\frac{t_0}{i} + \frac{-1}{i}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{1}{0.01 + \left(i \cdot 0.01\right) \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -5.00000000000000003e-42Initial program 99.7%
associate-/r/99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r/100.0%
sub-neg100.0%
distribute-lft-in100.0%
fma-def100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
fma-udef100.0%
*-commutative100.0%
Applied egg-rr100.0%
if -5.00000000000000003e-42 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 5.0000000000000001e-191Initial program 16.7%
associate-/r/16.6%
associate-*r*16.6%
*-commutative16.6%
associate-*r/16.6%
sub-neg16.6%
distribute-lft-in16.6%
fma-def16.6%
metadata-eval16.6%
metadata-eval16.6%
Simplified16.6%
clear-num16.6%
inv-pow16.6%
fma-udef16.6%
metadata-eval16.6%
metadata-eval16.6%
distribute-lft-in16.6%
sub-neg16.6%
*-commutative16.6%
pow-to-exp16.6%
expm1-def32.8%
add-log-exp16.6%
pow-to-exp16.6%
log-pow32.8%
log1p-udef98.1%
Applied egg-rr98.1%
unpow-198.1%
*-commutative98.1%
Simplified98.1%
clear-num98.1%
*-un-lft-identity98.1%
times-frac98.2%
metadata-eval98.2%
Applied egg-rr98.2%
if 5.0000000000000001e-191 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.3%
associate-/r/98.2%
associate-*r*98.3%
*-commutative98.3%
associate-*r/98.3%
sub-neg98.3%
distribute-lft-in98.2%
fma-def98.3%
metadata-eval98.3%
metadata-eval98.3%
Simplified98.3%
clear-num98.3%
inv-pow98.3%
fma-udef98.2%
metadata-eval98.2%
metadata-eval98.2%
distribute-lft-in98.3%
sub-neg98.3%
*-commutative98.3%
pow-to-exp66.8%
expm1-def68.4%
add-log-exp66.8%
pow-to-exp98.3%
log-pow68.4%
log1p-udef68.4%
Applied egg-rr68.4%
unpow-168.4%
*-commutative68.4%
Simplified68.4%
clear-num68.3%
*-un-lft-identity68.3%
times-frac68.2%
metadata-eval68.2%
Applied egg-rr68.2%
expm1-udef66.8%
div-sub66.9%
*-commutative66.9%
log1p-udef66.9%
exp-to-pow98.4%
Applied egg-rr98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.8%
associate-*r*1.8%
*-commutative1.8%
associate-*r/1.8%
sub-neg1.8%
distribute-lft-in1.8%
fma-def1.8%
metadata-eval1.8%
metadata-eval1.8%
Simplified1.8%
clear-num1.8%
inv-pow1.8%
fma-udef1.8%
metadata-eval1.8%
metadata-eval1.8%
distribute-lft-in1.8%
sub-neg1.8%
*-commutative1.8%
pow-to-exp1.8%
expm1-def1.8%
add-log-exp1.8%
pow-to-exp1.8%
log-pow1.8%
log1p-udef1.8%
Applied egg-rr1.8%
unpow-11.8%
*-commutative1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
associate-*r/99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification98.6%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (+ t_0 -1.0)) (t_2 (/ t_1 (/ i n))))
(if (<= t_2 (- INFINITY))
(* 100.0 (* (/ n i) t_1))
(if (<= t_2 5e-191)
(* n (/ 100.0 (/ i (expm1 (* n (log1p (/ i n)))))))
(if (<= t_2 INFINITY)
(* n (* 100.0 (+ (/ t_0 i) (/ -1.0 i))))
(* n (/ 1.0 (+ 0.01 (* (* i 0.01) (+ (/ 0.5 n) -0.5))))))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = t_0 + -1.0;
double t_2 = t_1 / (i / n);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = 100.0 * ((n / i) * t_1);
} else if (t_2 <= 5e-191) {
tmp = n * (100.0 / (i / expm1((n * log1p((i / n))))));
} else if (t_2 <= ((double) INFINITY)) {
tmp = n * (100.0 * ((t_0 / i) + (-1.0 / i)));
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = t_0 + -1.0;
double t_2 = t_1 / (i / n);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((n / i) * t_1);
} else if (t_2 <= 5e-191) {
tmp = n * (100.0 / (i / Math.expm1((n * Math.log1p((i / n))))));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = n * (100.0 * ((t_0 / i) + (-1.0 / i)));
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = t_0 + -1.0 t_2 = t_1 / (i / n) tmp = 0 if t_2 <= -math.inf: tmp = 100.0 * ((n / i) * t_1) elif t_2 <= 5e-191: tmp = n * (100.0 / (i / math.expm1((n * math.log1p((i / n)))))) elif t_2 <= math.inf: tmp = n * (100.0 * ((t_0 / i) + (-1.0 / i))) else: tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))) return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(t_0 + -1.0) t_2 = Float64(t_1 / Float64(i / n)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(100.0 * Float64(Float64(n / i) * t_1)); elseif (t_2 <= 5e-191) tmp = Float64(n * Float64(100.0 / Float64(i / expm1(Float64(n * log1p(Float64(i / n))))))); elseif (t_2 <= Inf) tmp = Float64(n * Float64(100.0 * Float64(Float64(t_0 / i) + Float64(-1.0 / i)))); else tmp = Float64(n * Float64(1.0 / Float64(0.01 + Float64(Float64(i * 0.01) * Float64(Float64(0.5 / n) + -0.5))))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + -1.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(100.0 * N[(N[(n / i), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-191], N[(n * N[(100.0 / N[(i / N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(n * N[(100.0 * N[(N[(t$95$0 / i), $MachinePrecision] + N[(-1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(1.0 / N[(0.01 + N[(N[(i * 0.01), $MachinePrecision] * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := t_0 + -1\\
t_2 := \frac{t_1}{\frac{i}{n}}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;100 \cdot \left(\frac{n}{i} \cdot t_1\right)\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-191}:\\
\;\;\;\;n \cdot \frac{100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;n \cdot \left(100 \cdot \left(\frac{t_0}{i} + \frac{-1}{i}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{1}{0.01 + \left(i \cdot 0.01\right) \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -inf.0Initial program 100.0%
div-sub100.0%
clear-num100.0%
sub-neg100.0%
div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
+-commutative100.0%
neg-mul-1100.0%
distribute-rgt-out100.0%
Simplified100.0%
if -inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 5.0000000000000001e-191Initial program 18.1%
associate-/r/17.9%
associate-*r*18.0%
*-commutative18.0%
associate-*r/18.0%
sub-neg18.0%
distribute-lft-in18.0%
fma-def18.0%
metadata-eval18.0%
metadata-eval18.0%
Simplified18.0%
clear-num18.0%
inv-pow18.0%
fma-udef18.0%
metadata-eval18.0%
metadata-eval18.0%
distribute-lft-in18.0%
sub-neg18.0%
*-commutative18.0%
pow-to-exp18.0%
expm1-def33.9%
add-log-exp18.0%
pow-to-exp18.0%
log-pow33.9%
log1p-udef98.1%
Applied egg-rr98.1%
unpow-198.1%
*-commutative98.1%
Simplified98.1%
clear-num98.1%
*-un-lft-identity98.1%
times-frac98.2%
metadata-eval98.2%
Applied egg-rr98.2%
clear-num98.1%
un-div-inv98.2%
Applied egg-rr98.2%
if 5.0000000000000001e-191 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.3%
associate-/r/98.2%
associate-*r*98.3%
*-commutative98.3%
associate-*r/98.3%
sub-neg98.3%
distribute-lft-in98.2%
fma-def98.3%
metadata-eval98.3%
metadata-eval98.3%
Simplified98.3%
clear-num98.3%
inv-pow98.3%
fma-udef98.2%
metadata-eval98.2%
metadata-eval98.2%
distribute-lft-in98.3%
sub-neg98.3%
*-commutative98.3%
pow-to-exp66.8%
expm1-def68.4%
add-log-exp66.8%
pow-to-exp98.3%
log-pow68.4%
log1p-udef68.4%
Applied egg-rr68.4%
unpow-168.4%
*-commutative68.4%
Simplified68.4%
clear-num68.3%
*-un-lft-identity68.3%
times-frac68.2%
metadata-eval68.2%
Applied egg-rr68.2%
expm1-udef66.8%
div-sub66.9%
*-commutative66.9%
log1p-udef66.9%
exp-to-pow98.4%
Applied egg-rr98.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.8%
associate-*r*1.8%
*-commutative1.8%
associate-*r/1.8%
sub-neg1.8%
distribute-lft-in1.8%
fma-def1.8%
metadata-eval1.8%
metadata-eval1.8%
Simplified1.8%
clear-num1.8%
inv-pow1.8%
fma-udef1.8%
metadata-eval1.8%
metadata-eval1.8%
distribute-lft-in1.8%
sub-neg1.8%
*-commutative1.8%
pow-to-exp1.8%
expm1-def1.8%
add-log-exp1.8%
pow-to-exp1.8%
log-pow1.8%
log1p-udef1.8%
Applied egg-rr1.8%
unpow-11.8%
*-commutative1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
associate-*r/99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification98.6%
(FPCore (i n) :precision binary64 (if (or (<= i -1.75e+15) (not (<= i 1.35e-5))) (* (expm1 i) (/ (* n 100.0) i)) (* n (/ 1.0 (+ 0.01 (* (* i 0.01) (+ (/ 0.5 n) -0.5)))))))
double code(double i, double n) {
double tmp;
if ((i <= -1.75e+15) || !(i <= 1.35e-5)) {
tmp = expm1(i) * ((n * 100.0) / i);
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -1.75e+15) || !(i <= 1.35e-5)) {
tmp = Math.expm1(i) * ((n * 100.0) / i);
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -1.75e+15) or not (i <= 1.35e-5): tmp = math.expm1(i) * ((n * 100.0) / i) else: tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))) return tmp
function code(i, n) tmp = 0.0 if ((i <= -1.75e+15) || !(i <= 1.35e-5)) tmp = Float64(expm1(i) * Float64(Float64(n * 100.0) / i)); else tmp = Float64(n * Float64(1.0 / Float64(0.01 + Float64(Float64(i * 0.01) * Float64(Float64(0.5 / n) + -0.5))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -1.75e+15], N[Not[LessEqual[i, 1.35e-5]], $MachinePrecision]], N[(N[(Exp[i] - 1), $MachinePrecision] * N[(N[(n * 100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n * N[(1.0 / N[(0.01 + N[(N[(i * 0.01), $MachinePrecision] * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.75 \cdot 10^{+15} \lor \neg \left(i \leq 1.35 \cdot 10^{-5}\right):\\
\;\;\;\;\mathsf{expm1}\left(i\right) \cdot \frac{n \cdot 100}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{1}{0.01 + \left(i \cdot 0.01\right) \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if i < -1.75e15 or 1.3499999999999999e-5 < i Initial program 47.6%
associate-*r/47.7%
sub-neg47.7%
distribute-lft-in47.7%
metadata-eval47.7%
metadata-eval47.7%
fma-udef47.7%
associate-/r/47.6%
*-commutative47.6%
expm1-log1p-u37.9%
expm1-udef27.8%
Applied egg-rr44.3%
expm1-def62.1%
expm1-log1p77.4%
associate-*l/76.5%
Simplified76.5%
Taylor expanded in n around inf 57.3%
if -1.75e15 < i < 1.3499999999999999e-5Initial program 7.6%
associate-/r/8.0%
associate-*r*8.0%
*-commutative8.0%
associate-*r/8.0%
sub-neg8.0%
distribute-lft-in8.0%
fma-def8.0%
metadata-eval8.0%
metadata-eval8.0%
Simplified8.0%
clear-num8.0%
inv-pow8.0%
fma-udef8.0%
metadata-eval8.0%
metadata-eval8.0%
distribute-lft-in8.0%
sub-neg8.0%
*-commutative8.0%
pow-to-exp8.0%
expm1-def18.5%
add-log-exp8.0%
pow-to-exp8.0%
log-pow18.5%
log1p-udef76.1%
Applied egg-rr76.1%
unpow-176.1%
*-commutative76.1%
Simplified76.1%
Taylor expanded in i around 0 90.7%
associate-*r*90.7%
*-commutative90.7%
sub-neg90.7%
associate-*r/90.7%
metadata-eval90.7%
metadata-eval90.7%
Simplified90.7%
Final simplification77.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.16e+64) (not (<= n 1.55))) (* 100.0 (/ (* n (expm1 i)) i)) (* n (/ 1.0 (+ 0.01 (* (* i 0.01) (+ (/ 0.5 n) -0.5)))))))
double code(double i, double n) {
double tmp;
if ((n <= -1.16e+64) || !(n <= 1.55)) {
tmp = 100.0 * ((n * expm1(i)) / i);
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.16e+64) || !(n <= 1.55)) {
tmp = 100.0 * ((n * Math.expm1(i)) / i);
} else {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.16e+64) or not (n <= 1.55): tmp = 100.0 * ((n * math.expm1(i)) / i) else: tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.16e+64) || !(n <= 1.55)) tmp = Float64(100.0 * Float64(Float64(n * expm1(i)) / i)); else tmp = Float64(n * Float64(1.0 / Float64(0.01 + Float64(Float64(i * 0.01) * Float64(Float64(0.5 / n) + -0.5))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.16e+64], N[Not[LessEqual[n, 1.55]], $MachinePrecision]], N[(100.0 * N[(N[(n * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n * N[(1.0 / N[(0.01 + N[(N[(i * 0.01), $MachinePrecision] * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.16 \cdot 10^{+64} \lor \neg \left(n \leq 1.55\right):\\
\;\;\;\;100 \cdot \frac{n \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{1}{0.01 + \left(i \cdot 0.01\right) \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\end{array}
\end{array}
if n < -1.16e64 or 1.55000000000000004 < n Initial program 22.8%
Taylor expanded in n around inf 36.7%
*-commutative36.7%
expm1-def90.4%
Simplified90.4%
if -1.16e64 < n < 1.55000000000000004Initial program 25.3%
associate-/r/25.2%
associate-*r*25.2%
*-commutative25.2%
associate-*r/25.2%
sub-neg25.2%
distribute-lft-in25.2%
fma-def25.2%
metadata-eval25.2%
metadata-eval25.2%
Simplified25.2%
clear-num25.2%
inv-pow25.2%
fma-udef25.2%
metadata-eval25.2%
metadata-eval25.2%
distribute-lft-in25.2%
sub-neg25.2%
*-commutative25.2%
pow-to-exp25.2%
expm1-def52.8%
add-log-exp25.2%
pow-to-exp25.2%
log-pow52.8%
log1p-udef91.2%
Applied egg-rr91.2%
unpow-191.2%
*-commutative91.2%
Simplified91.2%
Taylor expanded in i around 0 74.1%
associate-*r*74.1%
*-commutative74.1%
sub-neg74.1%
associate-*r/74.1%
metadata-eval74.1%
metadata-eval74.1%
Simplified74.1%
Final simplification83.5%
(FPCore (i n) :precision binary64 (if (<= n 0.095) (* n (/ 1.0 (+ 0.01 (* (* i 0.01) (+ (/ 0.5 n) -0.5))))) (* n (/ (* 100.0 (+ i (* (* i i) (- 0.5 (/ 0.5 n))))) i))))
double code(double i, double n) {
double tmp;
if (n <= 0.095) {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
} else {
tmp = n * ((100.0 * (i + ((i * i) * (0.5 - (0.5 / n))))) / i);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 0.095d0) then
tmp = n * (1.0d0 / (0.01d0 + ((i * 0.01d0) * ((0.5d0 / n) + (-0.5d0)))))
else
tmp = n * ((100.0d0 * (i + ((i * i) * (0.5d0 - (0.5d0 / n))))) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 0.095) {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
} else {
tmp = n * ((100.0 * (i + ((i * i) * (0.5 - (0.5 / n))))) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 0.095: tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))) else: tmp = n * ((100.0 * (i + ((i * i) * (0.5 - (0.5 / n))))) / i) return tmp
function code(i, n) tmp = 0.0 if (n <= 0.095) tmp = Float64(n * Float64(1.0 / Float64(0.01 + Float64(Float64(i * 0.01) * Float64(Float64(0.5 / n) + -0.5))))); else tmp = Float64(n * Float64(Float64(100.0 * Float64(i + Float64(Float64(i * i) * Float64(0.5 - Float64(0.5 / n))))) / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 0.095) tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))); else tmp = n * ((100.0 * (i + ((i * i) * (0.5 - (0.5 / n))))) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 0.095], N[(n * N[(1.0 / N[(0.01 + N[(N[(i * 0.01), $MachinePrecision] * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(N[(100.0 * N[(i + N[(N[(i * i), $MachinePrecision] * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.095:\\
\;\;\;\;n \cdot \frac{1}{0.01 + \left(i \cdot 0.01\right) \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{100 \cdot \left(i + \left(i \cdot i\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)}{i}\\
\end{array}
\end{array}
if n < 0.095000000000000001Initial program 24.5%
associate-/r/24.6%
associate-*r*24.6%
*-commutative24.6%
associate-*r/24.6%
sub-neg24.6%
distribute-lft-in24.6%
fma-def24.6%
metadata-eval24.6%
metadata-eval24.6%
Simplified24.6%
clear-num24.6%
inv-pow24.6%
fma-udef24.6%
metadata-eval24.6%
metadata-eval24.6%
distribute-lft-in24.6%
sub-neg24.6%
*-commutative24.6%
pow-to-exp20.9%
expm1-def39.2%
add-log-exp20.9%
pow-to-exp24.6%
log-pow39.2%
log1p-udef80.7%
Applied egg-rr80.7%
unpow-180.7%
*-commutative80.7%
Simplified80.7%
Taylor expanded in i around 0 69.3%
associate-*r*69.3%
*-commutative69.3%
sub-neg69.3%
associate-*r/69.3%
metadata-eval69.3%
metadata-eval69.3%
Simplified69.3%
if 0.095000000000000001 < n Initial program 22.9%
associate-/r/23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*r/23.2%
sub-neg23.2%
distribute-lft-in23.2%
fma-def23.2%
metadata-eval23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in i around 0 78.9%
distribute-lft-out78.9%
unpow278.9%
associate-*r/78.9%
metadata-eval78.9%
Simplified78.9%
Final simplification72.8%
(FPCore (i n)
:precision binary64
(if (<= i -0.64)
0.0
(if (<= i 3.2e-21)
(* 100.0 (+ n (* (- 0.5 (/ 0.5 n)) (* i n))))
(* 100.0 (/ (+ i (* 0.5 (* i i))) (/ i n))))))
double code(double i, double n) {
double tmp;
if (i <= -0.64) {
tmp = 0.0;
} else if (i <= 3.2e-21) {
tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n)));
} else {
tmp = 100.0 * ((i + (0.5 * (i * i))) / (i / n));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-0.64d0)) then
tmp = 0.0d0
else if (i <= 3.2d-21) then
tmp = 100.0d0 * (n + ((0.5d0 - (0.5d0 / n)) * (i * n)))
else
tmp = 100.0d0 * ((i + (0.5d0 * (i * i))) / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -0.64) {
tmp = 0.0;
} else if (i <= 3.2e-21) {
tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n)));
} else {
tmp = 100.0 * ((i + (0.5 * (i * i))) / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -0.64: tmp = 0.0 elif i <= 3.2e-21: tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n))) else: tmp = 100.0 * ((i + (0.5 * (i * i))) / (i / n)) return tmp
function code(i, n) tmp = 0.0 if (i <= -0.64) tmp = 0.0; elseif (i <= 3.2e-21) tmp = Float64(100.0 * Float64(n + Float64(Float64(0.5 - Float64(0.5 / n)) * Float64(i * n)))); else tmp = Float64(100.0 * Float64(Float64(i + Float64(0.5 * Float64(i * i))) / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -0.64) tmp = 0.0; elseif (i <= 3.2e-21) tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n))); else tmp = 100.0 * ((i + (0.5 * (i * i))) / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -0.64], 0.0, If[LessEqual[i, 3.2e-21], N[(100.0 * N[(n + N[(N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(i + N[(0.5 * N[(i * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -0.64:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 3.2 \cdot 10^{-21}:\\
\;\;\;\;100 \cdot \left(n + \left(0.5 - \frac{0.5}{n}\right) \cdot \left(i \cdot n\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i + 0.5 \cdot \left(i \cdot i\right)}{\frac{i}{n}}\\
\end{array}
\end{array}
if i < -0.640000000000000013Initial program 58.7%
Taylor expanded in i around 0 31.0%
Taylor expanded in i around 0 31.0%
if -0.640000000000000013 < i < 3.2000000000000002e-21Initial program 6.5%
Taylor expanded in i around 0 87.2%
associate-*r*87.5%
*-commutative87.5%
associate-*r/87.5%
metadata-eval87.5%
Simplified87.5%
if 3.2000000000000002e-21 < i Initial program 37.0%
associate-/r/37.2%
associate-*r*37.2%
*-commutative37.2%
associate-*r/37.2%
sub-neg37.2%
distribute-lft-in37.2%
fma-def37.2%
metadata-eval37.2%
metadata-eval37.2%
Simplified37.2%
Taylor expanded in i around 0 35.5%
distribute-lft-out35.5%
unpow235.5%
associate-*r/35.5%
metadata-eval35.5%
Simplified35.5%
Taylor expanded in n around inf 37.5%
associate-/l*40.5%
*-commutative40.5%
unpow240.5%
Simplified40.5%
Final simplification65.3%
(FPCore (i n) :precision binary64 (if (<= n 0.095) (* n (/ 1.0 (+ 0.01 (* (* i 0.01) (+ (/ 0.5 n) -0.5))))) (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (n <= 0.095) {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 0.095d0) then
tmp = n * (1.0d0 / (0.01d0 + ((i * 0.01d0) * ((0.5d0 / n) + (-0.5d0)))))
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 0.095) {
tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5))));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 0.095: tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= 0.095) tmp = Float64(n * Float64(1.0 / Float64(0.01 + Float64(Float64(i * 0.01) * Float64(Float64(0.5 / n) + -0.5))))); else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 0.095) tmp = n * (1.0 / (0.01 + ((i * 0.01) * ((0.5 / n) + -0.5)))); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 0.095], N[(n * N[(1.0 / N[(0.01 + N[(N[(i * 0.01), $MachinePrecision] * N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision]), $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 0.095:\\
\;\;\;\;n \cdot \frac{1}{0.01 + \left(i \cdot 0.01\right) \cdot \left(\frac{0.5}{n} + -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < 0.095000000000000001Initial program 24.5%
associate-/r/24.6%
associate-*r*24.6%
*-commutative24.6%
associate-*r/24.6%
sub-neg24.6%
distribute-lft-in24.6%
fma-def24.6%
metadata-eval24.6%
metadata-eval24.6%
Simplified24.6%
clear-num24.6%
inv-pow24.6%
fma-udef24.6%
metadata-eval24.6%
metadata-eval24.6%
distribute-lft-in24.6%
sub-neg24.6%
*-commutative24.6%
pow-to-exp20.9%
expm1-def39.2%
add-log-exp20.9%
pow-to-exp24.6%
log-pow39.2%
log1p-udef80.7%
Applied egg-rr80.7%
unpow-180.7%
*-commutative80.7%
Simplified80.7%
Taylor expanded in i around 0 69.3%
associate-*r*69.3%
*-commutative69.3%
sub-neg69.3%
associate-*r/69.3%
metadata-eval69.3%
metadata-eval69.3%
Simplified69.3%
if 0.095000000000000001 < n Initial program 22.9%
associate-/r/23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*r/23.2%
sub-neg23.2%
distribute-lft-in23.2%
fma-def23.2%
metadata-eval23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in i around 0 74.0%
associate-*r*74.0%
*-commutative74.0%
associate-*r/74.0%
metadata-eval74.0%
Simplified74.0%
Taylor expanded in n around inf 74.0%
*-commutative74.0%
Simplified74.0%
Final simplification71.0%
(FPCore (i n) :precision binary64 (if (<= i -1.82) 0.0 (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (i <= -1.82) {
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 (i <= (-1.82d0)) 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 (i <= -1.82) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.82: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (i <= -1.82) 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 (i <= -1.82) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.82], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.82:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if i < -1.82000000000000006Initial program 58.7%
Taylor expanded in i around 0 31.0%
Taylor expanded in i around 0 31.0%
if -1.82000000000000006 < i Initial program 15.6%
associate-/r/16.0%
associate-*r*16.0%
*-commutative16.0%
associate-*r/16.0%
sub-neg16.0%
distribute-lft-in16.0%
fma-def16.0%
metadata-eval16.0%
metadata-eval16.0%
Simplified16.0%
Taylor expanded in i around 0 70.8%
associate-*r*70.8%
*-commutative70.8%
associate-*r/70.8%
metadata-eval70.8%
Simplified70.8%
Taylor expanded in n around inf 71.2%
*-commutative71.2%
Simplified71.2%
Final simplification63.5%
(FPCore (i n) :precision binary64 (if (<= i -750000.0) 0.0 (if (<= i 1700000.0) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -750000.0) {
tmp = 0.0;
} else if (i <= 1700000.0) {
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 <= (-750000.0d0)) then
tmp = 0.0d0
else if (i <= 1700000.0d0) 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 <= -750000.0) {
tmp = 0.0;
} else if (i <= 1700000.0) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -750000.0: tmp = 0.0 elif i <= 1700000.0: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -750000.0) tmp = 0.0; elseif (i <= 1700000.0) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -750000.0) tmp = 0.0; elseif (i <= 1700000.0) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -750000.0], 0.0, If[LessEqual[i, 1700000.0], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -750000:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 1700000:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -7.5e5 or 1.7e6 < i Initial program 49.1%
Taylor expanded in i around 0 26.1%
Taylor expanded in i around 0 26.1%
if -7.5e5 < i < 1.7e6Initial program 6.3%
Taylor expanded in i around 0 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification60.9%
(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 23.9%
Taylor expanded in i around 0 14.5%
Taylor expanded in i around 0 14.7%
Final simplification14.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2023192
(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))))