New answers tagged

7

You can safely ignore the warning and red highlighting. It simply tells you that the variable will be injected into Block by the top-level rule (your function), rather than being the actual symbol originally present in Block's declaration list. Which is exactly what you want here. In most cases, things like that happen due to a programmer's mistake, which ...


3

This is a very quick-and-dirty, but gives 4X speed-up (7X with tweak for symmetry) on my crappy netbook for the n=8 case, don't have time or patience to test bigger cases to see scaling differences. Perhaps a description of what you're trying to calculate? It appears to be some combinatorial problem, there may well be a much more efficient scheme to do ...


1

You could introduce further conditional definitions for H which will prevent those computations whose results would end up being thrown away. For instance, you could add: H[i_, j_, k_, l_] /; (i > j || k > l) = Missing[]; As a toy example: m = Table[H[n, 2, 3, 4], {n, 1, 10}] (* Out: {(3 Sqrt[5])/128, (5 Sqrt[15])/256, Missing[], Missing[], ...


0

I figured it out. data = Import[ "/Users/myname/Documents/foldername/filename.txt", "Table"] Total[data, {1}] Part of the error was that I had an empty row at the end of my text file.


1

You need Import, Part (i.e. [[...]]), probably Span (i.e. ;;), and Total. Import the data: data = Import["path\to\yourdatafile.txt", "Table"]; Sum all entries in the first column: Total@data[[All, 1]] Sum entries in the third column and in the second to third row: Total@data[[2 ;; 3, 3]] Sum entries in column 2, rows 1 and 3: Total@data[[{1, 3}, ...


1

Here is how I would literally translate the definitions: Q = {{n1[x, y, t], n2[x, y, t]}, {n2[x, y, t], -n1[x, y, t]}}; r = {x, y}; p1[α_, β_] := Sum[D[Q[[γ, ϵ]], r[[α]]] D[ Q[[γ, ϵ]], r[[β]]], {γ, 1, 2}, {ϵ, 1, 2}] p3[α_, β_] := Sum[Q[[γ, ϵ]] D[ Q[[α, β]], r[[ϵ]], r[[γ]]], {γ, 1, 2}, {ϵ, 1, 2}] p2[α_, β_] := Sum[D[Q[[γ, ϵ]], r[[γ]]] D[ Q[[α, β]], ...


0

When you are first defining Kin[n1_,n2_] you are not specifying anything about n1 or n2. For simpler cases MMA returns ConditionalExpression. However, as much I have seen, for complicated evaluation MMA goes with an approximation which is more widely applicable (in your case n1,n2>1). To bypass this, you can always put Assumptions with your evaluation. ...


1

I am not sure whether the symbolic calculation is correct, but I would suggest that you don't pre-calculate the value of the sum; rather, let the sum be calculated when the values of $n_1$ and $n_2$ are on hand by using SetDelayed in your definition of K1: Clear[Kin] Kin[n1_, n2_] := Sum[(-1)^(m1 + m2 + 1) * Binomial[n1 + 1, m1 + 2] * Binomial[n2 + 1, m2 ...



Top 50 recent answers are included