
(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) -1.0) (/ i n))))
(if (<= t_0 0.0)
(* (/ (expm1 (* n (log1p (/ i n)))) i) (* n 100.0))
(if (<= t_0 INFINITY)
(* t_0 100.0)
(/ 1.0 (/ (+ 1.0 (* i -0.5)) (* n 100.0)))))))
double code(double i, double n) {
double t_0 = (pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = (expm1((n * log1p((i / n)))) / i) * (n * 100.0);
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = 1.0 / ((1.0 + (i * -0.5)) / (n * 100.0));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = (Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = (Math.expm1((n * Math.log1p((i / n)))) / i) * (n * 100.0);
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = 1.0 / ((1.0 + (i * -0.5)) / (n * 100.0));
}
return tmp;
}
def code(i, n): t_0 = (math.pow((1.0 + (i / n)), n) + -1.0) / (i / n) tmp = 0 if t_0 <= 0.0: tmp = (math.expm1((n * math.log1p((i / n)))) / i) * (n * 100.0) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = 1.0 / ((1.0 + (i * -0.5)) / (n * 100.0)) return tmp
function code(i, n) t_0 = Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i) * Float64(n * 100.0)); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(i * -0.5)) / Float64(n * 100.0))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(1.0 / N[(N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision] / N[(n * 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1 + i \cdot -0.5}{n \cdot 100}}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 27.7%
associate-*r/27.7%
sub-neg27.7%
distribute-lft-in27.7%
metadata-eval27.7%
metadata-eval27.7%
Simplified27.7%
metadata-eval27.7%
metadata-eval27.7%
distribute-lft-in27.7%
sub-neg27.7%
*-commutative27.7%
associate-*l/27.7%
associate-/r/27.7%
associate-*l*27.7%
add-exp-log27.7%
expm1-def27.7%
log-pow33.5%
log1p-udef96.0%
Applied egg-rr96.0%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.6%
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-def82.9%
Simplified82.9%
associate-*l/82.9%
div-inv82.8%
associate-/r*5.5%
Applied egg-rr5.5%
Taylor expanded in i around 0 20.3%
clear-num22.7%
inv-pow22.7%
div-inv22.7%
sub-neg22.7%
metadata-eval22.7%
clear-num22.7%
*-commutative22.7%
Applied egg-rr22.7%
unpow-122.7%
associate-*r/99.7%
*-commutative99.7%
distribute-lft-in99.7%
rgt-mult-inverse99.7%
Simplified99.7%
Final simplification97.0%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 0.0)
(* n (* (/ (expm1 (* n (log1p (/ i n)))) i) 100.0))
(if (<= t_0 INFINITY)
(* t_0 100.0)
(/ 1.0 (/ (+ 1.0 (* i -0.5)) (* n 100.0)))))))
double code(double i, double n) {
double t_0 = (pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = n * ((expm1((n * log1p((i / n)))) / i) * 100.0);
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = 1.0 / ((1.0 + (i * -0.5)) / (n * 100.0));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = (Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= 0.0) {
tmp = n * ((Math.expm1((n * Math.log1p((i / n)))) / i) * 100.0);
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = 1.0 / ((1.0 + (i * -0.5)) / (n * 100.0));
}
return tmp;
}
def code(i, n): t_0 = (math.pow((1.0 + (i / n)), n) + -1.0) / (i / n) tmp = 0 if t_0 <= 0.0: tmp = n * ((math.expm1((n * math.log1p((i / n)))) / i) * 100.0) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = 1.0 / ((1.0 + (i * -0.5)) / (n * 100.0)) return tmp
function code(i, n) t_0 = Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(n * Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i) * 100.0)); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(i * -0.5)) / Float64(n * 100.0))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(n * N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(1.0 / N[(N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision] / N[(n * 100.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;n \cdot \left(\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot 100\right)\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;t_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1 + i \cdot -0.5}{n \cdot 100}}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 27.7%
associate-*r/27.7%
sub-neg27.7%
distribute-lft-in27.7%
metadata-eval27.7%
metadata-eval27.7%
Simplified27.7%
metadata-eval27.7%
metadata-eval27.7%
distribute-lft-in27.7%
sub-neg27.7%
associate-*r/27.7%
associate-/r/27.7%
associate-*r*27.7%
add-exp-log27.7%
expm1-def27.7%
log-pow33.5%
log1p-udef95.9%
Applied egg-rr95.9%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 98.6%
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-def82.9%
Simplified82.9%
associate-*l/82.9%
div-inv82.8%
associate-/r*5.5%
Applied egg-rr5.5%
Taylor expanded in i around 0 20.3%
clear-num22.7%
inv-pow22.7%
div-inv22.7%
sub-neg22.7%
metadata-eval22.7%
clear-num22.7%
*-commutative22.7%
Applied egg-rr22.7%
unpow-122.7%
associate-*r/99.7%
*-commutative99.7%
distribute-lft-in99.7%
rgt-mult-inverse99.7%
Simplified99.7%
Final simplification96.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ (expm1 i) (/ i n)))))
(if (<= i -2e-15)
t_0
(if (<= i -2.65e-166)
(* (/ 100.0 i) (/ i (/ 1.0 n)))
(if (<= i 3.2e-91) (* 100.0 (+ n (* i -0.5))) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (expm1(i) / (i / n));
double tmp;
if (i <= -2e-15) {
tmp = t_0;
} else if (i <= -2.65e-166) {
tmp = (100.0 / i) * (i / (1.0 / n));
} else if (i <= 3.2e-91) {
tmp = 100.0 * (n + (i * -0.5));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (Math.expm1(i) / (i / n));
double tmp;
if (i <= -2e-15) {
tmp = t_0;
} else if (i <= -2.65e-166) {
tmp = (100.0 / i) * (i / (1.0 / n));
} else if (i <= 3.2e-91) {
tmp = 100.0 * (n + (i * -0.5));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (math.expm1(i) / (i / n)) tmp = 0 if i <= -2e-15: tmp = t_0 elif i <= -2.65e-166: tmp = (100.0 / i) * (i / (1.0 / n)) elif i <= 3.2e-91: tmp = 100.0 * (n + (i * -0.5)) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(expm1(i) / Float64(i / n))) tmp = 0.0 if (i <= -2e-15) tmp = t_0; elseif (i <= -2.65e-166) tmp = Float64(Float64(100.0 / i) * Float64(i / Float64(1.0 / n))); elseif (i <= 3.2e-91) tmp = Float64(100.0 * Float64(n + Float64(i * -0.5))); else tmp = t_0; 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, -2e-15], t$95$0, If[LessEqual[i, -2.65e-166], N[(N[(100.0 / i), $MachinePrecision] * N[(i / N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 3.2e-91], N[(100.0 * N[(n + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{if}\;i \leq -2 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;i \leq -2.65 \cdot 10^{-166}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{i}{\frac{1}{n}}\\
\mathbf{elif}\;i \leq 3.2 \cdot 10^{-91}:\\
\;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if i < -2.0000000000000002e-15 or 3.19999999999999996e-91 < i Initial program 46.6%
Taylor expanded in n around inf 63.6%
expm1-def70.1%
Simplified70.1%
if -2.0000000000000002e-15 < i < -2.64999999999999998e-166Initial program 17.3%
associate-*r/17.3%
sub-neg17.3%
distribute-lft-in17.3%
metadata-eval17.3%
metadata-eval17.3%
Simplified17.3%
Taylor expanded in i around 0 17.8%
*-commutative17.8%
Simplified17.8%
Taylor expanded in i around 0 51.5%
div-inv51.6%
times-frac86.3%
Applied egg-rr86.3%
if -2.64999999999999998e-166 < i < 3.19999999999999996e-91Initial program 2.9%
Taylor expanded in i around 0 97.4%
associate-*r*97.1%
associate-*r/97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in n around 0 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification81.5%
(FPCore (i n) :precision binary64 (if (or (<= n -1.45e-163) (not (<= n 1.35e-169))) (* n (/ (* 100.0 (expm1 i)) i)) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.45e-163) || !(n <= 1.35e-169)) {
tmp = n * ((100.0 * expm1(i)) / i);
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.45e-163) || !(n <= 1.35e-169)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.45e-163) or not (n <= 1.35e-169): tmp = n * ((100.0 * math.expm1(i)) / i) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.45e-163) || !(n <= 1.35e-169)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.45e-163], N[Not[LessEqual[n, 1.35e-169]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.45 \cdot 10^{-163} \lor \neg \left(n \leq 1.35 \cdot 10^{-169}\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.4500000000000001e-163 or 1.3500000000000001e-169 < n Initial program 21.8%
associate-/r/22.2%
associate-*r*22.1%
*-commutative22.1%
associate-*r/22.2%
sub-neg22.2%
distribute-lft-in22.2%
metadata-eval22.2%
metadata-eval22.2%
metadata-eval22.2%
fma-def22.2%
metadata-eval22.2%
Simplified22.2%
Taylor expanded in n around inf 37.4%
sub-neg37.4%
metadata-eval37.4%
+-commutative37.4%
Applied egg-rr37.4%
+-commutative37.4%
metadata-eval37.4%
distribute-lft-in37.5%
metadata-eval37.5%
sub-neg37.5%
expm1-def88.8%
Simplified88.8%
if -1.4500000000000001e-163 < n < 1.3500000000000001e-169Initial program 58.2%
associate-*r/58.2%
sub-neg58.2%
distribute-lft-in58.2%
metadata-eval58.2%
metadata-eval58.2%
Simplified58.2%
Taylor expanded in i around 0 76.8%
Taylor expanded in i around 0 76.8%
Final simplification86.8%
(FPCore (i n) :precision binary64 (if (or (<= n -1.05e-157) (not (<= n 1e-170))) (* 100.0 (/ n (/ i (expm1 i)))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.05e-157) || !(n <= 1e-170)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.05e-157) || !(n <= 1e-170)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.05e-157) or not (n <= 1e-170): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.05e-157) || !(n <= 1e-170)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.05e-157], N[Not[LessEqual[n, 1e-170]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.05 \cdot 10^{-157} \lor \neg \left(n \leq 10^{-170}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.05e-157 or 9.99999999999999983e-171 < n Initial program 21.8%
Taylor expanded in n around inf 37.4%
*-commutative37.4%
associate-/l*37.5%
expm1-def88.9%
Simplified88.9%
if -1.05e-157 < n < 9.99999999999999983e-171Initial program 58.2%
associate-*r/58.2%
sub-neg58.2%
distribute-lft-in58.2%
metadata-eval58.2%
metadata-eval58.2%
Simplified58.2%
Taylor expanded in i around 0 76.8%
Taylor expanded in i around 0 76.8%
Final simplification86.9%
(FPCore (i n) :precision binary64 (if (<= n -3.8e-162) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) (if (<= n 5.2e-174) 0.0 (* 100.0 (+ n (* (- 0.5 (/ 0.5 n)) (* i n)))))))
double code(double i, double n) {
double tmp;
if (n <= -3.8e-162) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 5.2e-174) {
tmp = 0.0;
} else {
tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (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 <= (-3.8d-162)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 5.2d-174) then
tmp = 0.0d0
else
tmp = 100.0d0 * (n + ((0.5d0 - (0.5d0 / n)) * (i * n)))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -3.8e-162) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 5.2e-174) {
tmp = 0.0;
} else {
tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.8e-162: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 5.2e-174: tmp = 0.0 else: tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n))) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.8e-162) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 5.2e-174) tmp = 0.0; else tmp = Float64(100.0 * Float64(n + Float64(Float64(0.5 - Float64(0.5 / n)) * Float64(i * n)))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -3.8e-162) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 5.2e-174) tmp = 0.0; else tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -3.8e-162], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 5.2e-174], 0.0, N[(100.0 * N[(n + N[(N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.8 \cdot 10^{-162}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 5.2 \cdot 10^{-174}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + \left(0.5 - \frac{0.5}{n}\right) \cdot \left(i \cdot n\right)\right)\\
\end{array}
\end{array}
if n < -3.80000000000000005e-162Initial program 25.0%
Taylor expanded in n around inf 38.6%
*-commutative38.6%
associate-/l*38.6%
expm1-def87.9%
Simplified87.9%
Taylor expanded in i around 0 62.7%
*-commutative62.7%
Simplified62.7%
if -3.80000000000000005e-162 < n < 5.2000000000000004e-174Initial program 58.2%
associate-*r/58.2%
sub-neg58.2%
distribute-lft-in58.2%
metadata-eval58.2%
metadata-eval58.2%
Simplified58.2%
Taylor expanded in i around 0 76.8%
Taylor expanded in i around 0 76.8%
if 5.2000000000000004e-174 < n Initial program 17.9%
Taylor expanded in i around 0 66.9%
associate-*r*66.5%
associate-*r/66.5%
metadata-eval66.5%
Simplified66.5%
Final simplification66.6%
(FPCore (i n) :precision binary64 (if (<= n -1.4e-161) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) (if (<= n 6.6e-174) 0.0 (* n (+ 100.0 (* 100.0 (* i (- 0.5 (/ 0.5 n)))))))))
double code(double i, double n) {
double tmp;
if (n <= -1.4e-161) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 6.6e-174) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / 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.4d-161)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 6.6d-174) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (100.0d0 * (i * (0.5d0 - (0.5d0 / n)))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -1.4e-161) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 6.6e-174) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n)))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.4e-161: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 6.6e-174: tmp = 0.0 else: tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n))))) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.4e-161) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 6.6e-174) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(100.0 * Float64(i * Float64(0.5 - Float64(0.5 / n)))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -1.4e-161) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 6.6e-174) tmp = 0.0; else tmp = n * (100.0 + (100.0 * (i * (0.5 - (0.5 / n))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -1.4e-161], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6.6e-174], 0.0, N[(n * N[(100.0 + N[(100.0 * N[(i * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.4 \cdot 10^{-161}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 6.6 \cdot 10^{-174}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + 100 \cdot \left(i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\right)\\
\end{array}
\end{array}
if n < -1.39999999999999996e-161Initial program 25.0%
Taylor expanded in n around inf 38.6%
*-commutative38.6%
associate-/l*38.6%
expm1-def87.9%
Simplified87.9%
Taylor expanded in i around 0 62.7%
*-commutative62.7%
Simplified62.7%
if -1.39999999999999996e-161 < n < 6.6000000000000002e-174Initial program 58.2%
associate-*r/58.2%
sub-neg58.2%
distribute-lft-in58.2%
metadata-eval58.2%
metadata-eval58.2%
Simplified58.2%
Taylor expanded in i around 0 76.8%
Taylor expanded in i around 0 76.8%
if 6.6000000000000002e-174 < n Initial program 17.9%
associate-/r/18.3%
associate-*r*18.3%
*-commutative18.3%
associate-*r/18.3%
sub-neg18.3%
distribute-lft-in18.3%
metadata-eval18.3%
metadata-eval18.3%
metadata-eval18.3%
fma-def18.3%
metadata-eval18.3%
Simplified18.3%
Taylor expanded in i around 0 66.9%
associate-*r/66.9%
metadata-eval66.9%
Simplified66.9%
Final simplification66.7%
(FPCore (i n) :precision binary64 (if (or (<= n -1.9e-164) (not (<= n 1.12e-170))) (* n (+ 100.0 (* i 50.0))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.9e-164) || !(n <= 1.12e-170)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-1.9d-164)) .or. (.not. (n <= 1.12d-170))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.9e-164) || !(n <= 1.12e-170)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.9e-164) or not (n <= 1.12e-170): tmp = n * (100.0 + (i * 50.0)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.9e-164) || !(n <= 1.12e-170)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.9e-164) || ~((n <= 1.12e-170))) tmp = n * (100.0 + (i * 50.0)); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.9e-164], N[Not[LessEqual[n, 1.12e-170]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.9 \cdot 10^{-164} \lor \neg \left(n \leq 1.12 \cdot 10^{-170}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.89999999999999995e-164 or 1.12000000000000009e-170 < n Initial program 21.8%
associate-/r/22.2%
associate-*r*22.1%
*-commutative22.1%
associate-*r/22.2%
sub-neg22.2%
distribute-lft-in22.2%
metadata-eval22.2%
metadata-eval22.2%
metadata-eval22.2%
fma-def22.2%
metadata-eval22.2%
Simplified22.2%
Taylor expanded in n around inf 37.4%
Taylor expanded in i around 0 61.6%
*-commutative61.6%
Simplified61.6%
if -1.89999999999999995e-164 < n < 1.12000000000000009e-170Initial program 58.2%
associate-*r/58.2%
sub-neg58.2%
distribute-lft-in58.2%
metadata-eval58.2%
metadata-eval58.2%
Simplified58.2%
Taylor expanded in i around 0 76.8%
Taylor expanded in i around 0 76.8%
Final simplification64.2%
(FPCore (i n) :precision binary64 (if (<= i -1.5) (* -200.0 (/ n i)) (if (<= i 2.05e-11) (* 100.0 (+ n (* i -0.5))) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -1.5) {
tmp = -200.0 * (n / i);
} else if (i <= 2.05e-11) {
tmp = 100.0 * (n + (i * -0.5));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-1.5d0)) then
tmp = (-200.0d0) * (n / i)
else if (i <= 2.05d-11) then
tmp = 100.0d0 * (n + (i * (-0.5d0)))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -1.5) {
tmp = -200.0 * (n / i);
} else if (i <= 2.05e-11) {
tmp = 100.0 * (n + (i * -0.5));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.5: tmp = -200.0 * (n / i) elif i <= 2.05e-11: tmp = 100.0 * (n + (i * -0.5)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -1.5) tmp = Float64(-200.0 * Float64(n / i)); elseif (i <= 2.05e-11) tmp = Float64(100.0 * Float64(n + Float64(i * -0.5))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -1.5) tmp = -200.0 * (n / i); elseif (i <= 2.05e-11) tmp = 100.0 * (n + (i * -0.5)); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.5], N[(-200.0 * N[(n / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.05e-11], N[(100.0 * N[(n + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.5:\\
\;\;\;\;-200 \cdot \frac{n}{i}\\
\mathbf{elif}\;i \leq 2.05 \cdot 10^{-11}:\\
\;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -1.5Initial program 58.4%
Taylor expanded in n around inf 85.9%
*-commutative85.9%
associate-/l*85.9%
expm1-def85.9%
Simplified85.9%
associate-*l/85.7%
div-inv85.7%
associate-/r*85.7%
Applied egg-rr85.7%
Taylor expanded in i around 0 30.2%
Taylor expanded in i around inf 30.2%
if -1.5 < i < 2.05e-11Initial program 8.2%
Taylor expanded in i around 0 88.1%
associate-*r*88.0%
associate-*r/88.0%
metadata-eval88.0%
Simplified88.0%
Taylor expanded in n around 0 87.3%
*-commutative87.3%
Simplified87.3%
if 2.05e-11 < i Initial program 44.1%
associate-*r/44.1%
sub-neg44.1%
distribute-lft-in44.0%
metadata-eval44.0%
metadata-eval44.0%
Simplified44.0%
Taylor expanded in i around 0 29.2%
Taylor expanded in i around 0 29.2%
Final simplification61.2%
(FPCore (i n) :precision binary64 (if (<= n -3.4e-165) (/ n (+ 0.01 (* i -0.005))) (if (<= n 3.1e-173) 0.0 (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -3.4e-165) {
tmp = n / (0.01 + (i * -0.005));
} else if (n <= 3.1e-173) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-3.4d-165)) then
tmp = n / (0.01d0 + (i * (-0.005d0)))
else if (n <= 3.1d-173) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -3.4e-165) {
tmp = n / (0.01 + (i * -0.005));
} else if (n <= 3.1e-173) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.4e-165: tmp = n / (0.01 + (i * -0.005)) elif n <= 3.1e-173: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.4e-165) tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); elseif (n <= 3.1e-173) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -3.4e-165) tmp = n / (0.01 + (i * -0.005)); elseif (n <= 3.1e-173) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -3.4e-165], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.1e-173], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.4 \cdot 10^{-165}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{elif}\;n \leq 3.1 \cdot 10^{-173}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -3.4e-165Initial program 25.0%
Taylor expanded in n around inf 38.6%
*-commutative38.6%
associate-/l*38.6%
expm1-def87.9%
Simplified87.9%
associate-*l/87.9%
associate-/l*87.9%
Applied egg-rr87.9%
Taylor expanded in i around 0 62.7%
*-commutative62.7%
Simplified62.7%
if -3.4e-165 < n < 3.10000000000000005e-173Initial program 58.2%
associate-*r/58.2%
sub-neg58.2%
distribute-lft-in58.2%
metadata-eval58.2%
metadata-eval58.2%
Simplified58.2%
Taylor expanded in i around 0 76.8%
Taylor expanded in i around 0 76.8%
if 3.10000000000000005e-173 < n Initial program 17.9%
associate-/r/18.3%
associate-*r*18.3%
*-commutative18.3%
associate-*r/18.3%
sub-neg18.3%
distribute-lft-in18.3%
metadata-eval18.3%
metadata-eval18.3%
metadata-eval18.3%
fma-def18.3%
metadata-eval18.3%
Simplified18.3%
Taylor expanded in n around inf 36.0%
Taylor expanded in i around 0 66.3%
*-commutative66.3%
Simplified66.3%
Final simplification66.5%
(FPCore (i n) :precision binary64 (if (<= n -3.4e-165) (* 100.0 (/ n (+ 1.0 (* i -0.5)))) (if (<= n 3.2e-174) 0.0 (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -3.4e-165) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 3.2e-174) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-3.4d-165)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 3.2d-174) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -3.4e-165) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 3.2e-174) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.4e-165: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 3.2e-174: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.4e-165) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 3.2e-174) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -3.4e-165) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 3.2e-174) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -3.4e-165], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.2e-174], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.4 \cdot 10^{-165}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 3.2 \cdot 10^{-174}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -3.4e-165Initial program 25.0%
Taylor expanded in n around inf 38.6%
*-commutative38.6%
associate-/l*38.6%
expm1-def87.9%
Simplified87.9%
Taylor expanded in i around 0 62.7%
*-commutative62.7%
Simplified62.7%
if -3.4e-165 < n < 3.2e-174Initial program 58.2%
associate-*r/58.2%
sub-neg58.2%
distribute-lft-in58.2%
metadata-eval58.2%
metadata-eval58.2%
Simplified58.2%
Taylor expanded in i around 0 76.8%
Taylor expanded in i around 0 76.8%
if 3.2e-174 < n Initial program 17.9%
associate-/r/18.3%
associate-*r*18.3%
*-commutative18.3%
associate-*r/18.3%
sub-neg18.3%
distribute-lft-in18.3%
metadata-eval18.3%
metadata-eval18.3%
metadata-eval18.3%
fma-def18.3%
metadata-eval18.3%
Simplified18.3%
Taylor expanded in n around inf 36.0%
Taylor expanded in i around 0 66.3%
*-commutative66.3%
Simplified66.3%
Final simplification66.5%
(FPCore (i n) :precision binary64 (if (<= i -27.0) 0.0 (if (<= i 2.05e-11) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -27.0) {
tmp = 0.0;
} else if (i <= 2.05e-11) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-27.0d0)) then
tmp = 0.0d0
else if (i <= 2.05d-11) then
tmp = n * 100.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -27.0) {
tmp = 0.0;
} else if (i <= 2.05e-11) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -27.0: tmp = 0.0 elif i <= 2.05e-11: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -27.0) tmp = 0.0; elseif (i <= 2.05e-11) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -27.0) tmp = 0.0; elseif (i <= 2.05e-11) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -27.0], 0.0, If[LessEqual[i, 2.05e-11], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -27:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 2.05 \cdot 10^{-11}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -27 or 2.05e-11 < i Initial program 51.6%
associate-*r/51.6%
sub-neg51.6%
distribute-lft-in51.6%
metadata-eval51.6%
metadata-eval51.6%
Simplified51.6%
Taylor expanded in i around 0 28.9%
Taylor expanded in i around 0 28.9%
if -27 < i < 2.05e-11Initial program 8.2%
Taylor expanded in i around 0 87.1%
*-commutative87.1%
Simplified87.1%
Final simplification60.7%
(FPCore (i n) :precision binary64 (if (<= i -2.0) (* -200.0 (/ n i)) (if (<= i 2.05e-11) (* n 100.0) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = -200.0 * (n / i);
} else if (i <= 2.05e-11) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-2.0d0)) then
tmp = (-200.0d0) * (n / i)
else if (i <= 2.05d-11) then
tmp = n * 100.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -2.0) {
tmp = -200.0 * (n / i);
} else if (i <= 2.05e-11) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.0: tmp = -200.0 * (n / i) elif i <= 2.05e-11: tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -2.0) tmp = Float64(-200.0 * Float64(n / i)); elseif (i <= 2.05e-11) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2.0) tmp = -200.0 * (n / i); elseif (i <= 2.05e-11) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2.0], N[(-200.0 * N[(n / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 2.05e-11], N[(n * 100.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2:\\
\;\;\;\;-200 \cdot \frac{n}{i}\\
\mathbf{elif}\;i \leq 2.05 \cdot 10^{-11}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -2Initial program 58.4%
Taylor expanded in n around inf 85.9%
*-commutative85.9%
associate-/l*85.9%
expm1-def85.9%
Simplified85.9%
associate-*l/85.7%
div-inv85.7%
associate-/r*85.7%
Applied egg-rr85.7%
Taylor expanded in i around 0 30.2%
Taylor expanded in i around inf 30.2%
if -2 < i < 2.05e-11Initial program 8.2%
Taylor expanded in i around 0 87.1%
*-commutative87.1%
Simplified87.1%
if 2.05e-11 < i Initial program 44.1%
associate-*r/44.1%
sub-neg44.1%
distribute-lft-in44.0%
metadata-eval44.0%
metadata-eval44.0%
Simplified44.0%
Taylor expanded in i around 0 29.2%
Taylor expanded in i around 0 29.2%
Final simplification61.1%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 27.9%
associate-*r/27.9%
sub-neg27.9%
distribute-lft-in27.9%
metadata-eval27.9%
metadata-eval27.9%
Simplified27.9%
Taylor expanded in i around 0 17.6%
Taylor expanded in i around 0 17.9%
Final simplification17.9%
(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 2023315
(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))))