# Tag Info

2

As a workaround you can generate a sequence and use FindSequenceFunction max = 10; seq = Sum[StirlingS2[i, 2], {i, 0, #}] & /@ Range[max] (* {0, 1, 4, 11, 26, 57, 120, 247, 502, 1013} *) f[n_] = FindSequenceFunction[seq][n] // Simplify (* -1 + 2^n - n *) seq === (f /@ Range[max]) (* True *)

5

As suggested by LLlAMnYP in a comment to this question, this is a humble contribution. The OP has already been answered. This is not answer per se but shows that CompileLength should not always be increased, and should even sometimes be reduced for significant speed gain. Consider the following (stupid) function: x1 = Function[{n, T, t}, (Table[Cos[(Mod[t, ...

3

It takes some careful coding to make sure the right values are explicitly numeric at the time they need to be (in the inner optimization). Can be done as below. And there may be better ways, I'm no expert. stratmin[p_ /; MatrixQ[p, Element[#, Reals] &], xlist_List /; VectorQ[xlist, Element[#, Reals] &]] := Module[ {y, c = Length[p], yvars, ...

6

This seems rather be a error of determining the type of i, j and k than Sum itself. When you introduce your iterator variables in a Module and make clear that they are of type integer, it compiles fine for me: fc = Compile[{{x, _Real, 2}}, Module[{i = 0, j = 0, k = 0}, Sum[x[[i, k]]*x[[j, k]], {k, 5}, {i, 12}, {j, i + 1, 12}]] ] Btw, I want to note ...

8

There is a symbolic calculation bug in there: Let's define: plus[k_, m_] := f[1/2 (2 + m + Sqrt[4 - 4 k + m^2])]; minus[k_, m_] := f[1/2 (2 + m - Sqrt[4 - 4 k + m^2])]; While (With[{m = 60}, Sum[minus[k, m], {k, 1, -1 + m, 2}]] // N) == (Sum[minus[k, m], {k, 1, -1 + m, 2}] /. m -> 60 // N) (* True *) on the other hand: (With[{m = ...

5

This is interesting! Here's a partial answer (so more of a long comment): Clear[f] f[x_] = x^2; Sum[f[1/2 (2 + m + Sqrt[4 - 4 k + m^2])], {k, 1, -1 + m, 2}] and the output is: whereas Sum[f[1/2 (2 + m - Sqrt[4 - 4 k + m^2])], {k, 1, -1 + m, 2}] doesn't evaluate (i.e. it returns itself), and Sum[f[1/2 (2 + m + Sqrt[4 - 4 k + m^2])] + f[1/2 (2 + m - ...

1

CenterDot @@ (Superscript @@@ FactorInteger[Sum[3^j + 3 2^j, {j, 1, 100}]]) $2^1\cdot 3^1\cdot 5^3\cdot 7^1\cdot 11^1\cdot 101^1\cdot 199^1\cdot 331^1\cdot 19961^1\cdot 32057^1\cdot 88046443^1\cdot 35714560581597807409^1$

6

You can do two things: 1) use machine-precision evaluation, rather than arbitrary precision ones as you are currently doing; 2) memoize the wavefun function so values used more than once do not have to be recalculated. intensity[x_, y_, μ_, nxmax_, nymax_] := Sum[(1/(Exp[((nx + ny + 1)/25 - μ)] - 1)) (wavefunc[x, nx]*wavefunc[y, ny])^2, {nx, 0, nxmax}, {ny, ...

1

One thing you can do is to use infinite precision numbers rather than finite. For example: q = Total[(-1)^Range[1000] Table[HarmonicNumber[n], {n, 1000}]] gives a very long fraction. Taking N[ ] of this gives 3.39641. Taking N[q,1000] gives it to 1000 digits, etc.

1

Make the replacement x -> 0 after evaulation. Let, with finite nn, s[x_, nn_] := Sum[a[j]*Sum[a[k]*k*x^(k - 1), {k, 1, nn}]^j, {j, 1, nn}]; Then, instead of writing s[0,nn], write s[x, 4] /. x -> 0 (* Out[49]= a[1]^2 + a[1]^2 a[2] + a[1]^3 a[3] + a[1]^4 a[4] *) Similarly for derivatives D[s[x, 4], x] /. x -> 0 (* Out[50]= 2 a[1] a[2] + 4 ...

1

If you were to write your expression with correct bracketing, which would be Plot[5/8 + Sum[((2*Cos[n*Pi/2] - n*Pi*Sin[n*Pi/2] - 1)*Cos[n*Pi*x])/(n^2*Pi^2), {n, 1, 20}], {x, 0, 1}] you would get

4

it's such a long time ago, I learned Taylor and so on. If my memory serves me right: s = Sum[D[f[x0], {x0, k}]/k! (x - x0)^k, {k, 0, n}]; ps = Table[s /. x0 -> 0, {n, 1, 4}] // Simplify {3 π x, 3 π x, 3 π x - (9 π^3 x^3)/2, 3 π x - (9 π^3 x^3)/2} With Mathematicas Series we get Series[f[x], {x, 0, #}] & /@ Range[1, 4] // Normal {3 π x, 3 π x, 3 ...

1

If you are interested in obtaining approximations of the zeros of that function, you don't really need to plot it to high precision. In this case, NSolve is able to give you numerical solutions for specific ranges of $x$, and it can do that at an arbitrary precision that you specify using the WorkingPrecision option: NSolve[f2 == 0 && 0 <= x ...

6

Might it have something to with the option NSumTerms? From the documentation: NSumTerms is the number of terms to use before extrapolation. By default NSum uses 15 terms at the beginning before approximating the tail. Thus trying it with just 16 terms instead of the default removes the error message. NSum[Log[Abs[m]], {m, 1, 25}, NSumTerms ...

Top 50 recent answers are included