Hot answers tagged

4

You can use With Table[With[{i = i}, Button[i, f[i]]], {i, 1, 2}]


4

There are many questions about the Collatz sequence on this site, for example here. I interpret your question to ask for the smallest integer n that, after 125 iterations, has not settled into the 4-2-1 loop that is conjectured to terminate all Collatz iterations. You can run 125 iterations and return the result with the following definition. ...


3

Most of your time is spent in defining PolarCoords. Let's take a look at your code. It looks like you've tried to optimize it already. Let's try to simplify it first: PolarCoords = Map[Function[i, ToPolarCoordinates /@ newCoord[[i]] /. {x_, y_} /; y < 0 -> {x, y + 2 \[Pi]}], Range@Length@pts] Simpler: PolarCoords = ...


3

If you use float instead integer you can reduce the computing time. data = RandomInteger[{1, 400}, {5000, 2}]; c = 10.; r = 60.; pts = c + r {Cos[#], Sin[#]} & /@ Range[0., 2. π, 2. π/16.]; newCoord = Table[(# - pts[[i]]) & /@ data, {i, 1, Length@pts}]; PolarCoords = Table[ToPolarCoordinates[#] & /@ ...


3

A simple solution would be myList = Map[# {vxstep, vystep} &, myList, {2}]


3

TableForm[Take[data, 5], TableHeadings -> {None, {"r", "r^(L+1) f[r]", "Fi[r] f[r]", "\[CurlyEpsilon]1", "\[CurlyEpsilon]2"}}] // Style[#, PrintPrecision -> 15] & EDIT PrintPrecision -> 15 can be set at the Notebook level. See this link .


3

NumberForm[TableForm[data, TableHeadings -> {None, {"r", "r^(L+1) f[r]", "Fi[r] f[r]", "\[CurlyEpsilon]1", "\[CurlyEpsilon]2"}}], {15, 15}] Update With dr = 0.00000001 the first 10 items would be


2

This too does the same thing: Button[#, f[#]] & /@ Range@2 Also an ugly but stupid way: Table["Button[" <> ToString@i <> ",f[" <> ToString@i <> "]]", {i, 2}] // ToExpression One can write it down without thinking.


2

Not a complete answer, but it may help to illustrate some of this behavior. If I run the simple example, Dynamic[Refresh[TableForm[{"ind2=", ind2, "j=", j}], UpdateInterval -> 1]] j = 0; num = 100; SetSharedVariable[j]; ParallelTable[ind2^2; Pause[2]; j++, {ind2, 1, num}] I find that Dynamic does not display ind2. It does, however, display j, which ...


1

Confirmation rather than answer. I'm not sure the original example is entirely functional, at least it was not for me. Mine is... SetDirectory["F:\\Temp"]; (* Adjust to suit your environment *) hist = Histogram[RandomVariate[NormalDistribution[0, 1], 10000], ScalingFunctions -> "Log", ImageSize -> 600] Note log scale on y-axis in resulting ...


1

I decided to do this in the old-fashioned procedural way. collatz[k_Integer?OddQ] := 3 k + 1 collatz[k_Integer?EvenQ] := k/2 collatzIter[k_ /; k > 2, n_: 125] := Module[{i = 0, c0 = k, c1}, While[++i < n, c1 = collatz[c0]; If[c1 < 2, Break[]]; c0 = c1]; {i, c1}] Module[{m = 2, r = {0, 0}}, While[r[[2]] <= 4, r = ...



Only top voted, non community-wiki answers of a minimum length are eligible