
(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)
(* 100.0 (- (/ t_0 (/ i n)) (/ n i)))
(/ 1.0 (+ (* (/ i n) -0.005) (* 0.01 (/ 1.0 n))))))))
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 / (i / n)) - (n / i));
} else {
tmp = 1.0 / (((i / n) * -0.005) + (0.01 * (1.0 / n)));
}
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 / (i / n)) - (n / i));
} else {
tmp = 1.0 / (((i / n) * -0.005) + (0.01 * (1.0 / n)));
}
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 / (i / n)) - (n / i)) else: tmp = 1.0 / (((i / n) * -0.005) + (0.01 * (1.0 / n))) 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(i / n)) - Float64(n / i))); else tmp = Float64(1.0 / Float64(Float64(Float64(i / n) * -0.005) + Float64(0.01 * Float64(1.0 / n)))); 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[(i / n), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(i / n), $MachinePrecision] * -0.005), $MachinePrecision] + N[(0.01 * N[(1.0 / n), $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(\frac{t_0}{\frac{i}{n}} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{i}{n} \cdot -0.005 + 0.01 \cdot \frac{1}{n}}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 22.1%
*-un-lft-identity22.1%
add-exp-log22.1%
expm1-def22.1%
log-pow29.4%
log1p-udef99.2%
Applied egg-rr99.2%
*-lft-identity99.2%
Simplified99.2%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
*-un-lft-identity99.9%
add-exp-log99.9%
expm1-def99.9%
log-pow76.2%
log1p-udef76.2%
Applied egg-rr76.2%
*-lft-identity76.2%
Simplified76.2%
expm1-udef76.2%
div-sub76.2%
*-commutative76.2%
log1p-udef76.2%
exp-to-pow99.9%
+-commutative99.9%
clear-num99.9%
Applied egg-rr99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 0.0%
expm1-def4.5%
Simplified4.5%
associate-*r/4.5%
div-inv4.5%
associate-/r*78.1%
Applied egg-rr78.1%
clear-num78.1%
inv-pow78.1%
div-inv78.0%
clear-num78.1%
associate-/r*77.7%
Applied egg-rr77.7%
unpow-177.7%
associate-*l/77.7%
*-lft-identity77.7%
associate-/l/78.0%
*-commutative78.0%
Simplified78.0%
Taylor expanded in i around 0 99.8%
Final simplification99.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)))) (/ n i)))
(if (<= t_1 INFINITY)
(* 100.0 (- (/ t_0 (/ i n)) (/ n i)))
(/ 1.0 (+ (* (/ i n) -0.005) (* 0.01 (/ 1.0 n))))))))
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)))) * (n / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 / (i / n)) - (n / i));
} else {
tmp = 1.0 / (((i / n) * -0.005) + (0.01 * (1.0 / n)));
}
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)))) * (n / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 / (i / n)) - (n / i));
} else {
tmp = 1.0 / (((i / n) * -0.005) + (0.01 * (1.0 / n)));
}
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)))) * (n / i)) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 / (i / n)) - (n / i)) else: tmp = 1.0 / (((i / n) * -0.005) + (0.01 * (1.0 / n))) 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(n / i))); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 / Float64(i / n)) - Float64(n / i))); else tmp = Float64(1.0 / Float64(Float64(Float64(i / n) * -0.005) + Float64(0.01 * Float64(1.0 / n)))); 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[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 / N[(i / n), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(i / n), $MachinePrecision] * -0.005), $MachinePrecision] + N[(0.01 * N[(1.0 / n), $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 \left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(\frac{t_0}{\frac{i}{n}} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{i}{n} \cdot -0.005 + 0.01 \cdot \frac{1}{n}}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 22.1%
clear-num22.1%
associate-/r/22.1%
clear-num21.7%
add-exp-log21.7%
expm1-def21.7%
log-pow29.1%
log1p-udef97.8%
Applied egg-rr97.8%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
*-un-lft-identity99.9%
add-exp-log99.9%
expm1-def99.9%
log-pow76.2%
log1p-udef76.2%
Applied egg-rr76.2%
*-lft-identity76.2%
Simplified76.2%
expm1-udef76.2%
div-sub76.2%
*-commutative76.2%
log1p-udef76.2%
exp-to-pow99.9%
+-commutative99.9%
clear-num99.9%
Applied egg-rr99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 0.0%
expm1-def4.5%
Simplified4.5%
associate-*r/4.5%
div-inv4.5%
associate-/r*78.1%
Applied egg-rr78.1%
clear-num78.1%
inv-pow78.1%
div-inv78.0%
clear-num78.1%
associate-/r*77.7%
Applied egg-rr77.7%
unpow-177.7%
associate-*l/77.7%
*-lft-identity77.7%
associate-/l/78.0%
*-commutative78.0%
Simplified78.0%
Taylor expanded in i around 0 99.8%
Final simplification98.3%
(FPCore (i n)
:precision binary64
(if (<= n -3.1e-201)
(/ 1.0 (/ (/ i (* 100.0 (expm1 i))) n))
(if (<= n 9.5e-207)
(/ 0.0 (/ i n))
(if (<= n 8.4e-20)
(/
1.0
(/ (+ 0.01 (+ (* i -0.005) (* 0.0008333333333333334 (pow i 2.0)))) n))
(* n (/ 100.0 (/ i (expm1 i))))))))
double code(double i, double n) {
double tmp;
if (n <= -3.1e-201) {
tmp = 1.0 / ((i / (100.0 * expm1(i))) / n);
} else if (n <= 9.5e-207) {
tmp = 0.0 / (i / n);
} else if (n <= 8.4e-20) {
tmp = 1.0 / ((0.01 + ((i * -0.005) + (0.0008333333333333334 * pow(i, 2.0)))) / n);
} else {
tmp = n * (100.0 / (i / expm1(i)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -3.1e-201) {
tmp = 1.0 / ((i / (100.0 * Math.expm1(i))) / n);
} else if (n <= 9.5e-207) {
tmp = 0.0 / (i / n);
} else if (n <= 8.4e-20) {
tmp = 1.0 / ((0.01 + ((i * -0.005) + (0.0008333333333333334 * Math.pow(i, 2.0)))) / n);
} else {
tmp = n * (100.0 / (i / Math.expm1(i)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.1e-201: tmp = 1.0 / ((i / (100.0 * math.expm1(i))) / n) elif n <= 9.5e-207: tmp = 0.0 / (i / n) elif n <= 8.4e-20: tmp = 1.0 / ((0.01 + ((i * -0.005) + (0.0008333333333333334 * math.pow(i, 2.0)))) / n) else: tmp = n * (100.0 / (i / math.expm1(i))) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.1e-201) tmp = Float64(1.0 / Float64(Float64(i / Float64(100.0 * expm1(i))) / n)); elseif (n <= 9.5e-207) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 8.4e-20) tmp = Float64(1.0 / Float64(Float64(0.01 + Float64(Float64(i * -0.005) + Float64(0.0008333333333333334 * (i ^ 2.0)))) / n)); else tmp = Float64(n * Float64(100.0 / Float64(i / expm1(i)))); end return tmp end
code[i_, n_] := If[LessEqual[n, -3.1e-201], N[(1.0 / N[(N[(i / N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 9.5e-207], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.4e-20], N[(1.0 / N[(N[(0.01 + N[(N[(i * -0.005), $MachinePrecision] + N[(0.0008333333333333334 * N[Power[i, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.1 \cdot 10^{-201}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{100 \cdot \mathsf{expm1}\left(i\right)}}{n}}\\
\mathbf{elif}\;n \leq 9.5 \cdot 10^{-207}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 8.4 \cdot 10^{-20}:\\
\;\;\;\;\frac{1}{\frac{0.01 + \left(i \cdot -0.005 + 0.0008333333333333334 \cdot {i}^{2}\right)}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\end{array}
\end{array}
if n < -3.0999999999999999e-201Initial program 22.1%
Taylor expanded in n around inf 33.2%
expm1-def71.8%
Simplified71.8%
associate-*r/71.7%
div-inv71.5%
associate-/r*84.3%
Applied egg-rr84.3%
clear-num84.8%
inv-pow84.8%
div-inv84.7%
clear-num84.8%
associate-/r*84.7%
Applied egg-rr84.7%
unpow-184.7%
associate-*l/84.9%
*-lft-identity84.9%
associate-/l/84.9%
*-commutative84.9%
Simplified84.9%
if -3.0999999999999999e-201 < n < 9.50000000000000007e-207Initial program 65.4%
associate-*r/65.4%
sub-neg65.4%
distribute-lft-in65.4%
metadata-eval65.4%
metadata-eval65.4%
Simplified65.4%
Taylor expanded in i around 0 85.4%
if 9.50000000000000007e-207 < n < 8.3999999999999996e-20Initial program 9.6%
Taylor expanded in n around inf 3.3%
expm1-def62.6%
Simplified62.6%
associate-*r/62.2%
div-inv62.1%
associate-/r*62.7%
Applied egg-rr62.7%
clear-num62.6%
inv-pow62.6%
div-inv62.5%
clear-num62.4%
associate-/r*62.5%
Applied egg-rr62.5%
unpow-162.5%
associate-*l/62.6%
*-lft-identity62.6%
associate-/l/62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in i around 0 84.1%
if 8.3999999999999996e-20 < n Initial program 21.7%
Taylor expanded in n around inf 47.6%
expm1-def80.7%
Simplified80.7%
clear-num80.7%
un-div-inv80.6%
Applied egg-rr80.6%
associate-/l*80.6%
associate-/r/98.6%
associate-/l*98.8%
Simplified98.8%
Final simplification89.4%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (* 100.0 (/ (expm1 i) i)))))
(if (<= n -3.6e-199)
t_0
(if (<= n 9e-207)
(/ 0.0 (/ i n))
(if (<= n 3.25e-31) (/ 1.0 (/ (+ 0.01 (* i -0.005)) n)) t_0)))))
double code(double i, double n) {
double t_0 = n * (100.0 * (expm1(i) / i));
double tmp;
if (n <= -3.6e-199) {
tmp = t_0;
} else if (n <= 9e-207) {
tmp = 0.0 / (i / n);
} else if (n <= 3.25e-31) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = n * (100.0 * (Math.expm1(i) / i));
double tmp;
if (n <= -3.6e-199) {
tmp = t_0;
} else if (n <= 9e-207) {
tmp = 0.0 / (i / n);
} else if (n <= 3.25e-31) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = n * (100.0 * (math.expm1(i) / i)) tmp = 0 if n <= -3.6e-199: tmp = t_0 elif n <= 9e-207: tmp = 0.0 / (i / n) elif n <= 3.25e-31: tmp = 1.0 / ((0.01 + (i * -0.005)) / n) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(n * Float64(100.0 * Float64(expm1(i) / i))) tmp = 0.0 if (n <= -3.6e-199) tmp = t_0; elseif (n <= 9e-207) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 3.25e-31) tmp = Float64(1.0 / Float64(Float64(0.01 + Float64(i * -0.005)) / n)); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -3.6e-199], t$95$0, If[LessEqual[n, 9e-207], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.25e-31], N[(1.0 / N[(N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{if}\;n \leq -3.6 \cdot 10^{-199}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 9 \cdot 10^{-207}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 3.25 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{\frac{0.01 + i \cdot -0.005}{n}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -3.6000000000000002e-199 or 3.24999999999999983e-31 < n Initial program 21.9%
associate-*r/22.0%
sub-neg22.0%
distribute-lft-in21.9%
metadata-eval21.9%
metadata-eval21.9%
Simplified21.9%
metadata-eval21.9%
metadata-eval21.9%
distribute-lft-in22.0%
sub-neg22.0%
associate-*r/21.9%
associate-/r/22.0%
associate-*r*22.0%
add-exp-log22.0%
expm1-def22.0%
log-pow22.7%
log1p-udef80.8%
Applied egg-rr80.8%
Taylor expanded in n around inf 39.1%
expm1-def90.4%
Simplified90.4%
if -3.6000000000000002e-199 < n < 8.99999999999999984e-207Initial program 65.4%
associate-*r/65.4%
sub-neg65.4%
distribute-lft-in65.4%
metadata-eval65.4%
metadata-eval65.4%
Simplified65.4%
Taylor expanded in i around 0 85.4%
if 8.99999999999999984e-207 < n < 3.24999999999999983e-31Initial program 9.6%
Taylor expanded in n around inf 3.3%
expm1-def62.6%
Simplified62.6%
associate-*r/62.2%
div-inv62.1%
associate-/r*62.7%
Applied egg-rr62.7%
clear-num62.6%
inv-pow62.6%
div-inv62.5%
clear-num62.4%
associate-/r*62.5%
Applied egg-rr62.5%
unpow-162.5%
associate-*l/62.6%
*-lft-identity62.6%
associate-/l/62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in i around 0 78.5%
*-commutative78.5%
Simplified78.5%
Final simplification88.7%
(FPCore (i n)
:precision binary64
(if (<= n -3.3e-202)
(* n (* 100.0 (/ (expm1 i) i)))
(if (<= n 7.2e-205)
(/ 0.0 (/ i n))
(if (<= n 3.25e-31)
(/ 1.0 (/ (+ 0.01 (* i -0.005)) n))
(* n (/ 100.0 (/ i (expm1 i))))))))
double code(double i, double n) {
double tmp;
if (n <= -3.3e-202) {
tmp = n * (100.0 * (expm1(i) / i));
} else if (n <= 7.2e-205) {
tmp = 0.0 / (i / n);
} else if (n <= 3.25e-31) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = n * (100.0 / (i / expm1(i)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -3.3e-202) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else if (n <= 7.2e-205) {
tmp = 0.0 / (i / n);
} else if (n <= 3.25e-31) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = n * (100.0 / (i / Math.expm1(i)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.3e-202: tmp = n * (100.0 * (math.expm1(i) / i)) elif n <= 7.2e-205: tmp = 0.0 / (i / n) elif n <= 3.25e-31: tmp = 1.0 / ((0.01 + (i * -0.005)) / n) else: tmp = n * (100.0 / (i / math.expm1(i))) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.3e-202) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); elseif (n <= 7.2e-205) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 3.25e-31) tmp = Float64(1.0 / Float64(Float64(0.01 + Float64(i * -0.005)) / n)); else tmp = Float64(n * Float64(100.0 / Float64(i / expm1(i)))); end return tmp end
code[i_, n_] := If[LessEqual[n, -3.3e-202], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.2e-205], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.25e-31], N[(1.0 / N[(N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.3 \cdot 10^{-202}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{elif}\;n \leq 7.2 \cdot 10^{-205}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 3.25 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{\frac{0.01 + i \cdot -0.005}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\end{array}
\end{array}
if n < -3.29999999999999989e-202Initial program 22.1%
associate-*r/22.1%
sub-neg22.1%
distribute-lft-in22.1%
metadata-eval22.1%
metadata-eval22.1%
Simplified22.1%
metadata-eval22.1%
metadata-eval22.1%
distribute-lft-in22.1%
sub-neg22.1%
associate-*r/22.1%
associate-/r/21.8%
associate-*r*21.8%
add-exp-log21.8%
expm1-def21.8%
log-pow24.0%
log1p-udef81.3%
Applied egg-rr81.3%
Taylor expanded in n around inf 33.0%
expm1-def84.6%
Simplified84.6%
if -3.29999999999999989e-202 < n < 7.1999999999999997e-205Initial program 65.4%
associate-*r/65.4%
sub-neg65.4%
distribute-lft-in65.4%
metadata-eval65.4%
metadata-eval65.4%
Simplified65.4%
Taylor expanded in i around 0 85.4%
if 7.1999999999999997e-205 < n < 3.24999999999999983e-31Initial program 9.6%
Taylor expanded in n around inf 3.3%
expm1-def62.6%
Simplified62.6%
associate-*r/62.2%
div-inv62.1%
associate-/r*62.7%
Applied egg-rr62.7%
clear-num62.6%
inv-pow62.6%
div-inv62.5%
clear-num62.4%
associate-/r*62.5%
Applied egg-rr62.5%
unpow-162.5%
associate-*l/62.6%
*-lft-identity62.6%
associate-/l/62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in i around 0 78.5%
*-commutative78.5%
Simplified78.5%
if 3.24999999999999983e-31 < n Initial program 21.7%
Taylor expanded in n around inf 47.6%
expm1-def80.7%
Simplified80.7%
clear-num80.7%
un-div-inv80.6%
Applied egg-rr80.6%
associate-/l*80.6%
associate-/r/98.6%
associate-/l*98.8%
Simplified98.8%
Final simplification88.7%
(FPCore (i n)
:precision binary64
(if (<= n -3.4e-206)
(/ 1.0 (/ (/ i (* 100.0 (expm1 i))) n))
(if (<= n 7.2e-205)
(/ 0.0 (/ i n))
(if (<= n 7.4e-37)
(/ 1.0 (/ (+ 0.01 (* i -0.005)) n))
(* n (/ 100.0 (/ i (expm1 i))))))))
double code(double i, double n) {
double tmp;
if (n <= -3.4e-206) {
tmp = 1.0 / ((i / (100.0 * expm1(i))) / n);
} else if (n <= 7.2e-205) {
tmp = 0.0 / (i / n);
} else if (n <= 7.4e-37) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = n * (100.0 / (i / expm1(i)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -3.4e-206) {
tmp = 1.0 / ((i / (100.0 * Math.expm1(i))) / n);
} else if (n <= 7.2e-205) {
tmp = 0.0 / (i / n);
} else if (n <= 7.4e-37) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = n * (100.0 / (i / Math.expm1(i)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.4e-206: tmp = 1.0 / ((i / (100.0 * math.expm1(i))) / n) elif n <= 7.2e-205: tmp = 0.0 / (i / n) elif n <= 7.4e-37: tmp = 1.0 / ((0.01 + (i * -0.005)) / n) else: tmp = n * (100.0 / (i / math.expm1(i))) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.4e-206) tmp = Float64(1.0 / Float64(Float64(i / Float64(100.0 * expm1(i))) / n)); elseif (n <= 7.2e-205) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 7.4e-37) tmp = Float64(1.0 / Float64(Float64(0.01 + Float64(i * -0.005)) / n)); else tmp = Float64(n * Float64(100.0 / Float64(i / expm1(i)))); end return tmp end
code[i_, n_] := If[LessEqual[n, -3.4e-206], N[(1.0 / N[(N[(i / N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.2e-205], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.4e-37], N[(1.0 / N[(N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.4 \cdot 10^{-206}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{100 \cdot \mathsf{expm1}\left(i\right)}}{n}}\\
\mathbf{elif}\;n \leq 7.2 \cdot 10^{-205}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 7.4 \cdot 10^{-37}:\\
\;\;\;\;\frac{1}{\frac{0.01 + i \cdot -0.005}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{100}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\end{array}
\end{array}
if n < -3.39999999999999985e-206Initial program 22.1%
Taylor expanded in n around inf 33.2%
expm1-def71.8%
Simplified71.8%
associate-*r/71.7%
div-inv71.5%
associate-/r*84.3%
Applied egg-rr84.3%
clear-num84.8%
inv-pow84.8%
div-inv84.7%
clear-num84.8%
associate-/r*84.7%
Applied egg-rr84.7%
unpow-184.7%
associate-*l/84.9%
*-lft-identity84.9%
associate-/l/84.9%
*-commutative84.9%
Simplified84.9%
if -3.39999999999999985e-206 < n < 7.1999999999999997e-205Initial program 65.4%
associate-*r/65.4%
sub-neg65.4%
distribute-lft-in65.4%
metadata-eval65.4%
metadata-eval65.4%
Simplified65.4%
Taylor expanded in i around 0 85.4%
if 7.1999999999999997e-205 < n < 7.4e-37Initial program 9.6%
Taylor expanded in n around inf 3.3%
expm1-def62.6%
Simplified62.6%
associate-*r/62.2%
div-inv62.1%
associate-/r*62.7%
Applied egg-rr62.7%
clear-num62.6%
inv-pow62.6%
div-inv62.5%
clear-num62.4%
associate-/r*62.5%
Applied egg-rr62.5%
unpow-162.5%
associate-*l/62.6%
*-lft-identity62.6%
associate-/l/62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in i around 0 78.5%
*-commutative78.5%
Simplified78.5%
if 7.4e-37 < n Initial program 21.7%
Taylor expanded in n around inf 47.6%
expm1-def80.7%
Simplified80.7%
clear-num80.7%
un-div-inv80.6%
Applied egg-rr80.6%
associate-/l*80.6%
associate-/r/98.6%
associate-/l*98.8%
Simplified98.8%
Final simplification88.8%
(FPCore (i n) :precision binary64 (if (or (<= i -1.42e-8) (not (<= i 5.5e-34))) (* 100.0 (/ (expm1 i) (/ i n))) (* 100.0 (+ n (* (* i n) (- 0.5 (/ 0.5 n)))))))
double code(double i, double n) {
double tmp;
if ((i <= -1.42e-8) || !(i <= 5.5e-34)) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((i <= -1.42e-8) || !(i <= 5.5e-34)) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n))));
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -1.42e-8) or not (i <= 5.5e-34): tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n)))) return tmp
function code(i, n) tmp = 0.0 if ((i <= -1.42e-8) || !(i <= 5.5e-34)) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(100.0 * Float64(n + Float64(Float64(i * n) * Float64(0.5 - Float64(0.5 / n))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[i, -1.42e-8], N[Not[LessEqual[i, 5.5e-34]], $MachinePrecision]], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n + N[(N[(i * n), $MachinePrecision] * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.42 \cdot 10^{-8} \lor \neg \left(i \leq 5.5 \cdot 10^{-34}\right):\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + \left(i \cdot n\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if i < -1.41999999999999998e-8 or 5.50000000000000014e-34 < i Initial program 44.0%
Taylor expanded in n around inf 67.3%
expm1-def71.4%
Simplified71.4%
if -1.41999999999999998e-8 < i < 5.50000000000000014e-34Initial program 9.4%
Taylor expanded in i around 0 88.0%
associate-*r*88.4%
associate-*r/88.4%
metadata-eval88.4%
Simplified88.4%
Final simplification80.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ 1.0 (/ (+ 0.01 (* i -0.005)) n))))
(if (<= n -2.4e-205)
t_0
(if (<= n 1.52e-204)
(/ 0.0 (/ i n))
(if (<= n 3.9e+32) t_0 (* 100.0 (+ n (* n (* i 0.5)))))))))
double code(double i, double n) {
double t_0 = 1.0 / ((0.01 + (i * -0.005)) / n);
double tmp;
if (n <= -2.4e-205) {
tmp = t_0;
} else if (n <= 1.52e-204) {
tmp = 0.0 / (i / n);
} else if (n <= 3.9e+32) {
tmp = t_0;
} else {
tmp = 100.0 * (n + (n * (i * 0.5)));
}
return tmp;
}
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 / ((0.01d0 + (i * (-0.005d0))) / n)
if (n <= (-2.4d-205)) then
tmp = t_0
else if (n <= 1.52d-204) then
tmp = 0.0d0 / (i / n)
else if (n <= 3.9d+32) then
tmp = t_0
else
tmp = 100.0d0 * (n + (n * (i * 0.5d0)))
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = 1.0 / ((0.01 + (i * -0.005)) / n);
double tmp;
if (n <= -2.4e-205) {
tmp = t_0;
} else if (n <= 1.52e-204) {
tmp = 0.0 / (i / n);
} else if (n <= 3.9e+32) {
tmp = t_0;
} else {
tmp = 100.0 * (n + (n * (i * 0.5)));
}
return tmp;
}
def code(i, n): t_0 = 1.0 / ((0.01 + (i * -0.005)) / n) tmp = 0 if n <= -2.4e-205: tmp = t_0 elif n <= 1.52e-204: tmp = 0.0 / (i / n) elif n <= 3.9e+32: tmp = t_0 else: tmp = 100.0 * (n + (n * (i * 0.5))) return tmp
function code(i, n) t_0 = Float64(1.0 / Float64(Float64(0.01 + Float64(i * -0.005)) / n)) tmp = 0.0 if (n <= -2.4e-205) tmp = t_0; elseif (n <= 1.52e-204) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 3.9e+32) tmp = t_0; else tmp = Float64(100.0 * Float64(n + Float64(n * Float64(i * 0.5)))); end return tmp end
function tmp_2 = code(i, n) t_0 = 1.0 / ((0.01 + (i * -0.005)) / n); tmp = 0.0; if (n <= -2.4e-205) tmp = t_0; elseif (n <= 1.52e-204) tmp = 0.0 / (i / n); elseif (n <= 3.9e+32) tmp = t_0; else tmp = 100.0 * (n + (n * (i * 0.5))); end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(1.0 / N[(N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -2.4e-205], t$95$0, If[LessEqual[n, 1.52e-204], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.9e+32], t$95$0, N[(100.0 * N[(n + N[(n * N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\frac{0.01 + i \cdot -0.005}{n}}\\
\mathbf{if}\;n \leq -2.4 \cdot 10^{-205}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 1.52 \cdot 10^{-204}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 3.9 \cdot 10^{+32}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if n < -2.4000000000000002e-205 or 1.51999999999999997e-204 < n < 3.8999999999999999e32Initial program 18.8%
Taylor expanded in n around inf 26.8%
expm1-def72.5%
Simplified72.5%
associate-*r/72.3%
div-inv72.2%
associate-/r*81.7%
Applied egg-rr81.7%
clear-num82.0%
inv-pow82.0%
div-inv82.0%
clear-num82.0%
associate-/r*82.0%
Applied egg-rr82.0%
unpow-182.0%
associate-*l/82.1%
*-lft-identity82.1%
associate-/l/82.1%
*-commutative82.1%
Simplified82.1%
Taylor expanded in i around 0 70.5%
*-commutative70.5%
Simplified70.5%
if -2.4000000000000002e-205 < n < 1.51999999999999997e-204Initial program 65.4%
associate-*r/65.4%
sub-neg65.4%
distribute-lft-in65.4%
metadata-eval65.4%
metadata-eval65.4%
Simplified65.4%
Taylor expanded in i around 0 85.4%
if 3.8999999999999999e32 < n Initial program 24.7%
Taylor expanded in n around inf 55.0%
expm1-def77.7%
Simplified77.7%
Taylor expanded in i around 0 72.3%
associate-*r*72.3%
Simplified72.3%
Final simplification72.5%
(FPCore (i n) :precision binary64 (if (or (<= n -9e+32) (not (<= n 0.1))) (* 100.0 (/ (* i n) i)) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -9e+32) || !(n <= 0.1)) {
tmp = 100.0 * ((i * n) / i);
} else {
tmp = 100.0 * (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 ((n <= (-9d+32)) .or. (.not. (n <= 0.1d0))) then
tmp = 100.0d0 * ((i * n) / i)
else
tmp = 100.0d0 * (i / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -9e+32) || !(n <= 0.1)) {
tmp = 100.0 * ((i * n) / i);
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -9e+32) or not (n <= 0.1): tmp = 100.0 * ((i * n) / i) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -9e+32) || !(n <= 0.1)) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); else tmp = Float64(100.0 * Float64(i / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -9e+32) || ~((n <= 0.1))) tmp = 100.0 * ((i * n) / i); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -9e+32], N[Not[LessEqual[n, 0.1]], $MachinePrecision]], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9 \cdot 10^{+32} \lor \neg \left(n \leq 0.1\right):\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -9.0000000000000007e32 or 0.10000000000000001 < n Initial program 18.4%
Taylor expanded in i around 0 5.8%
+-commutative5.8%
Simplified5.8%
div-inv5.7%
associate--l+32.7%
metadata-eval32.7%
+-rgt-identity32.7%
clear-num32.8%
*-commutative32.8%
Applied egg-rr32.8%
associate-*l/67.5%
Applied egg-rr67.5%
if -9.0000000000000007e32 < n < 0.10000000000000001Initial program 33.5%
Taylor expanded in i around 0 66.9%
Final simplification67.2%
(FPCore (i n) :precision binary64 (if (<= n -6e+32) (* 100.0 (/ (* i n) i)) (if (<= n 7.3e-22) (* 100.0 (/ i (/ i n))) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -6e+32) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= 7.3e-22) {
tmp = 100.0 * (i / (i / n));
} 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 <= (-6d+32)) then
tmp = 100.0d0 * ((i * n) / i)
else if (n <= 7.3d-22) then
tmp = 100.0d0 * (i / (i / n))
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 <= -6e+32) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= 7.3e-22) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -6e+32: tmp = 100.0 * ((i * n) / i) elif n <= 7.3e-22: tmp = 100.0 * (i / (i / n)) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -6e+32) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); elseif (n <= 7.3e-22) tmp = Float64(100.0 * Float64(i / Float64(i / n))); 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 <= -6e+32) tmp = 100.0 * ((i * n) / i); elseif (n <= 7.3e-22) tmp = 100.0 * (i / (i / n)); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -6e+32], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.3e-22], N[(100.0 * N[(i / N[(i / n), $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 -6 \cdot 10^{+32}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{elif}\;n \leq 7.3 \cdot 10^{-22}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -6e32Initial program 13.2%
Taylor expanded in i around 0 4.9%
+-commutative4.9%
Simplified4.9%
div-inv4.8%
associate--l+31.5%
metadata-eval31.5%
+-rgt-identity31.5%
clear-num31.6%
*-commutative31.6%
Applied egg-rr31.6%
associate-*l/62.3%
Applied egg-rr62.3%
if -6e32 < n < 7.30000000000000028e-22Initial program 35.0%
Taylor expanded in i around 0 65.3%
if 7.30000000000000028e-22 < n Initial program 21.7%
Taylor expanded in n around inf 47.6%
expm1-def80.7%
Simplified80.7%
Taylor expanded in i around 0 75.3%
associate-*r*75.3%
distribute-rgt-out75.3%
Simplified75.3%
Final simplification67.8%
(FPCore (i n) :precision binary64 (if (<= n 3.9e+32) (/ 1.0 (/ (+ 0.01 (* i -0.005)) n)) (* 100.0 (+ n (* n (* i 0.5))))))
double code(double i, double n) {
double tmp;
if (n <= 3.9e+32) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = 100.0 * (n + (n * (i * 0.5)));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 3.9d+32) then
tmp = 1.0d0 / ((0.01d0 + (i * (-0.005d0))) / n)
else
tmp = 100.0d0 * (n + (n * (i * 0.5d0)))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 3.9e+32) {
tmp = 1.0 / ((0.01 + (i * -0.005)) / n);
} else {
tmp = 100.0 * (n + (n * (i * 0.5)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 3.9e+32: tmp = 1.0 / ((0.01 + (i * -0.005)) / n) else: tmp = 100.0 * (n + (n * (i * 0.5))) return tmp
function code(i, n) tmp = 0.0 if (n <= 3.9e+32) tmp = Float64(1.0 / Float64(Float64(0.01 + Float64(i * -0.005)) / n)); else tmp = Float64(100.0 * Float64(n + Float64(n * Float64(i * 0.5)))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 3.9e+32) tmp = 1.0 / ((0.01 + (i * -0.005)) / n); else tmp = 100.0 * (n + (n * (i * 0.5))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 3.9e+32], N[(1.0 / N[(N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n + N[(n * N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.9 \cdot 10^{+32}:\\
\;\;\;\;\frac{1}{\frac{0.01 + i \cdot -0.005}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + n \cdot \left(i \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if n < 3.8999999999999999e32Initial program 25.0%
Taylor expanded in n around inf 29.4%
expm1-def65.2%
Simplified65.2%
associate-*r/65.0%
div-inv64.9%
associate-/r*73.2%
Applied egg-rr73.2%
clear-num73.5%
inv-pow73.5%
div-inv73.5%
clear-num73.5%
associate-/r*73.5%
Applied egg-rr73.5%
unpow-173.5%
associate-*l/73.6%
*-lft-identity73.6%
associate-/l/73.6%
*-commutative73.6%
Simplified73.6%
Taylor expanded in i around 0 66.2%
*-commutative66.2%
Simplified66.2%
if 3.8999999999999999e32 < n Initial program 24.7%
Taylor expanded in n around inf 55.0%
expm1-def77.7%
Simplified77.7%
Taylor expanded in i around 0 72.3%
associate-*r*72.3%
Simplified72.3%
Final simplification67.8%
(FPCore (i n) :precision binary64 (if (<= i -2e+144) (* 100.0 (* i (/ n i))) (if (<= i 2.0) (* n 100.0) (* n (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (i <= -2e+144) {
tmp = 100.0 * (i * (n / i));
} else if (i <= 2.0) {
tmp = n * 100.0;
} else {
tmp = n * (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 <= (-2d+144)) then
tmp = 100.0d0 * (i * (n / i))
else if (i <= 2.0d0) then
tmp = n * 100.0d0
else
tmp = n * (i * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -2e+144) {
tmp = 100.0 * (i * (n / i));
} else if (i <= 2.0) {
tmp = n * 100.0;
} else {
tmp = n * (i * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2e+144: tmp = 100.0 * (i * (n / i)) elif i <= 2.0: tmp = n * 100.0 else: tmp = n * (i * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= -2e+144) tmp = Float64(100.0 * Float64(i * Float64(n / i))); elseif (i <= 2.0) tmp = Float64(n * 100.0); else tmp = Float64(n * Float64(i * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2e+144) tmp = 100.0 * (i * (n / i)); elseif (i <= 2.0) tmp = n * 100.0; else tmp = n * (i * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2e+144], N[(100.0 * N[(i * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.0], N[(n * 100.0), $MachinePrecision], N[(n * N[(i * 50.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2 \cdot 10^{+144}:\\
\;\;\;\;100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;i \leq 2:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(i \cdot 50\right)\\
\end{array}
\end{array}
if i < -2.00000000000000005e144Initial program 72.8%
Taylor expanded in i around 0 46.1%
+-commutative46.1%
Simplified46.1%
div-inv46.1%
associate--l+46.1%
metadata-eval46.1%
+-rgt-identity46.1%
clear-num42.3%
*-commutative42.3%
Applied egg-rr42.3%
if -2.00000000000000005e144 < i < 2Initial program 12.2%
Taylor expanded in i around 0 73.5%
*-commutative73.5%
Simplified73.5%
if 2 < i Initial program 45.2%
Taylor expanded in n around inf 64.4%
expm1-def64.4%
Simplified64.4%
Taylor expanded in i around 0 40.6%
associate-*r*40.6%
Simplified40.6%
Taylor expanded in i around inf 40.6%
associate-*r*40.6%
*-commutative40.6%
Simplified40.6%
Final simplification63.7%
(FPCore (i n) :precision binary64 (if (<= i -1e+20) (* 100.0 (/ i (/ i n))) (if (<= i 2.0) (* n 100.0) (* n (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (i <= -1e+20) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 2.0) {
tmp = n * 100.0;
} else {
tmp = n * (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 <= (-1d+20)) then
tmp = 100.0d0 * (i / (i / n))
else if (i <= 2.0d0) then
tmp = n * 100.0d0
else
tmp = n * (i * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -1e+20) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 2.0) {
tmp = n * 100.0;
} else {
tmp = n * (i * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1e+20: tmp = 100.0 * (i / (i / n)) elif i <= 2.0: tmp = n * 100.0 else: tmp = n * (i * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= -1e+20) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (i <= 2.0) tmp = Float64(n * 100.0); else tmp = Float64(n * Float64(i * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -1e+20) tmp = 100.0 * (i / (i / n)); elseif (i <= 2.0) tmp = n * 100.0; else tmp = n * (i * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1e+20], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.0], N[(n * 100.0), $MachinePrecision], N[(n * N[(i * 50.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1 \cdot 10^{+20}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 2:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(i \cdot 50\right)\\
\end{array}
\end{array}
if i < -1e20Initial program 57.2%
Taylor expanded in i around 0 28.6%
if -1e20 < i < 2Initial program 9.3%
Taylor expanded in i around 0 81.6%
*-commutative81.6%
Simplified81.6%
if 2 < i Initial program 45.2%
Taylor expanded in n around inf 64.4%
expm1-def64.4%
Simplified64.4%
Taylor expanded in i around 0 40.6%
associate-*r*40.6%
Simplified40.6%
Taylor expanded in i around inf 40.6%
associate-*r*40.6%
*-commutative40.6%
Simplified40.6%
Final simplification64.0%
(FPCore (i n) :precision binary64 (if (<= i 2.0) (* n 100.0) (* n (* i 50.0))))
double code(double i, double n) {
double tmp;
if (i <= 2.0) {
tmp = n * 100.0;
} else {
tmp = n * (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 <= 2.0d0) then
tmp = n * 100.0d0
else
tmp = n * (i * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 2.0) {
tmp = n * 100.0;
} else {
tmp = n * (i * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 2.0: tmp = n * 100.0 else: tmp = n * (i * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= 2.0) tmp = Float64(n * 100.0); else tmp = Float64(n * Float64(i * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 2.0) tmp = n * 100.0; else tmp = n * (i * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 2.0], N[(n * 100.0), $MachinePrecision], N[(n * N[(i * 50.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 2:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(i \cdot 50\right)\\
\end{array}
\end{array}
if i < 2Initial program 19.6%
Taylor expanded in i around 0 65.0%
*-commutative65.0%
Simplified65.0%
if 2 < i Initial program 45.2%
Taylor expanded in n around inf 64.4%
expm1-def64.4%
Simplified64.4%
Taylor expanded in i around 0 40.6%
associate-*r*40.6%
Simplified40.6%
Taylor expanded in i around inf 40.6%
associate-*r*40.6%
*-commutative40.6%
Simplified40.6%
Final simplification59.9%
(FPCore (i n) :precision binary64 (* i -50.0))
double code(double i, double n) {
return i * -50.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = i * (-50.0d0)
end function
public static double code(double i, double n) {
return i * -50.0;
}
def code(i, n): return i * -50.0
function code(i, n) return Float64(i * -50.0) end
function tmp = code(i, n) tmp = i * -50.0; end
code[i_, n_] := N[(i * -50.0), $MachinePrecision]
\begin{array}{l}
\\
i \cdot -50
\end{array}
Initial program 24.9%
associate-*r/24.9%
sub-neg24.9%
distribute-lft-in24.9%
metadata-eval24.9%
metadata-eval24.9%
Simplified24.9%
metadata-eval24.9%
metadata-eval24.9%
distribute-lft-in24.9%
sub-neg24.9%
associate-*r/24.9%
associate-/r/25.0%
associate-*r*25.0%
add-exp-log25.0%
expm1-def25.0%
log-pow28.7%
log1p-udef81.1%
Applied egg-rr81.1%
Taylor expanded in i around 0 59.5%
associate-*r/59.5%
metadata-eval59.5%
Simplified59.5%
Taylor expanded in n around 0 2.9%
*-commutative2.9%
Simplified2.9%
Final simplification2.9%
(FPCore (i n) :precision binary64 (* n 100.0))
double code(double i, double n) {
return n * 100.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n * 100.0d0
end function
public static double code(double i, double n) {
return n * 100.0;
}
def code(i, n): return n * 100.0
function code(i, n) return Float64(n * 100.0) end
function tmp = code(i, n) tmp = n * 100.0; end
code[i_, n_] := N[(n * 100.0), $MachinePrecision]
\begin{array}{l}
\\
n \cdot 100
\end{array}
Initial program 24.9%
Taylor expanded in i around 0 52.7%
*-commutative52.7%
Simplified52.7%
Final simplification52.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 2024010
(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))))