# Tag Info

0

Plus is protected. but you can use unprotect. Unprotect[Plus]; F_[1, j___] + F_[2, j___] + F_[3, j___] := Defer@Sum[F[i, j], {i, 1, 3}] Protect[Plus];

3

If you don't want to change the system options just to make Sum auto-compile, then you could instead replace Sum by Total: Clear[vec, time]; vec = Table[i, {i, 100}, {j, 100}, {k, 300}]; time = Timing[ Table[Total[vec[[i, j, 1 ;; 250]]], {i, 1}, {j, 1}]][[1]]; time The resulting timing doesn't show any significant difference between 249 and 250, and is ...

0

While this has been answered many times, let me answer it once more: varnum = 10; vars = Symbol["a" <> ToString[#]] & /@ Range[varnum]; of = Total[-vars^2 + vars^4]; Minimize[of, vars]

8

The default SumCompileLength is 250. You can increase this number for example to 500 using: SetSystemOptions["CompileOptions" -> {"SumCompileLength" -> 500}]

3

You should have read Simon Woods's answer more carefully. The difference between this question and the previous one is just you don't need to sum over $j$ and $k$ now, with almost same analysis, you can figure out that data2 is equal to $$2 {\left((d.d^T)^2\right)}_{ij}(1 - f_{ij})/4$$ So here is the code: a = AbsoluteTiming; data0 = Table[Exp[-((i + j ...

2

Like Ajasja said in a comment, Compile is your best friend here (short of completely rewriting S1 and S2 like in your other question). Simply compiling everything together: With[{d = data}, S2 = Compile[ {{i, _Integer}, {j, _Integer}, {t, _Real}}, 1/4*Sum[ (d[[i, k]] d[[j, m]])^2 + (d[[j, k]] d[[i, m]])^2 - 2 d[[i, k]] d[[j, ...

0

a bit of a cheat maybe: Z[n_] := Product[1/(1 - t^i), {i, 1, n}] P1[list_] := (Z[1]^2) P2[list_] := Z[2] Sum[P1[{i, j}]*t^(-i - j), {i, 0, j - 1}, {j, 0, Infinity}] + Sum[P2[{j, j}]*t^(-2 j), {j, 0, Infinity}] + Sum[P1[{i, j}]*t^(-i - j), {i, j + 1, Infinity}, {j, 0, Infinity}] // Simplify (t (-(-1 + t) t^-j + (t^2 (3 + t))/(1 + t)^2))/(-1 + t)^4 ...

1

Assuming that if the integrand is complex we should take it to be zero, you can do this: uplim = 50; arg = If[Im@# > 0, 0, #] &@ N[2 Sqrt[z + 3/8 + 2^2]* Total@Table[((5^k)*Exp[-5])/(k!*Sqrt[2 \[Pi] 2^2])* Exp[-((z - k)^2)/(2 2^2)], {k, 0, uplim}] ]; Plot[arg, {z, -10, 20}] NIntegrate[arg, {z, -\[Infinity], \[Infinity]}] This ...

1

It cannot be real, since zunder the radical goes to minus infinity. Anyway, if you only need a numerical table, why do not you do something like this: f[y_, sig_, n_] := NIntegrate[ 2 Sqrt[z + 3/8 + sig^2]* Sum[((y^k)*Exp[-y])/(k!*Sqrt[2 \[Pi] sig^2])* Exp[-((z - k)^2)/(2 sig^2)], {k, 0, n}], {z, -\[Infinity], \[Infinity]}] Here nis ...

Top 50 recent answers are included