Skolan för
och datavetenskap

Numerical methods basic course II (Numeriska metoder grundkurs II), numfcl10

Info för omtenta mars 2011

Studenter i numfcl10 har rätt att gå upp på alla omtentor för DN1240. På frågor som kräver Matlab-programmering får man svara med ett Python-program om man vill.


For de grupper som har mojlighet kommer detta att ske i storgrupp under lunchtid 12.15-13.00, medan vi ocksa erbjuder individuella redovisningstillfallen for de grupper som inte kan hitta en mojlig tid bland de foreslagna.

- Varje grupp har 10 min pa sig att komma i ordning, ge sin presentation, samt overlamna till nasta grupp. Detta lamnar max ca. 8 min till sjalva presentationen.
- I storgrupper kommer det att finnas datorprojektor, for individuella redovisningar kan man anvanda laptop.
- Betyg ar endast godand eller icke godkand. Det gar ut pa att ni ska ge en presentation av er projektrapport. Allt behover inte inga i presentationen som ingar i rapporten, och ni valjer sjalva var ni vill lagga fokus.
- Det finns ingen utsedd opponent, men larare och andra studenter har mojlighet att stalla korta fragor.
- I samband med projektredovisningen ska en papperskopia av slutversionen av projektrapporten lamnas in. Detta är den rapport som ligger till grund ofor betygssattningen pa projektet.

Foljande lunchtider är avsatta or storgruppspresentationer (4 grupper vid varje tillfalle):

- ons 9/2, 12.15-13.00, rum 4523
- tor 10/2, 12.15-13.00, rum 4523
- fre 11/2, 12.15-13.00, rum 4523+1537
- man 14/2, 12.15-13.00, rum 4523
- tis 15/2, 12.15-13.00, rum 4523
- ons 16/2, 12.15-13.00, rum 4523
- fre 18/2, 12.15-13.00, rum 4523

Skriv till Kerstin Gustavsson ( som administrerar detta, och lamna namn pa gruppledare, vilket projekt ni har (1, 2 eller 3), samt vilka storgruppstider ni kan delta. Om ni inte har mojlighet att delta i nagot av de foreslagna tillfallena, ange nar ni kan komma for en individuell redovisning denna och nasta vecka aven lunchtidar bra). Kerstin aterkommer sedan med tid for er grupp att redovisa a snart som mojligt. Mvh, Johan Hoffman

Course evaluation

The course evaluation is now up. We are thankful if as many as possible answer to get a representative evaluation.


Projekt 1

Python template for project 1 available for download: with source terms
Python template for project 1 available for download: no source terms

To pass the PDE part (grade C) of the project it is enough to run a simulation using any of the PDE solvers of Module 6/game/ (,,,,...) and explain what happens in the simulation based on graphs or plots of the solution.

A simple derivation of the FEM-formulations can be downloaded here.


Tentan för denna kursomgång (F och CL) kommer att gå i salarna V23, V32, V33, V34, V35 på lördag den 18/12 kl 9-12.

Lösningar finns nu uppe: del1 och del2

Del 1 av tentan är nu rättad och resultaten finns inrapporterat i Rapp.

Del 2 av tentan är nu rättad och resultaten finns inrapporterat i Rapp.

89% av de som skrev tentan fick godkänt, bra jobbat!

Wednesday December 8, 2010

The attention for the course, focused on the study material, has had a negative impact on the students' learning as well as on the instructors' concentration. The faculty is fully committed to optimizing the learning outcome from the students' perspective, with full support from School management. We will work with the students to finish the course according to plan in a satisfactory way. To this end, the homepage has been somewhat restructured. A course analysis will be conducted as usual at the end of the course. In order for us to make the most of the many different issues that invariably arise when new concepts are introduced in traditional subjects, we ask for your cooperation in answering the coming course analysis questionnaire.

/Dean of CSC

On the media attention for this course

Articles have recently been published about this course in Ny Teknik, DN and Metro Teknik, connecting this course to the climate debate. This we find strange, since climate science is not part of the course.
This is a course about basic numerical methods, and computational mathematical modeling using differential equations. The course material discussed in media is available for inspection under "Course Material" below. A detailed reading list is available under course modules 1-6. Text material forming the basis for Modules 1-5 corresponds to the written exam, and is also available for download as "Excerpts...". We are very satisfied with this course material, and we have a good collaboration with the author Claes Johnson.
For discussions related to parts of the e-book "Mathematical Simulation Technology" that is not part of this course, we refer to the author Claes Johnson. In particular, analysis of climate models have not been a part of this course, or the parts of the book that is used in this course.

