
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 -50000000.0)
(/ (+ (* t_0 100.0) -100.0) (/ i n))
(if (<= t_1 0.0)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY)
(/ (* n (- (* 100.0 (pow (/ i n) n)) 100.0)) i)
(* n 100.0))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -50000000.0) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else if (t_1 <= 0.0) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (n * ((100.0 * pow((i / n), n)) - 100.0)) / i;
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -50000000.0) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else if (t_1 <= 0.0) {
tmp = 100.0 * (Math.expm1((n * Math.log1p((i / n)))) / (i / n));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (n * ((100.0 * Math.pow((i / n), n)) - 100.0)) / i;
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= -50000000.0: tmp = ((t_0 * 100.0) + -100.0) / (i / n) elif t_1 <= 0.0: tmp = 100.0 * (math.expm1((n * math.log1p((i / n)))) / (i / n)) elif t_1 <= math.inf: tmp = (n * ((100.0 * math.pow((i / n), n)) - 100.0)) / i else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -50000000.0) tmp = Float64(Float64(Float64(t_0 * 100.0) + -100.0) / Float64(i / n)); elseif (t_1 <= 0.0) tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_1 <= Inf) tmp = Float64(Float64(n * Float64(Float64(100.0 * (Float64(i / n) ^ n)) - 100.0)) / i); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -50000000.0], N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(n * N[(N[(100.0 * N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision]), $MachinePrecision] - 100.0), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq -50000000:\\
\;\;\;\;\frac{t\_0 \cdot 100 + -100}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{n \cdot \left(100 \cdot {\left(\frac{i}{n}\right)}^{n} - 100\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -5e7Initial program 99.7%
associate-*r/100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
fma-def100.0%
metadata-eval100.0%
Simplified100.0%
fma-udef100.0%
*-commutative100.0%
Applied egg-rr100.0%
if -5e7 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 26.3%
*-un-lft-identity26.3%
add-exp-log26.3%
expm1-def26.3%
log-pow40.5%
log1p-udef99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
Taylor expanded in i around inf 99.6%
associate-*r/99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in n around inf 99.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 i around 0 71.4%
*-commutative71.4%
Simplified71.4%
Final simplification93.9%
(FPCore (i n)
:precision binary64
(if (<= n -1.3e-35)
(/ (* (* n 100.0) (expm1 i)) i)
(if (<= n -1.72e-175)
(* (* n 100.0) (/ n (/ i (log (/ i n)))))
(if (<= n 2.2e-212)
(/ 0.0 (/ i n))
(if (<= n 2.8e-37)
(* 100.0 (/ i (/ i n)))
(* 100.0 (/ n (/ i (expm1 i)))))))))
double code(double i, double n) {
double tmp;
if (n <= -1.3e-35) {
tmp = ((n * 100.0) * expm1(i)) / i;
} else if (n <= -1.72e-175) {
tmp = (n * 100.0) * (n / (i / log((i / n))));
} else if (n <= 2.2e-212) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = 100.0 * (n / (i / expm1(i)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -1.3e-35) {
tmp = ((n * 100.0) * Math.expm1(i)) / i;
} else if (n <= -1.72e-175) {
tmp = (n * 100.0) * (n / (i / Math.log((i / n))));
} else if (n <= 2.2e-212) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = 100.0 * (n / (i / Math.expm1(i)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.3e-35: tmp = ((n * 100.0) * math.expm1(i)) / i elif n <= -1.72e-175: tmp = (n * 100.0) * (n / (i / math.log((i / n)))) elif n <= 2.2e-212: tmp = 0.0 / (i / n) elif n <= 2.8e-37: tmp = 100.0 * (i / (i / n)) else: tmp = 100.0 * (n / (i / math.expm1(i))) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.3e-35) tmp = Float64(Float64(Float64(n * 100.0) * expm1(i)) / i); elseif (n <= -1.72e-175) tmp = Float64(Float64(n * 100.0) * Float64(n / Float64(i / log(Float64(i / n))))); elseif (n <= 2.2e-212) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 2.8e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); end return tmp end
code[i_, n_] := If[LessEqual[n, -1.3e-35], N[(N[(N[(n * 100.0), $MachinePrecision] * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[n, -1.72e-175], N[(N[(n * 100.0), $MachinePrecision] * N[(n / N[(i / N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.2e-212], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.8e-37], N[(100.0 * N[(i / N[(i / n), $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 -1.3 \cdot 10^{-35}:\\
\;\;\;\;\frac{\left(n \cdot 100\right) \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{elif}\;n \leq -1.72 \cdot 10^{-175}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\\
\mathbf{elif}\;n \leq 2.2 \cdot 10^{-212}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\end{array}
\end{array}
if n < -1.30000000000000002e-35Initial program 37.1%
*-commutative37.1%
associate-/r/37.5%
associate-*l*37.5%
sub-neg37.5%
metadata-eval37.5%
Simplified37.5%
Taylor expanded in n around inf 41.1%
expm1-def84.6%
Simplified84.6%
associate-*l/84.7%
Applied egg-rr84.7%
if -1.30000000000000002e-35 < n < -1.72000000000000005e-175Initial program 26.5%
*-commutative26.5%
associate-/r/24.7%
associate-*l*24.7%
sub-neg24.7%
metadata-eval24.7%
Simplified24.7%
expm1-log1p-u24.7%
expm1-udef26.5%
metadata-eval26.5%
sub-neg26.5%
add-exp-log26.5%
expm1-def26.5%
log-pow26.5%
log1p-udef51.4%
Applied egg-rr51.4%
expm1-def97.9%
expm1-log1p97.9%
Simplified97.9%
Taylor expanded in n around 0 0.0%
associate-/l*0.0%
mul-1-neg0.0%
sub-neg0.0%
log-div66.8%
Simplified66.8%
if -1.72000000000000005e-175 < n < 2.20000000000000003e-212Initial program 69.8%
associate-*r/69.8%
sub-neg69.8%
distribute-lft-in69.8%
metadata-eval69.8%
metadata-eval69.8%
metadata-eval69.8%
fma-def69.8%
metadata-eval69.8%
Simplified69.8%
Taylor expanded in n around inf 59.8%
Taylor expanded in i around 0 87.1%
if 2.20000000000000003e-212 < n < 2.8000000000000001e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
if 2.8000000000000001e-37 < n Initial program 20.2%
Taylor expanded in n around inf 38.7%
*-commutative38.7%
associate-/l*38.7%
expm1-def94.6%
Simplified94.6%
Final simplification83.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
(if (<= n -5.4e-152)
t_0
(if (<= n 2.8e-210)
(/ 0.0 (/ i n))
(if (<= n 2.8e-37) (* 100.0 (/ i (/ i n))) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (n / (i / expm1(i)));
double tmp;
if (n <= -5.4e-152) {
tmp = t_0;
} else if (n <= 2.8e-210) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} 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 <= -5.4e-152) {
tmp = t_0;
} else if (n <= 2.8e-210) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (n / (i / math.expm1(i))) tmp = 0 if n <= -5.4e-152: tmp = t_0 elif n <= 2.8e-210: tmp = 0.0 / (i / n) elif n <= 2.8e-37: tmp = 100.0 * (i / (i / n)) 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 <= -5.4e-152) tmp = t_0; elseif (n <= 2.8e-210) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 2.8e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); 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, -5.4e-152], t$95$0, If[LessEqual[n, 2.8e-210], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.8e-37], N[(100.0 * N[(i / N[(i / n), $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 -5.4 \cdot 10^{-152}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{-210}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -5.39999999999999997e-152 or 2.8000000000000001e-37 < n Initial program 28.4%
Taylor expanded in n around inf 36.8%
*-commutative36.8%
associate-/l*36.8%
expm1-def84.7%
Simplified84.7%
if -5.39999999999999997e-152 < n < 2.8e-210Initial program 63.7%
associate-*r/63.7%
sub-neg63.7%
distribute-lft-in63.7%
metadata-eval63.7%
metadata-eval63.7%
metadata-eval63.7%
fma-def63.7%
metadata-eval63.7%
Simplified63.7%
Taylor expanded in n around inf 50.8%
Taylor expanded in i around 0 77.2%
if 2.8e-210 < n < 2.8000000000000001e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
Final simplification81.4%
(FPCore (i n)
:precision binary64
(if (<= n -5.4e-152)
(* (* n 100.0) (/ (expm1 i) i))
(if (<= n 8e-211)
(/ 0.0 (/ i n))
(if (<= n 1.75e-37)
(* 100.0 (/ i (/ i n)))
(* 100.0 (/ n (/ i (expm1 i))))))))
double code(double i, double n) {
double tmp;
if (n <= -5.4e-152) {
tmp = (n * 100.0) * (expm1(i) / i);
} else if (n <= 8e-211) {
tmp = 0.0 / (i / n);
} else if (n <= 1.75e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = 100.0 * (n / (i / expm1(i)));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -5.4e-152) {
tmp = (n * 100.0) * (Math.expm1(i) / i);
} else if (n <= 8e-211) {
tmp = 0.0 / (i / n);
} else if (n <= 1.75e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = 100.0 * (n / (i / Math.expm1(i)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -5.4e-152: tmp = (n * 100.0) * (math.expm1(i) / i) elif n <= 8e-211: tmp = 0.0 / (i / n) elif n <= 1.75e-37: tmp = 100.0 * (i / (i / n)) else: tmp = 100.0 * (n / (i / math.expm1(i))) return tmp
function code(i, n) tmp = 0.0 if (n <= -5.4e-152) tmp = Float64(Float64(n * 100.0) * Float64(expm1(i) / i)); elseif (n <= 8e-211) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 1.75e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); end return tmp end
code[i_, n_] := If[LessEqual[n, -5.4e-152], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8e-211], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.75e-37], N[(100.0 * N[(i / N[(i / n), $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 -5.4 \cdot 10^{-152}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\\
\mathbf{elif}\;n \leq 8 \cdot 10^{-211}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 1.75 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\end{array}
\end{array}
if n < -5.39999999999999997e-152Initial program 34.2%
*-commutative34.2%
associate-/r/34.0%
associate-*l*34.1%
sub-neg34.1%
metadata-eval34.1%
Simplified34.1%
Taylor expanded in n around inf 35.4%
expm1-def77.5%
Simplified77.5%
if -5.39999999999999997e-152 < n < 8.00000000000000069e-211Initial program 63.7%
associate-*r/63.7%
sub-neg63.7%
distribute-lft-in63.7%
metadata-eval63.7%
metadata-eval63.7%
metadata-eval63.7%
fma-def63.7%
metadata-eval63.7%
Simplified63.7%
Taylor expanded in n around inf 50.8%
Taylor expanded in i around 0 77.2%
if 8.00000000000000069e-211 < n < 1.7500000000000001e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
if 1.7500000000000001e-37 < n Initial program 20.2%
Taylor expanded in n around inf 38.7%
*-commutative38.7%
associate-/l*38.7%
expm1-def94.6%
Simplified94.6%
Final simplification81.4%
(FPCore (i n)
:precision binary64
(if (<= n -5.9e-152)
(* (/ n i) (* 100.0 (expm1 i)))
(if (<= n 1.35e-210)
(/ 0.0 (/ i n))
(if (<= n 2.8e-37)
(* 100.0 (/ i (/ i n)))
(* (* n 100.0) (+ 1.0 (* i (- 0.5 (/ 0.5 n)))))))))
double code(double i, double n) {
double tmp;
if (n <= -5.9e-152) {
tmp = (n / i) * (100.0 * expm1(i));
} else if (n <= 1.35e-210) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -5.9e-152) {
tmp = (n / i) * (100.0 * Math.expm1(i));
} else if (n <= 1.35e-210) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -5.9e-152: tmp = (n / i) * (100.0 * math.expm1(i)) elif n <= 1.35e-210: tmp = 0.0 / (i / n) elif n <= 2.8e-37: tmp = 100.0 * (i / (i / n)) else: tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n)))) return tmp
function code(i, n) tmp = 0.0 if (n <= -5.9e-152) tmp = Float64(Float64(n / i) * Float64(100.0 * expm1(i))); elseif (n <= 1.35e-210) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 2.8e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * Float64(0.5 - Float64(0.5 / n))))); end return tmp end
code[i_, n_] := If[LessEqual[n, -5.9e-152], N[(N[(n / i), $MachinePrecision] * N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.35e-210], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.8e-37], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.9 \cdot 10^{-152}:\\
\;\;\;\;\frac{n}{i} \cdot \left(100 \cdot \mathsf{expm1}\left(i\right)\right)\\
\mathbf{elif}\;n \leq 1.35 \cdot 10^{-210}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if n < -5.90000000000000011e-152Initial program 34.2%
associate-*r/34.3%
sub-neg34.3%
distribute-lft-in34.3%
metadata-eval34.3%
metadata-eval34.3%
metadata-eval34.3%
fma-def34.3%
metadata-eval34.3%
Simplified34.3%
fma-udef34.3%
metadata-eval34.3%
distribute-lft-in34.3%
metadata-eval34.3%
sub-neg34.3%
associate-*r/34.2%
*-commutative34.2%
div-inv34.2%
clear-num33.7%
add-exp-log33.7%
expm1-def33.7%
log-pow28.7%
log1p-udef71.2%
Applied egg-rr71.2%
Taylor expanded in n around inf 35.4%
expm1-def73.9%
*-commutative73.9%
associate-*r/63.0%
associate-*r*62.9%
Simplified62.9%
if -5.90000000000000011e-152 < n < 1.34999999999999996e-210Initial program 63.7%
associate-*r/63.7%
sub-neg63.7%
distribute-lft-in63.7%
metadata-eval63.7%
metadata-eval63.7%
metadata-eval63.7%
fma-def63.7%
metadata-eval63.7%
Simplified63.7%
Taylor expanded in n around inf 50.8%
Taylor expanded in i around 0 77.2%
if 1.34999999999999996e-210 < n < 2.8000000000000001e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
if 2.8000000000000001e-37 < n Initial program 20.2%
*-commutative20.2%
associate-/r/20.8%
associate-*l*20.8%
sub-neg20.8%
metadata-eval20.8%
Simplified20.8%
Taylor expanded in i around 0 81.8%
associate-*r/81.8%
metadata-eval81.8%
Simplified81.8%
Final simplification71.1%
(FPCore (i n)
:precision binary64
(if (<= n -5.9e-152)
(* 100.0 (* (expm1 i) (/ n i)))
(if (<= n 3e-218)
(/ 0.0 (/ i n))
(if (<= n 2.8e-37)
(* 100.0 (/ i (/ i n)))
(* (* n 100.0) (+ 1.0 (* i (- 0.5 (/ 0.5 n)))))))))
double code(double i, double n) {
double tmp;
if (n <= -5.9e-152) {
tmp = 100.0 * (expm1(i) * (n / i));
} else if (n <= 3e-218) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -5.9e-152) {
tmp = 100.0 * (Math.expm1(i) * (n / i));
} else if (n <= 3e-218) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -5.9e-152: tmp = 100.0 * (math.expm1(i) * (n / i)) elif n <= 3e-218: tmp = 0.0 / (i / n) elif n <= 2.8e-37: tmp = 100.0 * (i / (i / n)) else: tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n)))) return tmp
function code(i, n) tmp = 0.0 if (n <= -5.9e-152) tmp = Float64(100.0 * Float64(expm1(i) * Float64(n / i))); elseif (n <= 3e-218) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 2.8e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * Float64(1.0 + Float64(i * Float64(0.5 - Float64(0.5 / n))))); end return tmp end
code[i_, n_] := If[LessEqual[n, -5.9e-152], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3e-218], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.8e-37], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.9 \cdot 10^{-152}:\\
\;\;\;\;100 \cdot \left(\mathsf{expm1}\left(i\right) \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;n \leq 3 \cdot 10^{-218}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if n < -5.90000000000000011e-152Initial program 34.2%
associate-*r/34.3%
sub-neg34.3%
distribute-lft-in34.3%
metadata-eval34.3%
metadata-eval34.3%
metadata-eval34.3%
fma-def34.3%
metadata-eval34.3%
Simplified34.3%
fma-udef34.3%
metadata-eval34.3%
distribute-lft-in34.3%
metadata-eval34.3%
sub-neg34.3%
associate-*r/34.2%
*-commutative34.2%
div-inv34.2%
clear-num33.7%
add-exp-log33.7%
expm1-def33.7%
log-pow28.7%
log1p-udef71.2%
Applied egg-rr71.2%
Taylor expanded in n around inf 35.4%
expm1-def73.9%
associate-*l/63.0%
Simplified63.0%
if -5.90000000000000011e-152 < n < 2.9999999999999998e-218Initial program 63.7%
associate-*r/63.7%
sub-neg63.7%
distribute-lft-in63.7%
metadata-eval63.7%
metadata-eval63.7%
metadata-eval63.7%
fma-def63.7%
metadata-eval63.7%
Simplified63.7%
Taylor expanded in n around inf 50.8%
Taylor expanded in i around 0 77.2%
if 2.9999999999999998e-218 < n < 2.8000000000000001e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
if 2.8000000000000001e-37 < n Initial program 20.2%
*-commutative20.2%
associate-/r/20.8%
associate-*l*20.8%
sub-neg20.8%
metadata-eval20.8%
Simplified20.8%
Taylor expanded in i around 0 81.8%
associate-*r/81.8%
metadata-eval81.8%
Simplified81.8%
Final simplification71.1%
(FPCore (i n)
:precision binary64
(if (<= n -9.8e-147)
(* n (+ 100.0 (* i 50.0)))
(if (<= n 1.14e-210)
(/ 0.0 (/ i n))
(if (<= n 2.65e-37)
(* 100.0 (/ i (/ i n)))
(* 100.0 (+ n (* (- 0.5 (/ 0.5 n)) (* i n))))))))
double code(double i, double n) {
double tmp;
if (n <= -9.8e-147) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 1.14e-210) {
tmp = 0.0 / (i / n);
} else if (n <= 2.65e-37) {
tmp = 100.0 * (i / (i / n));
} 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 <= (-9.8d-147)) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (n <= 1.14d-210) then
tmp = 0.0d0 / (i / n)
else if (n <= 2.65d-37) then
tmp = 100.0d0 * (i / (i / n))
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 <= -9.8e-147) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 1.14e-210) {
tmp = 0.0 / (i / n);
} else if (n <= 2.65e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n)));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -9.8e-147: tmp = n * (100.0 + (i * 50.0)) elif n <= 1.14e-210: tmp = 0.0 / (i / n) elif n <= 2.65e-37: tmp = 100.0 * (i / (i / n)) else: tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n))) return tmp
function code(i, n) tmp = 0.0 if (n <= -9.8e-147) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (n <= 1.14e-210) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 2.65e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); 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 <= -9.8e-147) tmp = n * (100.0 + (i * 50.0)); elseif (n <= 1.14e-210) tmp = 0.0 / (i / n); elseif (n <= 2.65e-37) tmp = 100.0 * (i / (i / n)); else tmp = 100.0 * (n + ((0.5 - (0.5 / n)) * (i * n))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -9.8e-147], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.14e-210], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.65e-37], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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 -9.8 \cdot 10^{-147}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;n \leq 1.14 \cdot 10^{-210}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 2.65 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\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 < -9.8000000000000001e-147Initial program 34.2%
Taylor expanded in i around 0 50.6%
associate-*r*50.6%
associate-*r/50.6%
metadata-eval50.6%
Simplified50.6%
Taylor expanded in n around inf 50.8%
*-commutative50.8%
*-commutative50.8%
associate-*l*50.8%
Simplified50.8%
Taylor expanded in i around 0 50.8%
+-commutative50.8%
*-commutative50.8%
*-commutative50.8%
*-commutative50.8%
associate-*l*50.8%
distribute-lft-out50.9%
Simplified50.9%
if -9.8000000000000001e-147 < n < 1.14e-210Initial program 63.7%
associate-*r/63.7%
sub-neg63.7%
distribute-lft-in63.7%
metadata-eval63.7%
metadata-eval63.7%
metadata-eval63.7%
fma-def63.7%
metadata-eval63.7%
Simplified63.7%
Taylor expanded in n around inf 50.8%
Taylor expanded in i around 0 77.2%
if 1.14e-210 < n < 2.64999999999999998e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
if 2.64999999999999998e-37 < n Initial program 20.2%
Taylor expanded in i around 0 81.7%
associate-*r*81.7%
associate-*r/81.7%
metadata-eval81.7%
Simplified81.7%
Final simplification65.9%
(FPCore (i n)
:precision binary64
(if (<= n -7.4e-152)
(* n (+ 100.0 (* i 50.0)))
(if (<= n 7.4e-211)
(/ 0.0 (/ i n))
(if (<= n 1.9e-37)
(* 100.0 (/ i (/ i n)))
(* (* n 100.0) (+ 1.0 (* i (- 0.5 (/ 0.5 n)))))))))
double code(double i, double n) {
double tmp;
if (n <= -7.4e-152) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 7.4e-211) {
tmp = 0.0 / (i / n);
} else if (n <= 1.9e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.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 <= (-7.4d-152)) then
tmp = n * (100.0d0 + (i * 50.0d0))
else if (n <= 7.4d-211) then
tmp = 0.0d0 / (i / n)
else if (n <= 1.9d-37) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = (n * 100.0d0) * (1.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 <= -7.4e-152) {
tmp = n * (100.0 + (i * 50.0));
} else if (n <= 7.4e-211) {
tmp = 0.0 / (i / n);
} else if (n <= 1.9e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -7.4e-152: tmp = n * (100.0 + (i * 50.0)) elif n <= 7.4e-211: tmp = 0.0 / (i / n) elif n <= 1.9e-37: tmp = 100.0 * (i / (i / n)) else: tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n)))) return tmp
function code(i, n) tmp = 0.0 if (n <= -7.4e-152) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); elseif (n <= 7.4e-211) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 1.9e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * Float64(1.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 <= -7.4e-152) tmp = n * (100.0 + (i * 50.0)); elseif (n <= 7.4e-211) tmp = 0.0 / (i / n); elseif (n <= 1.9e-37) tmp = 100.0 * (i / (i / n)); else tmp = (n * 100.0) * (1.0 + (i * (0.5 - (0.5 / n)))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -7.4e-152], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.4e-211], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.9e-37], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(1.0 + N[(i * N[(0.5 - N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -7.4 \cdot 10^{-152}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{elif}\;n \leq 7.4 \cdot 10^{-211}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 1.9 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \left(1 + i \cdot \left(0.5 - \frac{0.5}{n}\right)\right)\\
\end{array}
\end{array}
if n < -7.3999999999999997e-152Initial program 34.2%
Taylor expanded in i around 0 50.6%
associate-*r*50.6%
associate-*r/50.6%
metadata-eval50.6%
Simplified50.6%
Taylor expanded in n around inf 50.8%
*-commutative50.8%
*-commutative50.8%
associate-*l*50.8%
Simplified50.8%
Taylor expanded in i around 0 50.8%
+-commutative50.8%
*-commutative50.8%
*-commutative50.8%
*-commutative50.8%
associate-*l*50.8%
distribute-lft-out50.9%
Simplified50.9%
if -7.3999999999999997e-152 < n < 7.3999999999999996e-211Initial program 63.7%
associate-*r/63.7%
sub-neg63.7%
distribute-lft-in63.7%
metadata-eval63.7%
metadata-eval63.7%
metadata-eval63.7%
fma-def63.7%
metadata-eval63.7%
Simplified63.7%
Taylor expanded in n around inf 50.8%
Taylor expanded in i around 0 77.2%
if 7.3999999999999996e-211 < n < 1.9000000000000002e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
if 1.9000000000000002e-37 < n Initial program 20.2%
*-commutative20.2%
associate-/r/20.8%
associate-*l*20.8%
sub-neg20.8%
metadata-eval20.8%
Simplified20.8%
Taylor expanded in i around 0 81.8%
associate-*r/81.8%
metadata-eval81.8%
Simplified81.8%
Final simplification65.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (* i (/ n i)))))
(if (<= i -1e+16)
t_0
(if (<= i 2.6e+32)
(* n 100.0)
(if (or (<= i 3.6e+244) (not (<= i 1.45e+300)))
(* 50.0 (* i n))
t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (i * (n / i));
double tmp;
if (i <= -1e+16) {
tmp = t_0;
} else if (i <= 2.6e+32) {
tmp = n * 100.0;
} else if ((i <= 3.6e+244) || !(i <= 1.45e+300)) {
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 * (n / i))
if (i <= (-1d+16)) then
tmp = t_0
else if (i <= 2.6d+32) then
tmp = n * 100.0d0
else if ((i <= 3.6d+244) .or. (.not. (i <= 1.45d+300))) 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 * (n / i));
double tmp;
if (i <= -1e+16) {
tmp = t_0;
} else if (i <= 2.6e+32) {
tmp = n * 100.0;
} else if ((i <= 3.6e+244) || !(i <= 1.45e+300)) {
tmp = 50.0 * (i * n);
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (i * (n / i)) tmp = 0 if i <= -1e+16: tmp = t_0 elif i <= 2.6e+32: tmp = n * 100.0 elif (i <= 3.6e+244) or not (i <= 1.45e+300): tmp = 50.0 * (i * n) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(i * Float64(n / i))) tmp = 0.0 if (i <= -1e+16) tmp = t_0; elseif (i <= 2.6e+32) tmp = Float64(n * 100.0); elseif ((i <= 3.6e+244) || !(i <= 1.45e+300)) 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 * (n / i)); tmp = 0.0; if (i <= -1e+16) tmp = t_0; elseif (i <= 2.6e+32) tmp = n * 100.0; elseif ((i <= 3.6e+244) || ~((i <= 1.45e+300))) 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[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -1e+16], t$95$0, If[LessEqual[i, 2.6e+32], N[(n * 100.0), $MachinePrecision], If[Or[LessEqual[i, 3.6e+244], N[Not[LessEqual[i, 1.45e+300]], $MachinePrecision]], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\mathbf{if}\;i \leq -1 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;i \leq 2.6 \cdot 10^{+32}:\\
\;\;\;\;n \cdot 100\\
\mathbf{elif}\;i \leq 3.6 \cdot 10^{+244} \lor \neg \left(i \leq 1.45 \cdot 10^{+300}\right):\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if i < -1e16 or 3.6e244 < i < 1.44999999999999993e300Initial program 65.3%
associate-*r/65.4%
sub-neg65.4%
distribute-lft-in65.4%
metadata-eval65.4%
metadata-eval65.4%
metadata-eval65.4%
fma-def65.4%
metadata-eval65.4%
Simplified65.4%
Taylor expanded in i around 0 30.8%
*-commutative30.8%
Simplified30.8%
div-inv30.8%
*-commutative30.8%
clear-num26.5%
associate-*l*26.5%
Applied egg-rr26.5%
if -1e16 < i < 2.6000000000000002e32Initial program 10.6%
Taylor expanded in i around 0 75.4%
*-commutative75.4%
Simplified75.4%
if 2.6000000000000002e32 < i < 3.6e244 or 1.44999999999999993e300 < i Initial program 44.6%
Taylor expanded in i around 0 35.6%
associate-*r*35.6%
associate-*r/35.6%
metadata-eval35.6%
Simplified35.6%
Taylor expanded in n around inf 35.9%
*-commutative35.9%
*-commutative35.9%
associate-*l*35.9%
Simplified35.9%
Taylor expanded in i around inf 35.9%
Final simplification55.6%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (+ 100.0 (* i 50.0)))))
(if (<= n -4.9e-151)
t_0
(if (<= n 3.6e-212)
(/ 0.0 (/ i n))
(if (<= n 2.8e-37) (* 100.0 (/ i (/ i n))) t_0)))))
double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double tmp;
if (n <= -4.9e-151) {
tmp = t_0;
} else if (n <= 3.6e-212) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (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 = n * (100.0d0 + (i * 50.0d0))
if (n <= (-4.9d-151)) then
tmp = t_0
else if (n <= 3.6d-212) then
tmp = 0.0d0 / (i / n)
else if (n <= 2.8d-37) then
tmp = 100.0d0 * (i / (i / n))
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 tmp;
if (n <= -4.9e-151) {
tmp = t_0;
} else if (n <= 3.6e-212) {
tmp = 0.0 / (i / n);
} else if (n <= 2.8e-37) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = n * (100.0 + (i * 50.0)) tmp = 0 if n <= -4.9e-151: tmp = t_0 elif n <= 3.6e-212: tmp = 0.0 / (i / n) elif n <= 2.8e-37: tmp = 100.0 * (i / (i / n)) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(n * Float64(100.0 + Float64(i * 50.0))) tmp = 0.0 if (n <= -4.9e-151) tmp = t_0; elseif (n <= 3.6e-212) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 2.8e-37) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = n * (100.0 + (i * 50.0)); tmp = 0.0; if (n <= -4.9e-151) tmp = t_0; elseif (n <= 3.6e-212) tmp = 0.0 / (i / n); elseif (n <= 2.8e-37) tmp = 100.0 * (i / (i / n)); 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]}, If[LessEqual[n, -4.9e-151], t$95$0, If[LessEqual[n, 3.6e-212], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.8e-37], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{if}\;n \leq -4.9 \cdot 10^{-151}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 3.6 \cdot 10^{-212}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{-37}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -4.89999999999999966e-151 or 2.8000000000000001e-37 < n Initial program 28.4%
Taylor expanded in i around 0 63.6%
associate-*r*63.6%
associate-*r/63.6%
metadata-eval63.6%
Simplified63.6%
Taylor expanded in n around inf 63.6%
*-commutative63.6%
*-commutative63.6%
associate-*l*63.6%
Simplified63.6%
Taylor expanded in i around 0 63.6%
+-commutative63.6%
*-commutative63.6%
*-commutative63.6%
*-commutative63.6%
associate-*l*63.6%
distribute-lft-out63.6%
Simplified63.6%
if -4.89999999999999966e-151 < n < 3.6000000000000001e-212Initial program 63.7%
associate-*r/63.7%
sub-neg63.7%
distribute-lft-in63.7%
metadata-eval63.7%
metadata-eval63.7%
metadata-eval63.7%
fma-def63.7%
metadata-eval63.7%
Simplified63.7%
Taylor expanded in n around inf 50.8%
Taylor expanded in i around 0 77.2%
if 3.6000000000000001e-212 < n < 2.8000000000000001e-37Initial program 6.3%
Taylor expanded in i around 0 65.6%
Final simplification65.8%
(FPCore (i n) :precision binary64 (if (or (<= n -1.6e+56) (not (<= n 1e-37))) (* n 100.0) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -1.6e+56) || !(n <= 1e-37)) {
tmp = n * 100.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.6d+56)) .or. (.not. (n <= 1d-37))) then
tmp = n * 100.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.6e+56) || !(n <= 1e-37)) {
tmp = n * 100.0;
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.6e+56) or not (n <= 1e-37): tmp = n * 100.0 else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.6e+56) || !(n <= 1e-37)) tmp = Float64(n * 100.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.6e+56) || ~((n <= 1e-37))) tmp = n * 100.0; else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.6e+56], N[Not[LessEqual[n, 1e-37]], $MachinePrecision]], N[(n * 100.0), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.6 \cdot 10^{+56} \lor \neg \left(n \leq 10^{-37}\right):\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.60000000000000002e56 or 1.00000000000000007e-37 < n Initial program 26.2%
Taylor expanded in i around 0 54.5%
*-commutative54.5%
Simplified54.5%
if -1.60000000000000002e56 < n < 1.00000000000000007e-37Initial program 38.0%
Taylor expanded in i around 0 52.5%
Final simplification53.7%
(FPCore (i n) :precision binary64 (if (or (<= n -1.86e+56) (not (<= n 1.5))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -1.86e+56) || !(n <= 1.5)) {
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.86d+56)) .or. (.not. (n <= 1.5d0))) 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.86e+56) || !(n <= 1.5)) {
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.86e+56) or not (n <= 1.5): 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.86e+56) || !(n <= 1.5)) 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.86e+56) || ~((n <= 1.5))) 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.86e+56], N[Not[LessEqual[n, 1.5]], $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.86 \cdot 10^{+56} \lor \neg \left(n \leq 1.5\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.86000000000000007e56 or 1.5 < n Initial program 26.8%
Taylor expanded in i around 0 68.2%
associate-*r*68.2%
associate-*r/68.2%
metadata-eval68.2%
Simplified68.2%
Taylor expanded in n around inf 68.2%
*-commutative68.2%
*-commutative68.2%
associate-*l*68.2%
Simplified68.2%
Taylor expanded in i around 0 68.2%
+-commutative68.2%
*-commutative68.2%
*-commutative68.2%
*-commutative68.2%
associate-*l*68.2%
distribute-lft-out68.2%
Simplified68.2%
if -1.86000000000000007e56 < n < 1.5Initial program 36.7%
Taylor expanded in i around 0 54.1%
Final simplification62.4%
(FPCore (i n) :precision binary64 (if (<= i 2.6e+32) (* n 100.0) (* 50.0 (* i n))))
double code(double i, double n) {
double tmp;
if (i <= 2.6e+32) {
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 <= 2.6d+32) 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 <= 2.6e+32) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 2.6e+32: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= 2.6e+32) 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 <= 2.6e+32) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 2.6e+32], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 2.6 \cdot 10^{+32}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < 2.6000000000000002e32Initial program 25.9%
Taylor expanded in i around 0 57.3%
*-commutative57.3%
Simplified57.3%
if 2.6000000000000002e32 < i Initial program 45.9%
Taylor expanded in i around 0 33.2%
associate-*r*33.2%
associate-*r/33.2%
metadata-eval33.2%
Simplified33.2%
Taylor expanded in n around inf 33.5%
*-commutative33.5%
*-commutative33.5%
associate-*l*33.5%
Simplified33.5%
Taylor expanded in i around inf 33.5%
Final simplification51.4%
(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 30.9%
Taylor expanded in i around 0 51.8%
associate-*r*52.0%
associate-*r/52.0%
metadata-eval52.0%
Simplified52.0%
Taylor expanded in n around 0 2.3%
*-commutative2.3%
Simplified2.3%
Final simplification2.3%
(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 30.9%
Taylor expanded in i around 0 44.2%
*-commutative44.2%
Simplified44.2%
Final simplification44.2%
(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 2024031
(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))))