
(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 14 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)))
(t_2 (* 100.0 (/ (- (* n t_0) n) i))))
(if (<= t_1 -2e-276)
t_2
(if (<= t_1 5e-259)
(* 100.0 (* n (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_1 INFINITY)
t_2
(*
100.0
(/
n
(+ 1.0 (+ (* 0.08333333333333333 (pow i 2.0)) (* i -0.5))))))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double t_2 = 100.0 * (((n * t_0) - n) / i);
double tmp;
if (t_1 <= -2e-276) {
tmp = t_2;
} else if (t_1 <= 5e-259) {
tmp = 100.0 * (n * (expm1((n * log1p((i / n)))) / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double t_2 = 100.0 * (((n * t_0) - n) / i);
double tmp;
if (t_1 <= -2e-276) {
tmp = t_2;
} else if (t_1 <= 5e-259) {
tmp = 100.0 * (n * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * Math.pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) t_2 = 100.0 * (((n * t_0) - n) / i) tmp = 0 if t_1 <= -2e-276: tmp = t_2 elif t_1 <= 5e-259: tmp = 100.0 * (n * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_1 <= math.inf: tmp = t_2 else: tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * math.pow(i, 2.0)) + (i * -0.5)))) return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) t_2 = Float64(100.0 * Float64(Float64(Float64(n * t_0) - n) / i)) tmp = 0.0 if (t_1 <= -2e-276) tmp = t_2; elseif (t_1 <= 5e-259) tmp = Float64(100.0 * Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_1 <= Inf) tmp = t_2; else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(Float64(0.08333333333333333 * (i ^ 2.0)) + Float64(i * -0.5))))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(100.0 * N[(N[(N[(n * t$95$0), $MachinePrecision] - n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-276], t$95$2, If[LessEqual[t$95$1, 5e-259], N[(100.0 * N[(n * 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], t$95$2, N[(100.0 * N[(n / N[(1.0 + N[(N[(0.08333333333333333 * N[Power[i, 2.0], $MachinePrecision]), $MachinePrecision] + N[(i * -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}}\\
t_2 := 100 \cdot \frac{n \cdot t\_0 - n}{i}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-276}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-259}:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + \left(0.08333333333333333 \cdot {i}^{2} + i \cdot -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -2e-276 or 4.99999999999999977e-259 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.8%
associate-/r/99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
metadata-eval99.7%
sub-neg99.7%
associate-/r/99.8%
div-sub99.6%
clear-num99.9%
sub-neg99.9%
div-inv99.7%
clear-num99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
associate-*r/99.9%
sub-div99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -2e-276 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 4.99999999999999977e-259Initial program 19.8%
associate-/r/18.7%
sub-neg18.7%
metadata-eval18.7%
Simplified18.7%
*-un-lft-identity18.7%
metadata-eval18.7%
sub-neg18.7%
add-exp-log18.7%
expm1-def18.7%
log-pow32.1%
log1p-udef97.7%
Applied egg-rr97.7%
*-lft-identity97.7%
Simplified97.7%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.9%
sub-neg1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in n around inf 1.9%
associate-/l*1.9%
expm1-def82.5%
Simplified82.5%
Taylor expanded in i around 0 100.0%
Final simplification98.4%
(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-276)
(* 100.0 (/ (- (* n t_0) n) i))
(if (<= t_1 0.0)
(* (/ (expm1 i) i) (* n 100.0))
(if (<= t_1 INFINITY)
(* 100.0 (- (* t_0 (/ n i)) (/ n i)))
(*
100.0
(/
n
(+ 1.0 (+ (* 0.08333333333333333 (pow i 2.0)) (* i -0.5))))))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -2e-276) {
tmp = 100.0 * (((n * t_0) - n) / i);
} else if (t_1 <= 0.0) {
tmp = (expm1(i) / i) * (n * 100.0);
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -2e-276) {
tmp = 100.0 * (((n * t_0) - n) / i);
} else if (t_1 <= 0.0) {
tmp = (Math.expm1(i) / i) * (n * 100.0);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * Math.pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= -2e-276: tmp = 100.0 * (((n * t_0) - n) / i) elif t_1 <= 0.0: tmp = (math.expm1(i) / i) * (n * 100.0) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 * (n / i)) - (n / i)) else: tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * math.pow(i, 2.0)) + (i * -0.5)))) return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -2e-276) tmp = Float64(100.0 * Float64(Float64(Float64(n * t_0) - n) / i)); elseif (t_1 <= 0.0) tmp = Float64(Float64(expm1(i) / i) * Float64(n * 100.0)); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i))); else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(Float64(0.08333333333333333 * (i ^ 2.0)) + Float64(i * -0.5))))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-276], N[(100.0 * N[(N[(N[(n * t$95$0), $MachinePrecision] - n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(N[(0.08333333333333333 * N[Power[i, 2.0], $MachinePrecision]), $MachinePrecision] + N[(i * -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^{-276}:\\
\;\;\;\;100 \cdot \frac{n \cdot t\_0 - n}{i}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(i\right)}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t\_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + \left(0.08333333333333333 \cdot {i}^{2} + i \cdot -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -2e-276Initial program 99.8%
associate-/r/99.5%
sub-neg99.5%
metadata-eval99.5%
Simplified99.5%
metadata-eval99.5%
sub-neg99.5%
associate-/r/99.8%
div-sub99.4%
clear-num99.8%
sub-neg99.8%
div-inv99.4%
clear-num99.8%
Applied egg-rr99.8%
sub-neg99.8%
Simplified99.8%
associate-*r/99.8%
sub-div99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -2e-276 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 19.5%
*-commutative19.5%
associate-/r/18.4%
associate-*l*18.4%
sub-neg18.4%
metadata-eval18.4%
Simplified18.4%
Taylor expanded in n around inf 35.6%
expm1-def79.8%
Simplified79.8%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.5%
associate-/r/98.6%
sub-neg98.6%
metadata-eval98.6%
Simplified98.6%
metadata-eval98.6%
sub-neg98.6%
associate-/r/98.5%
div-sub98.5%
clear-num98.6%
sub-neg98.6%
div-inv98.8%
clear-num98.8%
Applied egg-rr98.8%
sub-neg98.8%
Simplified98.8%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.9%
sub-neg1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in n around inf 1.9%
associate-/l*1.9%
expm1-def82.5%
Simplified82.5%
Taylor expanded in i around 0 100.0%
Final simplification86.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n))
(t_1 (/ (+ t_0 -1.0) (/ i n)))
(t_2 (* 100.0 (/ (- (* n t_0) n) i))))
(if (<= t_1 -2e-276)
t_2
(if (<= t_1 0.0)
(* (/ (expm1 i) i) (* n 100.0))
(if (<= t_1 INFINITY)
t_2
(*
100.0
(/
n
(+ 1.0 (+ (* 0.08333333333333333 (pow i 2.0)) (* i -0.5))))))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double t_2 = 100.0 * (((n * t_0) - n) / i);
double tmp;
if (t_1 <= -2e-276) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (expm1(i) / i) * (n * 100.0);
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double t_2 = 100.0 * (((n * t_0) - n) / i);
double tmp;
if (t_1 <= -2e-276) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (Math.expm1(i) / i) * (n * 100.0);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * Math.pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) t_2 = 100.0 * (((n * t_0) - n) / i) tmp = 0 if t_1 <= -2e-276: tmp = t_2 elif t_1 <= 0.0: tmp = (math.expm1(i) / i) * (n * 100.0) elif t_1 <= math.inf: tmp = t_2 else: tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * math.pow(i, 2.0)) + (i * -0.5)))) return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) t_2 = Float64(100.0 * Float64(Float64(Float64(n * t_0) - n) / i)) tmp = 0.0 if (t_1 <= -2e-276) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(expm1(i) / i) * Float64(n * 100.0)); elseif (t_1 <= Inf) tmp = t_2; else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(Float64(0.08333333333333333 * (i ^ 2.0)) + Float64(i * -0.5))))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(100.0 * N[(N[(N[(n * t$95$0), $MachinePrecision] - n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-276], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$2, N[(100.0 * N[(n / N[(1.0 + N[(N[(0.08333333333333333 * N[Power[i, 2.0], $MachinePrecision]), $MachinePrecision] + N[(i * -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}}\\
t_2 := 100 \cdot \frac{n \cdot t\_0 - n}{i}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-276}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(i\right)}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + \left(0.08333333333333333 \cdot {i}^{2} + i \cdot -0.5\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -2e-276 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.1%
associate-/r/99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
metadata-eval99.0%
sub-neg99.0%
associate-/r/99.1%
div-sub98.9%
clear-num99.1%
sub-neg99.1%
div-inv99.1%
clear-num99.2%
Applied egg-rr99.2%
sub-neg99.2%
Simplified99.2%
associate-*r/99.2%
sub-div99.3%
*-commutative99.3%
Applied egg-rr99.3%
if -2e-276 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 19.5%
*-commutative19.5%
associate-/r/18.4%
associate-*l*18.4%
sub-neg18.4%
metadata-eval18.4%
Simplified18.4%
Taylor expanded in n around inf 35.6%
expm1-def79.8%
Simplified79.8%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.9%
sub-neg1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in n around inf 1.9%
associate-/l*1.9%
expm1-def82.5%
Simplified82.5%
Taylor expanded in i around 0 100.0%
Final simplification86.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.2e-23) (not (<= n 2.1e-8))) (* 100.0 (/ n (/ i (expm1 i)))) (* 100.0 (/ n (+ 1.0 (+ (* 0.08333333333333333 (pow i 2.0)) (* i -0.5)))))))
double code(double i, double n) {
double tmp;
if ((n <= -1.2e-23) || !(n <= 2.1e-8)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.2e-23) || !(n <= 2.1e-8)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * Math.pow(i, 2.0)) + (i * -0.5))));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.2e-23) or not (n <= 2.1e-8): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 100.0 * (n / (1.0 + ((0.08333333333333333 * math.pow(i, 2.0)) + (i * -0.5)))) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.2e-23) || !(n <= 2.1e-8)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(Float64(0.08333333333333333 * (i ^ 2.0)) + Float64(i * -0.5))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.2e-23], N[Not[LessEqual[n, 2.1e-8]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(1.0 + N[(N[(0.08333333333333333 * N[Power[i, 2.0], $MachinePrecision]), $MachinePrecision] + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.2 \cdot 10^{-23} \lor \neg \left(n \leq 2.1 \cdot 10^{-8}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + \left(0.08333333333333333 \cdot {i}^{2} + i \cdot -0.5\right)}\\
\end{array}
\end{array}
if n < -1.19999999999999998e-23 or 2.09999999999999994e-8 < n Initial program 24.1%
associate-/r/24.6%
sub-neg24.6%
metadata-eval24.6%
Simplified24.6%
Taylor expanded in n around inf 38.9%
associate-/l*38.9%
expm1-def91.9%
Simplified91.9%
if -1.19999999999999998e-23 < n < 2.09999999999999994e-8Initial program 33.1%
associate-/r/31.2%
sub-neg31.2%
metadata-eval31.2%
Simplified31.2%
Taylor expanded in n around inf 26.3%
associate-/l*26.3%
expm1-def56.5%
Simplified56.5%
Taylor expanded in i around 0 69.5%
Final simplification83.2%
(FPCore (i n) :precision binary64 (if (or (<= n -2.9e-91) (not (<= n 2.1e-8))) (* 100.0 (/ n (/ i (expm1 i)))) (* 100.0 (/ (/ (* i 2.0) (+ i 2.0)) (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -2.9e-91) || !(n <= 2.1e-8)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = 100.0 * (((i * 2.0) / (i + 2.0)) / (i / n));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -2.9e-91) || !(n <= 2.1e-8)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 100.0 * (((i * 2.0) / (i + 2.0)) / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2.9e-91) or not (n <= 2.1e-8): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 100.0 * (((i * 2.0) / (i + 2.0)) / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -2.9e-91) || !(n <= 2.1e-8)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = Float64(100.0 * Float64(Float64(Float64(i * 2.0) / Float64(i + 2.0)) / Float64(i / n))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2.9e-91], N[Not[LessEqual[n, 2.1e-8]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(N[(i * 2.0), $MachinePrecision] / N[(i + 2.0), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.9 \cdot 10^{-91} \lor \neg \left(n \leq 2.1 \cdot 10^{-8}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\frac{i \cdot 2}{i + 2}}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -2.9000000000000001e-91 or 2.09999999999999994e-8 < n Initial program 22.8%
associate-/r/23.2%
sub-neg23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 36.6%
associate-/l*36.6%
expm1-def90.8%
Simplified90.8%
if -2.9000000000000001e-91 < n < 2.09999999999999994e-8Initial program 36.7%
Taylor expanded in i around 0 40.5%
+-commutative40.5%
Simplified40.5%
flip--22.2%
metadata-eval22.2%
difference-of-sqr-122.2%
associate--l+47.2%
metadata-eval47.2%
+-rgt-identity47.2%
associate-+l+47.2%
metadata-eval47.2%
associate-+l+47.2%
metadata-eval47.2%
Applied egg-rr47.2%
Taylor expanded in i around 0 65.9%
*-commutative65.9%
Simplified65.9%
Final simplification82.2%
(FPCore (i n)
:precision binary64
(if (<= n -9.5e+200)
(* 100.0 (/ (* i n) i))
(if (<= n -5.2e-205)
(* 100.0 (/ n (+ 1.0 (* i -0.5))))
(if (<= n 7e-287)
(* (* n 100.0) (/ 0.0 i))
(if (<= n 2.1e-8)
(* 100.0 (/ (/ (* i 2.0) (+ i 2.0)) (/ i n)))
(* (* n 100.0) (+ 1.0 (* i 0.5))))))))
double code(double i, double n) {
double tmp;
if (n <= -9.5e+200) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= -5.2e-205) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 7e-287) {
tmp = (n * 100.0) * (0.0 / i);
} else if (n <= 2.1e-8) {
tmp = 100.0 * (((i * 2.0) / (i + 2.0)) / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (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 <= (-9.5d+200)) then
tmp = 100.0d0 * ((i * n) / i)
else if (n <= (-5.2d-205)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 7d-287) then
tmp = (n * 100.0d0) * (0.0d0 / i)
else if (n <= 2.1d-8) then
tmp = 100.0d0 * (((i * 2.0d0) / (i + 2.0d0)) / (i / n))
else
tmp = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -9.5e+200) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= -5.2e-205) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 7e-287) {
tmp = (n * 100.0) * (0.0 / i);
} else if (n <= 2.1e-8) {
tmp = 100.0 * (((i * 2.0) / (i + 2.0)) / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -9.5e+200: tmp = 100.0 * ((i * n) / i) elif n <= -5.2e-205: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 7e-287: tmp = (n * 100.0) * (0.0 / i) elif n <= 2.1e-8: tmp = 100.0 * (((i * 2.0) / (i + 2.0)) / (i / n)) else: tmp = (n * 100.0) * (1.0 + (i * 0.5)) return tmp
function code(i, n) tmp = 0.0 if (n <= -9.5e+200) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); elseif (n <= -5.2e-205) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 7e-287) tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i)); elseif (n <= 2.1e-8) tmp = Float64(100.0 * Float64(Float64(Float64(i * 2.0) / Float64(i + 2.0)) / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -9.5e+200) tmp = 100.0 * ((i * n) / i); elseif (n <= -5.2e-205) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 7e-287) tmp = (n * 100.0) * (0.0 / i); elseif (n <= 2.1e-8) tmp = 100.0 * (((i * 2.0) / (i + 2.0)) / (i / n)); else tmp = (n * 100.0) * (1.0 + (i * 0.5)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -9.5e+200], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -5.2e-205], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7e-287], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.1e-8], N[(100.0 * N[(N[(N[(i * 2.0), $MachinePrecision] / N[(i + 2.0), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.5 \cdot 10^{+200}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{elif}\;n \leq -5.2 \cdot 10^{-205}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-287}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\
\mathbf{elif}\;n \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;100 \cdot \frac{\frac{i \cdot 2}{i + 2}}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\end{array}
\end{array}
if n < -9.49999999999999988e200Initial program 6.0%
Taylor expanded in i around 0 9.8%
+-commutative9.8%
Simplified9.8%
div-inv9.8%
clear-num9.8%
associate--l+30.4%
metadata-eval30.4%
+-rgt-identity30.4%
*-commutative30.4%
Applied egg-rr30.4%
associate-*l/85.7%
Applied egg-rr85.7%
if -9.49999999999999988e200 < n < -5.1999999999999997e-205Initial program 31.6%
associate-/r/29.5%
sub-neg29.5%
metadata-eval29.5%
Simplified29.5%
Taylor expanded in n around inf 24.1%
associate-/l*24.1%
expm1-def77.2%
Simplified77.2%
Taylor expanded in i around 0 67.7%
*-commutative67.7%
Simplified67.7%
if -5.1999999999999997e-205 < n < 7e-287Initial program 85.7%
*-commutative85.7%
associate-/r/85.7%
associate-*l*85.7%
sub-neg85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in i around 0 85.7%
if 7e-287 < n < 2.09999999999999994e-8Initial program 10.7%
Taylor expanded in i around 0 24.2%
+-commutative24.2%
Simplified24.2%
flip--8.5%
metadata-eval8.5%
difference-of-sqr-18.5%
associate--l+47.9%
metadata-eval47.9%
+-rgt-identity47.9%
associate-+l+47.9%
metadata-eval47.9%
associate-+l+47.9%
metadata-eval47.9%
Applied egg-rr47.9%
Taylor expanded in i around 0 64.3%
*-commutative64.3%
Simplified64.3%
if 2.09999999999999994e-8 < n Initial program 22.7%
*-commutative22.7%
associate-/r/23.2%
associate-*l*23.2%
sub-neg23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 42.7%
expm1-def94.3%
Simplified94.3%
Taylor expanded in i around 0 77.7%
*-commutative77.7%
Simplified77.7%
Final simplification73.4%
(FPCore (i n)
:precision binary64
(if (<= n -3.7e+199)
(* 100.0 (/ (* i n) i))
(if (<= n -4.2e-204)
(* 100.0 (/ n (+ 1.0 (* i -0.5))))
(if (<= n 7e-287)
(* (* n 100.0) (/ 0.0 i))
(if (<= n 2.1e-8)
(* 100.0 (/ i (/ i n)))
(* (* n 100.0) (+ 1.0 (* i 0.5))))))))
double code(double i, double n) {
double tmp;
if (n <= -3.7e+199) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= -4.2e-204) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 7e-287) {
tmp = (n * 100.0) * (0.0 / i);
} else if (n <= 2.1e-8) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (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.7d+199)) then
tmp = 100.0d0 * ((i * n) / i)
else if (n <= (-4.2d-204)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 7d-287) then
tmp = (n * 100.0d0) * (0.0d0 / i)
else if (n <= 2.1d-8) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -3.7e+199) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= -4.2e-204) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 7e-287) {
tmp = (n * 100.0) * (0.0 / i);
} else if (n <= 2.1e-8) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.7e+199: tmp = 100.0 * ((i * n) / i) elif n <= -4.2e-204: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 7e-287: tmp = (n * 100.0) * (0.0 / i) elif n <= 2.1e-8: tmp = 100.0 * (i / (i / n)) else: tmp = (n * 100.0) * (1.0 + (i * 0.5)) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.7e+199) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); elseif (n <= -4.2e-204) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 7e-287) tmp = Float64(Float64(n * 100.0) * Float64(0.0 / i)); elseif (n <= 2.1e-8) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -3.7e+199) tmp = 100.0 * ((i * n) / i); elseif (n <= -4.2e-204) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 7e-287) tmp = (n * 100.0) * (0.0 / i); elseif (n <= 2.1e-8) tmp = 100.0 * (i / (i / n)); else tmp = (n * 100.0) * (1.0 + (i * 0.5)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -3.7e+199], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -4.2e-204], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7e-287], N[(N[(n * 100.0), $MachinePrecision] * N[(0.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.1e-8], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.7 \cdot 10^{+199}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{elif}\;n \leq -4.2 \cdot 10^{-204}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-287}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{0}{i}\\
\mathbf{elif}\;n \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\end{array}
\end{array}
if n < -3.70000000000000021e199Initial program 6.0%
Taylor expanded in i around 0 9.8%
+-commutative9.8%
Simplified9.8%
div-inv9.8%
clear-num9.8%
associate--l+30.4%
metadata-eval30.4%
+-rgt-identity30.4%
*-commutative30.4%
Applied egg-rr30.4%
associate-*l/85.7%
Applied egg-rr85.7%
if -3.70000000000000021e199 < n < -4.20000000000000018e-204Initial program 31.6%
associate-/r/29.5%
sub-neg29.5%
metadata-eval29.5%
Simplified29.5%
Taylor expanded in n around inf 24.1%
associate-/l*24.1%
expm1-def77.2%
Simplified77.2%
Taylor expanded in i around 0 67.7%
*-commutative67.7%
Simplified67.7%
if -4.20000000000000018e-204 < n < 7e-287Initial program 85.7%
*-commutative85.7%
associate-/r/85.7%
associate-*l*85.7%
sub-neg85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in i around 0 85.7%
if 7e-287 < n < 2.09999999999999994e-8Initial program 10.7%
Taylor expanded in i around 0 24.2%
+-commutative24.2%
Simplified24.2%
Taylor expanded in i around 0 63.6%
if 2.09999999999999994e-8 < n Initial program 22.7%
*-commutative22.7%
associate-/r/23.2%
associate-*l*23.2%
sub-neg23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 42.7%
expm1-def94.3%
Simplified94.3%
Taylor expanded in i around 0 77.7%
*-commutative77.7%
Simplified77.7%
Final simplification73.3%
(FPCore (i n)
:precision binary64
(if (<= n -1.5e+92)
(* 100.0 (/ (* i n) i))
(if (<= n 2.1e-8)
(* 100.0 (/ i (/ i n)))
(* (* n 100.0) (+ 1.0 (* i 0.5))))))
double code(double i, double n) {
double tmp;
if (n <= -1.5e+92) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= 2.1e-8) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (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 <= (-1.5d+92)) then
tmp = 100.0d0 * ((i * n) / i)
else if (n <= 2.1d-8) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = (n * 100.0d0) * (1.0d0 + (i * 0.5d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -1.5e+92) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= 2.1e-8) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * 0.5));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.5e+92: tmp = 100.0 * ((i * n) / i) elif n <= 2.1e-8: tmp = 100.0 * (i / (i / n)) else: tmp = (n * 100.0) * (1.0 + (i * 0.5)) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.5e+92) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); elseif (n <= 2.1e-8) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * 0.5))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -1.5e+92) tmp = 100.0 * ((i * n) / i); elseif (n <= 2.1e-8) tmp = 100.0 * (i / (i / n)); else tmp = (n * 100.0) * (1.0 + (i * 0.5)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -1.5e+92], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.1e-8], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.5 \cdot 10^{+92}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{elif}\;n \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot 0.5\right)\\
\end{array}
\end{array}
if n < -1.50000000000000007e92Initial program 19.3%
Taylor expanded in i around 0 6.3%
+-commutative6.3%
Simplified6.3%
div-inv6.3%
clear-num6.3%
associate--l+30.6%
metadata-eval30.6%
+-rgt-identity30.6%
*-commutative30.6%
Applied egg-rr30.6%
associate-*l/71.9%
Applied egg-rr71.9%
if -1.50000000000000007e92 < n < 2.09999999999999994e-8Initial program 33.3%
Taylor expanded in i around 0 28.7%
+-commutative28.7%
Simplified28.7%
Taylor expanded in i around 0 65.8%
if 2.09999999999999994e-8 < n Initial program 22.7%
*-commutative22.7%
associate-/r/23.2%
associate-*l*23.2%
sub-neg23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 42.7%
expm1-def94.3%
Simplified94.3%
Taylor expanded in i around 0 77.7%
*-commutative77.7%
Simplified77.7%
Final simplification70.8%
(FPCore (i n) :precision binary64 (if (or (<= n -1.65e+93) (not (<= n 4e-8))) (* 100.0 (/ (* i n) i)) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -1.65e+93) || !(n <= 4e-8)) {
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 <= (-1.65d+93)) .or. (.not. (n <= 4d-8))) 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 <= -1.65e+93) || !(n <= 4e-8)) {
tmp = 100.0 * ((i * n) / i);
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.65e+93) or not (n <= 4e-8): tmp = 100.0 * ((i * n) / i) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.65e+93) || !(n <= 4e-8)) 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 <= -1.65e+93) || ~((n <= 4e-8))) 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, -1.65e+93], N[Not[LessEqual[n, 4e-8]], $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 -1.65 \cdot 10^{+93} \lor \neg \left(n \leq 4 \cdot 10^{-8}\right):\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.65000000000000004e93 or 4.0000000000000001e-8 < n Initial program 21.8%
Taylor expanded in i around 0 5.0%
+-commutative5.0%
Simplified5.0%
div-inv5.0%
clear-num5.0%
associate--l+27.1%
metadata-eval27.1%
+-rgt-identity27.1%
*-commutative27.1%
Applied egg-rr27.1%
associate-*l/73.8%
Applied egg-rr73.8%
if -1.65000000000000004e93 < n < 4.0000000000000001e-8Initial program 33.1%
Taylor expanded in i around 0 28.5%
+-commutative28.5%
Simplified28.5%
Taylor expanded in i around 0 66.0%
Final simplification69.8%
(FPCore (i n) :precision binary64 (if (<= n -1.5e+92) (* 100.0 (/ (* i n) i)) (if (<= n 2.05e-8) (* 100.0 (/ i (/ i n))) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -1.5e+92) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= 2.05e-8) {
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 <= (-1.5d+92)) then
tmp = 100.0d0 * ((i * n) / i)
else if (n <= 2.05d-8) 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 <= -1.5e+92) {
tmp = 100.0 * ((i * n) / i);
} else if (n <= 2.05e-8) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.5e+92: tmp = 100.0 * ((i * n) / i) elif n <= 2.05e-8: 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 <= -1.5e+92) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); elseif (n <= 2.05e-8) 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 <= -1.5e+92) tmp = 100.0 * ((i * n) / i); elseif (n <= 2.05e-8) 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, -1.5e+92], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.05e-8], 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 -1.5 \cdot 10^{+92}:\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{elif}\;n \leq 2.05 \cdot 10^{-8}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -1.50000000000000007e92Initial program 19.3%
Taylor expanded in i around 0 6.3%
+-commutative6.3%
Simplified6.3%
div-inv6.3%
clear-num6.3%
associate--l+30.6%
metadata-eval30.6%
+-rgt-identity30.6%
*-commutative30.6%
Applied egg-rr30.6%
associate-*l/71.9%
Applied egg-rr71.9%
if -1.50000000000000007e92 < n < 2.05000000000000016e-8Initial program 33.3%
Taylor expanded in i around 0 28.7%
+-commutative28.7%
Simplified28.7%
Taylor expanded in i around 0 65.8%
if 2.05000000000000016e-8 < n Initial program 22.7%
associate-/r/23.2%
sub-neg23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 42.7%
associate-/l*42.7%
expm1-def94.3%
Simplified94.3%
Taylor expanded in i around 0 77.7%
+-commutative77.7%
associate-*r*77.7%
distribute-rgt-out77.7%
Simplified77.7%
Final simplification70.8%
(FPCore (i n) :precision binary64 (if (<= i -2.0) (* (/ n i) -200.0) (if (<= i 3.5e+40) (* n 100.0) (* (* i n) 50.0))))
double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = (n / i) * -200.0;
} else if (i <= 3.5e+40) {
tmp = n * 100.0;
} else {
tmp = (i * n) * 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 / i) * (-200.0d0)
else if (i <= 3.5d+40) then
tmp = n * 100.0d0
else
tmp = (i * n) * 50.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = (n / i) * -200.0;
} else if (i <= 3.5e+40) {
tmp = n * 100.0;
} else {
tmp = (i * n) * 50.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.0: tmp = (n / i) * -200.0 elif i <= 3.5e+40: tmp = n * 100.0 else: tmp = (i * n) * 50.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -2.0) tmp = Float64(Float64(n / i) * -200.0); elseif (i <= 3.5e+40) tmp = Float64(n * 100.0); else tmp = Float64(Float64(i * n) * 50.0); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2.0) tmp = (n / i) * -200.0; elseif (i <= 3.5e+40) tmp = n * 100.0; else tmp = (i * n) * 50.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.0], N[(N[(n / i), $MachinePrecision] * -200.0), $MachinePrecision], If[LessEqual[i, 3.5e+40], N[(n * 100.0), $MachinePrecision], N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;\frac{n}{i} \cdot -200\\
\mathbf{elif}\;i \leq 3.5 \cdot 10^{+40}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\left(i \cdot n\right) \cdot 50\\
\end{array}
\end{array}
if i < -2Initial program 72.2%
associate-/r/68.2%
sub-neg68.2%
metadata-eval68.2%
Simplified68.2%
Taylor expanded in n around inf 74.2%
associate-/l*74.2%
expm1-def74.2%
Simplified74.2%
Taylor expanded in i around 0 39.8%
*-commutative39.8%
Simplified39.8%
Taylor expanded in i around inf 39.8%
if -2 < i < 3.4999999999999999e40Initial program 7.1%
associate-/r/7.6%
sub-neg7.6%
metadata-eval7.6%
Simplified7.6%
Taylor expanded in i around 0 81.8%
*-commutative81.8%
Simplified81.8%
if 3.4999999999999999e40 < i Initial program 44.3%
*-commutative44.3%
associate-/r/44.6%
associate-*l*44.5%
sub-neg44.5%
metadata-eval44.5%
Simplified44.5%
Taylor expanded in n around inf 62.6%
expm1-def62.6%
Simplified62.6%
Taylor expanded in i around 0 51.5%
*-commutative51.5%
Simplified51.5%
Taylor expanded in i around inf 51.5%
*-commutative51.5%
Simplified51.5%
Final simplification67.4%
(FPCore (i n) :precision binary64 (if (<= i -2.0) (/ (* n -200.0) i) (if (<= i 3.5e+40) (* n 100.0) (* (* i n) 50.0))))
double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = (n * -200.0) / i;
} else if (i <= 3.5e+40) {
tmp = n * 100.0;
} else {
tmp = (i * n) * 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 * (-200.0d0)) / i
else if (i <= 3.5d+40) then
tmp = n * 100.0d0
else
tmp = (i * n) * 50.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = (n * -200.0) / i;
} else if (i <= 3.5e+40) {
tmp = n * 100.0;
} else {
tmp = (i * n) * 50.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.0: tmp = (n * -200.0) / i elif i <= 3.5e+40: tmp = n * 100.0 else: tmp = (i * n) * 50.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -2.0) tmp = Float64(Float64(n * -200.0) / i); elseif (i <= 3.5e+40) tmp = Float64(n * 100.0); else tmp = Float64(Float64(i * n) * 50.0); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2.0) tmp = (n * -200.0) / i; elseif (i <= 3.5e+40) tmp = n * 100.0; else tmp = (i * n) * 50.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.0], N[(N[(n * -200.0), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[i, 3.5e+40], N[(n * 100.0), $MachinePrecision], N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;\frac{n \cdot -200}{i}\\
\mathbf{elif}\;i \leq 3.5 \cdot 10^{+40}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\left(i \cdot n\right) \cdot 50\\
\end{array}
\end{array}
if i < -2Initial program 72.2%
associate-/r/68.2%
sub-neg68.2%
metadata-eval68.2%
Simplified68.2%
Taylor expanded in n around inf 74.2%
associate-/l*74.2%
expm1-def74.2%
Simplified74.2%
Taylor expanded in i around 0 39.8%
*-commutative39.8%
Simplified39.8%
Taylor expanded in i around inf 39.8%
associate-*r/39.8%
Simplified39.8%
if -2 < i < 3.4999999999999999e40Initial program 7.1%
associate-/r/7.6%
sub-neg7.6%
metadata-eval7.6%
Simplified7.6%
Taylor expanded in i around 0 81.8%
*-commutative81.8%
Simplified81.8%
if 3.4999999999999999e40 < i Initial program 44.3%
*-commutative44.3%
associate-/r/44.6%
associate-*l*44.5%
sub-neg44.5%
metadata-eval44.5%
Simplified44.5%
Taylor expanded in n around inf 62.6%
expm1-def62.6%
Simplified62.6%
Taylor expanded in i around 0 51.5%
*-commutative51.5%
Simplified51.5%
Taylor expanded in i around inf 51.5%
*-commutative51.5%
Simplified51.5%
Final simplification67.4%
(FPCore (i n) :precision binary64 (if (<= i -2.0) (* (/ n i) -200.0) (* n 100.0)))
double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = (n / i) * -200.0;
} else {
tmp = n * 100.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-2.0d0)) then
tmp = (n / i) * (-200.0d0)
else
tmp = n * 100.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = (n / i) * -200.0;
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.0: tmp = (n / i) * -200.0 else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -2.0) tmp = Float64(Float64(n / i) * -200.0); else tmp = Float64(n * 100.0); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2.0) tmp = (n / i) * -200.0; else tmp = n * 100.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.0], N[(N[(n / i), $MachinePrecision] * -200.0), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;\frac{n}{i} \cdot -200\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if i < -2Initial program 72.2%
associate-/r/68.2%
sub-neg68.2%
metadata-eval68.2%
Simplified68.2%
Taylor expanded in n around inf 74.2%
associate-/l*74.2%
expm1-def74.2%
Simplified74.2%
Taylor expanded in i around 0 39.8%
*-commutative39.8%
Simplified39.8%
Taylor expanded in i around inf 39.8%
if -2 < i Initial program 16.2%
associate-/r/16.7%
sub-neg16.7%
metadata-eval16.7%
Simplified16.7%
Taylor expanded in i around 0 63.6%
*-commutative63.6%
Simplified63.6%
Final simplification58.8%
(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 27.6%
associate-/r/27.1%
sub-neg27.1%
metadata-eval27.1%
Simplified27.1%
Taylor expanded in i around 0 51.8%
*-commutative51.8%
Simplified51.8%
Final simplification51.8%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t\_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t\_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2024040
(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))))