scipy 1.8.0 Pypi GitHub Homepage
Other Docs
Other ParametersParametersReturnsBackRef
romberg(function, a, b, args=(), tol=1.48e-08, rtol=1.48e-08, show=False, divmax=10, vec_func=False)

Returns the integral of :None:None:`function` (a function of one variable) over the interval (a, b).

If show is 1, the triangular array of the intermediate results will be printed. If :None:None:`vec_func` is True (default is False), then :None:None:`function` is assumed to support vector arguments.

Other Parameters

args : tuple, optional

Extra arguments to pass to function. Each element of :None:None:`args` will be passed as a single argument to :None:None:`func`. Default is to pass no extra arguments.

tol, rtol : float, optional

The desired absolute and relative tolerances. Defaults are 1.48e-8.

show : bool, optional

Whether to print the results. Default is False.

divmax : int, optional

Maximum order of extrapolation. Default is 10.

vec_func : bool, optional

Whether :None:None:`func` handles arrays as arguments (i.e., whether it is a "vector" function). Default is False.

Parameters

function : callable

Function to be integrated.

a : float

Lower limit of integration.

b : float

Upper limit of integration.

Returns

results : float

Result of the integration.

Romberg integration of a callable function or method.

See Also

cumulative_trapezoid

Cumulative integration for sampled data.

dblquad

Double integrals.

fixed_quad

Fixed-order Gaussian quadrature.

ode

ODE integrator.

odeint

ODE integrator.

quad

Adaptive quadrature using QUADPACK.

romb

Integrators for sampled data.

simpson

Integrators for sampled data.

tplquad

Triple integrals.

Examples

Integrate a gaussian from 0 to 1 and compare to the error function.

>>> from scipy import integrate
... from scipy.special import erf
... gaussian = lambda x: 1/np.sqrt(np.pi) * np.exp(-x**2)
... result = integrate.romberg(gaussian, 0, 1, show=True) Romberg integration of <function vfunc at ...> from [0, 1]

Steps StepSize Results

1 1.000000 0.385872 2 0.500000 0.412631 0.421551 4 0.250000 0.419184 0.421368 0.421356 8 0.125000 0.420810 0.421352 0.421350 0.421350

16 0.062500 0.421215 0.421350 0.421350 0.421350 0.421350

32 0.031250 0.421317 0.421350 0.421350 0.421350 0.421350 0.421350

The final result is 0.421350396475 after 33 function evaluations.

>>> print("%g %g" % (2*result, erf(1)))
0.842701 0.842701
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.integrate._quadrature.simpson scipy.integrate._quadrature.quadrature scipy.integrate._quadrature.romb scipy.integrate._quadrature.cumulative_trapezoid scipy.integrate._quadrature.fixed_quad scipy.integrate._quadrature.vectorize1 scipy.integrate._quadrature.romberg

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/integrate/_quadrature.py#739
type: <class 'function'>
Commit: