
(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 (fma t_0 100.0 -100.0))
(t_2 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_2 -1e-13)
(* n (/ t_1 i))
(if (<= t_2 0.0)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_2 INFINITY) (* t_1 (/ n i)) (* n 100.0))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = fma(t_0, 100.0, -100.0);
double t_2 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_2 <= -1e-13) {
tmp = n * (t_1 / i);
} else if (t_2 <= 0.0) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1 * (n / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = fma(t_0, 100.0, -100.0) t_2 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_2 <= -1e-13) tmp = Float64(n * Float64(t_1 / i)); elseif (t_2 <= 0.0) tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_2 <= Inf) tmp = Float64(t_1 * Float64(n / 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[(t$95$0 * 100.0 + -100.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-13], N[(n * N[(t$95$1 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 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$2, Infinity], N[(t$95$1 * N[(n / i), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \mathsf{fma}\left(t\_0, 100, -100\right)\\
t_2 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-13}:\\
\;\;\;\;n \cdot \frac{t\_1}{i}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_1 \cdot \frac{n}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -1e-13Initial program 99.6%
lift-/.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
associate-*r/N/A
div-invN/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites100.0%
if -1e-13 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 25.1%
lift-/.f64N/A
lift-+.f64N/A
sqr-powN/A
sqr-powN/A
pow-to-expN/A
lower-expm1.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f6499.8
Applied rewrites99.8%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 97.9%
lift-/.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
clear-numN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites98.0%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
Final simplification94.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (expm1 i) i)))
(if (<= n -2.7e-219)
(* n (* 100.0 t_0))
(if (<= n 2.9e-147)
(/ (* n (* n 100.0)) n)
(if (<= n 1.05e-33)
(* 100.0 (* (- (log i) (log n)) (/ (* n n) i)))
(* (* n 100.0) t_0))))))
double code(double i, double n) {
double t_0 = expm1(i) / i;
double tmp;
if (n <= -2.7e-219) {
tmp = n * (100.0 * t_0);
} else if (n <= 2.9e-147) {
tmp = (n * (n * 100.0)) / n;
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((log(i) - log(n)) * ((n * n) / i));
} else {
tmp = (n * 100.0) * t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.expm1(i) / i;
double tmp;
if (n <= -2.7e-219) {
tmp = n * (100.0 * t_0);
} else if (n <= 2.9e-147) {
tmp = (n * (n * 100.0)) / n;
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((Math.log(i) - Math.log(n)) * ((n * n) / i));
} else {
tmp = (n * 100.0) * t_0;
}
return tmp;
}
def code(i, n): t_0 = math.expm1(i) / i tmp = 0 if n <= -2.7e-219: tmp = n * (100.0 * t_0) elif n <= 2.9e-147: tmp = (n * (n * 100.0)) / n elif n <= 1.05e-33: tmp = 100.0 * ((math.log(i) - math.log(n)) * ((n * n) / i)) else: tmp = (n * 100.0) * t_0 return tmp
function code(i, n) t_0 = Float64(expm1(i) / i) tmp = 0.0 if (n <= -2.7e-219) tmp = Float64(n * Float64(100.0 * t_0)); elseif (n <= 2.9e-147) tmp = Float64(Float64(n * Float64(n * 100.0)) / n); elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(log(i) - log(n)) * Float64(Float64(n * n) / i))); else tmp = Float64(Float64(n * 100.0) * t_0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]}, If[LessEqual[n, -2.7e-219], N[(n * N[(100.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.9e-147], N[(N[(n * N[(n * 100.0), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(N[Log[i], $MachinePrecision] - N[Log[n], $MachinePrecision]), $MachinePrecision] * N[(N[(n * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{expm1}\left(i\right)}{i}\\
\mathbf{if}\;n \leq -2.7 \cdot 10^{-219}:\\
\;\;\;\;n \cdot \left(100 \cdot t\_0\right)\\
\mathbf{elif}\;n \leq 2.9 \cdot 10^{-147}:\\
\;\;\;\;\frac{n \cdot \left(n \cdot 100\right)}{n}\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \left(\left(\log i - \log n\right) \cdot \frac{n \cdot n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot t\_0\\
\end{array}
\end{array}
if n < -2.7e-219Initial program 26.5%
Taylor expanded in n around inf
lower-expm1.f6460.7
Applied rewrites60.7%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6478.9
Applied rewrites78.9%
if -2.7e-219 < n < 2.9000000000000001e-147Initial program 45.2%
Taylor expanded in i around 0
+-commutativeN/A
Applied rewrites3.1%
Taylor expanded in n around 0
lower-/.f64N/A
Applied rewrites12.4%
Taylor expanded in i around 0
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6468.7
Applied rewrites68.7%
if 2.9000000000000001e-147 < n < 1.05e-33Initial program 14.9%
Taylor expanded in n around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6481.2
Applied rewrites81.2%
if 1.05e-33 < n Initial program 21.0%
Taylor expanded in n around inf
lower-expm1.f6471.6
Applied rewrites71.6%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lower-/.f6492.0
Applied rewrites92.0%
Final simplification81.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (expm1 i) i)))
(if (<= n -2e-310)
(* n (* 100.0 t_0))
(if (<= n 1.05e-33)
(* 100.0 (/ (* n (- (log i) (log n))) (/ i n)))
(* (* n 100.0) t_0)))))
double code(double i, double n) {
double t_0 = expm1(i) / i;
double tmp;
if (n <= -2e-310) {
tmp = n * (100.0 * t_0);
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((n * (log(i) - log(n))) / (i / n));
} else {
tmp = (n * 100.0) * t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.expm1(i) / i;
double tmp;
if (n <= -2e-310) {
tmp = n * (100.0 * t_0);
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((n * (Math.log(i) - Math.log(n))) / (i / n));
} else {
tmp = (n * 100.0) * t_0;
}
return tmp;
}
def code(i, n): t_0 = math.expm1(i) / i tmp = 0 if n <= -2e-310: tmp = n * (100.0 * t_0) elif n <= 1.05e-33: tmp = 100.0 * ((n * (math.log(i) - math.log(n))) / (i / n)) else: tmp = (n * 100.0) * t_0 return tmp
function code(i, n) t_0 = Float64(expm1(i) / i) tmp = 0.0 if (n <= -2e-310) tmp = Float64(n * Float64(100.0 * t_0)); elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(n * Float64(log(i) - log(n))) / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * t_0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]}, If[LessEqual[n, -2e-310], N[(n * N[(100.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(n * N[(N[Log[i], $MachinePrecision] - N[Log[n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{expm1}\left(i\right)}{i}\\
\mathbf{if}\;n \leq -2 \cdot 10^{-310}:\\
\;\;\;\;n \cdot \left(100 \cdot t\_0\right)\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \frac{n \cdot \left(\log i - \log n\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot t\_0\\
\end{array}
\end{array}
if n < -1.999999999999994e-310Initial program 30.1%
Taylor expanded in n around inf
lower-expm1.f6459.0
Applied rewrites59.0%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6475.4
Applied rewrites75.4%
if -1.999999999999994e-310 < n < 1.05e-33Initial program 28.9%
Taylor expanded in n around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
lower-log.f6473.3
Applied rewrites73.3%
if 1.05e-33 < n Initial program 21.0%
Taylor expanded in n around inf
lower-expm1.f6471.6
Applied rewrites71.6%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lower-/.f6492.0
Applied rewrites92.0%
Final simplification79.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ (* n (expm1 i)) i))))
(if (<= n -4.25e-35)
t_0
(if (<= n -2.7e-219)
(* (expm1 i) (* 100.0 (/ n i)))
(if (<= n 1.05e-33) (* 100.0 (/ (+ 1.0 -1.0) (/ i n))) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * ((n * expm1(i)) / i);
double tmp;
if (n <= -4.25e-35) {
tmp = t_0;
} else if (n <= -2.7e-219) {
tmp = expm1(i) * (100.0 * (n / i));
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * ((n * Math.expm1(i)) / i);
double tmp;
if (n <= -4.25e-35) {
tmp = t_0;
} else if (n <= -2.7e-219) {
tmp = Math.expm1(i) * (100.0 * (n / i));
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * ((n * math.expm1(i)) / i) tmp = 0 if n <= -4.25e-35: tmp = t_0 elif n <= -2.7e-219: tmp = math.expm1(i) * (100.0 * (n / i)) elif n <= 1.05e-33: tmp = 100.0 * ((1.0 + -1.0) / (i / n)) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(Float64(n * expm1(i)) / i)) tmp = 0.0 if (n <= -4.25e-35) tmp = t_0; elseif (n <= -2.7e-219) tmp = Float64(expm1(i) * Float64(100.0 * Float64(n / i))); elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(1.0 + -1.0) / Float64(i / n))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(N[(n * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -4.25e-35], t$95$0, If[LessEqual[n, -2.7e-219], N[(N[(Exp[i] - 1), $MachinePrecision] * N[(100.0 * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(1.0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{if}\;n \leq -4.25 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -2.7 \cdot 10^{-219}:\\
\;\;\;\;\mathsf{expm1}\left(i\right) \cdot \left(100 \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \frac{1 + -1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -4.2500000000000001e-35 or 1.05e-33 < n Initial program 22.6%
Taylor expanded in n around inf
lower-/.f64N/A
lower-*.f64N/A
lower-expm1.f6489.4
Applied rewrites89.4%
if -4.2500000000000001e-35 < n < -2.7e-219Initial program 32.2%
Taylor expanded in n around inf
lower-expm1.f6463.2
Applied rewrites63.2%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
clear-numN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6459.8
Applied rewrites59.8%
if -2.7e-219 < n < 1.05e-33Initial program 36.9%
Taylor expanded in i around 0
Applied rewrites62.7%
Final simplification79.0%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (expm1 i) i)))
(if (<= n -2.7e-219)
(* n (* 100.0 t_0))
(if (<= n 1.05e-33)
(* 100.0 (/ (+ 1.0 -1.0) (/ i n)))
(* (* n 100.0) t_0)))))
double code(double i, double n) {
double t_0 = expm1(i) / i;
double tmp;
if (n <= -2.7e-219) {
tmp = n * (100.0 * t_0);
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = (n * 100.0) * t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.expm1(i) / i;
double tmp;
if (n <= -2.7e-219) {
tmp = n * (100.0 * t_0);
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = (n * 100.0) * t_0;
}
return tmp;
}
def code(i, n): t_0 = math.expm1(i) / i tmp = 0 if n <= -2.7e-219: tmp = n * (100.0 * t_0) elif n <= 1.05e-33: tmp = 100.0 * ((1.0 + -1.0) / (i / n)) else: tmp = (n * 100.0) * t_0 return tmp
function code(i, n) t_0 = Float64(expm1(i) / i) tmp = 0.0 if (n <= -2.7e-219) tmp = Float64(n * Float64(100.0 * t_0)); elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(1.0 + -1.0) / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * t_0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]}, If[LessEqual[n, -2.7e-219], N[(n * N[(100.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(1.0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{expm1}\left(i\right)}{i}\\
\mathbf{if}\;n \leq -2.7 \cdot 10^{-219}:\\
\;\;\;\;n \cdot \left(100 \cdot t\_0\right)\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \frac{1 + -1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot t\_0\\
\end{array}
\end{array}
if n < -2.7e-219Initial program 26.5%
Taylor expanded in n around inf
lower-expm1.f6460.7
Applied rewrites60.7%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6478.9
Applied rewrites78.9%
if -2.7e-219 < n < 1.05e-33Initial program 36.9%
Taylor expanded in i around 0
Applied rewrites62.7%
if 1.05e-33 < n Initial program 21.0%
Taylor expanded in n around inf
lower-expm1.f6471.6
Applied rewrites71.6%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lower-/.f6492.0
Applied rewrites92.0%
Final simplification79.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (* 100.0 (/ (expm1 i) i)))))
(if (<= n -2.7e-219)
t_0
(if (<= n 1.05e-33) (* 100.0 (/ (+ 1.0 -1.0) (/ i n))) t_0))))
double code(double i, double n) {
double t_0 = n * (100.0 * (expm1(i) / i));
double tmp;
if (n <= -2.7e-219) {
tmp = t_0;
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = n * (100.0 * (Math.expm1(i) / i));
double tmp;
if (n <= -2.7e-219) {
tmp = t_0;
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = n * (100.0 * (math.expm1(i) / i)) tmp = 0 if n <= -2.7e-219: tmp = t_0 elif n <= 1.05e-33: tmp = 100.0 * ((1.0 + -1.0) / (i / n)) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(n * Float64(100.0 * Float64(expm1(i) / i))) tmp = 0.0 if (n <= -2.7e-219) tmp = t_0; elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(1.0 + -1.0) / Float64(i / n))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -2.7e-219], t$95$0, If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(1.0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{if}\;n \leq -2.7 \cdot 10^{-219}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \frac{1 + -1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -2.7e-219 or 1.05e-33 < n Initial program 24.4%
Taylor expanded in n around inf
lower-expm1.f6464.8
Applied rewrites64.8%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6483.9
Applied rewrites83.9%
if -2.7e-219 < n < 1.05e-33Initial program 36.9%
Taylor expanded in i around 0
Applied rewrites62.7%
Final simplification79.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ (* n (expm1 i)) i))))
(if (<= n -2.9e-131)
t_0
(if (<= n 1.05e-33) (* 100.0 (/ (+ 1.0 -1.0) (/ i n))) t_0))))
double code(double i, double n) {
double t_0 = 100.0 * ((n * expm1(i)) / i);
double tmp;
if (n <= -2.9e-131) {
tmp = t_0;
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * ((n * Math.expm1(i)) / i);
double tmp;
if (n <= -2.9e-131) {
tmp = t_0;
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * ((n * math.expm1(i)) / i) tmp = 0 if n <= -2.9e-131: tmp = t_0 elif n <= 1.05e-33: tmp = 100.0 * ((1.0 + -1.0) / (i / n)) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(Float64(n * expm1(i)) / i)) tmp = 0.0 if (n <= -2.9e-131) tmp = t_0; elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(1.0 + -1.0) / Float64(i / n))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(N[(n * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -2.9e-131], t$95$0, If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(1.0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{if}\;n \leq -2.9 \cdot 10^{-131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \frac{1 + -1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -2.9000000000000002e-131 or 1.05e-33 < n Initial program 22.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower-*.f64N/A
lower-expm1.f6483.0
Applied rewrites83.0%
if -2.9000000000000002e-131 < n < 1.05e-33Initial program 40.0%
Taylor expanded in i around 0
Applied rewrites61.8%
Final simplification77.3%
(FPCore (i n)
:precision binary64
(if (<= n -6.2e-157)
(*
n
(fma i (fma i (fma i 4.166666666666667 16.666666666666668) 50.0) 100.0))
(if (<= n 1.05e-33)
(* 100.0 (/ (+ 1.0 -1.0) (/ i n)))
(*
(* n 100.0)
(/
(*
i
(fma
i
(fma i (fma i 0.041666666666666664 0.16666666666666666) 0.5)
1.0))
i)))))
double code(double i, double n) {
double tmp;
if (n <= -6.2e-157) {
tmp = n * fma(i, fma(i, fma(i, 4.166666666666667, 16.666666666666668), 50.0), 100.0);
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = (n * 100.0) * ((i * fma(i, fma(i, fma(i, 0.041666666666666664, 0.16666666666666666), 0.5), 1.0)) / i);
}
return tmp;
}
function code(i, n) tmp = 0.0 if (n <= -6.2e-157) tmp = Float64(n * fma(i, fma(i, fma(i, 4.166666666666667, 16.666666666666668), 50.0), 100.0)); elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(1.0 + -1.0) / Float64(i / n))); else tmp = Float64(Float64(n * 100.0) * Float64(Float64(i * fma(i, fma(i, fma(i, 0.041666666666666664, 0.16666666666666666), 0.5), 1.0)) / i)); end return tmp end
code[i_, n_] := If[LessEqual[n, -6.2e-157], N[(n * N[(i * N[(i * N[(i * 4.166666666666667 + 16.666666666666668), $MachinePrecision] + 50.0), $MachinePrecision] + 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(1.0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] * N[(N[(i * N[(i * N[(i * N[(i * 0.041666666666666664 + 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.2 \cdot 10^{-157}:\\
\;\;\;\;n \cdot \mathsf{fma}\left(i, \mathsf{fma}\left(i, \mathsf{fma}\left(i, 4.166666666666667, 16.666666666666668\right), 50\right), 100\right)\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \frac{1 + -1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot 100\right) \cdot \frac{i \cdot \mathsf{fma}\left(i, \mathsf{fma}\left(i, \mathsf{fma}\left(i, 0.041666666666666664, 0.16666666666666666\right), 0.5\right), 1\right)}{i}\\
\end{array}
\end{array}
if n < -6.1999999999999996e-157Initial program 23.8%
Taylor expanded in n around inf
lower-expm1.f6458.8
Applied rewrites58.8%
Taylor expanded in i around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.0
Applied rewrites60.0%
Taylor expanded in i around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-inN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites60.8%
if -6.1999999999999996e-157 < n < 1.05e-33Initial program 40.2%
Taylor expanded in i around 0
Applied rewrites62.9%
if 1.05e-33 < n Initial program 21.0%
Taylor expanded in n around inf
lower-expm1.f6471.6
Applied rewrites71.6%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lower-/.f6492.0
Applied rewrites92.0%
Taylor expanded in i around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.6
Applied rewrites85.6%
Final simplification68.6%
(FPCore (i n)
:precision binary64
(let* ((t_0
(*
n
(fma
i
(fma i (fma i 4.166666666666667 16.666666666666668) 50.0)
100.0))))
(if (<= n -6.2e-157)
t_0
(if (<= n 1.05e-33) (* 100.0 (/ (+ 1.0 -1.0) (/ i n))) t_0))))
double code(double i, double n) {
double t_0 = n * fma(i, fma(i, fma(i, 4.166666666666667, 16.666666666666668), 50.0), 100.0);
double tmp;
if (n <= -6.2e-157) {
tmp = t_0;
} else if (n <= 1.05e-33) {
tmp = 100.0 * ((1.0 + -1.0) / (i / n));
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(n * fma(i, fma(i, fma(i, 4.166666666666667, 16.666666666666668), 50.0), 100.0)) tmp = 0.0 if (n <= -6.2e-157) tmp = t_0; elseif (n <= 1.05e-33) tmp = Float64(100.0 * Float64(Float64(1.0 + -1.0) / Float64(i / n))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(i * N[(i * N[(i * 4.166666666666667 + 16.666666666666668), $MachinePrecision] + 50.0), $MachinePrecision] + 100.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -6.2e-157], t$95$0, If[LessEqual[n, 1.05e-33], N[(100.0 * N[(N[(1.0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \mathsf{fma}\left(i, \mathsf{fma}\left(i, \mathsf{fma}\left(i, 4.166666666666667, 16.666666666666668\right), 50\right), 100\right)\\
\mathbf{if}\;n \leq -6.2 \cdot 10^{-157}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;100 \cdot \frac{1 + -1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -6.1999999999999996e-157 or 1.05e-33 < n Initial program 22.7%
Taylor expanded in n around inf
lower-expm1.f6463.8
Applied rewrites63.8%
Taylor expanded in i around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
Taylor expanded in i around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-inN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites70.1%
if -6.1999999999999996e-157 < n < 1.05e-33Initial program 40.2%
Taylor expanded in i around 0
Applied rewrites62.9%
Final simplification68.3%
(FPCore (i n)
:precision binary64
(let* ((t_0
(*
n
(fma
i
(fma i (fma i 4.166666666666667 16.666666666666668) 50.0)
100.0))))
(if (<= n -6.2e-157) t_0 (if (<= n 1.05e-33) (/ 0.0 i) t_0))))
double code(double i, double n) {
double t_0 = n * fma(i, fma(i, fma(i, 4.166666666666667, 16.666666666666668), 50.0), 100.0);
double tmp;
if (n <= -6.2e-157) {
tmp = t_0;
} else if (n <= 1.05e-33) {
tmp = 0.0 / i;
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(n * fma(i, fma(i, fma(i, 4.166666666666667, 16.666666666666668), 50.0), 100.0)) tmp = 0.0 if (n <= -6.2e-157) tmp = t_0; elseif (n <= 1.05e-33) tmp = Float64(0.0 / i); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(i * N[(i * N[(i * 4.166666666666667 + 16.666666666666668), $MachinePrecision] + 50.0), $MachinePrecision] + 100.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -6.2e-157], t$95$0, If[LessEqual[n, 1.05e-33], N[(0.0 / i), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \mathsf{fma}\left(i, \mathsf{fma}\left(i, \mathsf{fma}\left(i, 4.166666666666667, 16.666666666666668\right), 50\right), 100\right)\\
\mathbf{if}\;n \leq -6.2 \cdot 10^{-157}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;\frac{0}{i}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -6.1999999999999996e-157 or 1.05e-33 < n Initial program 22.7%
Taylor expanded in n around inf
lower-expm1.f6463.8
Applied rewrites63.8%
Taylor expanded in i around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
Taylor expanded in i around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-inN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites70.1%
if -6.1999999999999996e-157 < n < 1.05e-33Initial program 40.2%
lift-/.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
associate-*r/N/A
div-invN/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
+-commutativeN/A
clear-numN/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
Applied rewrites13.0%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6462.9
Applied rewrites62.9%
(FPCore (i n) :precision binary64 (if (<= n -6.2e-157) (* n (fma i (fma i 16.666666666666668 50.0) 100.0)) (if (<= n 1.05e-33) (/ 0.0 i) (* n (fma 50.0 i 100.0)))))
double code(double i, double n) {
double tmp;
if (n <= -6.2e-157) {
tmp = n * fma(i, fma(i, 16.666666666666668, 50.0), 100.0);
} else if (n <= 1.05e-33) {
tmp = 0.0 / i;
} else {
tmp = n * fma(50.0, i, 100.0);
}
return tmp;
}
function code(i, n) tmp = 0.0 if (n <= -6.2e-157) tmp = Float64(n * fma(i, fma(i, 16.666666666666668, 50.0), 100.0)); elseif (n <= 1.05e-33) tmp = Float64(0.0 / i); else tmp = Float64(n * fma(50.0, i, 100.0)); end return tmp end
code[i_, n_] := If[LessEqual[n, -6.2e-157], N[(n * N[(i * N[(i * 16.666666666666668 + 50.0), $MachinePrecision] + 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.05e-33], N[(0.0 / i), $MachinePrecision], N[(n * N[(50.0 * i + 100.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.2 \cdot 10^{-157}:\\
\;\;\;\;n \cdot \mathsf{fma}\left(i, \mathsf{fma}\left(i, 16.666666666666668, 50\right), 100\right)\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;\frac{0}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \mathsf{fma}\left(50, i, 100\right)\\
\end{array}
\end{array}
if n < -6.1999999999999996e-157Initial program 23.8%
Taylor expanded in n around inf
lower-expm1.f6458.8
Applied rewrites58.8%
lift-expm1.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lower-/.f6478.6
Applied rewrites78.6%
lift-expm1.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6478.6
Applied rewrites78.6%
Taylor expanded in i around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6460.4
Applied rewrites60.4%
if -6.1999999999999996e-157 < n < 1.05e-33Initial program 40.2%
lift-/.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
associate-*r/N/A
div-invN/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
+-commutativeN/A
clear-numN/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
Applied rewrites13.0%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6462.9
Applied rewrites62.9%
if 1.05e-33 < n Initial program 21.0%
Taylor expanded in n around inf
lower-expm1.f6471.6
Applied rewrites71.6%
Taylor expanded in i around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f6480.2
Applied rewrites80.2%
Final simplification66.8%
(FPCore (i n) :precision binary64 (let* ((t_0 (* n (fma 50.0 i 100.0)))) (if (<= n -6.2e-157) t_0 (if (<= n 1.05e-33) (/ 0.0 i) t_0))))
double code(double i, double n) {
double t_0 = n * fma(50.0, i, 100.0);
double tmp;
if (n <= -6.2e-157) {
tmp = t_0;
} else if (n <= 1.05e-33) {
tmp = 0.0 / i;
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(n * fma(50.0, i, 100.0)) tmp = 0.0 if (n <= -6.2e-157) tmp = t_0; elseif (n <= 1.05e-33) tmp = Float64(0.0 / i); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(50.0 * i + 100.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -6.2e-157], t$95$0, If[LessEqual[n, 1.05e-33], N[(0.0 / i), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \mathsf{fma}\left(50, i, 100\right)\\
\mathbf{if}\;n \leq -6.2 \cdot 10^{-157}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;\frac{0}{i}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -6.1999999999999996e-157 or 1.05e-33 < n Initial program 22.7%
Taylor expanded in n around inf
lower-expm1.f6463.8
Applied rewrites63.8%
Taylor expanded in i around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f6465.4
Applied rewrites65.4%
if -6.1999999999999996e-157 < n < 1.05e-33Initial program 40.2%
lift-/.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
associate-*r/N/A
div-invN/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
+-commutativeN/A
clear-numN/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
Applied rewrites13.0%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6462.9
Applied rewrites62.9%
(FPCore (i n) :precision binary64 (if (<= i 9.5e+25) (* n 100.0) (* n (* i 50.0))))
double code(double i, double n) {
double tmp;
if (i <= 9.5e+25) {
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 <= 9.5d+25) 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 <= 9.5e+25) {
tmp = n * 100.0;
} else {
tmp = n * (i * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 9.5e+25: tmp = n * 100.0 else: tmp = n * (i * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= 9.5e+25) 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 <= 9.5e+25) tmp = n * 100.0; else tmp = n * (i * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 9.5e+25], N[(n * 100.0), $MachinePrecision], N[(n * N[(i * 50.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 9.5 \cdot 10^{+25}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(i \cdot 50\right)\\
\end{array}
\end{array}
if i < 9.5000000000000005e25Initial program 23.1%
Taylor expanded in i around 0
*-commutativeN/A
lower-*.f6463.7
Applied rewrites63.7%
if 9.5000000000000005e25 < i Initial program 42.6%
Taylor expanded in n around inf
lower-expm1.f6444.9
Applied rewrites44.9%
Taylor expanded in i around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f6421.5
Applied rewrites21.5%
Taylor expanded in i around inf
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6421.5
Applied rewrites21.5%
(FPCore (i n) :precision binary64 (* n (fma 50.0 i 100.0)))
double code(double i, double n) {
return n * fma(50.0, i, 100.0);
}
function code(i, n) return Float64(n * fma(50.0, i, 100.0)) end
code[i_, n_] := N[(n * N[(50.0 * i + 100.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
n \cdot \mathsf{fma}\left(50, i, 100\right)
\end{array}
Initial program 27.2%
Taylor expanded in n around inf
lower-expm1.f6457.4
Applied rewrites57.4%
Taylor expanded in i around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f6456.1
Applied rewrites56.1%
(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.2%
Taylor expanded in i around 0
*-commutativeN/A
lower-*.f6451.3
Applied rewrites51.3%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t\_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t\_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2024214
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:alt
(! :herbie-platform default (let ((lnbase (if (== (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) (* 100 (/ (- (exp (* n lnbase)) 1) (/ i n)))))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))