Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Re: When is a List not a List?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90963] Re: [mg90956] Re: [mg90947] When is a List not a List?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 1 Aug 2008 02:58:38 -0400 (EDT)
  • References: <200807310656.CAA07700@smc.vnet.net> <16711231.1217501820078.JavaMail.root@m08> <op.ue54zeqq2c6ksp@bobbys-imac>

When I wrote "Plot does not evaluate its arguments" I meant it in the  
usual (although inaccurate) sense that people frequently  use in this  
context, namely: that the so called Evaluator does not pre-evaluate  
the arguments of Plot  (if you do not like to thing of "the  
Evaluator", another way of saying this is that "Mathematica" does not  
evaluate the arguments before Plot is applied and leaves any  
evaluating to Plot.) Of course, you are right that Plot does evaluate  
its arguments in some way (this sort of behavior is also referred in  
the often used phrase:  "Plot evaluates its arguments in a non- 
standard way"). The fact that this "non-standard" evaluation results  
in a plot of a function is actually new in version 6; in all previous  
versions all you will get is an error message about the values of the  
function being plotted not being numeric.
Anyway, my point was that this has been a normal (non quirky) behavior  
of Mathematica since version 1 and has been discussed here a number of  
times.  (It must be at least the fourth of fifth time in 10 years that  
I am addressing this issue on this forum). It is also fully documented  
(with examples) in the Mathematica online documentation, all past  
printed documentation and a vast number of books dealing with  
Mathematica.

Andrzej Kozlowski


On 31 Jul 2008, at 20:15, DrMajorBob wrote:

> But Plot DOES evaluate its arguments, of course, and DOES  
> (eventually) see that multiple functions are being plotted. (Else  
> they couldn't be plotted.)
>
> It's just not happening before colors are assigned.
>
> Nonetheless, it's prudent to take note of what functions actually  
> do, and get used to it. Calling everything in sight a quirk serves  
> no purpose.
>
> (Paraphrasing Andrzej, perhaps.)
>
> Bobby
>
> On Thu, 31 Jul 2008 05:04:10 -0500, Andrzej Kozlowski <akoz at mimuw.edu.pl 
> > wrote:
>
>> There is nothing at all quirky about this. Yes, FullForm[Table[g[x,
>> n], {n, 1, 2}]] and FullForm[{g[x, 1], g[x, 2]}] are indeed  
>> identical,
>> but that is because FullForm evaluates its argument. But Plot has
>> attribute:
>>
>> In[2]:= Attributes[Plot]
>> Out[2]= {HoldAll, Protected}
>>
>> so, unlike FullForm, it does not evaluate its argument. In your first
>> example,  Plot[{g[x, 1], g[x, 2]}, {x, 0, 1}, PlotStyle -> {Red,
>> Blue}], the first argument of Plot has an explicit List bracket, so
>> Plot can see that it supposed to treat the argument as two different
>> functions, without evaluating the argument. But in the second case,  
>> it
>> does not see an explicit bracket, so it treats the entire expression
>> as the graph of a single function (in versions of Mathematica  
>> before 6
>> you would not have got any plot at all in this case).
>>
>> If you use Evaluate in the second code you will get the same result  
>> as
>> you get form the first:
>>
>> Plot[Evaluate[Table[g[x, n], {n, 1, 2}]], {x, 0, 1}, PlotStyle ->
>> {Red, Blue}]
>>
>> Finally, since you have given ample proof that, in spite of many  
>> years
>> of using Mathematica, you have not mastered its basics (this
>> particular issue has been raised and answered a countless number of
>> times on this forum), why do you keep assuming that the problems that
>> you keep coming across are Mathematica's "quirks" rather than (as is
>> much more likely) gaps in your won understanding? What do you think  
>> of
>> first year undergraduate students who whenever they do not understand
>> something in their introductory lectures claim that it is wrong, or
>> blame their textbook or their lecture rather then themselves?
>>
>> Andrzej Kozlowski
>>
>>
>>
>> On 31 Jul 2008, at 08:56, AES wrote:
>>
>>>  g[x_, n_] := x^n
>>>  FullForm[Table[g[x, n], {n, 1, 2}]]
>>>  FullForm[{g[x, 1], g[x, 2]}]
>>>  Plot[{g[x, 1], g[x, 2]}, {x, 0, 1}, PlotStyle -> {Red, Blue}]
>>>  Plot[Table[g[x, n], {n, 1, 2}], {x, 0, 1}, PlotStyle -> {Red,  
>>> Blue}]
>>>
>>> The FullForm[]s are identical.  One Plot[] has red and blue curves;
>>> the
>>> other has two blue curves.
>>>
>>> Quirky!
>>>
>>
>>
>>
>
>
>
> -- 
> DrMajorBob at longhorns.com



  • Prev by Date: Re: Re: When is a List not a List?
  • Next by Date: Re: Performance of Array Addition
  • Previous by thread: Re: Re: Re: When is a List not a List?
  • Next by thread: Re: Re: When is a List not a List?