MathGroup Archive 2008

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

Search the Archive

Re: Re: Timing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88011] Re: [mg87971] Re: Timing
  • From: "W_Craig Carter" <ccarter at mit.edu>
  • Date: Mon, 21 Apr 2008 14:40:02 -0400 (EDT)
  • References: <480A0EE6.3090109@csl.pl> <200804211038.GAA28042@smc.vnet.net>

Dear Artur,
The previous method should work (in a very weak interpretation of
work) if you replace the expr with;

expr = Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 -
        2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]

Note:

FullSimplify[Together[expr], Element[n, Integers]]

is considerably simpler

((3 + 2*Sqrt[2])^2^(-1 + n)*(-4 + 3*Sqrt[2]) -
  (3 - 2*Sqrt[2])^2^(-1 + n)*(4 + 3*Sqrt[2]))/8

I can't immediately see that this result should be integer, but I am
getting integers for the first 10

t = Table[nexpr /. n -> i, {i, 1, 10}] // Expand
Map[IntegerQ, t]


In general, Do is slow compared to Table, but it is the size of the
expression that is the limiting factor here.

On Mon, Apr 21, 2008 at 9:09 AM, Artur <grafix at csl.pl> wrote:
> Dear Craig,
>  My problem is find such numbers n that expression
>
>
>  ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4
> Sqrt[2])
>  is divisable by (2^n - 1)
>
>  or another words (2^n - 1) is divisor of ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) -
> (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])
>
>  My procedure Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 -
> 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)],   Print[n]], {n, 1,
> 17}]
>
>  is extremaly slow (probably Expand function do that as aslowly but without
> Expand we don't have integers. I don't have idea how improove them.
>  Best wishes
>  Artur
>
>
>
>
>
>
>
>
>
>  W_Craig Carter pisze:
>
>
>
> > Hello Artur,
> > I am not sure I understand your question:
> >
> > Are you asking for
> > Member[expr,Integers] && Element[n,Integers]
> > for 1 <= n <= 17 ?
> >
> > If so, this may be a hint, although it does not exactly check the above:
> >
> > Map[Element[Rationalize[#, .00000001], Integers] & ,
> >  Table[expr /. n -> i, {i, 1, 30}]]
> >
> > and it is reasonably fast.  This approximate method gets worse for
> > large n; so I don't trust the result except for n=1,3,5
> >
> > Note, that
> > Map[Element[Rationalize[Expand[#], .00000001], Integers] & ,
> >  Table[expr /. n -> i, {i, 1, 10}]]
> >
> > Gives a different result and is much slower, thus emphasizing the
> > result for large n.
> >
> > I am curious to see the better solutions....
> >
> > On Mon, Apr 21, 2008 at 6:38 AM, Artur <grafix at csl.pl> wrote:
> >
> >
> > > Who know how change bellow procedure to received reasonable timing?
> > >
> > >  Part:
> > >  Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) -
> > >  1))/(4 Sqrt[2])]/(2^n - 1)
> > >  is every time integer
> > >  > Timing[Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 -
> > >  > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)],
> > >  >   Print[n]], {n, 1, 17}]]
> > >  >
> > >  I will be greatfull for any help! (Mayby some N[] or Floor[N[]]  or
> > >  Int[N[]] will be quickest
> > >
> > >  Best wishes
> > >  Artur
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
>



-- 
W. Craig Carter


  • References:
  • Prev by Date: Re: Exclusions
  • Next by Date: Re: Polygon cutter
  • Previous by thread: Re: Re: Timing
  • Next by thread: Re: Re: Re: Timing