
(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 13 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) (/ n (+ 0.01 (* i -0.005)))))))
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 = n / (0.01 + (i * -0.005));
}
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 = n / (0.01 + (i * -0.005));
}
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 = n / (0.01 + (i * -0.005)) 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)))) / Float64(i / n)) * 100.0); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); 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] / N[(i / n), $MachinePrecision]), $MachinePrecision] * 100.0), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(n / N[(0.01 + N[(i * -0.005), $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)}{\frac{i}{n}} \cdot 100\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 28.0%
associate-*r/28.0%
sub-neg28.0%
distribute-lft-in28.0%
metadata-eval28.0%
metadata-eval28.0%
metadata-eval28.0%
fma-def28.0%
metadata-eval28.0%
Simplified28.0%
fma-udef28.0%
metadata-eval28.0%
distribute-lft-in28.0%
metadata-eval28.0%
sub-neg28.0%
*-commutative28.0%
add-exp-log28.0%
expm1-def28.0%
log-pow40.5%
log1p-udef98.1%
Applied egg-rr98.1%
associate-/l*97.5%
associate-/r/98.1%
Applied egg-rr98.1%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-*r/0.0%
sub-neg0.0%
distribute-lft-in0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
fma-def0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in n around inf 1.8%
associate-/l*1.8%
*-commutative1.8%
fma-neg1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.5%
(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)))) (* 100.0 (/ n i)))
(if (<= t_0 INFINITY) (* t_0 100.0) (/ n (+ 0.01 (* i -0.005)))))))
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)))) * (100.0 * (n / i));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = n / (0.01 + (i * -0.005));
}
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)))) * (100.0 * (n / i));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = n / (0.01 + (i * -0.005));
}
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)))) * (100.0 * (n / i)) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = n / (0.01 + (i * -0.005)) 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(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(100.0 * Float64(n / i))); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); 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[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(100.0 * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(n / N[(0.01 + N[(i * -0.005), $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:\\
\;\;\;\;\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \left(100 \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 28.0%
associate-*r/28.0%
sub-neg28.0%
distribute-lft-in28.0%
metadata-eval28.0%
metadata-eval28.0%
metadata-eval28.0%
fma-def28.0%
metadata-eval28.0%
Simplified28.0%
fma-udef28.0%
metadata-eval28.0%
distribute-lft-in28.0%
metadata-eval28.0%
sub-neg28.0%
*-commutative28.0%
associate-*l/28.0%
div-inv28.0%
clear-num27.6%
associate-*l*27.6%
add-exp-log27.6%
expm1-def27.6%
log-pow40.1%
log1p-udef96.7%
Applied egg-rr96.7%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-*r/0.0%
sub-neg0.0%
distribute-lft-in0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
fma-def0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in n around inf 1.8%
associate-/l*1.8%
*-commutative1.8%
fma-neg1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification97.5%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 0.0)
(* n (* 100.0 (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_0 INFINITY) (* t_0 100.0) (/ n (+ 0.01 (* i -0.005)))))))
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 * (100.0 * (expm1((n * log1p((i / n)))) / i));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = n / (0.01 + (i * -0.005));
}
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 * (100.0 * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = n / (0.01 + (i * -0.005));
}
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 * (100.0 * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = n / (0.01 + (i * -0.005)) 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(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); 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[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(n / N[(0.01 + N[(i * -0.005), $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(100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 28.0%
associate-*r/28.0%
sub-neg28.0%
distribute-lft-in28.0%
metadata-eval28.0%
metadata-eval28.0%
metadata-eval28.0%
fma-def28.0%
metadata-eval28.0%
Simplified28.0%
fma-udef28.0%
metadata-eval28.0%
distribute-lft-in28.0%
metadata-eval28.0%
sub-neg28.0%
*-commutative28.0%
add-exp-log28.0%
expm1-def28.0%
log-pow40.5%
log1p-udef98.1%
Applied egg-rr98.1%
associate-/r/97.3%
*-commutative97.3%
*-un-lft-identity97.3%
times-frac97.3%
metadata-eval97.3%
Applied egg-rr97.3%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-*r/0.0%
sub-neg0.0%
distribute-lft-in0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
fma-def0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in n around inf 1.8%
associate-/l*1.8%
*-commutative1.8%
fma-neg1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification97.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 0.0)
(* n (/ 100.0 (/ i (expm1 (* n (log1p (/ i n)))))))
(if (<= t_0 INFINITY) (* t_0 100.0) (/ n (+ 0.01 (* i -0.005)))))))
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 * (100.0 / (i / expm1((n * log1p((i / n))))));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 * 100.0;
} else {
tmp = n / (0.01 + (i * -0.005));
}
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 * (100.0 / (i / Math.expm1((n * Math.log1p((i / n))))));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * 100.0;
} else {
tmp = n / (0.01 + (i * -0.005));
}
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 * (100.0 / (i / math.expm1((n * math.log1p((i / n)))))) elif t_0 <= math.inf: tmp = t_0 * 100.0 else: tmp = n / (0.01 + (i * -0.005)) 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(100.0 / Float64(i / expm1(Float64(n * log1p(Float64(i / n))))))); elseif (t_0 <= Inf) tmp = Float64(t_0 * 100.0); else tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); 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[(100.0 / N[(i / N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 * 100.0), $MachinePrecision], N[(n / N[(0.01 + N[(i * -0.005), $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 \frac{100}{\frac{i}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < 0.0Initial program 28.0%
associate-*r/28.0%
sub-neg28.0%
distribute-lft-in28.0%
metadata-eval28.0%
metadata-eval28.0%
metadata-eval28.0%
fma-def28.0%
metadata-eval28.0%
Simplified28.0%
fma-udef28.0%
metadata-eval28.0%
distribute-lft-in28.0%
metadata-eval28.0%
sub-neg28.0%
*-commutative28.0%
add-exp-log28.0%
expm1-def28.0%
log-pow40.5%
log1p-udef98.1%
Applied egg-rr98.1%
associate-/r/97.3%
*-commutative97.3%
*-un-lft-identity97.3%
times-frac97.3%
metadata-eval97.3%
Applied egg-rr97.3%
clear-num97.3%
un-div-inv97.4%
Applied egg-rr97.4%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-*r/0.0%
sub-neg0.0%
distribute-lft-in0.0%
metadata-eval0.0%
metadata-eval0.0%
metadata-eval0.0%
fma-def0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in n around inf 1.8%
associate-/l*1.8%
*-commutative1.8%
fma-neg1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.0%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
(if (<= n -1.4e-206)
t_0
(if (<= n 2.35e-200)
(* (/ 0.0 i) (* n 100.0))
(if (<= n 1.5e-21) (/ n (+ 0.01 (* i -0.005))) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (n / (i / expm1(i)));
double tmp;
if (n <= -1.4e-206) {
tmp = t_0;
} else if (n <= 2.35e-200) {
tmp = (0.0 / i) * (n * 100.0);
} else if (n <= 1.5e-21) {
tmp = n / (0.01 + (i * -0.005));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (n / (i / Math.expm1(i)));
double tmp;
if (n <= -1.4e-206) {
tmp = t_0;
} else if (n <= 2.35e-200) {
tmp = (0.0 / i) * (n * 100.0);
} else if (n <= 1.5e-21) {
tmp = n / (0.01 + (i * -0.005));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (n / (i / math.expm1(i))) tmp = 0 if n <= -1.4e-206: tmp = t_0 elif n <= 2.35e-200: tmp = (0.0 / i) * (n * 100.0) elif n <= 1.5e-21: tmp = n / (0.01 + (i * -0.005)) 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 <= -1.4e-206) tmp = t_0; elseif (n <= 2.35e-200) tmp = Float64(Float64(0.0 / i) * Float64(n * 100.0)); elseif (n <= 1.5e-21) tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); 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, -1.4e-206], t$95$0, If[LessEqual[n, 2.35e-200], N[(N[(0.0 / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.5e-21], N[(n / N[(0.01 + N[(i * -0.005), $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 -1.4 \cdot 10^{-206}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 2.35 \cdot 10^{-200}:\\
\;\;\;\;\frac{0}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;n \leq 1.5 \cdot 10^{-21}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -1.4000000000000001e-206 or 1.49999999999999996e-21 < n Initial program 24.8%
associate-/r/24.7%
sub-neg24.7%
metadata-eval24.7%
Simplified24.7%
Taylor expanded in n around inf 33.7%
associate-/l*33.7%
expm1-def86.2%
Simplified86.2%
if -1.4000000000000001e-206 < n < 2.35e-200Initial program 65.5%
*-commutative65.5%
associate-/r/65.8%
associate-*l*65.8%
sub-neg65.8%
metadata-eval65.8%
Simplified65.8%
Taylor expanded in i around 0 85.5%
if 2.35e-200 < n < 1.49999999999999996e-21Initial program 17.5%
associate-*r/17.5%
sub-neg17.5%
distribute-lft-in17.5%
metadata-eval17.5%
metadata-eval17.5%
metadata-eval17.5%
fma-def17.5%
metadata-eval17.5%
Simplified17.5%
Taylor expanded in n around inf 3.0%
associate-/l*3.0%
*-commutative3.0%
fma-neg3.0%
metadata-eval3.0%
Simplified3.0%
Taylor expanded in i around 0 55.7%
*-commutative55.7%
Simplified55.7%
Final simplification81.8%
(FPCore (i n)
:precision binary64
(if (<= n -8e-38)
(* n (/ (* 100.0 (expm1 i)) i))
(if (<= n 2.3e+30)
(/ n (+ 0.01 (+ (* i -0.005) (* 0.0008333333333333334 (pow i 2.0)))))
(* 100.0 (/ n (/ i (expm1 i)))))))
double code(double i, double n) {
double tmp;
if (n <= -8e-38) {
tmp = n * ((100.0 * expm1(i)) / i);
} else if (n <= 2.3e+30) {
tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * pow(i, 2.0))));
} else {
tmp = 100.0 * (n / (i / expm1(i)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -8e-38) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else if (n <= 2.3e+30) {
tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * Math.pow(i, 2.0))));
} else {
tmp = 100.0 * (n / (i / Math.expm1(i)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -8e-38: tmp = n * ((100.0 * math.expm1(i)) / i) elif n <= 2.3e+30: tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * math.pow(i, 2.0)))) else: tmp = 100.0 * (n / (i / math.expm1(i))) return tmp
function code(i, n) tmp = 0.0 if (n <= -8e-38) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); elseif (n <= 2.3e+30) tmp = Float64(n / Float64(0.01 + Float64(Float64(i * -0.005) + Float64(0.0008333333333333334 * (i ^ 2.0))))); else tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); end return tmp end
code[i_, n_] := If[LessEqual[n, -8e-38], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.3e+30], N[(n / N[(0.01 + N[(N[(i * -0.005), $MachinePrecision] + N[(0.0008333333333333334 * N[Power[i, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8 \cdot 10^{-38}:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{elif}\;n \leq 2.3 \cdot 10^{+30}:\\
\;\;\;\;\frac{n}{0.01 + \left(i \cdot -0.005 + 0.0008333333333333334 \cdot {i}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\end{array}
\end{array}
if n < -7.9999999999999997e-38Initial program 25.6%
associate-*r/25.6%
sub-neg25.6%
distribute-lft-in25.6%
metadata-eval25.6%
metadata-eval25.6%
metadata-eval25.6%
fma-def25.6%
metadata-eval25.6%
Simplified25.6%
Taylor expanded in n around inf 43.8%
associate-/l*43.8%
*-commutative43.8%
fma-neg43.8%
metadata-eval43.8%
Simplified43.8%
clear-num43.8%
associate-/r/43.9%
clear-num43.9%
fma-udef43.9%
metadata-eval43.9%
metadata-eval43.9%
distribute-rgt-in43.9%
sub-neg43.9%
expm1-def88.2%
Applied egg-rr88.2%
if -7.9999999999999997e-38 < n < 2.3e30Initial program 32.7%
associate-*r/32.7%
sub-neg32.7%
distribute-lft-in32.7%
metadata-eval32.7%
metadata-eval32.7%
metadata-eval32.7%
fma-def32.7%
metadata-eval32.7%
Simplified32.7%
Taylor expanded in n around inf 20.1%
associate-/l*20.1%
*-commutative20.1%
fma-neg20.1%
metadata-eval20.1%
Simplified20.1%
Taylor expanded in i around 0 67.3%
if 2.3e30 < n Initial program 21.6%
associate-/r/22.4%
sub-neg22.4%
metadata-eval22.4%
Simplified22.4%
Taylor expanded in n around inf 33.1%
associate-/l*33.1%
expm1-def96.5%
Simplified96.5%
Final simplification81.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (+ 100.0 (* i 50.0)))) (t_1 (/ n (+ 0.01 (* i -0.005)))))
(if (<= n -3e+209)
t_0
(if (<= n -2.35e-206)
t_1
(if (<= n 3.8e-195)
(* (/ 0.0 i) (* n 100.0))
(if (<= n 1.7e-51) t_1 t_0))))))
double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double t_1 = n / (0.01 + (i * -0.005));
double tmp;
if (n <= -3e+209) {
tmp = t_0;
} else if (n <= -2.35e-206) {
tmp = t_1;
} else if (n <= 3.8e-195) {
tmp = (0.0 / i) * (n * 100.0);
} else if (n <= 1.7e-51) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = n * (100.0d0 + (i * 50.0d0))
t_1 = n / (0.01d0 + (i * (-0.005d0)))
if (n <= (-3d+209)) then
tmp = t_0
else if (n <= (-2.35d-206)) then
tmp = t_1
else if (n <= 3.8d-195) then
tmp = (0.0d0 / i) * (n * 100.0d0)
else if (n <= 1.7d-51) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double t_1 = n / (0.01 + (i * -0.005));
double tmp;
if (n <= -3e+209) {
tmp = t_0;
} else if (n <= -2.35e-206) {
tmp = t_1;
} else if (n <= 3.8e-195) {
tmp = (0.0 / i) * (n * 100.0);
} else if (n <= 1.7e-51) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = n * (100.0 + (i * 50.0)) t_1 = n / (0.01 + (i * -0.005)) tmp = 0 if n <= -3e+209: tmp = t_0 elif n <= -2.35e-206: tmp = t_1 elif n <= 3.8e-195: tmp = (0.0 / i) * (n * 100.0) elif n <= 1.7e-51: tmp = t_1 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(n * Float64(100.0 + Float64(i * 50.0))) t_1 = Float64(n / Float64(0.01 + Float64(i * -0.005))) tmp = 0.0 if (n <= -3e+209) tmp = t_0; elseif (n <= -2.35e-206) tmp = t_1; elseif (n <= 3.8e-195) tmp = Float64(Float64(0.0 / i) * Float64(n * 100.0)); elseif (n <= 1.7e-51) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = n * (100.0 + (i * 50.0)); t_1 = n / (0.01 + (i * -0.005)); tmp = 0.0; if (n <= -3e+209) tmp = t_0; elseif (n <= -2.35e-206) tmp = t_1; elseif (n <= 3.8e-195) tmp = (0.0 / i) * (n * 100.0); elseif (n <= 1.7e-51) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -3e+209], t$95$0, If[LessEqual[n, -2.35e-206], t$95$1, If[LessEqual[n, 3.8e-195], N[(N[(0.0 / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.7e-51], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(100 + i \cdot 50\right)\\
t_1 := \frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{if}\;n \leq -3 \cdot 10^{+209}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -2.35 \cdot 10^{-206}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq 3.8 \cdot 10^{-195}:\\
\;\;\;\;\frac{0}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;n \leq 1.7 \cdot 10^{-51}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -2.99999999999999985e209 or 1.70000000000000001e-51 < n Initial program 18.5%
associate-*r/18.4%
sub-neg18.4%
distribute-lft-in18.4%
metadata-eval18.4%
metadata-eval18.4%
metadata-eval18.4%
fma-def18.4%
metadata-eval18.4%
Simplified18.4%
Taylor expanded in n around inf 35.8%
associate-/l*35.8%
*-commutative35.8%
fma-neg35.8%
metadata-eval35.8%
Simplified35.8%
clear-num35.8%
associate-/r/35.8%
clear-num35.8%
fma-udef35.8%
metadata-eval35.8%
metadata-eval35.8%
distribute-rgt-in35.8%
sub-neg35.8%
expm1-def92.1%
Applied egg-rr92.1%
Taylor expanded in i around 0 74.6%
*-commutative74.6%
Simplified74.6%
if -2.99999999999999985e209 < n < -2.3499999999999999e-206 or 3.80000000000000013e-195 < n < 1.70000000000000001e-51Initial program 27.9%
associate-*r/27.9%
sub-neg27.9%
distribute-lft-in27.9%
metadata-eval27.9%
metadata-eval27.9%
metadata-eval27.9%
fma-def27.9%
metadata-eval27.9%
Simplified27.9%
Taylor expanded in n around inf 22.9%
associate-/l*22.9%
*-commutative22.9%
fma-neg22.9%
metadata-eval22.9%
Simplified22.9%
Taylor expanded in i around 0 59.9%
*-commutative59.9%
Simplified59.9%
if -2.3499999999999999e-206 < n < 3.80000000000000013e-195Initial program 65.5%
*-commutative65.5%
associate-/r/65.8%
associate-*l*65.8%
sub-neg65.8%
metadata-eval65.8%
Simplified65.8%
Taylor expanded in i around 0 85.5%
Final simplification68.4%
(FPCore (i n)
:precision binary64
(if (<= n -6.1e+208)
(* n (+ 100.0 (* i 50.0)))
(if (<= n 1.35e-43)
(/ n (+ 0.01 (* i -0.005)))
(* 100.0 (+ n (* (* i n) (- 0.5 (/ 0.5 n))))))))
double code(double i, double n) {
double tmp;
if (n <= -6.1e+208) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 1.35e-43) {
tmp = n / (0.01 + (i * -0.005));
} else {
tmp = 100.0 * (n + ((i * n) * (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 <= (-6.1d+208)) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (n <= 1.35d-43) then
tmp = n / (0.01d0 + (i * (-0.005d0)))
else
tmp = 100.0d0 * (n + ((i * n) * (0.5d0 - (0.5d0 / n))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -6.1e+208) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 1.35e-43) {
tmp = n / (0.01 + (i * -0.005));
} else {
tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -6.1e+208: tmp = n * (100.0 + (i * 50.0)) elif n <= 1.35e-43: tmp = n / (0.01 + (i * -0.005)) else: tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n)))) return tmp
function code(i, n) tmp = 0.0 if (n <= -6.1e+208) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (n <= 1.35e-43) tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); else tmp = Float64(100.0 * Float64(n + Float64(Float64(i * n) * Float64(0.5 - Float64(0.5 / n))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -6.1e+208) tmp = n * (100.0 + (i * 50.0)); elseif (n <= 1.35e-43) tmp = n / (0.01 + (i * -0.005)); else tmp = 100.0 * (n + ((i * n) * (0.5 - (0.5 / n)))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -6.1e+208], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.35e-43], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n + N[(N[(i * n), $MachinePrecision] * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.1 \cdot 10^{+208}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;n \leq 1.35 \cdot 10^{-43}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + \left(i \cdot n\right) \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if n < -6.09999999999999975e208Initial program 14.6%
associate-*r/14.5%
sub-neg14.5%
distribute-lft-in14.5%
metadata-eval14.5%
metadata-eval14.5%
metadata-eval14.5%
fma-def14.5%
metadata-eval14.5%
Simplified14.5%
Taylor expanded in n around inf 59.8%
associate-/l*59.7%
*-commutative59.7%
fma-neg59.7%
metadata-eval59.7%
Simplified59.7%
clear-num59.7%
associate-/r/59.8%
clear-num59.9%
fma-udef59.8%
metadata-eval59.8%
metadata-eval59.8%
distribute-rgt-in59.9%
sub-neg59.9%
expm1-def96.5%
Applied egg-rr96.5%
Taylor expanded in i around 0 69.4%
*-commutative69.4%
Simplified69.4%
if -6.09999999999999975e208 < n < 1.34999999999999996e-43Initial program 33.5%
associate-*r/33.5%
sub-neg33.5%
distribute-lft-in33.5%
metadata-eval33.5%
metadata-eval33.5%
metadata-eval33.5%
fma-def33.5%
metadata-eval33.5%
Simplified33.5%
Taylor expanded in n around inf 27.6%
associate-/l*27.6%
*-commutative27.6%
fma-neg27.6%
metadata-eval27.6%
Simplified27.6%
Taylor expanded in i around 0 58.7%
*-commutative58.7%
Simplified58.7%
if 1.34999999999999996e-43 < n Initial program 20.7%
associate-/r/21.3%
sub-neg21.3%
metadata-eval21.3%
Simplified21.3%
Taylor expanded in i around 0 78.6%
distribute-lft-out78.6%
associate-*r*78.6%
associate-*r/78.6%
metadata-eval78.6%
Simplified78.6%
Final simplification65.6%
(FPCore (i n) :precision binary64 (if (or (<= n -2e+209) (not (<= n 7e-52))) (* n (+ 100.0 (* i 50.0))) (/ n (+ 0.01 (* i -0.005)))))
double code(double i, double n) {
double tmp;
if ((n <= -2e+209) || !(n <= 7e-52)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = n / (0.01 + (i * -0.005));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-2d+209)) .or. (.not. (n <= 7d-52))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = n / (0.01d0 + (i * (-0.005d0)))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -2e+209) || !(n <= 7e-52)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = n / (0.01 + (i * -0.005));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2e+209) or not (n <= 7e-52): tmp = n * (100.0 + (i * 50.0)) else: tmp = n / (0.01 + (i * -0.005)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -2e+209) || !(n <= 7e-52)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -2e+209) || ~((n <= 7e-52))) tmp = n * (100.0 + (i * 50.0)); else tmp = n / (0.01 + (i * -0.005)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -2e+209], N[Not[LessEqual[n, 7e-52]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2 \cdot 10^{+209} \lor \neg \left(n \leq 7 \cdot 10^{-52}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\end{array}
\end{array}
if n < -2.0000000000000001e209 or 7.0000000000000001e-52 < n Initial program 18.5%
associate-*r/18.4%
sub-neg18.4%
distribute-lft-in18.4%
metadata-eval18.4%
metadata-eval18.4%
metadata-eval18.4%
fma-def18.4%
metadata-eval18.4%
Simplified18.4%
Taylor expanded in n around inf 35.8%
associate-/l*35.8%
*-commutative35.8%
fma-neg35.8%
metadata-eval35.8%
Simplified35.8%
clear-num35.8%
associate-/r/35.8%
clear-num35.8%
fma-udef35.8%
metadata-eval35.8%
metadata-eval35.8%
distribute-rgt-in35.8%
sub-neg35.8%
expm1-def92.1%
Applied egg-rr92.1%
Taylor expanded in i around 0 74.6%
*-commutative74.6%
Simplified74.6%
if -2.0000000000000001e209 < n < 7.0000000000000001e-52Initial program 34.1%
associate-*r/34.1%
sub-neg34.1%
distribute-lft-in34.1%
metadata-eval34.1%
metadata-eval34.1%
metadata-eval34.1%
fma-def34.1%
metadata-eval34.1%
Simplified34.1%
Taylor expanded in n around inf 28.1%
associate-/l*28.1%
*-commutative28.1%
fma-neg28.1%
metadata-eval28.1%
Simplified28.1%
Taylor expanded in i around 0 59.2%
*-commutative59.2%
Simplified59.2%
Final simplification65.5%
(FPCore (i n) :precision binary64 (if (<= i 1.6e+64) (* n 100.0) (* n (* i 50.0))))
double code(double i, double n) {
double tmp;
if (i <= 1.6e+64) {
tmp = n * 100.0;
} else {
tmp = n * (i * 50.0);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 1.6d+64) then
tmp = n * 100.0d0
else
tmp = n * (i * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 1.6e+64) {
tmp = n * 100.0;
} else {
tmp = n * (i * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 1.6e+64: tmp = n * 100.0 else: tmp = n * (i * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= 1.6e+64) tmp = Float64(n * 100.0); else tmp = Float64(n * Float64(i * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 1.6e+64) tmp = n * 100.0; else tmp = n * (i * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 1.6e+64], N[(n * 100.0), $MachinePrecision], N[(n * N[(i * 50.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 1.6 \cdot 10^{+64}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(i \cdot 50\right)\\
\end{array}
\end{array}
if i < 1.60000000000000009e64Initial program 24.2%
associate-/r/24.2%
sub-neg24.2%
metadata-eval24.2%
Simplified24.2%
Taylor expanded in i around 0 59.6%
*-commutative59.6%
Simplified59.6%
if 1.60000000000000009e64 < i Initial program 43.4%
associate-/r/43.8%
sub-neg43.8%
metadata-eval43.8%
Simplified43.8%
Taylor expanded in i around 0 38.8%
distribute-lft-out38.8%
associate-*r*38.8%
associate-*r/38.8%
metadata-eval38.8%
Simplified38.8%
Taylor expanded in n around inf 39.2%
associate-*r*39.2%
*-commutative39.2%
*-commutative39.2%
Simplified39.2%
Taylor expanded in i around inf 39.2%
*-commutative39.2%
*-commutative39.2%
associate-*l*39.2%
Simplified39.2%
Final simplification55.9%
(FPCore (i n) :precision binary64 (* n (+ 100.0 (* i 50.0))))
double code(double i, double n) {
return n * (100.0 + (i * 50.0));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n * (100.0d0 + (i * 50.0d0))
end function
public static double code(double i, double n) {
return n * (100.0 + (i * 50.0));
}
def code(i, n): return n * (100.0 + (i * 50.0))
function code(i, n) return Float64(n * Float64(100.0 + Float64(i * 50.0))) end
function tmp = code(i, n) tmp = n * (100.0 + (i * 50.0)); end
code[i_, n_] := N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
n \cdot \left(100 + i \cdot 50\right)
\end{array}
Initial program 27.7%
associate-*r/27.7%
sub-neg27.7%
distribute-lft-in27.7%
metadata-eval27.7%
metadata-eval27.7%
metadata-eval27.7%
fma-def27.7%
metadata-eval27.7%
Simplified27.7%
Taylor expanded in n around inf 31.3%
associate-/l*31.3%
*-commutative31.3%
fma-neg31.3%
metadata-eval31.3%
Simplified31.3%
clear-num31.5%
associate-/r/31.3%
clear-num31.3%
fma-udef31.3%
metadata-eval31.3%
metadata-eval31.3%
distribute-rgt-in31.3%
sub-neg31.3%
expm1-def74.4%
Applied egg-rr74.4%
Taylor expanded in i around 0 55.5%
*-commutative55.5%
Simplified55.5%
Final simplification55.5%
(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 27.7%
associate-/r/27.7%
sub-neg27.7%
metadata-eval27.7%
Simplified27.7%
Taylor expanded in i around 0 55.2%
distribute-lft-out55.2%
associate-*r*55.4%
associate-*r/55.4%
metadata-eval55.4%
Simplified55.4%
Taylor expanded in n around 0 2.7%
*-commutative2.7%
Simplified2.7%
Final simplification2.7%
(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.7%
associate-/r/27.7%
sub-neg27.7%
metadata-eval27.7%
Simplified27.7%
Taylor expanded in i around 0 49.8%
*-commutative49.8%
Simplified49.8%
Final simplification49.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 2024027
(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))))