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.

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

See Also:<br />

Parameters<br />

function : callable<br />

a : float<br />

b : float<br />

Returns<br />

results : float<br />

Function to be integrated.<br />

Lower limit of integration.<br />

Upper limit of integration.<br />

Result of the integration.<br />

fixed_quad<br />

Fixed-order Gaussian quadrature.<br />

quad<br />

Adaptive quadrature using QUADPACK.<br />

dblquad, tplquad, romb, simps, trapz<br />

cumtrapz<br />

Cumulative integration for sampled data.<br />

ode, odeint<br />

References<br />

[R1]<br />

Examples<br />

Integrate a gaussian from 0,1 and compare to the error function.<br />

>>> from <strong>scipy</strong>.special import erf<br />

>>> gaussian = lambda x: 1/np.sqrt(np.pi) * np.exp(-x**2)<br />

>>> result = romberg(gaussian, 0, 1, show=True)<br />

Romberg integration of from [0, 1]<br />

Steps StepSize Results<br />

1 1.000000 0.385872<br />

2 0.500000 0.412631 0.421551<br />

4 0.250000 0.419184 0.421368 0.421356<br />

8 0.125000 0.420810 0.421352 0.421350 0.421350<br />

16 0.062500 0.421215 0.421350 0.421350 0.421350 0.421350<br />

32 0.031250 0.421317 0.421350 0.421350 0.421350 0.421350 0.421350<br />

The final result is 0.421350396475 after 33 function evaluations.<br />

>>> print 2*result,erf(1)<br />

0.84270079295 0.84270079295<br />

182 Chapter 3. Reference

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

Saved successfully!

Ooh no, something went wrong!