/Johan Hoffman, kursansvarig


  • [2011-12-10] Module 6 is now up, together with an updated project description (they are both examined as part of the project report). Module 6 includes a number of prototype solvers you can use in the project.
  • [2011-12-08] A link to the course material can be found under the section Course material.
  • [2011-12-08] Lecture notes for all lectures are now on the homepage (the last lecture notes include solutions of preparation exam).
  • [2011-12-08] The deadline for the submission of the project report is extended until January 28, 2011. More details and dates concerning the peer review and oral presentations will follow shortly. The project description has been updated, the requirements for the report will be finalized soon.
  • [2011-12-06] A preparation exam is now available under Course material, together with a list of concepts/methods.
  • [2011-12-01] Lecture notes for lecture 9 available (including simple but general FEM program "")
  • [2011-11-30] Module 5 is now available below, may be updated during the week.
  • [2011-11-19] Full version of module 4 is now available below.
  • [2011-11-16] E-book updated, together with excerpts: some bug fixes for chapter 39 "Particle-spring systems".
  • [2010-11-16] Minor corrections in module 3: Fixed handling of "t" and "t0" in the game, updated example usage of timestep() in the function documentation, minor typos in the module text.
  • [2010-11-12] Schedule for module examination is updated, see "Course schedule", in particular examination of Module 6 is now included in the project and will not be part of the written examination, see "Examination" for details.
  • [2010-11-11] The course E-book has been updated, and an excerpt from the E-book is now available containing only the chapters forming the basis for modules 1-5: download below under "Course literature".
  • [2010-11-09] All students attending this course must register themselves as "active" on the KTH Rapp System, no later than Friday, November 12.
  • [2010-11-09] Module 3 has been updated with some clearer instructions.

Above you see a number of examples of solutions to differential equations from different application areas.

Ongoing research projects at the NA department

Course description

Integrals and differential equations are basic models in science, that often are too complex to solve using analytical techniques. The computer revolution of the last century has open up new exciting possibilities for mathematical modeling, by solving equations using numerical methods.
In this course you learn how to use a computer to solve integrals, algebraic and differential equations from physics and engineering, and you also practice how to apply these equations to model real world phenomena. Computational methods typically result in approximate solutions, and in this course we present techniques for estimating and controlling the numerical error in a computation.
Models from physics are presented in the form of particle models, ordinary and partial differential equations. Explicit numerical methods can take the form of simple time stepping algorithms like Euler's method, whereas implicit methods result in algebraic systems of equations that need to be solved, for example using Newton's method. Approximation of a complex function by a combination of simple functions is central, for example in the form of finite element methods for partial differential equations.
The goal of this course is that you should learn basic theory for numerical methods, practise the implementation of the methods, and use these programs to simulate real world phenomena. Detailed goals for the course are given in respective course module.


Course contact email:

Discussion forum at Bilda

Office hours: see teachers below.


