From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Perfect Cube
Date: Fri, 13 Feb 2009 06:19:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 10
Message-ID: <gn33cl$nli$>
References: <gn2kcl$c3d$> <gn2vq9$c3b$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1234505941 24242 (13 Feb 2009 06:19:01 GMT)
NNTP-Posting-Date: Fri, 13 Feb 2009 06:19:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:518044

"Husam Aldahiyat" <> wrote in message <gn2vq9$c3b$>...
> if mod(a^(1/3),1)
> 	s='no';
> else
> 	s='yes';
> end

  As Matt has shown, Husam, the test with a^(1/3) fails to work properly most of the time.  The trouble is with the fraction 1/3 which cannot be expressed exactly.  A 1/2 or 1/4 power seems to work all right as far as I have tried.  Algorithms do exist that can find any n-th root exactly for a number that is the n-th power of an integer.  I once found one in an ancient book on arithmetic that had belonged to my father.

Roger Stafford