Class LebedevQuadrature

java.lang.Object
org.hipparchus.analysis.integration.LebedevQuadrature

public class LebedevQuadrature extends Object
Lebedev quadrature rules for integrating a function over the surface of the unit sphere. This is not a Trivariate Integrator, although the integrate() method takes in input a Trivariate function. It does perform integration on the surface of the unit sphere.

Inspired by the sphere_lebedev_rule C++ code by John Burkardt, itself based on the public domain "Lebedev-Laikov" algorithm and tables by Vyacheslav Lebedev and Dmitri Laikov.

For a rule of a given order N, with unit points (x_i,y_i,z_i) and weights w_i (which sum to 1), the integral of a function f over the unit sphere is approximated as 4*PI * sum(w_i * f(x_i,y_i,z_i)).

Usage: the simplest way to integrate a function over the unit sphere is to call integrate(TrivariateFunction, int) with the function to integrate and the desired order (number of points), for example:


 double integral = LebedevQuadrature.integrate((x, y, z) -> x * x + y * y + z * z, 110);
 

The order must be one of the values listed in AVAILABLE_ORDERS; higher orders give a more accurate approximation at the cost of evaluating the function at more points. When the required accuracy is unknown in advance, getRuleAtLeast(int) can be used to pick the smallest available rule with at least a given number of points. For repeated integrations with the same order, it is more efficient to retrieve the LebedevQuadrature.Rule once with getRule(int) or getRuleAtLeast(int) and reuse it, evaluating the function directly on its points and weights, rather than calling integrate(TrivariateFunction, int) repeatedly.

Reference: Vyacheslav Lebedev, Dmitri Laikov, "A quadrature formula for the sphere of the 131st algebraic order of accuracy", Russian Academy of Sciences Doklady Mathematics, Volume 59, Number 3, 1999, pages 477-481.

Original algorithm and tables: Vyacheslav Lebedev and Dmitri Laikov
Since:
4.1
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A Lebedev quadrature rule: unit-sphere points and weights (weights sum to 1).
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    genOh(int code, double aIn, double bIn, double v, double[] x, double[] y, double[] z, double[] w, int start)
    Generate points under OH (octahedral) symmetry, given a point specified by A and B, with weight V, writing into x/y/z/w starting at index start.
    getRule(int order)
    Get the Lebedev rule with the given exact order.
    getRuleAtLeast(int minimumOrder)
    Get the smallest available rule with at least the requested number of points.
    static double
    integrate(TrivariateFunction function, int order)
    Integrate a function over the surface of the unit sphere using the Lebedev rule of the given order.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getRuleAtLeast

      public static LebedevQuadrature.Rule getRuleAtLeast(int minimumOrder)
      Get the smallest available rule with at least the requested number of points.
      Parameters:
      minimumOrder - minimum number of points desired
      Returns:
      a Lebedev rule
    • getRule

      public static LebedevQuadrature.Rule getRule(int order)
      Get the Lebedev rule with the given exact order.
      Parameters:
      order - number of points, must be one of AVAILABLE_ORDERS
      Returns:
      a Lebedev rule
      Throws:
      MathIllegalArgumentException - if order is not one of AVAILABLE_ORDERS
    • integrate

      public static double integrate(TrivariateFunction function, int order)
      Integrate a function over the surface of the unit sphere using the Lebedev rule of the given order.
      Parameters:
      function - function to integrate, taking the Cartesian coordinates of a unit-sphere point
      order - number of points, must be one of AVAILABLE_ORDERS
      Returns:
      approximation of the integral of function over the unit sphere
      Throws:
      MathIllegalArgumentException - if order is not one of AVAILABLE_ORDERS
      NullArgumentException - if function is null
    • genOh

      public static int genOh(int code, double aIn, double bIn, double v, double[] x, double[] y, double[] z, double[] w, int start)
      Generate points under OH (octahedral) symmetry, given a point specified by A and B, with weight V, writing into x/y/z/w starting at index start.
      Parameters:
      code - symmetry code selecting the point pattern to generate
      aIn - coordinate value A
      bIn - coordinate value B
      v - weight assigned to the generated points
      x - array to write generated x coordinates into
      y - array to write generated y coordinates into
      z - array to write generated z coordinates into
      w - array to write generated weights into
      start - index to start writing points at
      Returns:
      the number of points generated