nl en

Numerical Recipes in Astrophysics


From 2024/2025 onwards, this course will be split into two parts.

Admission requirements

Students should be experienced with programming in either C/C++ or Python. Knowledge of calculus at the bachelor’s level is also required. In terms of the Leiden Astronomy bachelor's curriculum, the prerequisites for this course are Programming NA and Analyse 3 (NA).


In this course you will learn how and why some of the most powerful and broadly used algorithms in astrophysics work and gain a deeper understanding of numerical methods.This will allow you to identify the right tool for the job for whatever computational problem you may encounter in astrophysics, and to program more effectively, whether you are fitting data, sampling a distribution, integrating orbits or optimizing your computational model.

During the lectures we will discuss numerics and consider and derive specific algorithms that are useful in astrophysics. During the problem classes students will work together on applying this knowledge to a computational problem through coding.

The topics covered in the course include:

  • Numerical error and precision

  • Solving linear equations

  • Solving differential equations

  • Inter- and extrapolation

  • Numerical integration and differentiation

  • Random numbers and distribution sampling

  • Root finding, minimization and maximization

  • Fast Fourier transforms and applications

  • Modelling data

Course objectives

Upon completion of this course you will be able to judge which numerical algorithm or tool is right for any computational problem typically encountered in

In specific, after this course, you will be able to:

  • Evaluate the outcomes of computational codes

  • Construct an efficient computer program

  • Solve a wide array of astrophysical problems


See Astronomy master schedules

You will find the timetables for all courses and degree programmes of Leiden University in the tool MyTimetable (login). Any teaching activities that you have sucessfully registered for in MyStudyMap will automatically be displayed in MyTimeTable. Any timetables that you add manually, will be saved and automatically displayed the next time you sign in.

MyTimetable allows you to integrate your timetable with your calendar apps such as Outlook, Google Calendar, Apple Calendar and other calendar apps on your smartphone. Any timetable changes will be automatically synced with your calendar. If you wish, you can also receive an email notification of the change. You can turn notifications on in ‘Settings’ (after login).

For more information, watch the video or go the the 'help-page' in MyTimetable. Please note: Joint Degree students Leiden/Delft have to merge their two different timetables into one. This video explains how to do this.

Mode of instruction

  • Lectures

  • Exercise classes

Assessment method

In addition to a written theory exam, there will be four coding exercise sets (roughly one every three lectures) that will count towards your final grade, under the condition that you achieved a passing grade on the exam. The exam will count for 50%, the four hand-in exercise sets collectively constitute the final 50%.

Reading list

  • Numerical Recipes: The Art of Scientific Computing, Third Edition (W.H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery), ISBN: 9780521880688 (optional)


From the academic year 2022-2023 on every student has to register for courses with the new enrollment tool MyStudyMap. There are two registration periods per year: registration for the fall semester opens in July and registration for the spring semester opens in December. Please see this page for more information.

Please note that it is compulsory to both preregister and confirm your participation for every exam and retake. Not being registered for a course means that you are not allowed to participate in the final exam of the course. Confirming your exam participation is possible until ten days before the exam.

Extensive FAQ's on MyStudymap can be found here.


Lecturer: Dr. M.P. (Marcel) van Daalen


Soft skills
After completing this course you will be able to:

  • Work collaboratively on numerical problems

  • Program effectively