public void LegendreOrthonormality()
 {
     foreach (int n in TestUtilities.GenerateIntegerValues(1, 100, 3))
     {
         foreach (int m in TestUtilities.GenerateIntegerValues(1, 100, 3))
         {
             Func <double, double> f = delegate(double x) {
                 return(OrthogonalPolynomials.LegendreP(n, x) * OrthogonalPolynomials.LegendreP(m, x));
             };
             Interval r = Interval.FromEndpoints(-1.0, 1.0);
             double   I = FunctionMath.Integrate(f, r);
             Console.WriteLine("{0} {1} {2}", n, m, I);
             if (n == m)
             {
                 Assert.IsTrue(TestUtilities.IsNearlyEqual(I, 2.0 / (2 * n + 1)));
             }
             else
             {
                 Assert.IsTrue(Math.Abs(I) < TestUtilities.TargetPrecision);
             }
         }
     }
 }
 public void LegendreInvalidArgument()
 {
     OrthogonalPolynomials.LegendreP(2, -1.1);
 }
 public void LegendreRecurrence()
 {
     foreach (int n in orders)
     {
         foreach (double x in bArguments)
         {
             Assert.IsTrue(TestUtilities.IsNearlyEqual((n + 1) * OrthogonalPolynomials.LegendreP(n + 1, x), (2 * n + 1) * x * OrthogonalPolynomials.LegendreP(n, x) - n * OrthogonalPolynomials.LegendreP(n - 1, x)));
         }
     }
 }