MathGroup Archive 2002

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

Search the Archive

Re: Sequence and Or

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34238] Re: Sequence and Or
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 11 May 2002 04:04:54 -0400 (EDT)
  • References: <abfs7e$gsn$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"DrBob" <majort at cox-internet.com> wrote in message
news:abfs7e$gsn$1 at smc.vnet.net...

> Second and third, look at the following:
>
> Quit
>
> SetAttributes[myApply,HoldAll]
> myApply[f_,{x__}]:=f[x]
> p1 := 1 == 1
> p2 := FullSimplify[Gamma[z]*z == z!]
> expr := {p1, p2};
>
> Timing[ReleaseHold[Hold[expr] /. OwnValues[expr] /. {x___} :> Or[x]]]
> Timing[Or@@expr]
> Timing[Or@@expr]
> Timing[myApply[Or,expr]]
> Timing[myApply[Or,{p1,p2}]]
>
> {0. Second,True}
> {0.219 Second,True}
> {0. Second,True}
> {0. Second,myApply[Or,expr]}
> {0. Second,True}
>
> The third and fourth output lines mystify me.  The fourth suggests that
> Andrezej's "myApply" method doesn't salvage efficiency for situations
> where you wouldn't want to type in all the logical expressions in a
> list.
>
> The difference in timing for identical expressions in the second and
> third output lines must be due (I suppose?) to startup costs.

Bobby,

Re fourth output:
MyApply is working on the unevaluated expr, which is not of the form {x__},
and it has no rule for this, so the input is returned unchanged.

Re second and third outputs:
The following seems to indicate that some storing of results is involved.

    Timing[FullSimplify[Gamma[z]*z == z!]]

        {5. Second,True}

    Timing[FullSimplify[Gamma[z]*z == z!]]

        {0. Second,True}

    Timing[FullSimplify[2*Gamma[z]*z == 2*(z!)]]

        {2.53 Second,True}

The solutions depend on the details of the structure of  expr  - there may
not be a global solution to this sort of problem.

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

 0565




  • Prev by Date: Re: How to put parameter list in or near a graph?
  • Next by Date: Color Functions
  • Previous by thread: Re: Sequence and Or
  • Next by thread: RE: Re: RE: Sequence and Or