Re: Prime Segment Diagram; why the codes run very slowly?
- To: mathgroup at smc.vnet.net
- Subject: [mg106981] Re: [mg106965] Prime Segment Diagram; why the codes run very slowly?
- From: a boy <a.dozy.boy at gmail.com>
- Date: Sat, 30 Jan 2010 07:13:01 -0500 (EST)
- References: <201001291249.HAA29223@smc.vnet.net> <4B62F712.4050108@wolfram.com>
Pscheibe given a very good implementation. However I appreciate Daniel's
implementation more, for the clearness.
Yes,the line y=x must intersect each segment , as long as the number
sequence(here is {prime[i]}) is incremental.
Now think about drawing such segment diagram with prime delta sequence
{prime[i+1]-prime[i]}.
Block[{$RecursionLimit = 1000},
pt[0] = {0, 0};
pt[j_Integer] :=
pt[j - 1] +
If[OddQ[j], {Prime[j + 1] - Prime[j], 0}, {0,
Prime[j + 1] - Prime[j]}];
n = 400;
pt[n]
Graphics[{Green, Line[Table[pt[i], {i, 1, n}]], Blue,
Line[{{0, 0}, {pt[n][[1]], pt[n][[1]]}}]}, Axes -> True]
]
I think the line y=x has infinite points of intersection with prime delta
segment diagram. This implies the balance of prime distribution.
How to prove this?
On Fri, Jan 29, 2010 at 10:56 PM, Daniel Lichtblau <danl at wolfram.com> wrote:
> a boy wrote:
>
>> 2010-01-29
>>
>> Suppose p[i] is the i-th prime. Start from coordinate origin (0,0) ,
>> first line to (2,0), then line to (2,3), then to (2+5,3), then to
>> (7,3+7), then to (7+11,10), and so go on...... here 2,3,5,7,11 is the
>> prime list. I call this Prime Segment Diagram. It is very interest!
>>
>> Conjecture: The line y=x intersect with every segment of Prime
>> Segment Diagram.
>>
>> It implies the balance of prime distribution.
>>
>>
>> In[139]:=
>>
>> point[0] = {0, 0};
>> point[n_] :=
>> If[OddQ[n], {point[n - 1][[1]] + Prime[n],
>> point[n - 1][[2]]}, {point[n - 1][[1]], point[n - 1][[2]] + Prime
>> [n]}]
>> n = 22;
>> point[n]
>> Graphics[{Green, Line[Table[point[i], {i, 1, n}]], Blue,
>> Line[{{0, 0}, {point[n][[1]], point[n][[1]]}}]}, Axes -> True]
>>
>> why these simple codes run very slowly when n>20? how to optimize?
>>
>>
> This should be reasonably fast:
>
> pt[0] = {0, 0};
> pt[j_Integer] :=
> pt[j] = pt[j - 1] + If[OddQ[j], {Prime[j], 0}, {0, Prime[j]}]
>
> The line y=x must intersect each vertical segment. This can be shown by an
> inductive argument, observing that each time you jump upward, you add more
> th the y coordinate than you previously added to the x coordinate in moving
> sideways.
>
> Daniel
>
- References:
- Prime Segment Diagram; why the codes run very slowly?
- From: a boy <a.dozy.boy@gmail.com>
- Prime Segment Diagram; why the codes run very slowly?