Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

LegendreP & Gauss quad bug

  • To: mathgroup at
  • Subject: [mg25414] LegendreP & Gauss quad bug
  • From: Paul Cally <cally at>
  • Date: Fri, 29 Sep 2000 01:07:11 -0400 (EDT)
  • Organization: Monash University
  • Sender: owner-wri-mathgroup at

There is a bug in the V4 implementation of the Legendre function
LegendreP, at
least in the linux version.

I am running Mathematica 4.0 under RedHat 6.2 linux. I have found the
following bug:

Mathematica 4.0 for Linux
Copyright 1988-1999 Wolfram Research, Inc.
 -- Motif graphics initialized --

In[1]:= LegendreP[5,2,N[1/3]]

Out[1]= -10.3704

In[2]:= LegendreP[5,2,N[1/3,20]]

Out[2]= -0.17283950617283951

In[3]:= %%/%

Out[3]= 60.


LegendreP[n,m,x] appears to work properly if x is a machine precision
number, but if it is higher precision, it gives a result which is out by

EXACTLY the factor m!/n! This error is NOT present in Version 3.0
under Digital Unix.

Please note that this also causes the standard package
to give wrong results for the quadrature weights if n is odd and
is set to greater than 16.

In[1]:= << NumericalMath`GaussianQuadrature`

In[2]:= GaussianQuadratureWeights[3, -1, 1]

Out[2]= {{-0.774597, 0.555556}, {0, 0.888889}, {0.774597, 0.555556}}

In[3]:= GaussianQuadratureWeights[3, -1, 1,17]

Out[3]= {{-0.77459666924148337703585, 0.98360655737704918033},

>    {0, 0.0327868852459016393443},

>    {0.77459666924148337703585, 0.98360655737704918033}}

If n is even, there is no abscissa at x=0, and the error scales away.
However, if n is odd, the unscaled weight associated with the exact
x=0 is correct but all the others are wrong. When normalized, all the
weights are therefore greatly in error.

Paul Cally


|Assoc Prof Paul Cally            |    Ph:  +61 3 9905-4471                |
|Dept of Mathematics & Statistics |    Fax: +61 3 9905-3867                |
|Monash University                |    paul.cally at        |
|PO Box 28M, Victoria 3800        |                                        |
|AUSTRALIA                        | |

  • Prev by Date: Re: Optimizing a simple sampling function for speed
  • Next by Date: Re: Nice graphs with Mathematica
  • Previous by thread: Finding all roots of a group of equations
  • Next by thread: Bug: Mathematica multipies statements together