Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4681 > unrolled thread

Difference table via DifferenceDelta[ ]. Why do I need two Table[ ] calls?

Started by"Christopher O. Young" <cy56@comcast.net>
First post2011-08-31 11:41 +0000
Last post2011-09-02 07:30 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Difference table via DifferenceDelta[ ]. Why do I need two Table[ ] calls? "Christopher O. Young" <cy56@comcast.net> - 2011-08-31 11:41 +0000
    Re: Difference table via DifferenceDelta[ ]. Why do I need two Table[ ] calls? Christopher Young <cy56@comcast.net> - 2011-09-02 07:31 +0000
    Re: Difference table via DifferenceDelta[ ]. Why do I need two Table[ ] calls? "Alexey Popkov" <lehin.p@gmail.com> - 2011-09-02 07:30 +0000

#4681 — Difference table via DifferenceDelta[ ]. Why do I need two Table[ ] calls?

From"Christopher O. Young" <cy56@comcast.net>
Date2011-08-31 11:41 +0000
SubjectDifference table via DifferenceDelta[ ]. Why do I need two Table[ ] calls?
Message-ID<j3l6l1$d81$1@smc.vnet.net>
The following gives me a difference table for x^3, but it would be nice if I
could do it with only 1 Table call.

Grid[
 Table[
  Table[
    DifferenceDelta[x^3, {x, n}] // Evaluate,
   {x, -6, 6 - n + 1}
   ]
  , {n, 1, 3}
  ],
 Alignment -> Right
 ]

The following hangs up, though. I have to abort it after several minutes of
nothing happening.

Table[
 DifferenceDelta[x^3, {x, n}] // Evaluate,
 {x, -6, 6},
 {n, 1, 3}
]

Any help appreciated.

Chris Young
cy56@comcast.net

[toc] | [next] | [standalone]


#4698

FromChristopher Young <cy56@comcast.net>
Date2011-09-02 07:31 +0000
Message-ID<j3q0on$6f2$1@smc.vnet.net>
In reply to#4681
Thanks, I'll be wary of DifferenceDelta. Looks like Differences will 
work just as well for me here.

On Sep 1, 2011, at 11:08 AM, Alexey Popkov wrote:

> Christopher,
>
> DifferenceDelta is an autoloaded function:
>
> In[1]:= ClearAttributes[DifferenceDelta, {Protected, ReadProtected}]
>           Definition[DifferenceDelta]
> Out[2]= DifferenceDelta :=
> System`Dump`AutoLoad[Hold[DifferenceDelta], Hold[DifferenceDelta],
>  Discrete`DifferenceDelta`] /; System`Dump`TestLoad
>
> The need for Evaluate in your code is an inconsistency: such code should
> work well without beating the HoldAll attributes of Table. And error
> messages when your code is evaluated without Evaluate clearly show very bad
> design of this function. I recommend do not rely on such functions.
>
> As for why you have to evaluate your code twice, you may be interested in
> this thread:
> 
http://stackoverflow.com/questions/5649379/why-do-i-have-to-evaluate-this-twice
>
>
> Alexey

Chris Young
cy56@comcast.net

[toc] | [prev] | [next] | [standalone]


#4701

From"Alexey Popkov" <lehin.p@gmail.com>
Date2011-09-02 07:30 +0000
Message-ID<j3q0mq$6eq$1@smc.vnet.net>
In reply to#4681
Christopher,

DifferenceDelta is an autoloaded function:

In[1]:= ClearAttributes[DifferenceDelta, {Protected, ReadProtected}]
            Definition[DifferenceDelta]
Out[2]= DifferenceDelta :=
 System`Dump`AutoLoad[Hold[DifferenceDelta], Hold[DifferenceDelta],
   Discrete`DifferenceDelta`] /; System`Dump`TestLoad

The need for Evaluate in your code is an inconsistency: such code should
work well without beating the HoldAll attributes of Table. And error
messages when your code is evaluated without Evaluate clearly show very bad
design of this function. I recommend do not rely on such functions.

As for why you have to evaluate your code twice, you may be interested in
this thread:
http://stackoverflow.com/questions/5649379/why-do-i-have-to-evaluate-this-twice


Alexey


----- Original Message ----- 
From: "Christopher O. Young" <cy56@comcast.net>
Newsgroups: comp.soft-sys.math.mathematica
Sent: Wednesday, August 31, 2011 3:41 PM
Subject: Difference table via DifferenceDelta[ ]. Why do I need two Table[ ]
calls?


> The following gives me a difference table for x^3, but it would be nice if
> I
> could do it with only 1 Table call.
>
> Grid[
> Table[
>  Table[
>    DifferenceDelta[x^3, {x, n}] // Evaluate,
>   {x, -6, 6 - n + 1}
>   ]
>  , {n, 1, 3}
>  ],
> Alignment -> Right
> ]
>
> The following hangs up, though. I have to abort it after several minutes
> of
> nothing happening.
>
> Table[
> DifferenceDelta[x^3, {x, n}] // Evaluate,
> {x, -6, 6},
> {n, 1, 3}
> ]
>
> Any help appreciated.
>
> Chris Young
> cy56@comcast.net
>
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web