Reputation
Next tag badge:
215/100 score
20/20 answers
Badges
7 213 302
Newest
 Enlightened
Impact
~450k people reached

Mar
22
comment Update a function avoiding infinite recursion
@Stefano Yes, it is expected. Try to figure out on your own why this is so. I also think that whatever your problem is, you should be able to solve it without the rather heavy machinery I described in my post.
Mar
22
comment Update a function avoiding infinite recursion
@Stefano Yes, this is exactly what happens. Glad I could help. Thanks for the accept.
Mar
22
comment What tools can help in realizing tail recursion?
Since people tend to look at the plots and tables first, could you also make a new benchmark with my new code, and place that alongside the old one? This would stress the occasional importance of small details even much more.
Mar
22
comment What tools can help in realizing tail recursion?
@Mr.Wizard I think I tried it and something did not work, but I don't remember for sure. Besides, conceptually, I like the composition idea more, since it clearly states that what I pass is a composition of a previous and current functions.
Mar
21
answered Update a function avoiding infinite recursion
Mar
21
comment What tools can help in realizing tail recursion?
Re: critique - thanks for pointing this out, but not so fast with burying my stuff :) - see the new section in my answer.
Mar
21
comment What tools can help in realizing tail recursion?
@Mr.Wizard *relevant, sorry.
Mar
21
comment What tools can help in realizing tail recursion?
@Mr.Wizard Actually, when comparing the same functions ( addition in both cases), yours is about twice faster (a factor of 2 that I predicted:-)), but for multiplication they are asymptotically the same. Since it was fast to do, I added a relevent section with a fix, explanations, and a benchmark.
Mar
21
revised What tools can help in realizing tail recursion?
Added a section on speed improvements
Mar
21
comment What tools can help in realizing tail recursion?
@Mr.Wizard Ok, here is a fix. The culprit it Composition with its Flat attribute - this is what leads to a quadratic complexity. Use instead ClearAll[composition]; SetAttributes[composition, HoldAllComplete]; composition[f_, g_][x_] := f[g[x]], and all seems sweet and dandy. In fact, for n = 100000, my new version beats yours 4 times, in my benchmarks.
Mar
21
comment What tools can help in realizing tail recursion?
@Mr.Wizard Alas it looks like I completely exhausted my time quota for SE today, so I can't dive into it right now (although I'd really like to). I don't yet know why the complexity is so bad, although I have some thoughts. Will get back to this as soon as I can. But, to rehabilitate a bit, I still think that the main value of the answer is in the concept. When you exceed a critical $RecursionLimit, the kernel will likely crash. With my method, this won't happen. Of course, I agree that performance should be improved for it to be practical, judging from your benchmarks.
Mar
21
comment Numerical integration with OwnValues
@Szabolcs But that one wasn't the biggest surprise. The one on Position was - you managed to write a full-fledged answer with links and formatting etc, citations from docs - in under 5 minutes.
Mar
21
answered Only perform a symbolic differentiation once
Mar
21
comment Numerical integration with OwnValues
@halirutan Yesterday, I wanted to tell the same to Szabolcs twice (for his answers on array memory management, and on Position - the latter took him just 5 mins!).
Mar
21
answered Numerical integration with OwnValues
Mar
21
revised What tools can help in realizing tail recursion?
edited tags
Mar
21
awarded  Nice Answer
Mar
21
comment How can I get the right hand side of a delayed expression?
Nothing to be sorry about :-). There is no rush with anything here on SE, including accepting an answer. It is actually usually better to wait for some time, to give people an incentive to post alternative solutions.
Mar
21
comment How can I get the right hand side of a delayed expression?
See my answer - it gives you that. If you are interested in the input, use DownValues[In].
Mar
21
answered How can I get the right hand side of a delayed expression?