blob: 0e20a6c331c83f5849827a255d6ad03476d6b548 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
def f(double x):
return x ** 2 - x
def integrate_f(double a, double b, int N):
cdef int i
cdef double s
cdef double dx
s = 0
dx = (b - a) / N
for i in range(N):
s += f(a + i * dx)
return s * dx
|