Skip to content

tk-yoshimura/DoubleDoubleAdvancedIntegrate

Repository files navigation

DoubleDoubleAdvancedIntegrate

Double-Double Advanced Numerical Integration Implements

Requirement

.NET 8.0
DoubleDouble
DoubleDoubleComplex
DoubleDoubleIntegrate

Install

Download DLL
Download Nuget

Usage

Line Integral

// Line integral on the line with integrand f(x, y) = x + 2 y
(ddouble value, ddouble error, long eval_points) = LineIntegral.AdaptiveIntegrate(
    (x, y) => x + 2 * y,
    Line2D.Line((0, 1), (2, 3)),
    Interval.Unit, eps: 0, maxdepth: 16
);
// Line integral on the (t, t^2) with integrand f(x, y) = x + 2 y
(ddouble value, ddouble error, long eval_points) = LineIntegral.AdaptiveIntegrate(
    (x, y) => x + 2 * y,
    new Line2D(t => (t, t * t), t => (1, 2 * t)),
    (0, 1), eps: 0, maxdepth: 16
);
// Line integral on the unit circle with integrand f(x, y) = x^2 + y^2
(ddouble value, ddouble error, long eval_points) = LineIntegral.AdaptiveIntegrate(
    (x, y) => x * x + y * y,
    Line2D.Circle,
    Interval.OmniAzimuth, eps: 0, maxdepth: 16
);
// Ellipse circumference
(ddouble value, ddouble error, long eval_points) = LineIntegral.AdaptiveIntegrate(
    (x, y) => 1,
    Line2D.Circle * (1.5, 2),
    Interval.OmniAzimuth, eps: 0, maxdepth: 16
);
// Line integral on the helix with integrand f(x, y, z) = z^2
(ddouble value, ddouble error, long eval_points) = LineIntegral.AdaptiveIntegrate(
    (x, y, z) => z * z,
    Line3D.Helix,
    Interval.OmniAzimuth, eps: 0, maxdepth: 16
);
// Line integral on the unit circle (z = 1) with integrand f(x, y, z) = x^2 + y^2 + z
(ddouble value, ddouble error, long eval_points) = LineIntegral.AdaptiveIntegrate(
    (x, y, z) => x * x + y * y + z,
    Line3D.Circle + (0, 0, 1),
    Interval.OmniAzimuth, eps: 0, maxdepth: 16
);

Surface Integral

// Surface integral on the [0, 2]x[0, 1] with integrand f(x, y) = (x - y)^2
(ddouble value, ddouble error, long eval_points) = SurfaceIntegral.AdaptiveIntegrate(
    (x, y) => ddouble.Square(x - y),
    Surface2D.Ortho,
    (0, 2), (0, 1), eps: 0, maxdepth: 4
);
// Surface integral on the triangle with integrand f(x, y) = 2 x + y
(ddouble value, ddouble error, long eval_points) = SurfaceIntegral.AdaptiveIntegrate(
    (x, y) => 2 * x + y,
    Surface2D.Triangle((0, 0), (1, 0), (0, 1)),
    Interval.Unit, Interval.Unit, eps: 0, maxdepth: 4
);
// 2-dimensional Gaussian integration in polar coordinates
(ddouble value, ddouble error, long eval_points) = SurfaceIntegral.AdaptiveIntegrate(
    (x, y) => ddouble.Exp(-(x * x + y * y)),
    Surface2D.InfinityCircle,
    Interval.Unit, Interval.OmniAzimuth, eps: 0, maxdepth: 4
);
// Surface integral on the unit sphere with integrand f(x, y, z) = x^2 + y + z^3
(ddouble value, ddouble error, long eval_points) = SurfaceIntegral.AdaptiveIntegrate(
    (x, y, z) => x * x + y + z * z * z,
    Surface3D.Sphere,
    Interval.OmniAltura, Interval.OmniAzimuth, eps: 0, maxdepth: 4
);
// Surface integral on the unit sphere and (x > 0) with integrand f(x, y, z) = x^2 + y + z^3
(ddouble value, ddouble error, long eval_points) = SurfaceIntegral.AdaptiveIntegrate(
    (x, y, z) => x * x + y + z * z * z,
    Surface3D.Rotate(Surface3D.Sphere, (0, 0, 1), (1, 0, 0)),
    (0, ddouble.PI / 2), Interval.OmniAzimuth, eps: 0, maxdepth: 4
);

Volume Integral

// Volume integral on the ellipsoid with integrand f(x, y, z) = x^2 + y
(ddouble value, ddouble error, long eval_points) = VolumeIntegral.AdaptiveIntegrate(
    (x, y, z) => x * x + y,
    Volume3D.Sphere * (2, 3, 5),
    Interval.Unit, Interval.OmniAltura, Interval.OmniAzimuth,
    eps: 0, maxdepth: 2
);

Complex Integral

note: If the integral path contains poles, the accuracy of the calculation results cannot be guaranteed.

(Complex value, ddouble error, long eval_points) = ComplexIntegral.AdaptiveIntegrate(
    z => 1 / z,
    Line2D.Circle,
    Interval.OmniAzimuth, eps: 0, maxdepth: 16
);

Vector Integral

(ddouble value, ddouble error, long eval_points) = LineVectorIntegral.AdaptiveIntegrate(
    (x, y, z) => (x * x * y * z, 3 * x * y, y * y),
    Line3D.Helix,
    (0, ddouble.PI / 2), eps: 0, maxdepth: 16
);
(ddouble value, ddouble error, long eval_points) = SurfaceVectorIntegral.AdaptiveIntegrate(
    (x, y, z) => (-x, -y, -z),
    Surface3D.Cylinder,
    (0, ddouble.PI / 2), (0d, 1d), eps: 0, maxdepth: 16
);

Licence

MIT

Author

T.Yoshimura