Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8454
| From | Christoph Lhotka <christoph.lhotka@fundp.ac.be> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Why does the order of down values come back? |
| Date | 2012-02-10 11:00 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jh2tcb$rg$1@smc.vnet.net> (permalink) |
| References | <jgo0e9$a2k$1@smc.vnet.net> <jgtj0n$6dc$1@smc.vnet.net> <201202091037.FAA18309@smc.vnet.net> |
hi,
On 02/09/2012 11:37 AM, Oleksandr Rasputinov wrote:
> A very good point. To tell the truth, the only time I've ever had to worry
> about the order of DownValues is when there is some ambiguity in their
> ordering, so I had never noticed the ordering based on position in the
> hash table of those values for which the hash is sufficient to completely
> specify the way in which they are applied. It would be interesting to know
> to what extent the hash table (or tables, if multiple levels of hashing
> are applied, as one might anticipate from the statements about ordering
> based on specificity) is used in the resolution of more complicated
> DownValues and at which point the process reduces to a sequential test for
> applicability by pattern matching (i.e., when the ordering begins to
> matter). Perhaps this can be determined by experiment?
It is an interesting problem to find out how the order of downvalues
changes the results. You can make your own experiments like I did below:
f[0] := 0; f[1] := 1; f[n_] := f[n - 1] + f[n - 2]
dvl = Permutations[DownValues[f]] /. f -> cf;
cf[n] /. dvl
{cf[-2 + n] + cf[-1 + n], cf[-2 + n] + cf[-1 + n],
cf[-2 + n] + cf[-1 + n], cf[-2 + n] + cf[-1 + n],
cf[-2 + n] + cf[-1 + n], cf[-2 + n] + cf[-1 + n]}
cf[1] /. dvl
{1, cf[-1] + cf[0], 1, 1, cf[-1] + cf[0], cf[-1] + cf[0]}
cf[0] /. dvl
{0, 0, 0, cf[-2] + cf[-1], cf[-2] + cf[-1], cf[-2] + cf[-1]}
As you see, I produced a table of all possible permutations
of the internal rules for f named dvl and replaced f by a copy
of it called cf to avoid the acting of the internal evaluation
chain (you could also clear f after the definition of dvl).
The output shows in which way the ordering matters for
cf[n], cf[1], cf[0] (i.e. also for f[n], f[1], f[0]).
Wolfram did a good choice.
Best,
Christoph
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why does the order of down values come back? Shizu <slivo.vitz@msa.hinet.net> - 2012-02-06 07:45 +0000
Re: Why does the order of down values come back? David Reiss <dbreiss@gmail.com> - 2012-02-07 09:06 +0000
Re: Why does the order of down values come back? David Reiss <dbreiss@gmail.com> - 2012-02-07 09:07 +0000
Re: Why does the order of down values come back? "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-02-07 09:08 +0000
Re: Why does the order of down values come back? A Retey <awnl@gmx-topmail.de> - 2012-02-11 20:48 +0000
Re: Why does the order of down values come back? DrMajorBob <btreat1@austin.rr.com> - 2012-02-08 10:29 +0000
Re: Why does the order of down values come back? Leonid Shifrin <lshifr@gmail.com> - 2012-02-08 10:32 +0000
Re: Why does the order of down values come back? "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-02-09 10:39 +0000
Re: Why does the order of down values come back? Christoph Lhotka <christoph.lhotka@fundp.ac.be> - 2012-02-10 11:00 +0000
Re: Why does the order of down values come back? Leonid Shifrin <lshifr@gmail.com> - 2012-02-11 20:43 +0000
csiph-web