"unexpected EOF while parsing"

232 Views Asked by At

I'm trying to implement this part of code. The error "unexpected EOF while parsing" occurs in the last line. I tried various things but can't seem to find what is wrong (T^T)

def simpsonsumme(f, a, b, N):
    X = np.linspace(a, b, N)
    if N%2 == 0:
        return ((b-a)/(3*(N)) * ( f(0) + 4*np.sum(f(X[1:-1:2])) + 2*np.sum(f(X[2:-2:2])) + f(N)))

(I'm trying to implement the simpsons rule. f is a function; [a,b] the intervall of the integration and N the number of sections in [a,b], maybe that is somewhat helpful context)

Thank you in advance!

0

There are 0 best solutions below