Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Solving Diophantine Equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61228] Re: Solving Diophantine Equations
  • From: mike_in_england2000 at yahoo.co.uk
  • Date: Thu, 13 Oct 2005 01:39:36 -0400 (EDT)
  • References: <dii90q$9ee$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

As far as I can see, the problem is because you are generating a large
table of Null values since the If statement returns Null when the
result is false.  I ran your expression with a much smaller range of n
values:

test = Table[
    If[(x^3 - 1)/(x -
        1) == (y^n - 1)/(y - 1) && x â?  y, {{x, y,
            n},}], {x, 2, 1000}, {y, 2, 1000}, {n, 1, 10, 2}];

Then lets have a look how much memory this expression takes up:

ByteCount[test] /(1024.*1024)

gives 41.9084 mega-bytes and there is where your problem lies since
your expression will be 100 times bigger than mine giving over 4gb.

I spent a while trying to think of a nice and elegant way of solving
your problem but as you may be able to tell if you look at some of my
past questions on this group I am not yet particularly good at coming
up with elegant solutions.  The following Just Works (tm)

sols = {};
Do[
  Do[
    Do[
      If[(x^3 - 1)/(
    x - 1) == (y^n - 1)/(y - 1) && x â?  y, AppendTo[sols, {x, y, n}]];
      , {x, 2, 1000}
      ]
    , {y, 2, 1000}
    ]
  , {n, 1, 1001, 2}
  ]

AppendTo is Highly inefficient but in this case the resulting list is
very small so it doesn't make a blind bit of difference.  I ran this
for a couple of hours and got the following solutions before getting
bored

{x,y,n}
{5, 2, 5}
{90, 2, 13}

If memory serves then n was around 350 when I terminated the
calculation.  I am sure someone else on this group will come up with a
more elegant solution- which I await with interest.

HTH

Mike


  • Prev by Date: TagSet and the listability of Plus[ ]
  • Next by Date: Re: "Leibnitz" from for partial differentiation?
  • Previous by thread: Re: Solving Diophantine Equations
  • Next by thread: Re: Solving Diophantine Equations