> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fincept.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Numerical Integration (Quadrature)

> Compute the definite integral of a built-in function over [a, b] using various quadrature methods. Supports trapezoid rule, Simpson's rule (more accurate for smooth functions), Gauss-Legendre quadrature (optimal for polynomials), Romberg integration (adaptive Richardson extrapolation), and adaptive quadrature (automatic error control). Essential for probability calculations, pricing path-dependent options, and computing expectations. [Tier: BASIC, Credits: 1]



## OpenAPI

````yaml api-specs/numerical.json post /quantlib/numerical/integration/quadrature
openapi: 3.1.0
info:
  title: FinceptQuantLib API - Numerical
  description: >-
    Numerical module endpoints for FinceptQuantLib API. The Numerical module
    (Basic Tier, 1 credit per request) provides comprehensive numerical methods
    including finite difference differentiation, Fast Fourier Transform (FFT),
    numerical integration (quadrature and Monte Carlo), interpolation methods
    (linear, cubic, spline), linear algebra operations (matrix decomposition,
    solving systems), ODE solvers, root finding algorithms, optimization
    methods, and nonlinear least squares fitting. Essential for quantitative
    analysis, scientific computing, and numerical model implementation.
  version: 3.0.0
  contact:
    name: Fincept API Support
    url: https://fincept.in
servers:
  - url: https://api.fincept.in
    description: Fincept API Production Server
security:
  - APIKeyHeader: []
tags:
  - name: quantlib-numerical
    description: >-
      Numerical methods including differentiation, FFT, integration,
      interpolation, linear algebra, ODE solvers, root finding, and optimization
    x-displayName: Numerical
paths:
  /quantlib/numerical/integration/quadrature:
    post:
      tags:
        - quantlib-numerical
      summary: Numerical Integration (Quadrature)
      description: >-
        Compute the definite integral of a built-in function over [a, b] using
        various quadrature methods. Supports trapezoid rule, Simpson's rule
        (more accurate for smooth functions), Gauss-Legendre quadrature (optimal
        for polynomials), Romberg integration (adaptive Richardson
        extrapolation), and adaptive quadrature (automatic error control).
        Essential for probability calculations, pricing path-dependent options,
        and computing expectations. [Tier: BASIC, Credits: 1]
      operationId: quadrature
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - func_name
                - a
                - b
              properties:
                func_name:
                  type: string
                  description: Built-in function to integrate
                  enum:
                    - exp
                    - log
                    - sin
                    - cos
                    - sqrt
                    - tan
                    - x2
                    - x3
                  example: exp
                a:
                  type: number
                  description: Lower integration bound
                  example: 0
                b:
                  type: number
                  description: Upper integration bound
                  example: 1
                method:
                  type: string
                  description: Integration method to use
                  enum:
                    - trapezoid
                    - simpson
                    - gauss_legendre
                    - romberg
                    - adaptive
                  default: simpson
                  example: simpson
                'n':
                  type: integer
                  description: >-
                    Number of intervals/points (for trapezoid, simpson,
                    gauss_legendre methods)
                  default: 100
                  example: 100
            example:
              func_name: exp
              a: 0
              b: 1
              method: simpson
              'n': 100
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      function:
                        type: string
                        example: exp
                      a:
                        type: number
                        description: Lower bound
                        example: 0
                      b:
                        type: number
                        description: Upper bound
                        example: 1
                      method:
                        type: string
                        example: simpson
                      integral:
                        type: number
                        description: Computed integral value (e^1 - e^0 = e - 1 ≈ 1.718)
                        example: 1.7182818
              example:
                success: true
                data:
                  function: exp
                  a: 0
                  b: 1
                  method: simpson
                  integral: 1.7182818
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientTierError'
        '422':
          description: Validation Error
      security:
        - APIKeyHeader: []
components:
  responses:
    UnauthorizedError:
      description: Authentication information is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Invalid API key
    InsufficientTierError:
      description: API tier insufficient for this endpoint
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Endpoint requires Basic tier or higher
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key for authentication. Get your key at
        https://api.fincept.in/auth/register

````