MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Legendre Polynomials


kazimir04 at yahoo.co.uk (Kazimir) wrote:
> > BesselJ[1.5, 0] evaluates to 0 but
> > (BesselJ[xx, yyy] /. xx -> 1.5) /. yyy -> 0 evaluates to complex
> > infinity
> >
> > I seem to encounter many of these problems with Bessel and Legendre
> > functions where I get actual diffrent numerical results depending on
> > How I set the parameters.
>
> I worked with Legendre Polynomils and also experienced the problem. If
> you use
> LegendreP[60, 1.] you have the correct answer 1.

It's correct, yes. But it easily might not have been.

It would have been safer to use either LegendreP[60, 1] or
LegendreP[60, x] /. x->1 , which both give 1 precisely.

> It looks like it uses
> a smart algorythm. If you use LegendreP[60, x] /. x -> 1. mathematica
> first finds the explicit forms of the polynomail, and only afer that
> puts x->1. which means that you have to sum up tirms of odre say 10^20
> to get 1. Due ti rounding errors you may obtain a wrong answer.

Indeed!

In[13]:= LegendreP[60, x] /. x->1.

Out[13]= -180992.

et cetera

In[14]:= LegendreP[60, x] /. x->1.00000000000000000000000

Out[14]= 0.

but _finally_

In[15]:= LegendreP[60, x] /. x->1.000000000000000000000000

Out[15]= 1.

Ah, the perils of using inexact numbers.

David Cantrell


  • Prev by Date: Re: Position different in 5.0 and 5.1?
  • Next by Date: Re: Position different in 5.0 and 5.1?
  • Previous by thread: Re: Legendre Polynomials
  • Next by thread: Re (correction): confusion about Thread[]