Skip main navigation

Hands-on: Numerical integration

Vectorised numerical integration using the Riemann sum.
© CSC - IT Center for Science Ltd.

We continue studying vectorized operations with numerical integration.

Source code for this exercise is located in numpy/integration/

A simple method for evaluating integrals numerically is by the middle Riemann
sum

[S = int_a^b f(x) dx = sum_{i=1}^n f(x’_i) Delta x]

with

[x’_i = (x_i + x_{i-1}) / 2 ; x_0 = a, x_n = b]

Calculate the integral in the interval [0,π/2] and investigate how much the
Riemann sum of sin differs from 1.0. Avoid for loops. Investigate also how the results changes with the choice of Δx.

© CSC - IT Center for Science Ltd.
This article is from the free online

Python in High Performance Computing

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education