Skip to content
Snippets Groups Projects
Forked from agnumpde / dune-tectonic
129 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
trapezoidal.py 267 B
# x: vector of domain values
# y: vector of function values f(x)
def trapezoidal(x, y) :
    # returns integral of (x, y = f(x)) calculated with trapezoidal rule 
	res = 0.0
	for i in range(1, len(x)) :
		res += (x[i] - x[i - 1]) * (y[i] + y[i - 1]) / 2.0
	return res