Johan Hoffman ( [office hours: Mondays 10:30-11:30]
Johan Jansson ( [office hours: Tuesdays 13:30-14:30 and Fridays 12:00-13:00 in lab room Orange]
Ninni Carlsund (
Katarina Gustavsson ( [office hours: Wednesday 15:30-16:30]
Mattias Sandberg ( [office hours: Fridays 15:00-16:00]

Rodrigo Vilela De Abreu ( [office hours: Wednesdays 8:30-9:30]
Jeannette Spuhler ( [office hours: Fridays 13:30-14:30]
Oana Marin ( [office hours: Mondays 15:30-16:30]
Jelena Popovic ( [office hours: Wednesdays 15:00-16:00]

Course material

The course uses a set of chapters from a draft of the e-book "Body and Soul, Mathematical Simulation Technology", by Johan Jansson and Claes Johnson. A specification of the chapters included in this course can be found here.

Preparation for the written exam

List of concepts and methods for the written exam.

A very short summary sheet with some of the methods used in the course and their properties.

A preparation exam. Short solutions for the first part..

Old exams for other DN1240 courses (some differences, about 50% of the questions map directly between the courses)

Get started with modules pdf

Module 1: Fundamental theorem of calculus, time stepping pdf zip
Module 2: Function approximation pdf zip
Module 3: ODE I (explicit/implicit methods) pdf zip
Module 4: ODE II (systems) pdf zip, Updated version of
Module 5: Fixed-point iteration, systems and non-linear equations pdf zip
Module 6: PDE pdf zip

Checking system for module questions

Live DVD/USB image, login: simtek, password: simtek. NB! If you boot from a DVD, nothing you do is saved, and will be lost when you turn off the computer, so save your work to a USB stick or similar.

Project pdf

Part A: ODE modeling
Part B: PDE modeling, first part
Part C: PDE modeling, second part

Supplementary course DN1242 (only F)

Part D: extra problems (error analysis) for project

Python programming reference literature

The course literature from the introductory computer science courses based on Python can be used as reference:

Tutorials/reference sheets for Python modules (Numpy/Pylab) used in the course: The course is based on Python. For students interested to extend their programming skills to Matlab, the following books are available at the CSC student expedition:
  • Gerd Eriksson, Numeriska algoritmer med Matlab (50 kr)
  • Matlab 7 i korthet (40 kr)

FEniCS/DOLFIN documentation (used for PDE/FEM and mesh representation in the course)

The FEniCS project is an open source project for the automation of solving (partial) differential equations (PDE) by the finite element method (FEM). In this course you will learn the basic concepts of FEM, and be able to understand how FEniCS works "under the hood". You will then use FEniCS to build PDE solvers for the basic models presented in the course. FEniCS consists of several different components/sub-projects, the one you will interact with is called DOLFIN, and is the C++/Python interface for solving problems.

Below some documentation to FEniCS/DOLFIN is presented. Try to use the built-in Python help() function as much as possible, and browse the documentation below to get an overview of the system (this will also be presented in the lectures), or to find a specific detail which for some reason is unavailable in the Python help.

  • The DOLFIN user manual gives a basic overview of what DOLFIN is and its components. Could be slightly outdated and incomplete, since it's being replaced by a more comprehensive documentation project. The code examples for solvers are primarily in C++, and can be skipped.
  • The Programmer's reference gives a complete index of all the classes, functions and definitions in DOLFIN. Is a C++ reference, but the class/function names are typically the same in C++ and Python. Should be used together with Python's help() function.
  • The FEniCS Python tutorial gives a comrehensive tutorial for solving basic PDEs with FEniCS in Python. The assumed background knowledge is too advanced for this course, but for those who are interested, it could give details about features you are interested in.


Examination by teacher (in connection with Lab sessions) according to deadlines below give bonus points for written exam:

Module 1: 0.5 + 0.5 bonus point
Module 2: 0.5 bonus point
Module 3: 0.5 bonus point
Module 4: 1.0 bonus point
Module 5: 1.0 bonus point

Total: 4 bonus points

Lab work and examination within modules can be done in groups of 2, projects can be done in groups of 2-4, but each student should individually be able to answer to the full content.

Basic examination [LABA 1.5 hp + TEN1 3.0 hp]

  • Module examination (each module separately): see course schedule (below)
    [pass/fail - with bonus points for written exam at "pass" in time for deadline]
  • Written examination (based on Modules 1-5): December 18
    [graded A-F]
Examination of Module 6 is included in the project, and will not be part of the written examination.

Project examination [LABB 1.5 hp]

  • Submission of project reports (project parts A,B,C): see course schedule
  • Peer review report (1 page) on the reports on part A+B+C of another group: see course schedule
  • Submission of final version of report (Project A+B+C): see course schedule
    [graded A-F]
  • Oral examination of final report (seminar): see course schedule

  • Supplementary course DN1242 [1.5 hp]: extra submission Part D for project: see course schedule
    [graded A-F]

Assessment criteria for project report.

Final course grade = (2.0*TEN1 + 1.0*LABB)/3.0 (A-E = 5-1)

Course schedule

KTH official course schedule
Classroom directions

Week 1 (v43)

  • Lecture (F+CL), Monday 25/10, 08:15-10:00, M1
    Intro Module 1 + admin
    Intro lecture slides
    lecture notes
  • Lab (F), Tuesday 26/10, 10:15-12:00, Orange, Gul, Brun
    Module 1
  • Lab (CL), Wednesday 27/10, 08:15-10:00, Grön, Brun
    Module 1
  • Lecture (F+CL), Thursday 28/10, 08:15-10:00, M1
    Module 1
    lecture notes: f2-1, f2-2, f2-3, f2-4,
  • Excercise (F+CL), Friday 29/10, 10:15-12:00, F: E51-E53 CL: Q36
    Module 1
    Material from the CL-exercise.
Week 2 (v44)
  • Lecture (F+CL), Monday 1/11, 08:15-10:00, M1
    Module 2
    lecture notes: f3-0, f3-1, f3-2, f3-3, f3-4,
  • Lab (CL), Monday 1/11, 10:15-12:00, Grön, Brun
    Module 2
    Exam Module 1: 4.1-4.3
  • Lab (F), Tuesday 2/11, 10:15-12:00, Orange, Gul, Brun
    Module 2
    Exam Module 1: 4.1-4.3
  • Lecture (F+CL), Wednesday 3/11, 08:15-10:00, M1
    Module 3
    lecture notes: f4-0, f4-1, f4-2, f4-3, f4-35,
  • Excercise (F+CL), Thursday 4/11, 08:15-10:00, F: E51-E53, CL: Q36
    Module 2
    Material from the CL-exercise.
Week 3 (v45)
  • Lab (CL), Monday 8/11, 13:15-15:00, Grön, Brun
    Module 3
    Exam Module 1: 4.4-4.5
  • Lab (F), Tuesday 9/11, 10:15-12:00, Orange, Gul, Brun
    Module 3
    Exam Module 1: 4.4-4.5
  • Lecture (F+CL), Wednesday 10/11, 08:15-10:00, M1
    Module 3
    Stability lecture slides
    lecture notes: f5-1, f5-2, f5-3, f5-4, f5-5, f5-6, f5-7, f5-8, f5-9, f5-10,11,
  • Excercise (F+CL), Thursday 11/11, 13:15-15:00 , F: E51-E53, CL: Q36
    Module 3
    Material from the CL-exercise.
Week 4 (v46)
  • Lecture (F+CL), Monday 15/11, 13:15-15:00, Q1
    Module 4: ODE systems: elastic bodies, wave propagation, gravitation; stability, error analysis
    lecture notes: f6-1,2
  • Lab (F), Tuesday 16/11, 10:15-12:00, Orange, Gul, Brun
    Module 3+4
    Exam Module 2
  • Lab (CL), Thursday 18/11, 10:15-12:00, Orange, Grön
    Module 3+4
    Exam Module 2
Week 5 (v47)
  • Lecture (F+CL), Monday 22/11, 10:15-12:00, Q1
    Module 5
    lecture notes: f7
  • Excercise (F+CL), Wednesday 24/11, 10:15-12:00, F: E51-E53, CL: Q36
    Module 4
  • Lab (CL), Thursday 25/11, 08:15-10:00, Grön, Brun
    Module 5, Exam Module 3
  • Lab (F), Thursday 25/11, 13:15-15:00, Orange, Gul, Brun
    Module 5, Exam Module 3
Week 6 (v48)
  • Lecture (F+CL), Monday 29/11, 10:15-12:00, Q1
    Module 6
    lecture notes: f8
  • Excercise (F+CL), Tuesday 30/11, 13:15-15:00, F: E51-E53, CL: Q36
    Module 5
  • Lecture (F+CL), Wednesday 1/12, 10:15-12:00, M1
    Module 6
    lecture notes: f9
  • Lab (F), Thursday 2/12, 08:15-10:00, Orange, Gul, Brun
    Module 6, Exam Module 4
  • Lab (CL), Thursday 2/12, 13:15-15:00, Grön, Brun
    Module 6, Exam Module 4
Week 7 (v49)
  • Lecture (CL), Monday 6/12, 10:15-12:00, V1
    Module 6
  • Lecture (F), Monday 6/12, 13:15-15:00, V1
    Module 6
    lecture notes: f10
  • Lab (F+CL), Tuesday 7/12, 10:15-12:00, Röd, Gul, Grön, Orange, Brun
  • Lecture (F), Wednesday 8/12, 10:15-12:00, V1
    Preparation for written exam
  • Lecture (CL), Wednesday 8/12, 13:15-15:00, V1
    Preparation for written exam
    lecture notes: f11
  • Friday 10/12
    Exam Module 5
Week 8 (v50)
  • Written exam (F+CL), Saturday 18/12, 09:00-12:00
Week 9 (January, 2011)
  • Lecture (F+CL), Tuesday 18/1 08:15 in D1
    Project tutorial
    lecture notes: f12
  • Supervision (F+CL), Thursday 20/1
    Project supervision in smaller groups
Week 10 (January, 2011)
  • Lab (F+CL), Tuesday 25/1, 08:15-10:00, Gul, Grön, Brun (Project supervision)
  • Friday 28/1 Exam Proj A+B+C(+D): submission of partial report
  • Thursday 3/2 Exam: submission of peer review report
  • Exam: oral presentation in seminar + final report
Copyright © Sidansvarig: Johan Hoffman <>
Uppdaterad 2011-03-09