From ab1f6083458c50d969bd35367d13524b3297212f Mon Sep 17 00:00:00 2001 From: diluculo Date: Mon, 16 Sep 2019 11:44:00 +0900 Subject: [PATCH] Fix typos --- .../IntegrationTests/IntegrationTest.cs | 27 ++++++++++++++----- src/Numerics/Integrate.cs | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Numerics.Tests/IntegrationTests/IntegrationTest.cs b/src/Numerics.Tests/IntegrationTests/IntegrationTest.cs index c8422144..dd988098 100644 --- a/src/Numerics.Tests/IntegrationTests/IntegrationTest.cs +++ b/src/Numerics.Tests/IntegrationTests/IntegrationTest.cs @@ -62,7 +62,7 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests } /// - /// Test Function: f(x,y) = 1 / (1 + x^2) + /// Test Function: f(x) = 1 / (1 + x^2) /// /// First input value. /// Function result. @@ -72,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests } /// - /// Test Function: f(x,y) = log(x) + /// Test Function: f(x) = log(x) /// /// First input value. /// Function result. @@ -120,7 +120,7 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests /// Test Function Stop point. /// private const double StopD = 1; - + /// /// Target area square. /// @@ -140,7 +140,7 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests /// Target area. /// private const double TargetAreaD = -1; - + /// /// Test Integrate facade for simple use cases. /// @@ -183,6 +183,21 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests 1e-10, "DoubleExponential, Target 1e-10"); + // integrate_(0)^(1) log(x) dx = -1 + // Note that DoubleExponential returns -oo. + + Assert.AreEqual( + TargetAreaD, + Integrate.OnClosedInterval(TargetFunctionD, StartD, StopD), + 1e-10, + "Interval"); + + Assert.AreEqual( + TargetAreaD, + Integrate.GaussLegendre(TargetFunctionD, StartD, StopD, order: 1024), + 1e-10, + "GaussLegendre, order 128"); + Assert.AreEqual( TargetAreaD, Integrate.GaussKronrod(TargetFunctionD, StartD, StopD, 1e-10, order: 15), @@ -440,7 +455,7 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests Assert.AreEqual( expected, - Integrate.GausLegendre((x) => Math.Exp(-x * x / 2), a, b, order: 128), + Integrate.GaussLegendre((x) => Math.Exp(-x * x / 2), a, b, order: 128), 1e-10, "GL Integral of e^(-x^2 /2) from {0} to {1}", a, b); } @@ -469,7 +484,7 @@ namespace MathNet.Numerics.UnitTests.IntegrationTests Assert.AreEqual( expected, - factor * Integrate.GausLegendre((x) => 1 / (1 + x * x), a, b, order: 128), + factor * Integrate.GaussLegendre((x) => 1 / (1 + x * x), a, b, order: 128), 1e-10, "GL Integral of sin(pi*x)/(pi*x) from -oo to oo"); } diff --git a/src/Numerics/Integrate.cs b/src/Numerics/Integrate.cs index 6057ed6a..9c7e0370 100644 --- a/src/Numerics/Integrate.cs +++ b/src/Numerics/Integrate.cs @@ -164,7 +164,7 @@ namespace MathNet.Numerics /// Where the interval stops. /// Defines an Nth order Gauss-Legendre rule. The order also defines the number of abscissas and weights for the rule. Precomputed Gauss-Legendre abscissas/weights for orders 2-20, 32, 64, 96, 100, 128, 256, 512, 1024 are used, otherwise they're calculated on the fly. /// Approximation of the finite integral in the given interval. - public static double GausLegendre(Func f, double intervalBegin, double intervalEnd, int order = 128) + public static double GaussLegendre(Func f, double intervalBegin, double intervalEnd, int order = 128) { // Reference: // Formula used for variable subsitution from