Help us shape the future of Go! Take the 2026 Go Developer Survey

integrate

package
v0.8.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

README

Gonum integrate GoDoc

Package integrate provides numerical evaluation of definite integrals of single-variable functions for the Go programming language.

Documentation

Overview

Package integrate provides functions to compute an integral given a specific list of evaluations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Romberg

func Romberg(f []float64, dx float64) float64

Romberg returns an approximate value of the integral

\int_a^b f(x)dx

computed using the Romberg's method. The function f is given as a slice of equally-spaced samples, that is,

f[i] = f(a + i*dx)

and dx is the spacing between the samples.

The length of f must be 2^k + 1, where k is a positive integer, and dx must be positive.

See https://en.wikipedia.org/wiki/Romberg%27s_method for a description of the algorithm.

func Simpsons

func Simpsons(x, f []float64) float64

Simpsons returns an approximate value of the integral

\int_a^b f(x)dx

computed using the Simpsons's method. The function f is given as a slice of samples evaluated at locations in x, that is,

f[i] = f(x[i]), x[0] = a, x[len(x)-1] = b

The slice x must be sorted in strictly increasing order. x and f must be of equal length and the length must be at least 3.

See https://en.wikipedia.org/wiki/Simpson%27s_rule#Composite_Simpson's_rule_for_irregularly_spaced_data for more information.

func Trapezoidal

func Trapezoidal(x, f []float64) float64

Trapezoidal returns an approximate value of the integral

\int_a^b f(x) dx

computed using the trapezoidal rule. The function f is given as a slice of samples evaluated at locations in x, that is,

f[i] = f(x[i]), x[0] = a, x[len(x)-1] = b

The slice x must be sorted in strictly increasing order. x and f must be of equal length and the length must be at least 2.

The trapezoidal rule approximates f by a piecewise linear function and estimates

\int_x[i]^x[i+1] f(x) dx

as

(x[i+1] - x[i]) * (f[i] + f[i+1])/2

More details on the trapezoidal rule can be found at: https://en.wikipedia.org/wiki/Trapezoidal_rule

Types

This section is empty.

Directories

Path Synopsis
Package quad provides numerical evaluation of definite integrals of single-variable functions.
Package quad provides numerical evaluation of definite integrals of single-variable functions.
Package testquad provides integrals for testing quadrature algorithms.
Package testquad provides integrals for testing quadrature algorithms.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL