On Thursday, March 20, 2014 5:32:15 PM UTC-4, Paweł Biernat wrote: > > Taking into account your suggestions I came up with an ad-hoc > implementation tailored for my needs. Instead of computing > Laguerre(n,1,t-n) I compute the whole expression > Laguerre(n,1,t-n)*exp(-(t-n))*(t-n) via a function laguerrel_xexpx. > Because I incorporated the exponential factor into the recursive formula > for laguerre polynomials the NaNs are no longer so significant. Even if > they occur they are due to underflows, which can be simply converted to > exact zeros. The Julia implementation is now roughly order of magnitude > faster than Mathematica and still works for arbitrarily large t. Many > thanks! Also, if you have any suggestions for further performance > improvement please let me know. >
It would be better to avoid the NaNs in the first place (which come when you multiply 0 * Inf, from an underflow times an overflow). For one thing, floating-point exceptions are slow. For another thing, it's possible that the final result of the computation is not an underflow but is rather something that is non-negligible. If you are really sure that the NaNs correspond to negliglbe contributions in infinite precision, it would be better to just avoid computing those n's entirely; if you can be a bit more clever how you choose which n's to sum, you could try to sum only the non-negligible contributions.
