In [25]:
import diffeq_midpoint as p1

diffeq_midpoint

Taylor Patti

Uses the midpoint integration rule along with numpy vectors to produce a continuous vector which gives integral data for an array of prespecified points.

Here we use it to integrate sin from 0 to pi.


In [26]:
function_call = p1.vector_midpoint(p1.np.sin, 0, p1.np.pi, 10000)
print function_call[1][-1]


1.99999990953

Observe the close adherance to the actual value of this cannonical value.

We can also call it at a different value of x. Let's look at the value of this integral from 0 to pi over 2. Again, the result will have strikingly close adherance to the analytical value of this integral.


In [28]:
print function_call[1][5000]


1.00031411403