
(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 (if (<= (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n)) INFINITY) (/ (* (expm1 (* n (log1p (/ i n)))) 100.0) (/ i n)) (* 100.0 (/ n (+ (fma i -0.5 1.0) (* i (* i 0.08333333333333333)))))))
double code(double i, double n) {
double tmp;
if (((pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= ((double) INFINITY)) {
tmp = (expm1((n * log1p((i / n)))) * 100.0) / (i / n);
} else {
tmp = 100.0 * (n / (fma(i, -0.5, 1.0) + (i * (i * 0.08333333333333333))));
}
return tmp;
}
function code(i, n) tmp = 0.0 if (Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) <= Inf) tmp = Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) * 100.0) / Float64(i / n)); else tmp = Float64(100.0 * Float64(n / Float64(fma(i, -0.5, 1.0) + Float64(i * Float64(i * 0.08333333333333333))))); end return tmp end
code[i_, n_] := If[LessEqual[N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * 100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(N[(i * -0.5 + 1.0), $MachinePrecision] + N[(i * N[(i * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot 100}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\mathsf{fma}\left(i, -0.5, 1\right) + i \cdot \left(i \cdot 0.08333333333333333\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 31.9%
associate-*r/31.9%
*-commutative31.9%
pow-to-exp29.1%
expm1-def37.9%
add-log-exp29.1%
pow-to-exp31.9%
log-pow37.9%
log1p-udef96.8%
Applied egg-rr96.8%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-def80.3%
Simplified80.3%
Taylor expanded in i around 0 100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
fma-def100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification97.4%
(FPCore (i n) :precision binary64 (if (<= (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n)) INFINITY) (* n (/ (expm1 (* n (log1p (/ i n)))) (/ i 100.0))) (* 100.0 (/ n (+ (fma i -0.5 1.0) (* i (* i 0.08333333333333333)))))))
double code(double i, double n) {
double tmp;
if (((pow((1.0 + (i / n)), n) + -1.0) / (i / n)) <= ((double) INFINITY)) {
tmp = n * (expm1((n * log1p((i / n)))) / (i / 100.0));
} else {
tmp = 100.0 * (n / (fma(i, -0.5, 1.0) + (i * (i * 0.08333333333333333))));
}
return tmp;
}
function code(i, n) tmp = 0.0 if (Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) <= Inf) tmp = Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / 100.0))); else tmp = Float64(100.0 * Float64(n / Float64(fma(i, -0.5, 1.0) + Float64(i * Float64(i * 0.08333333333333333))))); end return tmp end
code[i_, n_] := If[LessEqual[N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], Infinity], N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(N[(i * -0.5 + 1.0), $MachinePrecision] + N[(i * N[(i * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}} \leq \infty:\\
\;\;\;\;n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{100}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\mathsf{fma}\left(i, -0.5, 1\right) + i \cdot \left(i \cdot 0.08333333333333333\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 31.9%
associate-*r/31.9%
*-commutative31.9%
pow-to-exp29.1%
expm1-def37.9%
add-log-exp29.1%
pow-to-exp31.9%
log-pow37.9%
log1p-udef96.8%
Applied egg-rr96.8%
associate-/r/96.1%
Applied egg-rr96.1%
*-commutative96.1%
associate-/l*96.1%
Simplified96.1%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in n around inf 1.9%
*-commutative1.9%
associate-/l*1.9%
expm1-def80.3%
Simplified80.3%
Taylor expanded in i around 0 100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
fma-def100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification96.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
(if (<= n -3.4e-218)
t_0
(if (<= n 1.72e-267)
(* 100.0 (/ 0.0 (/ i n)))
(if (<= n 3e-67)
(* 100.0 (/ n (+ (fma i -0.5 1.0) (* i (* i 0.08333333333333333)))))
t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (n / (i / expm1(i)));
double tmp;
if (n <= -3.4e-218) {
tmp = t_0;
} else if (n <= 1.72e-267) {
tmp = 100.0 * (0.0 / (i / n));
} else if (n <= 3e-67) {
tmp = 100.0 * (n / (fma(i, -0.5, 1.0) + (i * (i * 0.08333333333333333))));
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(100.0 * Float64(n / Float64(i / expm1(i)))) tmp = 0.0 if (n <= -3.4e-218) tmp = t_0; elseif (n <= 1.72e-267) tmp = Float64(100.0 * Float64(0.0 / Float64(i / n))); elseif (n <= 3e-67) tmp = Float64(100.0 * Float64(n / Float64(fma(i, -0.5, 1.0) + Float64(i * Float64(i * 0.08333333333333333))))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -3.4e-218], t$95$0, If[LessEqual[n, 1.72e-267], N[(100.0 * N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3e-67], N[(100.0 * N[(n / N[(N[(i * -0.5 + 1.0), $MachinePrecision] + N[(i * N[(i * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{if}\;n \leq -3.4 \cdot 10^{-218}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 1.72 \cdot 10^{-267}:\\
\;\;\;\;100 \cdot \frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 3 \cdot 10^{-67}:\\
\;\;\;\;100 \cdot \frac{n}{\mathsf{fma}\left(i, -0.5, 1\right) + i \cdot \left(i \cdot 0.08333333333333333\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -3.39999999999999986e-218 or 3.00000000000000032e-67 < n Initial program 20.8%
Taylor expanded in n around inf 35.8%
*-commutative35.8%
associate-/l*35.8%
expm1-def90.5%
Simplified90.5%
if -3.39999999999999986e-218 < n < 1.72e-267Initial program 94.4%
Taylor expanded in i around 0 100.0%
if 1.72e-267 < n < 3.00000000000000032e-67Initial program 22.9%
Taylor expanded in n around inf 6.6%
*-commutative6.6%
associate-/l*6.6%
expm1-def32.3%
Simplified32.3%
Taylor expanded in i around 0 70.7%
+-commutative70.7%
associate-+r+70.7%
+-commutative70.7%
*-commutative70.7%
fma-def70.7%
*-commutative70.7%
unpow270.7%
associate-*l*70.7%
Simplified70.7%
Final simplification88.4%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ (expm1 i) (/ i n)))))
(if (<= i -2.2e-8)
t_0
(if (<= i 6.8e-33)
(* 100.0 (+ n (* (- 0.5 (/ 0.5 n)) (* i n))))
(if (<= i 2.3e+256) t_0 (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
double code(double i, double n) {
double t_0 = 100.0 * (expm1(i) / (i / n));
double tmp;
if (i <= -2.2e-8) {
tmp = t_0;
} else if (i <= 6.8e-33) {
tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n)));
} else if (i <= 2.3e+256) {
tmp = t_0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (Math.expm1(i) / (i / n));
double tmp;
if (i <= -2.2e-8) {
tmp = t_0;
} else if (i <= 6.8e-33) {
tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n)));
} else if (i <= 2.3e+256) {
tmp = t_0;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (math.expm1(i) / (i / n)) tmp = 0 if i <= -2.2e-8: tmp = t_0 elif i <= 6.8e-33: tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n))) elif i <= 2.3e+256: tmp = t_0 else: tmp = 100.0 * (n / (1.0 + (i * -0.5))) return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(expm1(i) / Float64(i / n))) tmp = 0.0 if (i <= -2.2e-8) tmp = t_0; elseif (i <= 6.8e-33) tmp = Float64(100.0 * Float64(n + Float64(Float64(0.5 - Float64(0.5 / n)) * Float64(i * n)))); elseif (i <= 2.3e+256) tmp = t_0; else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -2.2e-8], t$95$0, If[LessEqual[i, 6.8e-33], N[(100.0 * N[(n + N[(N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.3e+256], t$95$0, N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{if}\;i \leq -2.2 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;i \leq 6.8 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \left(n + \left(0.5 - \frac{0.5}{n}\right) \cdot \left(i \cdot n\right)\right)\\
\mathbf{elif}\;i \leq 2.3 \cdot 10^{+256}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if i < -2.1999999999999998e-8 or 6.8000000000000001e-33 < i < 2.2999999999999999e256Initial program 50.4%
Taylor expanded in n around inf 72.1%
expm1-def75.2%
Simplified75.2%
if -2.1999999999999998e-8 < i < 6.8000000000000001e-33Initial program 8.6%
Taylor expanded in i around 0 85.6%
associate-*r*85.6%
*-commutative85.6%
associate-*r/85.6%
metadata-eval85.6%
Simplified85.6%
if 2.2999999999999999e256 < i Initial program 28.6%
Taylor expanded in n around inf 15.5%
*-commutative15.5%
associate-/l*15.5%
expm1-def15.5%
Simplified15.5%
Taylor expanded in i around 0 74.3%
*-commutative74.3%
Simplified74.3%
Final simplification81.0%
(FPCore (i n) :precision binary64 (if (or (<= n -5e-221) (not (<= n 4.2e-131))) (* n (/ (expm1 i) (/ i 100.0))) (* 100.0 (/ 0.0 (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -5e-221) || !(n <= 4.2e-131)) {
tmp = n * (expm1(i) / (i / 100.0));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -5e-221) || !(n <= 4.2e-131)) {
tmp = n * (Math.expm1(i) / (i / 100.0));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -5e-221) or not (n <= 4.2e-131): tmp = n * (math.expm1(i) / (i / 100.0)) else: tmp = 100.0 * (0.0 / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -5e-221) || !(n <= 4.2e-131)) tmp = Float64(n * Float64(expm1(i) / Float64(i / 100.0))); else tmp = Float64(100.0 * Float64(0.0 / Float64(i / n))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -5e-221], N[Not[LessEqual[n, 4.2e-131]], $MachinePrecision]], N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5 \cdot 10^{-221} \lor \neg \left(n \leq 4.2 \cdot 10^{-131}\right):\\
\;\;\;\;n \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{100}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -4.99999999999999996e-221 or 4.19999999999999994e-131 < n Initial program 20.7%
associate-*r/20.7%
*-commutative20.7%
pow-to-exp17.9%
expm1-def22.8%
add-log-exp17.9%
pow-to-exp20.7%
log-pow22.8%
log1p-udef79.2%
Applied egg-rr79.2%
associate-/r/79.1%
Applied egg-rr79.1%
*-commutative79.1%
associate-/l*79.1%
Simplified79.1%
Taylor expanded in n around inf 88.4%
if -4.99999999999999996e-221 < n < 4.19999999999999994e-131Initial program 55.9%
Taylor expanded in i around 0 72.9%
Final simplification85.9%
(FPCore (i n) :precision binary64 (if (or (<= n -1.9e-217) (not (<= n 2.4e-136))) (* 100.0 (/ n (/ i (expm1 i)))) (* 100.0 (/ 0.0 (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -1.9e-217) || !(n <= 2.4e-136)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.9e-217) || !(n <= 2.4e-136)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.9e-217) or not (n <= 2.4e-136): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 100.0 * (0.0 / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.9e-217) || !(n <= 2.4e-136)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = Float64(100.0 * Float64(0.0 / Float64(i / n))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.9e-217], N[Not[LessEqual[n, 2.4e-136]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.9 \cdot 10^{-217} \lor \neg \left(n \leq 2.4 \cdot 10^{-136}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.89999999999999993e-217 or 2.3999999999999999e-136 < n Initial program 20.7%
Taylor expanded in n around inf 33.8%
*-commutative33.8%
associate-/l*33.8%
expm1-def88.5%
Simplified88.5%
if -1.89999999999999993e-217 < n < 2.3999999999999999e-136Initial program 55.9%
Taylor expanded in i around 0 72.9%
Final simplification86.0%
(FPCore (i n)
:precision binary64
(if (<= n -1.1e-217)
(* n (/ (* 100.0 (expm1 i)) i))
(if (<= n 3.1e-132)
(* 100.0 (/ 0.0 (/ i n)))
(* n (/ (expm1 i) (/ i 100.0))))))
double code(double i, double n) {
double tmp;
if (n <= -1.1e-217) {
tmp = n * ((100.0 * expm1(i)) / i);
} else if (n <= 3.1e-132) {
tmp = 100.0 * (0.0 / (i / n));
} else {
tmp = n * (expm1(i) / (i / 100.0));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -1.1e-217) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else if (n <= 3.1e-132) {
tmp = 100.0 * (0.0 / (i / n));
} else {
tmp = n * (Math.expm1(i) / (i / 100.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.1e-217: tmp = n * ((100.0 * math.expm1(i)) / i) elif n <= 3.1e-132: tmp = 100.0 * (0.0 / (i / n)) else: tmp = n * (math.expm1(i) / (i / 100.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.1e-217) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); elseif (n <= 3.1e-132) tmp = Float64(100.0 * Float64(0.0 / Float64(i / n))); else tmp = Float64(n * Float64(expm1(i) / Float64(i / 100.0))); end return tmp end
code[i_, n_] := If[LessEqual[n, -1.1e-217], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.1e-132], N[(100.0 * N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.1 \cdot 10^{-217}:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{elif}\;n \leq 3.1 \cdot 10^{-132}:\\
\;\;\;\;100 \cdot \frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{100}}\\
\end{array}
\end{array}
if n < -1.09999999999999991e-217Initial program 19.3%
associate-/r/19.6%
associate-*r*19.6%
*-commutative19.6%
associate-*r/19.7%
sub-neg19.7%
distribute-lft-in19.6%
fma-def19.7%
metadata-eval19.7%
metadata-eval19.7%
Simplified19.7%
fma-udef19.6%
*-commutative19.6%
Applied egg-rr19.6%
Taylor expanded in n around inf 36.5%
sub-neg36.5%
metadata-eval36.5%
metadata-eval36.5%
distribute-lft-in36.4%
metadata-eval36.4%
sub-neg36.4%
expm1-def86.5%
Simplified86.5%
if -1.09999999999999991e-217 < n < 3.10000000000000008e-132Initial program 55.9%
Taylor expanded in i around 0 72.9%
if 3.10000000000000008e-132 < n Initial program 22.2%
associate-*r/22.2%
*-commutative22.2%
pow-to-exp19.2%
expm1-def22.0%
add-log-exp19.2%
pow-to-exp22.2%
log-pow22.0%
log1p-udef76.2%
Applied egg-rr76.2%
associate-/r/76.6%
Applied egg-rr76.6%
*-commutative76.6%
associate-/l*76.6%
Simplified76.6%
Taylor expanded in n around inf 90.6%
Final simplification85.9%
(FPCore (i n) :precision binary64 (if (or (<= n -6.5e-219) (not (<= n 4.1e-132))) (* n (+ 100.0 (+ (* 16.666666666666668 (* i i)) (* i 50.0)))) (* 100.0 (/ 0.0 (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -6.5e-219) || !(n <= 4.1e-132)) {
tmp = n * (100.0 + ((16.666666666666668 * (i * i)) + (i * 50.0)));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-6.5d-219)) .or. (.not. (n <= 4.1d-132))) then
tmp = n * (100.0d0 + ((16.666666666666668d0 * (i * i)) + (i * 50.0d0)))
else
tmp = 100.0d0 * (0.0d0 / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -6.5e-219) || !(n <= 4.1e-132)) {
tmp = n * (100.0 + ((16.666666666666668 * (i * i)) + (i * 50.0)));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -6.5e-219) or not (n <= 4.1e-132): tmp = n * (100.0 + ((16.666666666666668 * (i * i)) + (i * 50.0))) else: tmp = 100.0 * (0.0 / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -6.5e-219) || !(n <= 4.1e-132)) tmp = Float64(n * Float64(100.0 + Float64(Float64(16.666666666666668 * Float64(i * i)) + Float64(i * 50.0)))); else tmp = Float64(100.0 * Float64(0.0 / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -6.5e-219) || ~((n <= 4.1e-132))) tmp = n * (100.0 + ((16.666666666666668 * (i * i)) + (i * 50.0))); else tmp = 100.0 * (0.0 / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -6.5e-219], N[Not[LessEqual[n, 4.1e-132]], $MachinePrecision]], N[(n * N[(100.0 + N[(N[(16.666666666666668 * N[(i * i), $MachinePrecision]), $MachinePrecision] + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.5 \cdot 10^{-219} \lor \neg \left(n \leq 4.1 \cdot 10^{-132}\right):\\
\;\;\;\;n \cdot \left(100 + \left(16.666666666666668 \cdot \left(i \cdot i\right) + i \cdot 50\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -6.49999999999999958e-219 or 4.10000000000000007e-132 < n Initial program 20.7%
associate-/r/21.0%
associate-*r*21.0%
*-commutative21.0%
associate-*r/21.0%
sub-neg21.0%
distribute-lft-in21.0%
fma-def21.0%
metadata-eval21.0%
metadata-eval21.0%
Simplified21.0%
Taylor expanded in i around 0 69.3%
+-commutative69.3%
distribute-lft-out69.3%
Simplified69.3%
Taylor expanded in n around inf 71.6%
distribute-lft-in71.6%
associate-*r*71.6%
metadata-eval71.6%
unpow271.6%
associate-*r*71.6%
metadata-eval71.6%
Simplified71.6%
if -6.49999999999999958e-219 < n < 4.10000000000000007e-132Initial program 55.9%
Taylor expanded in i around 0 72.9%
Final simplification71.8%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ i (/ i n)))))
(if (<= i -5e+36)
t_0
(if (<= i 3200.0) (* n 100.0) (if (<= i 7e+255) (* 50.0 (* i n)) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (i / (i / n));
double tmp;
if (i <= -5e+36) {
tmp = t_0;
} else if (i <= 3200.0) {
tmp = n * 100.0;
} else if (i <= 7e+255) {
tmp = 50.0 * (i * n);
} else {
tmp = t_0;
}
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 = 100.0d0 * (i / (i / n))
if (i <= (-5d+36)) then
tmp = t_0
else if (i <= 3200.0d0) then
tmp = n * 100.0d0
else if (i <= 7d+255) then
tmp = 50.0d0 * (i * n)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = 100.0 * (i / (i / n));
double tmp;
if (i <= -5e+36) {
tmp = t_0;
} else if (i <= 3200.0) {
tmp = n * 100.0;
} else if (i <= 7e+255) {
tmp = 50.0 * (i * n);
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (i / (i / n)) tmp = 0 if i <= -5e+36: tmp = t_0 elif i <= 3200.0: tmp = n * 100.0 elif i <= 7e+255: tmp = 50.0 * (i * n) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(i / Float64(i / n))) tmp = 0.0 if (i <= -5e+36) tmp = t_0; elseif (i <= 3200.0) tmp = Float64(n * 100.0); elseif (i <= 7e+255) tmp = Float64(50.0 * Float64(i * n)); else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = 100.0 * (i / (i / n)); tmp = 0.0; if (i <= -5e+36) tmp = t_0; elseif (i <= 3200.0) tmp = n * 100.0; elseif (i <= 7e+255) tmp = 50.0 * (i * n); else tmp = t_0; end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -5e+36], t$95$0, If[LessEqual[i, 3200.0], N[(n * 100.0), $MachinePrecision], If[LessEqual[i, 7e+255], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{if}\;i \leq -5 \cdot 10^{+36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;i \leq 3200:\\
\;\;\;\;n \cdot 100\\
\mathbf{elif}\;i \leq 7 \cdot 10^{+255}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if i < -4.99999999999999977e36 or 6.99999999999999971e255 < i Initial program 57.6%
Taylor expanded in i around 0 33.8%
if -4.99999999999999977e36 < i < 3200Initial program 9.3%
Taylor expanded in i around 0 80.6%
*-commutative80.6%
Simplified80.6%
if 3200 < i < 6.99999999999999971e255Initial program 51.7%
Taylor expanded in i around 0 35.3%
associate-*r*35.3%
*-commutative35.3%
associate-*r/35.3%
metadata-eval35.3%
Simplified35.3%
Taylor expanded in n around inf 35.5%
*-commutative35.5%
associate-*r*35.5%
Simplified35.5%
Taylor expanded in i around inf 35.5%
Final simplification63.4%
(FPCore (i n)
:precision binary64
(if (<= n -4e+271)
(/ (* 100.0 (* i n)) i)
(if (<= n -2.4e-220)
(* 100.0 (/ n (+ 1.0 (* i -0.5))))
(if (<= n 1.35e-134)
(* 100.0 (/ 0.0 (/ i n)))
(* n (+ 100.0 (* i 50.0)))))))
double code(double i, double n) {
double tmp;
if (n <= -4e+271) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -2.4e-220) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 1.35e-134) {
tmp = 100.0 * (0.0 / (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 <= (-4d+271)) then
tmp = (100.0d0 * (i * n)) / i
else if (n <= (-2.4d-220)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 1.35d-134) then
tmp = 100.0d0 * (0.0d0 / (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 <= -4e+271) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -2.4e-220) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 1.35e-134) {
tmp = 100.0 * (0.0 / (i / n));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -4e+271: tmp = (100.0 * (i * n)) / i elif n <= -2.4e-220: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 1.35e-134: tmp = 100.0 * (0.0 / (i / n)) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -4e+271) tmp = Float64(Float64(100.0 * Float64(i * n)) / i); elseif (n <= -2.4e-220) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 1.35e-134) tmp = Float64(100.0 * Float64(0.0 / 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 <= -4e+271) tmp = (100.0 * (i * n)) / i; elseif (n <= -2.4e-220) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 1.35e-134) tmp = 100.0 * (0.0 / (i / n)); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -4e+271], N[(N[(100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[n, -2.4e-220], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.35e-134], N[(100.0 * N[(0.0 / 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 -4 \cdot 10^{+271}:\\
\;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\
\mathbf{elif}\;n \leq -2.4 \cdot 10^{-220}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 1.35 \cdot 10^{-134}:\\
\;\;\;\;100 \cdot \frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -3.99999999999999981e271Initial program 9.9%
associate-*r/9.9%
*-commutative9.9%
pow-to-exp9.9%
expm1-def9.9%
add-log-exp9.9%
pow-to-exp9.9%
log-pow9.9%
log1p-udef91.5%
Applied egg-rr91.5%
Taylor expanded in n around inf 91.7%
associate-*r/83.9%
expm1-def92.1%
Simplified92.1%
Taylor expanded in i around 0 52.5%
if -3.99999999999999981e271 < n < -2.4000000000000001e-220Initial program 20.4%
Taylor expanded in n around inf 29.8%
*-commutative29.8%
associate-/l*29.8%
expm1-def85.0%
Simplified85.0%
Taylor expanded in i around 0 65.2%
*-commutative65.2%
Simplified65.2%
if -2.4000000000000001e-220 < n < 1.3499999999999999e-134Initial program 55.9%
Taylor expanded in i around 0 72.9%
if 1.3499999999999999e-134 < n Initial program 22.2%
Taylor expanded in i around 0 74.0%
associate-*r*74.0%
*-commutative74.0%
associate-*r/74.0%
metadata-eval74.0%
Simplified74.0%
Taylor expanded in n around inf 74.2%
*-commutative74.2%
associate-*r*74.2%
Simplified74.2%
Taylor expanded in n around 0 74.2%
+-commutative74.2%
*-commutative74.2%
distribute-lft-in74.2%
*-rgt-identity74.2%
distribute-rgt-in74.2%
+-commutative74.2%
associate-*l*74.2%
distribute-lft-out74.2%
associate-*l*74.2%
metadata-eval74.2%
Simplified74.2%
Final simplification69.4%
(FPCore (i n) :precision binary64 (if (or (<= n -1.7e+52) (not (<= n 2.92e-67))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -1.7e+52) || !(n <= 2.92e-67)) {
tmp = n * (100.0 + (i * 50.0));
} 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.7d+52)) .or. (.not. (n <= 2.92d-67))) then
tmp = n * (100.0d0 + (i * 50.0d0))
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.7e+52) || !(n <= 2.92e-67)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.7e+52) or not (n <= 2.92e-67): tmp = n * (100.0 + (i * 50.0)) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.7e+52) || !(n <= 2.92e-67)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); 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.7e+52) || ~((n <= 2.92e-67))) tmp = n * (100.0 + (i * 50.0)); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.7e+52], N[Not[LessEqual[n, 2.92e-67]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.7 \cdot 10^{+52} \lor \neg \left(n \leq 2.92 \cdot 10^{-67}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.7e52 or 2.92000000000000004e-67 < n Initial program 19.7%
Taylor expanded in i around 0 68.1%
associate-*r*68.1%
*-commutative68.1%
associate-*r/68.1%
metadata-eval68.1%
Simplified68.1%
Taylor expanded in n around inf 68.2%
*-commutative68.2%
associate-*r*68.2%
Simplified68.2%
Taylor expanded in n around 0 68.2%
+-commutative68.2%
*-commutative68.2%
distribute-lft-in68.2%
*-rgt-identity68.2%
distribute-rgt-in68.2%
+-commutative68.2%
associate-*l*68.2%
distribute-lft-out68.2%
associate-*l*68.2%
metadata-eval68.2%
Simplified68.2%
if -1.7e52 < n < 2.92000000000000004e-67Initial program 35.9%
Taylor expanded in i around 0 60.6%
Final simplification65.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.3e-216) (not (<= n 1.35e-134))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ 0.0 (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -1.3e-216) || !(n <= 1.35e-134)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-1.3d-216)) .or. (.not. (n <= 1.35d-134))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 100.0d0 * (0.0d0 / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.3e-216) || !(n <= 1.35e-134)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (0.0 / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.3e-216) or not (n <= 1.35e-134): tmp = n * (100.0 + (i * 50.0)) else: tmp = 100.0 * (0.0 / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.3e-216) || !(n <= 1.35e-134)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = Float64(100.0 * Float64(0.0 / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.3e-216) || ~((n <= 1.35e-134))) tmp = n * (100.0 + (i * 50.0)); else tmp = 100.0 * (0.0 / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.3e-216], N[Not[LessEqual[n, 1.35e-134]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.3 \cdot 10^{-216} \lor \neg \left(n \leq 1.35 \cdot 10^{-134}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.2999999999999999e-216 or 1.3499999999999999e-134 < n Initial program 20.7%
Taylor expanded in i around 0 66.3%
associate-*r*66.4%
*-commutative66.4%
associate-*r/66.4%
metadata-eval66.4%
Simplified66.4%
Taylor expanded in n around inf 66.3%
*-commutative66.3%
associate-*r*66.3%
Simplified66.3%
Taylor expanded in n around 0 66.3%
+-commutative66.3%
*-commutative66.3%
distribute-lft-in66.3%
*-rgt-identity66.3%
distribute-rgt-in66.3%
+-commutative66.3%
associate-*l*66.3%
distribute-lft-out66.3%
associate-*l*66.3%
metadata-eval66.3%
Simplified66.3%
if -1.2999999999999999e-216 < n < 1.3499999999999999e-134Initial program 55.9%
Taylor expanded in i around 0 72.9%
Final simplification67.3%
(FPCore (i n) :precision binary64 (if (<= n -400000.0) (/ (* 100.0 (* i n)) i) (if (<= n 3e-67) (* 100.0 (/ i (/ i n))) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -400000.0) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= 3e-67) {
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 <= (-400000.0d0)) then
tmp = (100.0d0 * (i * n)) / i
else if (n <= 3d-67) 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 <= -400000.0) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= 3e-67) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -400000.0: tmp = (100.0 * (i * n)) / i elif n <= 3e-67: 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 <= -400000.0) tmp = Float64(Float64(100.0 * Float64(i * n)) / i); elseif (n <= 3e-67) 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 <= -400000.0) tmp = (100.0 * (i * n)) / i; elseif (n <= 3e-67) 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, -400000.0], N[(N[(100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[n, 3e-67], 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 -400000:\\
\;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\
\mathbf{elif}\;n \leq 3 \cdot 10^{-67}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -4e5Initial program 17.5%
associate-*r/17.5%
*-commutative17.5%
pow-to-exp13.5%
expm1-def13.5%
add-log-exp13.5%
pow-to-exp17.5%
log-pow13.5%
log1p-udef72.7%
Applied egg-rr72.7%
Taylor expanded in n around inf 48.1%
associate-*r/46.8%
expm1-def94.3%
Simplified94.3%
Taylor expanded in i around 0 57.7%
if -4e5 < n < 3.00000000000000032e-67Initial program 36.7%
Taylor expanded in i around 0 60.1%
if 3.00000000000000032e-67 < n Initial program 22.8%
Taylor expanded in i around 0 76.6%
associate-*r*76.6%
*-commutative76.6%
associate-*r/76.6%
metadata-eval76.6%
Simplified76.6%
Taylor expanded in n around inf 76.7%
*-commutative76.7%
associate-*r*76.7%
Simplified76.7%
Taylor expanded in n around 0 76.7%
+-commutative76.7%
*-commutative76.7%
distribute-lft-in76.7%
*-rgt-identity76.7%
distribute-rgt-in76.7%
+-commutative76.7%
associate-*l*76.7%
distribute-lft-out76.7%
associate-*l*76.7%
metadata-eval76.7%
Simplified76.7%
Final simplification65.2%
(FPCore (i n) :precision binary64 (if (<= i 3100.0) (* n 100.0) (* 50.0 (* i n))))
double code(double i, double n) {
double tmp;
if (i <= 3100.0) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 3100.0d0) then
tmp = n * 100.0d0
else
tmp = 50.0d0 * (i * n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 3100.0) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 3100.0: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= 3100.0) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 3100.0) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 3100.0], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 3100:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < 3100Initial program 20.3%
Taylor expanded in i around 0 64.9%
*-commutative64.9%
Simplified64.9%
if 3100 < i Initial program 48.7%
Taylor expanded in i around 0 31.1%
associate-*r*31.2%
*-commutative31.2%
associate-*r/31.2%
metadata-eval31.2%
Simplified31.2%
Taylor expanded in n around inf 31.5%
*-commutative31.5%
associate-*r*31.5%
Simplified31.5%
Taylor expanded in i around inf 31.5%
Final simplification57.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 26.3%
Taylor expanded in i around 0 57.6%
associate-*r*57.7%
*-commutative57.7%
associate-*r/57.7%
metadata-eval57.7%
Simplified57.7%
Taylor expanded in n around 0 2.8%
*-commutative2.8%
Simplified2.8%
Final simplification2.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 26.3%
Taylor expanded in i around 0 52.3%
*-commutative52.3%
Simplified52.3%
Final simplification52.3%
(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 2023195
(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))))