New answers tagged

7

Runs in a quarter-second by reformulating as a single two-index sum: c = Compile[{{x, _Integer}}, Sum[1/Sqrt[a^2 + t^2 + (100000 - 0.7)^2] - 1/Sqrt[a^2 + t^2 + (100000 + 0.7)^2], {t, 1, x - 1}, {a, t + 1, 40000}], CompilationTarget -> "C", Parallelization -> True, RuntimeOptions -> "Speed"]; c[...


6

This runs in about a second: Needs["CCompilerDriver`"] c = Compile[{{x, _Integer}}, Block[{pover,t}, pover = 0.0; t = 1.0; While[t <= x - 1, pover = pover + Total[Table[ 1.0/Sqrt[a^2 + t^2 + (100000.0 - 0.7)^2] - 1.0/Sqrt[a^2 + t^2 + (100000.0 + 0.7)^2], {a, t + 1, 40000.0, 1}]]; t++]; ...


2

tst = Block[{x = rlist[[1]], y = rlist[[1]]}, Module[{sol = (Last[#1] &) /@ First[NDSolve[{eqs, ic}, var, {t, -tmax, tmax}]], Bsol}, Bsol = Table[Map[#1[t1] &, sol, {1}], {t1, ttlist}]; Map[(#1 . G0 . ConjugateTranspose[#1] &)[ttmesh Partition[#1 . Bsol, 2]] &, smat, {2}]]]; // AbsoluteTiming (* {0.0249631, Null} *...


Top 50 recent answers are included