# Tag Info

4

The function Txk[x,k,n] calculates the contribution of the k^th zero at position x. The parameter n governs how many terms in the sum are used. This corresponds to Havil's equation on the bottom of page 196 of his book Gamma. Note that ExpIntegralEi should be used as @Guesswhoitis suggests, and as discussed here. I think there is a typo in the book, hence ...

2

Simply taking the answer from the 20x20 case and applying it directly to this case will isn't really applicable (it crashes my machine, requiring a hard restart). But I think we can improve upon your code and get the answer (about 700 times faster on my machine). First, I can say that to get the value of your function CC2 for a single time point will take ...

0

Okay, so I tried to write the function like you were saying, taking advantage of the Total built-in function, and there is some improvement. cc2Comp = Compile[{{t, _Real}}, Evaluate@ Module[{ndim, data, c, Δ, λ0, costable, sintable, table1, table2, table3, table4}, ndim = 20; data = Array[Exp[-((#1 + #2 - 20.)/5)^2] Exp[-((#1 - #2)/5)^2] & ...

9

The problem is that it reevaluates the sum every single time you call it, recomputing every 20^4 term again and again. You just need to compile the function CC2 so that it performs the summation only once. Using the code you have, it takes my machine about 6 seconds to compute a single data point: CC2[0.003] // AbsoluteTiming (* {6.069311, 1.49893} *) ...

2

i = 2; j = 2; FixedPoint[Plus[#, f1[i++]/f2[j++]] &, f1[1.]/f2[1]]

4

You can find when $f_{2}(x) = 10^{-15}$, and then calculate the summation: f1[x_] := Exp[-x]; f2[x_] := 1/x; mybound = 10^-15; maxx = (x /. Solve[f2[x] == mybound, x])[[1]]; mysum = Sum[f1[x]/f2[x], {x, 0, maxx}] N[mysum, 10] (* 0.9206735942 *)

3

the NestWhile approach f1[x_] := Exp[-x]; f2[x_] := 1/x NestWhile[ {#[[1]] + f1[#[[2]]]/f2[#[[2]]] , #[[2]] + 1} & , {0, 1} , f2[#[[2]]] > 1/1000 & ] // First // N 0.920674 ( NSum is most certainly the better approach unless you have some peculiar functions )

7

Have you tried using NSum? In your question, it seems to me that you try to sum numeric values (instead of analytically evaluating a sum) and I think NSum is better for this. Simple example: f1[x_] := x; f2[x_] := Exp[x]; NSum[f1[x]/f2[x], {x, 1, Infinity}] (* 0.920674 *)

5

You might try this: FindInstance[{j > 0, i > 0, 1/j + 1/i == 3/10}, {j, i}, Integers, 10] This paper on page 19 proves that there are only 4 (counting permutations) Egyptian fractions for 3 / 10. http://www.nntdm.net/papers/nntdm-19/NNTDM-19-2-15-25.pdf So no matter how large N is 4 is the maximum value of that coefficient.

7

prod[n_Integer?Positive] := Sum[x^(1/i), {i, n}]* Sum[x^(1/i), {i, n}]; Coefficient[prod[50], x^(3/10)] 4 Or Coefficient[prod[50], x, 3/10] 4

3

Thanks to ConstantArray[], not much effort is needed: mysum[n_Integer, z_] := Sum[HypergeometricPFQ[ConstantArray[1, k], ConstantArray[2, k], z], {k, 1, n}] Test: mysum[3, z] (-1 + E^z)/z + HypergeometricPFQ[{1, 1, 1}, {2, 2, 2}, z] + (-EulerGamma - Gamma[0, -z] - Log[-z])/z

2

You can use your knowledge of other generating functions to construct a new one. $\frac{1}{1-x} =1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^{10}+...+$ $\frac{1}{1-x^2} = 1 + x^2 + x^4 + x^6 + x^8 + x^{10} +...+$ You just want to zero every even exponent in the first gf so subtraction is indicated. ...

3

Interesting problem. Following is cleaner IMO, and quite a bit faster on larger cases than accepted ans. (e.g. over 1000X faster on {n, k, m, M} = {7, 20, 5, 6}, ~5000X faster on {n, k, m, M} = {8, 21, 6, 7}) : Module[{f, jp, n = #1, k = #2, m = #3, M = #4}, jp = IntegerPartitions[k, {n}, Range[0, k]]; f[x_] := f[x] = b[m, x, M]; Tr[Multinomial ...

4

For a non-symmetric real matrix you can consider using LibraryLink to speed things up. It still won't be as fast as the Total/Tr answer, but it may be useful otherwise (call this C program SumUpperTriangle.c): #include "WolframLibrary.h" DLLEXPORT int SumUpperTriangle(WolframLibraryData libData, mint Argc, MArgument *Args, MArgument Res) { /* Variable ...

5

I found this question quite interesting, so I thought I would collect the answers contributed in comments for future reference and to have the question appear as answered in search. I generated a slightly bigger matrix to play with, and minimally modified the code to render it independent of the size of the matrix. I also compared timings of each method to ...

0

As used in a recent answer recent answer, one can easily define a function which contracts two tensors: DotAt[T_?TensorQ, U_?TensorQ, m_Integer?Positive, n_Integer?Positive] := With[{dimT = Length@Dimensions@T, dimU = Length@Dimensions@U}, Dot[Transpose[T, Insert[Range[dimT - 1], dimT, m]], Transpose[U, Insert[Range[2, dimU], 1, ...

2

You can define your tensor contraction routine using the builtins Dot and Transpose. Here is an example: DotAt[T_?TensorQ, U_?TensorQ, m_Integer?Positive, n_Integer?Positive] := With[{dimT = ArrayDepth@T, dimU = ArrayDepth@U}, Dot[Transpose[T, Insert[Range[dimT - 1], dimT, m]], Transpose[U, Insert[Range[2, dimU], 1, n]]]] DotAt[T, ...

0

It seems that Residue (and Series on which it is based) is unable to analyze all the cases in which the formula for the residue might vary. Reduce can do it, within its limitations, if we reduce the system 1/function == 0 && nu == pole. Here's the OP's example. fn = (w^(n/2 + I nu) ws^(-(n/2) + I nu))/(n/2 + I nu)^2; We need to add some ...

1

You almost had it.You were right to use Outer[]; what you missed was to interpret the sum as an appropriate matrix multiplication. Observe: Table[Subscript[m, i], {i, 5}].Outer[f, Table[Subscript[τ, i], {i, 5}], Table[Subscript[γ, j], {j, 4}]]. Table[Subscript[n, j], {j, 4}] == ...

Top 50 recent answers are included