37,919 reputation
554155
bio website
location
age
visits member for 2 years, 3 months
seen 3 hours ago

May
21
comment A fast way to compare interval
I'm surprised you find Rasher's and my solutions so slow on a list of length 2000. For me they both take a fraction of a second. Perhaps your ListT is not a packed array. Try evaluating ListT = Developer`ToPackedArray[ListT]; and run the benchmarks again.
May
20
comment Building adjacency matrix from set data
In your example you have a unique symbol for each player and game. When you have thousands of players do you intend to use thousands of symbols? Does the actual data consist of hundreds of expressions like g1 = {p1, p3, p5} ?
May
19
comment How to do memoization together with evaluation of a complicated function
Oops, sorry, missed that. Maybe Function instead: (f[x_] := f[x] = #) &[test[x]]
May
19
comment How to do memoization together with evaluation of a complicated function
How about With[{t = test[x]}, f[x_] := f[x] = t]
May
19
comment A fast way to compare interval
It is still not clear. Please could you include what the result should be for your example ListT and check that the posted code actually generates that result.
May
19
comment How to optimize my code?
Is it necessary to use exact arithmetic? For example try using 20.0 as the radius. By the way you did not include a definition for coordinateList so your code does not run.
May
17
comment Exp is slower for some number ranges
It appears that Exp[I x] slows down for Abs[x] >= 512. The transition is clearer like this: w = ConstantArray[N[I], {5000000}]; t = Table[{n, Timing[Exp[n w]][[1]]}, {n, 510, 514, 0.1}]
May
15
comment How do you add options to a function that is being mapped?
I edited this answer slightly as I felt it was misleading to say that you need to use a pure function.
May
14
comment Drawing pairs (graph, circle packing)
The second version improves things by using constraints to insist that the circles on connected vertices touch each other. The original vertex positions go in as a starting point to FindMaximum, which seeks a local maximum (whereas NMaxmimize looks for a global optimum). It can still give unsatisfactory results, with overlapping circles for non-edges. I think this means that FindMaximum has found a local maximum which is not a global optimum. I guess this could be remedied with more constraints.
May
14
comment Drawing pairs (graph, circle packing)
The original algorithm is not very good - it doesn't constrain the circles on connected vertices to touch, it just attempts to minimize the gaps. At the same time it is trying to minimize the movement of the vertices from their initial positions (which is not really what we want to do). So it reaches a point where it will sacrifice the circle-packing in order to avoid rearranging the vertex positions.
May
11
comment Distribution of 10 points within a unit square
@Mr.Wizard, perhaps with sufficient runs with different random seeds! Otherwise it probably needs someone who really understands numerical optimization. Personally I just treat NMaximize as a black box full of magic.
May
11
comment Simplify with Assumptions Sqrt[(expr)^2]
@Mr.Wizard, I have no experience with it - I just checked the system options to see if there was anything that might be responsible for the behaviour change between 4 and 5 variables.
May
11
comment Distribution of 10 points within a unit square
@RahulNarain, thanks! I've just added your solution to my post.
May
11
comment Contour coloring and (List)ContourPlot projection
You should also consider future visitors to the site. What if someone is searching for how to put a border around streamplot arrows - they probably won't expect to find the answer under a question about "Contour coloring"!
May
11
comment Contour coloring and (List)ContourPlot projection
You should not combine multiple questions into one just because you need answers to all of them to get the final result you're after. The site works better if you ask one question at a time. Suppose different people provide answers to the different questions - which one will you accept? Or should people only post if they can answer all the questions? What if one of the questions is a duplicate or off topic - shall we close the whole thing?
May
9
comment How to choose a solution of a differential equation?
AFAIK there is no way to specify preferred functions for the output of DSolve. Your "workaround" of explicitly applying the desired transformation rule is probably the best solution.
May
8
comment Problems using hand-made transformation functions
You should use _. patterns for the powers p and q or it will fail for Gamma[z + 1]/Gamma[z].
May
6
comment “Legended” not working with “Plot” or “LogLinearPlot”
@b.gatessucks, looks like a bug to me. PlotLegends -> LineLegend@{"Log(x)", None, "x Cos(x)"} works though.
May
6
comment Is it possible to change to a functional approach in this game-based procedural algorithm?
While it's true that new users tend to use procedural loops when alternative structures would be more appropriate, it is an over-simplification to state that loops are undesirable. If you have an algorithm which is most naturally expressed as a procedural loop, forcing a functional approach can obscure the underlying logic and make the code harder to write and to reason about. You are asking the correct question - "what is the most appropriate way to represent the nature of the game?" If the answer is "as a loop" then my advice would be to code it as a loop.
May
6
comment “Legended” not working with “Plot” or “LogLinearPlot”
The documentation for Legended states that Legended can be used as a symbolic wrapper for data elements and datasets in functions such as ListPlot and BarChart. So it does appear that it is not intended to work with the Plot* family.