15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.4.2 Integrating functions, given fixed samples<br />

SciPy Reference Guide, Release 0.8.dev<br />

trapz(y[, x, dx, axis]) Integrate along the given axis using the composite trapezoidal rule.<br />

cumtrapz(y[, x, dx, Cumulatively integrate y(x) using samples along the given axis and the composite<br />

axis])<br />

trapezoidal rule.<br />

simps(y[, x, dx, axis,<br />

even])<br />

Integrate y(x) using samples along the given axis and the composite<br />

romb(y[, dx, axis,<br />

show])<br />

Romberg integration using samples of a function<br />

trapz(y, x=None, dx=1.0, axis=-1)<br />

Integrate along the given axis using the composite trapezoidal rule.<br />

Integrate y (x) along given axis.<br />

See Also:<br />

Parameters<br />

y : array_like<br />

Input array to integrate.<br />

x : array_like, optional<br />

If x is None, then spacing between all y elements is dx.<br />

dx : scalar, optional<br />

If x is None, spacing given by dx is assumed. Default is 1.<br />

axis : int, optional<br />

Returns<br />

out : float<br />

sum, cumsum<br />

Notes<br />

Specify the axis.<br />

Definite integral as approximated by trapezoidal rule.<br />

Image [R3] illustrates trapezoidal rule – y-axis locations of points will be taken from y array, by default x-axis<br />

distances between points will be 1.0, alternatively they can be provided with x array or with dx scalar. Return<br />

value will be equal to combined area under the red lines.<br />

References<br />

[R2], [R3]<br />

Examples<br />

>>> np.trapz([1,2,3])<br />

4.0<br />

>>> np.trapz([1,2,3], x=[4,6,8])<br />

8.0<br />

>>> np.trapz([1,2,3], dx=2)<br />

8.0<br />

>>> a = np.arange(6).reshape(2, 3)<br />

>>> a<br />

array([[0, 1, 2],<br />

[3, 4, 5]])<br />

3.4. Integration and ODEs (<strong>scipy</strong>.integrate) 183

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!