# Search Results

Results tagged with Search options user 3246
30 results

Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

Of the solutions so far, those based on IntegerPartitions by @Xavier and @march are orders of magnitude faster than those based on Tuples (@djphd and @eldo). Just for interest, the following method ba …
answered Dec 3 '15 by KennyColnago
You could use the code HilbertCurve3D[n] by Michael Trott (page 93 of The Mathematica Guidebook for Programming) from this question. Given input n, the function returns $2^{3n}$ orderly points within …
Because your selector is 0 or 1, SplitBy can be used as follows. Select[SplitBy[mylist*selector, Positive], #[[1]] > 0 &]
answered Nov 28 '15 by KennyColnago
Hector can beat his own code with: HectorSymms[n_Integer?Positive]:=Flatten[Table[Thread[{i,Range[i,n-i]+1}],{i,1,n/2}],1] On my system, the timing forfasterSymms[1351]is 0.233s, whileHectorSymms[1 …
answered Nov 20 '13 by KennyColnago
Late, but a slightly different approach avoidingSquareFreeQ, PrimeOmega, and PrimeNu. See Sloane's A143658, the number of squarefree integers not exceeding $2^n$. Fast, since the sum is only to the sq …
answered Nov 13 '13 by KennyColnago
Something with rules: Partition[{a, b, c, d, e, f, g, h, i}, 3] /. {x_, y_, z_?AtomQ} -> {{x, y}, z}
answered Aug 25 '15 by KennyColnago
Pick is typically faster than Select. On large lists, I would recommend Pick[list, Total[Mod[Total[list, {2}], 2], {2}], 0] which is 10 or 20 times faster than these variations. Select[list, Mod[T …
answered Mar 9 '18 by KennyColnago
You could use Pick and UnitStep as follows: index = Pick[Range[Length[a]], UnitStep[10 - a], 0]
answered Aug 31 '16 by KennyColnago
Pick is usually fast, and parallel processing may help, depending on your computer. ParallelTable[Total[Pick[values, indices, k]], {k, Union[indices]}]
answered Feb 20 '17 by KennyColnago
This is a small version of a PE problem which asks for counts of certain solutions. If the OP is interested, there is a generating function approach to finding such counts. Consider the product of bin …
answered Oct 29 '13 by KennyColnago
A double Transpose might be considered "beautiful", and it certainly can be very fast too. Transpose[Transpose[{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}] + {a, b}]
answered Apr 21 '16 by KennyColnago
The prime factors of an input integernare returned byFactorIntegerin the first positions of a list of pairs. The second position in each pair is the exponent of the corresponding prime, which you want …
answered Mar 17 '14 by KennyColnago
Using v10.4.1, Reduce returns 2^17=131072 solutions beginning with these 5. With[{a = 7946761, m = 130356633908760178920}, x /. {ToRules[Reduce[x^2 == a, x, Modulus -> m][[Range[5]]]]}] (* {28 …
answered Oct 17 '16 by KennyColnago
Check out the answer here, by @s0rce and @DanielLichtblau, for an ingenious use of FrobeniusSolve. KnapsackLikeProblem[list_List, n_Integer] := With[{s = FrobeniusSolve[list, n]}, Map[Flat …
answered Nov 13 '16 by KennyColnago
I think your sol is trying to find the Lagrange points of the system. As pointed out, NSolve can fail to give all 5 Lagrange points. Use LagrangePoints[m] below to get solutions for all 5 points, rega …
answered Dec 8 '15 by KennyColnago

15 30 50 per page