help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: normalized ALF (Assotiated Legendre Function)


From: Marco Caliari
Subject: Re: normalized ALF (Assotiated Legendre Function)
Date: Thu, 14 Feb 2008 09:02:36 +0100 (CET)

Hi Ben.

Enclosed, my last (I think) version. I removed scale2 since it did not help too much to prevent NaNs. I also substituted the unnecessary matrix LP with 3 vectors LPM1, LPM2, LPM3.
Feel free to submit the code to the proper list.

Best regards,

Marco

On Wednesday, February 13, 2008, at 11:02AM, "Ben Abbott" <address@hidden> 
wrote:
On Wednesday, February 13, 2008, at 09:58AM, "Marco Caliari" <address@hidden> 
wrote:
I discovered that the warning is misleading. Consider

legendre(151,0)

The last entry is -Inf and the script "should" returns a warning (you
should replace scale == inf with abs(scale) == inf). But, there is no
instability: the value -Inf is "right", in the sense that it is too large
in magnitude to be represented. Now consider

legendre(151,eps)

Again a warning (due to the check on a and b), but, again, no instability.

Moreover, Matlab has no warnings and it is less robust. Consider

legendre(151,-0.9)

in Matlab and with the script now enclosed. To conclude, I would suggest
to leave the warnings out.

Marco


ok.

I'll begin adding some tests and include on for "legendre(151,0) == Inf".

If you have any other good examples, feel free to post them!

Ben


A couple of tests ...

%!test
%! result = legendre (151, 0);
%! ## Don't compare to "-Inf" since it would fail on 64 bit systems.
%! assert (result(end) < -1.7976e308 && all (isfinite (result(1:end-1))));

%!test
%! result = legendre (150, 0);
%! ## This agrees with Matlab's result.
%! assert (result(end), 3.7532741115719e+306, 0.0000000000001e+306)




Attachment: legendre.m
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]