       Re: Solving Diophantine Equations

• To: mathgroup at smc.vnet.net
• Subject: [mg61381] Re: Solving Diophantine Equations
• From: "Diana" <diana53xiii at earthlink.remove13.net>
• Date: Mon, 17 Oct 2005 02:29:49 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Ray,

I am a beginning - intermediate Mathematica user.

The algorithm you and Andrzej have coded works great. Could I trouble you to
explain briefly what the code is doing? To the un-initiated, the
sophisticated code is hard to interpret.

As was mentioned in this thread, I am trying to corroborate the findings of
Pingzhi Yuan in 2004.

I hope to use your improvements towards the equations of twenty other
Diophantine equation articles, as well, for a thesis.

Thanks,

Diana

"Ray Koopman" <koopman at sfu.ca> wrote in message
news:diprnq\$hn2\$1 at smc.vnet.net...
> Andrzej Kozlowski wrote:
>> That was wrong again! Trying to write these loops is so frustrating,
>> perhaps I should go back to functional programming... Anyway, I think
>> and hope this is now right at last:
>>
>> g[a_, b_, c_:5] := Block[{y, ls = {}, x, n},
>>     Do[ y = 2; While[(y^n - y^2)/((y - 1)*y) < a,
>>       Do[If[(x^3 - 1)/(x - 1) == (y^n - 1)/(y - 1) &&
>>            x != y, ls = {ls, {x, y, n}}],
>>          {x, y^((n - 1)/2), (y^n - y^2)/((y - 1)*y)}];
>>         y++], {n, c, b, 2}]; ls]
>>
>>
>> It is certainly not easy to find solutions, though, pretty big
>> searches so far have yielded just two, e.g.
>>
>> In:=
>> g[100000,30]//Timing
>>
>> Out=
>> {58.0157 Second,{{{},{5,2,5}},{90,2,13}}}
>>
>> [...]
>
> Procedural code such as this often benefits from the old
> standard tricks such as moving computations outside the loop
> and replacing division by multiplication.
>
> In:=
> g[a_, b_, c_:5] := Block[{y, ls = {}, x, n},
> Do[y = 2;
>   While[(y^n - y^2)/((y - 1)*y) < a,
>         Do[If[(x^3 - 1)/(x - 1) == (y^n - 1)/(y - 1) && x != y,
>               ls = {ls, {x, y, n}}],
>            {x, y^((n - 1)/2), (y^n - y^2)/((y - 1)*y)}];
>         y++],
>   {n, c, b, 2}];
> ls]
>
> In:=
> gg[a_, b_, c_:5] := Block[{y, x, n, r}, Reap[
> Do[y = 2;
>   While[y^(n-1) - y < (y - 1)a,
>         r = (y^n - 1)/(y - 1);
>         Do[If[x != y && (x+1)x+1 == r, Sow[{x, y, n}]],
>            {x, y^((n-1)/2), (y^(n-1) - y)/(y - 1)}];
>         y++],
>   {n, c, b, 2}]][[2,1]]]
>
> In:= g[10^5,30]//Timing
>       gg[10^5,30]//Timing
>
> Out= {30.28 Second,{{{},{5,2,5}},{90,2,13}}}
> Out= {11.09 Second,{{5,2,5},{90,2,13}}}
>

```

• Prev by Date: Re: formatting table with integers and floats in a column
• Next by Date: Re: Getting a pure text widget?
• Previous by thread: Re: Solving Diophantine Equations
• Next by thread: Re: Solving Diophantine Equations