Tag Info

New answers tagged

0

Try to read this. I used the package some time ago and it works quite nicely.


1

Just another way to index (not as concise as kguler) but may be useful to note is MapIndexed: Sqrt[Total @ MapIndexed[(#2[[1]] - 1 - μ)^2 #1 &, y]] yielding 0.793748 #2 is the index starting at {1}, hence need for #2[[1]] lists/arrays start at 1, so reindexing -> #2[[1]]-1 as per kguler


1

If what you wish to calculate is $\sqrt{\sum _{i=0}^3 (i-\mu )^2 y_i}$, this can be done: Sqrt@Total[(Range[0, 3] - μ)^2 y] which gives 0.793748. The function Range[0,3] gives the numbers {0,1,2,3}, each of which is subtracted from mu and squared. These are then multiplied by the corresponding element of y and the collection is summed using Total.


2

First, you can get the desired result using much simpler form Sqrt[Sum[(i - 1 - μ)^2 y[[i]], {i, 1, 4}]] (* 0.793748 *) Notes on your code: In Mathematica indices start at 1, not 0. Furthermore, you need to use y[[i]] to refer to ith Part of a list y, not y[i]. With these changes Sqrt[\!\( \*SubsuperscriptBox[\(∑\), \(i = 1\), \(4\)]\( ...


2

You may consider this, rl= (a_. Sum[b_. Subscript[x_, i_], {i_, i0_: 1, n_}]) :> Sum[(a b) Subscript[x, i], {i, i0, n}]; exp = Sum[2/9 Subscript[x, i], {i, 1, n}] + 2 Sum[1/9 Subscript[x, i], {i, 1, n}]; Apply transformation rule repeatedly: exp //. rl Collecting more than two sums: exp1 = 1 Sum[3/9 Subscript[x, i], {i, 1, n}] + 3 ...


1

Use a replacement rule rule = (a1_. * Sum[c1_. Subscript[x_, i_], {i_, i0_: 1, n_}] + a2_. * Sum[c2_. Subscript[x_, i_], {i_, i0_: 1, n_}]) :> Sum[(a1*c1 + a2*c2) Subscript[x, i], {i, i0, n}]; expr = Sum[2/9 Subscript[x, i], {i, 1, n}] + 2 Sum[1/9 Subscript[x, i], {i, 1, n}]; expr /. rule Sum[(4*Subscript[x, i])/9, {i, 1, n}]


5

Something like this?: expr = -t^Range[0, 5] // Total toΣ[expr_Plus] := Block[{n}, HoldForm[Sum[#, {n, #2}]] & @@ {FindSequenceFunction[List @@ expr, n], Length@expr}] toΣ@expr If you want to manually set the initial index: toΣ[expr_Plus, init_Integer: 1] := Block[{n, l = Length@expr}, HoldForm[Sum[#, {n, init, #2}]] & @@ ...


0

I suspect that it relates to convergence. Here are some experiments which may give a clue to that. Sum[Binomial[m - r - 1, b] z^(r + b) (-1)^(a + b + r + 1), {b, 0, m - r - 1, 1}, GenerateConditions -> True] ConditionalExpression[((-1)^(a + r) (1 - z)^(m - r) z^r)/(-1 + z), m - r \[Element] Integers && (z != 1 || Re[m - r] > 1) && m ...


2

You can use the Map function directly: f[n_] := N[Sum[(i + 1)/n^2, {i, 1, n}]]; n= {10, 100, 1000, 10000}; f /@ n(**or Map[f, n]) {0.65, 0.515, 0.5015, 0.50015} Or Tr[ N[Sum[(i+1)/n^2,{i,1,n}]],List] {0.65, 0.515, 0.5015, 0.50015}


1

Total takes a second argument which specifies the levels to sum together. In your case you want to preserve the lowest two levels so you need to total down to level -3: Total[Table[m, {k, 10}, {j, k}, {i, j}], -3] This will work if you have more indices.


7

I have had the same troubles. When Sum returns an expression containing Pochhammer, it's very often wrong. However, I never experienced this problem with FindSequenceFunction: Table[gg4[q, 1], {q, 2, 6}] (*{2/15, 2/315, 2/5005, 4/153153, 5/2909907}*) gg4k1[q_] = FullSimplify[FindSequenceFunction[Table[gg4[q, 1], {q, 2, 11}], q - 1]] (*(2^(5 - 4 q) ...



Top 50 recent answers are included