
(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 12 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 (+ (/ i n) 1.0) n)) (t_1 (- t_0 1.0)) (t_2 (/ t_1 (/ i n))))
(if (<= t_2 (- INFINITY))
(* (* (/ 100.0 i) t_1) n)
(if (<= t_2 0.0)
(* (/ (* (expm1 (* (log1p (/ i n)) n)) 100.0) i) n)
(if (<= t_2 INFINITY)
(* (fma (/ t_0 i) n (/ (- n) i)) 100.0)
(* (/ 1.0 (fma (fma 0.0008333333333333334 i -0.005) i 0.01)) n))))))
double code(double i, double n) {
double t_0 = pow(((i / n) + 1.0), n);
double t_1 = t_0 - 1.0;
double t_2 = t_1 / (i / n);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = ((100.0 / i) * t_1) * n;
} else if (t_2 <= 0.0) {
tmp = ((expm1((log1p((i / n)) * n)) * 100.0) / i) * n;
} else if (t_2 <= ((double) INFINITY)) {
tmp = fma((t_0 / i), n, (-n / i)) * 100.0;
} else {
tmp = (1.0 / fma(fma(0.0008333333333333334, i, -0.005), i, 0.01)) * n;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(i / n) + 1.0) ^ n t_1 = Float64(t_0 - 1.0) t_2 = Float64(t_1 / Float64(i / n)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(Float64(100.0 / i) * t_1) * n); elseif (t_2 <= 0.0) tmp = Float64(Float64(Float64(expm1(Float64(log1p(Float64(i / n)) * n)) * 100.0) / i) * n); elseif (t_2 <= Inf) tmp = Float64(fma(Float64(t_0 / i), n, Float64(Float64(-n) / i)) * 100.0); else tmp = Float64(Float64(1.0 / fma(fma(0.0008333333333333334, i, -0.005), i, 0.01)) * n); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(100.0 / i), $MachinePrecision] * t$95$1), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision] * 100.0), $MachinePrecision] / i), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(N[(t$95$0 / i), $MachinePrecision] * n + N[((-n) / i), $MachinePrecision]), $MachinePrecision] * 100.0), $MachinePrecision], N[(N[(1.0 / N[(N[(0.0008333333333333334 * i + -0.005), $MachinePrecision] * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{i}{n} + 1\right)}^{n}\\
t_1 := t\_0 - 1\\
t_2 := \frac{t\_1}{\frac{i}{n}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\left(\frac{100}{i} \cdot t\_1\right) \cdot n\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right) \cdot 100}{i} \cdot n\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{i}, n, \frac{-n}{i}\right) \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.0008333333333333334, i, -0.005\right), i, 0.01\right)} \cdot n\\
\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)) < -inf.0Initial program 100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6433.3
Applied rewrites33.3%
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
lift-/.f64N/A
lower--.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 24.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
pow-to-expN/A
lift-log1p.f64N/A
lift-*.f64N/A
lift-expm1.f6499.7
Applied rewrites99.7%
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 99.8%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6499.9
Applied rewrites99.9%
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 n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6481.1
Applied rewrites81.1%
Applied rewrites81.1%
Taylor expanded in i around 0
Applied rewrites99.7%
Final simplification99.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ (/ i n) 1.0) n)) (t_1 (- t_0 1.0)) (t_2 (/ t_1 (/ i n))))
(if (<= t_2 (- INFINITY))
(* (* (/ 100.0 i) t_1) n)
(if (<= t_2 0.0)
(* (* (expm1 (* (log1p (/ i n)) n)) (/ 100.0 i)) n)
(if (<= t_2 INFINITY)
(* (fma (/ t_0 i) n (/ (- n) i)) 100.0)
(* (/ 1.0 (fma (fma 0.0008333333333333334 i -0.005) i 0.01)) n))))))
double code(double i, double n) {
double t_0 = pow(((i / n) + 1.0), n);
double t_1 = t_0 - 1.0;
double t_2 = t_1 / (i / n);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = ((100.0 / i) * t_1) * n;
} else if (t_2 <= 0.0) {
tmp = (expm1((log1p((i / n)) * n)) * (100.0 / i)) * n;
} else if (t_2 <= ((double) INFINITY)) {
tmp = fma((t_0 / i), n, (-n / i)) * 100.0;
} else {
tmp = (1.0 / fma(fma(0.0008333333333333334, i, -0.005), i, 0.01)) * n;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(i / n) + 1.0) ^ n t_1 = Float64(t_0 - 1.0) t_2 = Float64(t_1 / Float64(i / n)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(Float64(100.0 / i) * t_1) * n); elseif (t_2 <= 0.0) tmp = Float64(Float64(expm1(Float64(log1p(Float64(i / n)) * n)) * Float64(100.0 / i)) * n); elseif (t_2 <= Inf) tmp = Float64(fma(Float64(t_0 / i), n, Float64(Float64(-n) / i)) * 100.0); else tmp = Float64(Float64(1.0 / fma(fma(0.0008333333333333334, i, -0.005), i, 0.01)) * n); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(100.0 / i), $MachinePrecision] * t$95$1), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision] * N[(100.0 / i), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(N[(t$95$0 / i), $MachinePrecision] * n + N[((-n) / i), $MachinePrecision]), $MachinePrecision] * 100.0), $MachinePrecision], N[(N[(1.0 / N[(N[(0.0008333333333333334 * i + -0.005), $MachinePrecision] * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{i}{n} + 1\right)}^{n}\\
t_1 := t\_0 - 1\\
t_2 := \frac{t\_1}{\frac{i}{n}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\left(\frac{100}{i} \cdot t\_1\right) \cdot n\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right) \cdot \frac{100}{i}\right) \cdot n\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{i}, n, \frac{-n}{i}\right) \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.0008333333333333334, i, -0.005\right), i, 0.01\right)} \cdot n\\
\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)) < -inf.0Initial program 100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6433.3
Applied rewrites33.3%
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
lift-/.f64N/A
lower--.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 24.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
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 99.8%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6499.9
Applied rewrites99.9%
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 n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6481.1
Applied rewrites81.1%
Applied rewrites81.1%
Taylor expanded in i around 0
Applied rewrites99.7%
Final simplification99.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* (* (/ (expm1 i) i) 100.0) n)))
(if (<= n -3e-240)
t_0
(if (<= n 4.7e-220)
(* (/ (* n n) n) 100.0)
(if (<= n 9.2e-17)
(*
(/
1.0
(fma
(fma
(fma (* i i) -1.388888888888889e-5 0.0008333333333333334)
i
-0.005)
i
0.01))
n)
t_0)))))
double code(double i, double n) {
double t_0 = ((expm1(i) / i) * 100.0) * n;
double tmp;
if (n <= -3e-240) {
tmp = t_0;
} else if (n <= 4.7e-220) {
tmp = ((n * n) / n) * 100.0;
} else if (n <= 9.2e-17) {
tmp = (1.0 / fma(fma(fma((i * i), -1.388888888888889e-5, 0.0008333333333333334), i, -0.005), i, 0.01)) * n;
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(Float64(expm1(i) / i) * 100.0) * n) tmp = 0.0 if (n <= -3e-240) tmp = t_0; elseif (n <= 4.7e-220) tmp = Float64(Float64(Float64(n * n) / n) * 100.0); elseif (n <= 9.2e-17) tmp = Float64(Float64(1.0 / fma(fma(fma(Float64(i * i), -1.388888888888889e-5, 0.0008333333333333334), i, -0.005), i, 0.01)) * n); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision] * 100.0), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[n, -3e-240], t$95$0, If[LessEqual[n, 4.7e-220], N[(N[(N[(n * n), $MachinePrecision] / n), $MachinePrecision] * 100.0), $MachinePrecision], If[LessEqual[n, 9.2e-17], N[(N[(1.0 / N[(N[(N[(N[(i * i), $MachinePrecision] * -1.388888888888889e-5 + 0.0008333333333333334), $MachinePrecision] * i + -0.005), $MachinePrecision] * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{\mathsf{expm1}\left(i\right)}{i} \cdot 100\right) \cdot n\\
\mathbf{if}\;n \leq -3 \cdot 10^{-240}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 4.7 \cdot 10^{-220}:\\
\;\;\;\;\frac{n \cdot n}{n} \cdot 100\\
\mathbf{elif}\;n \leq 9.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(i \cdot i, -1.388888888888889 \cdot 10^{-5}, 0.0008333333333333334\right), i, -0.005\right), i, 0.01\right)} \cdot n\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -2.99999999999999991e-240 or 9.20000000000000035e-17 < n Initial program 25.6%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6489.9
Applied rewrites89.9%
if -2.99999999999999991e-240 < n < 4.7000000000000003e-220Initial program 68.9%
Taylor expanded in i around 0
+-commutativeN/A
Applied rewrites0.7%
Taylor expanded in n around 0
Applied rewrites24.6%
Taylor expanded in i around 0
Applied rewrites24.6%
Taylor expanded in i around 0
Applied rewrites82.6%
if 4.7000000000000003e-220 < n < 9.20000000000000035e-17Initial program 14.4%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6454.1
Applied rewrites54.1%
Applied rewrites54.0%
Taylor expanded in i around 0
Applied rewrites78.9%
Final simplification87.8%
(FPCore (i n)
:precision binary64
(let* ((t_0
(*
(/
1.0
(fma
(fma
(fma (* i i) -1.388888888888889e-5 0.0008333333333333334)
i
-0.005)
i
0.01))
n)))
(if (<= n -2.8e+120)
(* (fma (fma 16.666666666666668 i 50.0) i 100.0) n)
(if (<= n -3e-240)
t_0
(if (<= n 4.7e-220)
(* (/ (* n n) n) 100.0)
(if (<= n 9.2e-17)
t_0
(*
(fma
(fma (fma 0.041666666666666664 i 0.16666666666666666) i 0.5)
i
1.0)
(* 100.0 n))))))))
double code(double i, double n) {
double t_0 = (1.0 / fma(fma(fma((i * i), -1.388888888888889e-5, 0.0008333333333333334), i, -0.005), i, 0.01)) * n;
double tmp;
if (n <= -2.8e+120) {
tmp = fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n;
} else if (n <= -3e-240) {
tmp = t_0;
} else if (n <= 4.7e-220) {
tmp = ((n * n) / n) * 100.0;
} else if (n <= 9.2e-17) {
tmp = t_0;
} else {
tmp = fma(fma(fma(0.041666666666666664, i, 0.16666666666666666), i, 0.5), i, 1.0) * (100.0 * n);
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(1.0 / fma(fma(fma(Float64(i * i), -1.388888888888889e-5, 0.0008333333333333334), i, -0.005), i, 0.01)) * n) tmp = 0.0 if (n <= -2.8e+120) tmp = Float64(fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n); elseif (n <= -3e-240) tmp = t_0; elseif (n <= 4.7e-220) tmp = Float64(Float64(Float64(n * n) / n) * 100.0); elseif (n <= 9.2e-17) tmp = t_0; else tmp = Float64(fma(fma(fma(0.041666666666666664, i, 0.16666666666666666), i, 0.5), i, 1.0) * Float64(100.0 * n)); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(1.0 / N[(N[(N[(N[(i * i), $MachinePrecision] * -1.388888888888889e-5 + 0.0008333333333333334), $MachinePrecision] * i + -0.005), $MachinePrecision] * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[n, -2.8e+120], N[(N[(N[(16.666666666666668 * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, -3e-240], t$95$0, If[LessEqual[n, 4.7e-220], N[(N[(N[(n * n), $MachinePrecision] / n), $MachinePrecision] * 100.0), $MachinePrecision], If[LessEqual[n, 9.2e-17], t$95$0, N[(N[(N[(N[(0.041666666666666664 * i + 0.16666666666666666), $MachinePrecision] * i + 0.5), $MachinePrecision] * i + 1.0), $MachinePrecision] * N[(100.0 * n), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(i \cdot i, -1.388888888888889 \cdot 10^{-5}, 0.0008333333333333334\right), i, -0.005\right), i, 0.01\right)} \cdot n\\
\mathbf{if}\;n \leq -2.8 \cdot 10^{+120}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(16.666666666666668, i, 50\right), i, 100\right) \cdot n\\
\mathbf{elif}\;n \leq -3 \cdot 10^{-240}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 4.7 \cdot 10^{-220}:\\
\;\;\;\;\frac{n \cdot n}{n} \cdot 100\\
\mathbf{elif}\;n \leq 9.2 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, i, 0.16666666666666666\right), i, 0.5\right), i, 1\right) \cdot \left(100 \cdot n\right)\\
\end{array}
\end{array}
if n < -2.8000000000000001e120Initial program 8.5%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6497.9
Applied rewrites97.9%
Taylor expanded in i around 0
Applied rewrites74.7%
if -2.8000000000000001e120 < n < -2.99999999999999991e-240 or 4.7000000000000003e-220 < n < 9.20000000000000035e-17Initial program 30.6%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6471.0
Applied rewrites71.0%
Applied rewrites70.9%
Taylor expanded in i around 0
Applied rewrites74.0%
if -2.99999999999999991e-240 < n < 4.7000000000000003e-220Initial program 68.9%
Taylor expanded in i around 0
+-commutativeN/A
Applied rewrites0.7%
Taylor expanded in n around 0
Applied rewrites24.6%
Taylor expanded in i around 0
Applied rewrites24.6%
Taylor expanded in i around 0
Applied rewrites82.6%
if 9.20000000000000035e-17 < n Initial program 25.4%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6493.9
Applied rewrites93.9%
Taylor expanded in i around 0
Applied rewrites83.3%
Applied rewrites83.3%
Final simplification77.6%
(FPCore (i n)
:precision binary64
(if (<= n -5.6e+188)
(* (fma (fma 16.666666666666668 i 50.0) i 100.0) n)
(if (<= n -3e-240)
(* (/ 1.0 (fma -0.005 i 0.01)) n)
(if (<= n 4.7e-220)
(* (/ (* n n) n) 100.0)
(if (<= n 7.2e-13)
(* (/ 1.0 (fma (fma 0.0008333333333333334 i -0.005) i 0.01)) n)
(*
(fma
(fma (fma 0.041666666666666664 i 0.16666666666666666) i 0.5)
i
1.0)
(* 100.0 n)))))))
double code(double i, double n) {
double tmp;
if (n <= -5.6e+188) {
tmp = fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n;
} else if (n <= -3e-240) {
tmp = (1.0 / fma(-0.005, i, 0.01)) * n;
} else if (n <= 4.7e-220) {
tmp = ((n * n) / n) * 100.0;
} else if (n <= 7.2e-13) {
tmp = (1.0 / fma(fma(0.0008333333333333334, i, -0.005), i, 0.01)) * n;
} else {
tmp = fma(fma(fma(0.041666666666666664, i, 0.16666666666666666), i, 0.5), i, 1.0) * (100.0 * n);
}
return tmp;
}
function code(i, n) tmp = 0.0 if (n <= -5.6e+188) tmp = Float64(fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n); elseif (n <= -3e-240) tmp = Float64(Float64(1.0 / fma(-0.005, i, 0.01)) * n); elseif (n <= 4.7e-220) tmp = Float64(Float64(Float64(n * n) / n) * 100.0); elseif (n <= 7.2e-13) tmp = Float64(Float64(1.0 / fma(fma(0.0008333333333333334, i, -0.005), i, 0.01)) * n); else tmp = Float64(fma(fma(fma(0.041666666666666664, i, 0.16666666666666666), i, 0.5), i, 1.0) * Float64(100.0 * n)); end return tmp end
code[i_, n_] := If[LessEqual[n, -5.6e+188], N[(N[(N[(16.666666666666668 * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, -3e-240], N[(N[(1.0 / N[(-0.005 * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, 4.7e-220], N[(N[(N[(n * n), $MachinePrecision] / n), $MachinePrecision] * 100.0), $MachinePrecision], If[LessEqual[n, 7.2e-13], N[(N[(1.0 / N[(N[(0.0008333333333333334 * i + -0.005), $MachinePrecision] * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], N[(N[(N[(N[(0.041666666666666664 * i + 0.16666666666666666), $MachinePrecision] * i + 0.5), $MachinePrecision] * i + 1.0), $MachinePrecision] * N[(100.0 * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.6 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(16.666666666666668, i, 50\right), i, 100\right) \cdot n\\
\mathbf{elif}\;n \leq -3 \cdot 10^{-240}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(-0.005, i, 0.01\right)} \cdot n\\
\mathbf{elif}\;n \leq 4.7 \cdot 10^{-220}:\\
\;\;\;\;\frac{n \cdot n}{n} \cdot 100\\
\mathbf{elif}\;n \leq 7.2 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.0008333333333333334, i, -0.005\right), i, 0.01\right)} \cdot n\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, i, 0.16666666666666666\right), i, 0.5\right), i, 1\right) \cdot \left(100 \cdot n\right)\\
\end{array}
\end{array}
if n < -5.5999999999999996e188Initial program 10.0%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6496.8
Applied rewrites96.8%
Taylor expanded in i around 0
Applied rewrites76.7%
if -5.5999999999999996e188 < n < -2.99999999999999991e-240Initial program 31.6%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6484.1
Applied rewrites84.1%
Applied rewrites84.1%
Taylor expanded in i around 0
Applied rewrites70.8%
if -2.99999999999999991e-240 < n < 4.7000000000000003e-220Initial program 68.9%
Taylor expanded in i around 0
+-commutativeN/A
Applied rewrites0.7%
Taylor expanded in n around 0
Applied rewrites24.6%
Taylor expanded in i around 0
Applied rewrites24.6%
Taylor expanded in i around 0
Applied rewrites82.6%
if 4.7000000000000003e-220 < n < 7.1999999999999996e-13Initial program 13.3%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6457.3
Applied rewrites57.3%
Applied rewrites57.2%
Taylor expanded in i around 0
Applied rewrites76.5%
if 7.1999999999999996e-13 < n Initial program 26.6%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6494.3
Applied rewrites94.3%
Taylor expanded in i around 0
Applied rewrites83.2%
Applied rewrites83.2%
Final simplification76.9%
(FPCore (i n)
:precision binary64
(if (<= n -5.6e+188)
(* (fma (fma 16.666666666666668 i 50.0) i 100.0) n)
(if (<= n -3e-240)
(* (/ 1.0 (fma -0.005 i 0.01)) n)
(if (<= n 2.15e-128)
0.0
(*
(fma
(fma (fma 0.041666666666666664 i 0.16666666666666666) i 0.5)
i
1.0)
(* 100.0 n))))))
double code(double i, double n) {
double tmp;
if (n <= -5.6e+188) {
tmp = fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n;
} else if (n <= -3e-240) {
tmp = (1.0 / fma(-0.005, i, 0.01)) * n;
} else if (n <= 2.15e-128) {
tmp = 0.0;
} else {
tmp = fma(fma(fma(0.041666666666666664, i, 0.16666666666666666), i, 0.5), i, 1.0) * (100.0 * n);
}
return tmp;
}
function code(i, n) tmp = 0.0 if (n <= -5.6e+188) tmp = Float64(fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n); elseif (n <= -3e-240) tmp = Float64(Float64(1.0 / fma(-0.005, i, 0.01)) * n); elseif (n <= 2.15e-128) tmp = 0.0; else tmp = Float64(fma(fma(fma(0.041666666666666664, i, 0.16666666666666666), i, 0.5), i, 1.0) * Float64(100.0 * n)); end return tmp end
code[i_, n_] := If[LessEqual[n, -5.6e+188], N[(N[(N[(16.666666666666668 * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, -3e-240], N[(N[(1.0 / N[(-0.005 * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, 2.15e-128], 0.0, N[(N[(N[(N[(0.041666666666666664 * i + 0.16666666666666666), $MachinePrecision] * i + 0.5), $MachinePrecision] * i + 1.0), $MachinePrecision] * N[(100.0 * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.6 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(16.666666666666668, i, 50\right), i, 100\right) \cdot n\\
\mathbf{elif}\;n \leq -3 \cdot 10^{-240}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(-0.005, i, 0.01\right)} \cdot n\\
\mathbf{elif}\;n \leq 2.15 \cdot 10^{-128}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, i, 0.16666666666666666\right), i, 0.5\right), i, 1\right) \cdot \left(100 \cdot n\right)\\
\end{array}
\end{array}
if n < -5.5999999999999996e188Initial program 10.0%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6496.8
Applied rewrites96.8%
Taylor expanded in i around 0
Applied rewrites76.7%
if -5.5999999999999996e188 < n < -2.99999999999999991e-240Initial program 31.6%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6484.1
Applied rewrites84.1%
Applied rewrites84.1%
Taylor expanded in i around 0
Applied rewrites70.8%
if -2.99999999999999991e-240 < n < 2.14999999999999997e-128Initial program 46.7%
lift-/.f64N/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
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites10.8%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6466.7
Applied rewrites66.7%
Applied rewrites66.7%
if 2.14999999999999997e-128 < n Initial program 22.3%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6488.7
Applied rewrites88.7%
Taylor expanded in i around 0
Applied rewrites80.2%
Applied rewrites80.2%
Final simplification74.3%
(FPCore (i n)
:precision binary64
(if (<= n -5.6e+188)
(* (fma (fma 16.666666666666668 i 50.0) i 100.0) n)
(if (<= n -3e-240)
(* (/ 1.0 (fma -0.005 i 0.01)) n)
(if (<= n 2.15e-128)
0.0
(*
(fma (fma (fma 4.166666666666667 i 16.666666666666668) i 50.0) i 100.0)
n)))))
double code(double i, double n) {
double tmp;
if (n <= -5.6e+188) {
tmp = fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n;
} else if (n <= -3e-240) {
tmp = (1.0 / fma(-0.005, i, 0.01)) * n;
} else if (n <= 2.15e-128) {
tmp = 0.0;
} else {
tmp = fma(fma(fma(4.166666666666667, i, 16.666666666666668), i, 50.0), i, 100.0) * n;
}
return tmp;
}
function code(i, n) tmp = 0.0 if (n <= -5.6e+188) tmp = Float64(fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n); elseif (n <= -3e-240) tmp = Float64(Float64(1.0 / fma(-0.005, i, 0.01)) * n); elseif (n <= 2.15e-128) tmp = 0.0; else tmp = Float64(fma(fma(fma(4.166666666666667, i, 16.666666666666668), i, 50.0), i, 100.0) * n); end return tmp end
code[i_, n_] := If[LessEqual[n, -5.6e+188], N[(N[(N[(16.666666666666668 * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, -3e-240], N[(N[(1.0 / N[(-0.005 * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, 2.15e-128], 0.0, N[(N[(N[(N[(4.166666666666667 * i + 16.666666666666668), $MachinePrecision] * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.6 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(16.666666666666668, i, 50\right), i, 100\right) \cdot n\\
\mathbf{elif}\;n \leq -3 \cdot 10^{-240}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(-0.005, i, 0.01\right)} \cdot n\\
\mathbf{elif}\;n \leq 2.15 \cdot 10^{-128}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(4.166666666666667, i, 16.666666666666668\right), i, 50\right), i, 100\right) \cdot n\\
\end{array}
\end{array}
if n < -5.5999999999999996e188Initial program 10.0%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6496.8
Applied rewrites96.8%
Taylor expanded in i around 0
Applied rewrites76.7%
if -5.5999999999999996e188 < n < -2.99999999999999991e-240Initial program 31.6%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6484.1
Applied rewrites84.1%
Applied rewrites84.1%
Taylor expanded in i around 0
Applied rewrites70.8%
if -2.99999999999999991e-240 < n < 2.14999999999999997e-128Initial program 46.7%
lift-/.f64N/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
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites10.8%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6466.7
Applied rewrites66.7%
Applied rewrites66.7%
if 2.14999999999999997e-128 < n Initial program 22.3%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6488.7
Applied rewrites88.7%
Taylor expanded in i around 0
Applied rewrites80.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* (fma (fma 16.666666666666668 i 50.0) i 100.0) n)))
(if (<= n -5.6e+188)
t_0
(if (<= n -3e-240)
(* (/ 1.0 (fma -0.005 i 0.01)) n)
(if (<= n 2.15e-128) 0.0 t_0)))))
double code(double i, double n) {
double t_0 = fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n;
double tmp;
if (n <= -5.6e+188) {
tmp = t_0;
} else if (n <= -3e-240) {
tmp = (1.0 / fma(-0.005, i, 0.01)) * n;
} else if (n <= 2.15e-128) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n) tmp = 0.0 if (n <= -5.6e+188) tmp = t_0; elseif (n <= -3e-240) tmp = Float64(Float64(1.0 / fma(-0.005, i, 0.01)) * n); elseif (n <= 2.15e-128) tmp = 0.0; else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[(16.666666666666668 * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[n, -5.6e+188], t$95$0, If[LessEqual[n, -3e-240], N[(N[(1.0 / N[(-0.005 * i + 0.01), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, 2.15e-128], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(16.666666666666668, i, 50\right), i, 100\right) \cdot n\\
\mathbf{if}\;n \leq -5.6 \cdot 10^{+188}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -3 \cdot 10^{-240}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(-0.005, i, 0.01\right)} \cdot n\\
\mathbf{elif}\;n \leq 2.15 \cdot 10^{-128}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -5.5999999999999996e188 or 2.14999999999999997e-128 < n Initial program 19.1%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6490.8
Applied rewrites90.8%
Taylor expanded in i around 0
Applied rewrites75.5%
if -5.5999999999999996e188 < n < -2.99999999999999991e-240Initial program 31.6%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6484.1
Applied rewrites84.1%
Applied rewrites84.1%
Taylor expanded in i around 0
Applied rewrites70.8%
if -2.99999999999999991e-240 < n < 2.14999999999999997e-128Initial program 46.7%
lift-/.f64N/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
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites10.8%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6466.7
Applied rewrites66.7%
Applied rewrites66.7%
(FPCore (i n) :precision binary64 (if (<= i -4.2e+58) 0.0 (* (fma (fma 16.666666666666668 i 50.0) i 100.0) n)))
double code(double i, double n) {
double tmp;
if (i <= -4.2e+58) {
tmp = 0.0;
} else {
tmp = fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n;
}
return tmp;
}
function code(i, n) tmp = 0.0 if (i <= -4.2e+58) tmp = 0.0; else tmp = Float64(fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n); end return tmp end
code[i_, n_] := If[LessEqual[i, -4.2e+58], 0.0, N[(N[(N[(16.666666666666668 * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -4.2 \cdot 10^{+58}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(16.666666666666668, i, 50\right), i, 100\right) \cdot n\\
\end{array}
\end{array}
if i < -4.20000000000000024e58Initial program 73.7%
lift-/.f64N/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
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites67.2%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6439.8
Applied rewrites39.8%
Applied rewrites39.8%
if -4.20000000000000024e58 < i Initial program 20.0%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6479.8
Applied rewrites79.8%
Taylor expanded in i around 0
Applied rewrites72.4%
(FPCore (i n) :precision binary64 (if (<= i -4.2e+58) 0.0 (if (<= i 1.6e+21) (* 100.0 n) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -4.2e+58) {
tmp = 0.0;
} else if (i <= 1.6e+21) {
tmp = 100.0 * n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-4.2d+58)) then
tmp = 0.0d0
else if (i <= 1.6d+21) then
tmp = 100.0d0 * n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -4.2e+58) {
tmp = 0.0;
} else if (i <= 1.6e+21) {
tmp = 100.0 * n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -4.2e+58: tmp = 0.0 elif i <= 1.6e+21: tmp = 100.0 * n else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -4.2e+58) tmp = 0.0; elseif (i <= 1.6e+21) tmp = Float64(100.0 * n); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -4.2e+58) tmp = 0.0; elseif (i <= 1.6e+21) tmp = 100.0 * n; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -4.2e+58], 0.0, If[LessEqual[i, 1.6e+21], N[(100.0 * n), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -4.2 \cdot 10^{+58}:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 1.6 \cdot 10^{+21}:\\
\;\;\;\;100 \cdot n\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -4.20000000000000024e58 or 1.6e21 < i Initial program 60.2%
lift-/.f64N/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
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites53.6%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6432.0
Applied rewrites32.0%
Applied rewrites32.0%
if -4.20000000000000024e58 < i < 1.6e21Initial program 10.5%
Taylor expanded in i around 0
lower-*.f6480.2
Applied rewrites80.2%
(FPCore (i n) :precision binary64 (if (<= i -1.55) 0.0 (* (fma 50.0 i 100.0) n)))
double code(double i, double n) {
double tmp;
if (i <= -1.55) {
tmp = 0.0;
} else {
tmp = fma(50.0, i, 100.0) * n;
}
return tmp;
}
function code(i, n) tmp = 0.0 if (i <= -1.55) tmp = 0.0; else tmp = Float64(fma(50.0, i, 100.0) * n); end return tmp end
code[i_, n_] := If[LessEqual[i, -1.55], 0.0, N[(N[(50.0 * i + 100.0), $MachinePrecision] * n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.55:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(50, i, 100\right) \cdot n\\
\end{array}
\end{array}
if i < -1.55000000000000004Initial program 62.0%
lift-/.f64N/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
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites57.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-/.f6432.6
Applied rewrites32.6%
Applied rewrites32.6%
if -1.55000000000000004 < i Initial program 20.3%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6479.4
Applied rewrites79.4%
Taylor expanded in i around 0
Applied rewrites73.0%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 27.8%
lift-/.f64N/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
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites21.7%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6417.9
Applied rewrites17.9%
Applied rewrites17.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t\_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t\_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2024255
(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))))