Astronomy 415: Fall 2022

Computational Astrophysics

Milky Way in CDM and WDM (Polisensky & Ricotti 2011) 

This course will provide the astronomy student with a basic knowledge of numerical methods in astrophysics. By the end of the course students should be comfortable working in a Unix environment, compiling and running codes, and employing a variety of visualization techniques to analyze the results. This process will be motivated by concrete examples of modern problems in astrophysics that demand numerical approaches.

The exact details of the material covered will depend on the existing level of computer sophistication among the class participants. However, in broad outline the major course topics will include linear algebra, root finding, least-square fitting, Monte Carlo methods, numerical integration, N-body methods, fluid dynamics, FFTs and time-series analysis.


    Instructor:  Massimo Ricotti
    TA: Haoying Dai 
    Class:       ATL 2428
    Lectures:    Tuesday and Thursday from 2:00pm to 2:15pm
    First class: Tue Aug 30 
    Last  class: Thu Dec 08

What's New?

Contact info and Notes

Course Outline

The Syllabus is available on ELMS and here: Syllabus.

DateLectureReading (NRiC)Lecture NotesHomework

#1Aug 30Introduction to the course--Intro Architecture
#2Sept 1Computer architectureComputer architectureclass02.pdf
#3Sept 6Introduction to UNIXtutorial-Intro Programs
#4Sept 8Introduction to C1.1-1.2, tutorial-
#5Sept 13Examples in C and debugger 1.1-1.2, tutorialGDB.pdf
#6Sept 15Parellel Computing (CPU and GPU)tutorial-
#7Sept 20Data representation1.3class05.pdf/pres05.pdfHW1 due
#8Sept 22Linear algebra, part 1 (Gauss-Jordan elimination)2.0-2.3class06.pdf/pres06.pdf
#9Sept 27Linear algebra, part 2 (LU & SVD decomposition)2.4-2.6class07.pdf/pres07.pdf
#10Sept 29 Root finding in 1-D9.0-9.1, 9.4, 9.6class08.pdf/pres08.pdf
#11Oct 04Root finding in multi-D, and numerical differentiation5.7class09.pdf/pres09.pdfHW2 due
#12Oct 06Statistics and the K-S test14.0-14.3class10.pdf/pres10.pdf
#13Oct 11Least-squares fitting15.0-15.2, 15.4-15.5class11.pdf/pres11.pdf
#14Oct 13Random numbers and cryptography7.0-7.2class12.pdf/pres12.pdf
#15Oct 18Numerical integration7.6, 4.0-4.4, 4.6class13.pdf/pres13.pdfHW3 due
#16Oct 20Integration of ODEs, part 1 (IVPs)16.0-16.1class14.pdfi/pres14.pdf
#17Oct 25Integration of ODEs, part 2 (leapfrog)-class15.pdf/pres15.pdf
#18Oct 27Integration of ODEs, part 3 (stiff ODEs & 2-pt BVPs)16.6, 17.0class16.pdf/pres16.pdfHW4 due
#19Nov 01Integration of ODEs, part 4-class17.pdf/pres17.pdf
#20Nov 03N-body techniques, part 1 -class18.pdf/pres18.pdf
#21Nov 08N-body techniques, part 2 (PP)19.0, 19.4-19.6class19.pdf/pres19.pdfHW5 due
#22Nov 10N-body techniques, part 3 and 4 (PM)-class20.pdf/pres20.pdf class21.pdf/pres21.pdf
#23Nov 15Integration of PDEs, part 1 (ell & hyp) 19.2class22.pdf/pres22.pdf
#24Nov 17 Integration of PDEs, part 2 (hyp & par)19.2class23.pdf/pres23.pdfHW6 due
#25Nov 22Fluid dynamics, part 1 (eqns)19.3class24.pdf/pres24.pdf
-Nov 24no class Thanksgiving--
#26Nov 29Fluid dynamics, part 2 (methods)-class25.pdf/pres25.pdf
#27Dec 01Term project presentations--Term Project Due
#28Dec 06 Term project presentations--
#29Dec 08 Term project presentations--
-Likely not coveredFourier transform, part 1 (intro)12.0-12.1, 19.4class26.pdf
-Likely not coveredFourier transform, part 2 (FFT)12.2, 13.0-13.2, 13.4class27.pdf
-Likely not coveredOther topics-class28.pdf


There are no required textbooks
Numerical recipes [3rd Edition], by Press, W.H. et al.

Course Grading

The homework is the most important part of the class. In class participation is strongly encouraged.

Class Survey

Survey on Computer Proficiency


Homework will be assigned every week or every other week and posted on ELMS. Their due dates will be announced at the time they are assigned. On the due date the students will be expected to turn in their homework in class. The homework turned in will be graded and returned to the students. I will provide solutions (also posted on ELMS) and discuss them in class.

Link to Numerical Recipes sources in C and in FORTRAN: it is preferable to compile the recipes as separate files rather than cut and paste the functions into your source code.

Note that in order to use NRiC routines the easiest way is to include nr.h header file and nrutil.c and nrutil.h to use vectors and matrices. You can find these files here.

Homework assigned: posted on ELMS

You can turn in your homework either by email or using Dropbox. If you do not have yet a Dropbox account please open one using this link: Dropbox personal referral link (using this link we will both get extra free storage). Once you have dropbox account create a directory within Dropbox named ASTR415_22_Lastname, and share it with me using the following email (mricotti at


Old Class Notes

    These notes were part of the "first edition" of this course (ASTR688N) in Spring 2001.

Useful Links

Tutorial on Python: PYTHON TUTORIAL

Numpy: Numpy reference

Matplotlib: Matplotlib reference


Debugger's Links: Using GNU's GDB Debugger Debugging Floating Point Exceptions

OpenMP links: OpenMP Tutorial

Wiki OpenMP

CUDA and GPU computing: Nvidia webpage with examples to download Wiki OpenCL Wiki CUDA

Check out the UMD Astronomy Computing Wiki!

(In the listings below, a "W" link indicates a Wikipedia entry on the topic is available.)

Online Tutorials Free Software General Stuff