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: Re: When is a List not a List?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90985] Re: [mg90968] Re: [mg90956] Re: [mg90947] When is a List not a List?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 2 Aug 2008 03:25:08 -0400 (EDT)
  • References: <200807310656.CAA07700@smc.vnet.net> <200808010659.CAA25763@smc.vnet.net> <4D3584F1-F616-4156-BD7A-9BE63878A8B0@mimuw.edu.pl>

Of course it should have been something like

Plot[x /. Solve[x^3 - 3 x^2 + a == 0, x], {a, -3, 5}]

Andrzej Kozlowski

On 1 Aug 2008, at 14:35, Andrzej Kozlowski wrote:

> I am not sure about the "no argument part". First, it seems to me  
> obvious that one should try to learn Mathematica before trying to  
> use it, and reading the documentation is a pretty basic part of  
> learning. Why should you then call something a "quirk" if it is both  
> documented and even exemplified.
> However, there is more to that. In view of what you have been  
> arguing, perhaps you could tell us if it "seems odd to you"  that  
> Plot does not use different colors in the example below. It does not  
> seem odd to me at all, and I doubt that even beginners (AES  
> excepting, of course) will find it "a quirk".
>
>
> Plot[x /. Solve[x^3 - 3 x + a x == 0, x], {a, -3, 3}]
>
> Andrzej Kozlowski
>
>
> On 1 Aug 2008, at 08:59, DrMajorBob wrote:
>
>> No argument here. That's the behavior, and we've seen it a thousand  
>> times.
>> A "quirk" is only a quirk the first 100 times we see it, or  
>> thereabouts.
>> (Pick a number.)
>>
>> Plot COULD assign colors after evaluation, OTOH... the fact that it
>> doesn't is a design choice/artifact, not a necessity preordained by  
>> fate.
>>
>> That being so, users are entitled to find it odd at first glance.  
>> (Or even
>> second... maybe third.)
>>
>> Bobby
>>
>> On Thu, 31 Jul 2008 13:56:56 -0500, Andrzej Kozlowski <akoz at mimuw.edu.pl 
>> >
>> wrote:
>>
>>> 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
>>>
>>>
>>
>>
>>
>> -- 
>> DrMajorBob at longhorns.com
>>
>



  • Prev by Date: Re: Re: When is a List not a List?
  • Next by Date: Re: Re: Re: When is a List not a List?
  • Previous by thread: Re: Re: When is a List not a List?
  • Next by thread: Re: Re: Re: When is a List not a List?