MathGroup Archive 2003

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

Search the Archive

Re: Compile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45333] Re: Compile
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Wed, 31 Dec 2003 03:23:40 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 12/30/03 at 4:14 AM, dontsendhere@. (Maxim) wrote:

> I don't see any problem with Plot[Random[],{x,0,1},Compiled->True] either, it was just an 
> illustration (if you don't like Random[], you can insert A Very
> Complicated Expression instead). But you have to read the thread from the beginning, the problem is 
> with
> 
> Module[{y := If[NumericQ[x], x, 1]},
>   Plot[x y, {x, 0, 1}, Compiled -> True]
> ]

But this too works as should be expected from the documentation. In order for the expression x y to be Compiled it must be evaluated and this must happen before Plot assigns values to any portion of the expression. Consequently, when it is evaluated x is not numeric so y evaluates to 1 and the product evaluates to x. Hence, with Compiled->True a line with slope = 1 results.

OTOH, with Compiled->False, Plot supplies a numeric value to x then evaluates the expression. Since x is now numeric, y evalutes to x and the product evaluates to x^2. The resulting plot is a parabola.

--
To reply via email subtract one hundred and four


  • Prev by Date: Re: queueing theory : sample code
  • Next by Date: Re: Printing "Alias" Definitions
  • Previous by thread: Re: Compile
  • Next by thread: Selecting all cells of a certain type