Lecture Notes

This course makes use of Athena, MIT's UNIX-based computing environment. OCW does not provide access to this environment.

1–2 Introduction: Problem formulation, algorithm development, algorithm implementation, and algorithm verification. Structure and documentation

Lec #1 (PDF)

Lec #2 (PDF)

Lec #1

Class introduction; overview of languages; program development.

Lec #2

Discussion of aspects of computers and their operation. An example is given of program development for a simple case of computing the area of a figure.

Links that are in the notes for this lecture:

What is big-endian?

Green's Theorem

The IEEE standard for floating point arithmetic

Minor links for those interested:

Velocity Engine

3–7 FORTRAN: "Formula Translation". Program creation, compilation and linking, variables and parameters, flow control, subroutines and functions. Structure and documentation. Use of libraries, internal and external communication, and interaction with other languages. FORTRAN: implementation issues: compilation errors, segmentation violations, Not-a-Number (NaN), Input/Output (IOSTAT) errors, Runtime errors. Transportable code, standard extensions. FORTRAN 90 differences and similarities to FORTRAN 77

Lec #3 (PDF)

Lec #4 (PDF)

Lec #5 (PDF)

Lec #6 (PDF)

Lec #7 (PDF)

Lec #3

Started FORTRAN (Formula Translation). Went through the basic elements that make up this language. An on-line version of a FORTRAN 77 manual can be found here. In reading these notes, you should think about operations you want to do and what command or commands do you use to do that. The list on FORTRAN intrinsic functions can be found here.

Other links to look at:

The FORTRAN Programming Language

Wikipedia Definition of FORTRAN

Lec #4

Continued with showing the elements of the FORTRAN and more detail on the typically encountered features of the language. Topics covered: subroutines and functions; intrinsic functions; constants and variables; input output with open/close, read/write, formats; character strings.

The links in this lecture were to FORTRAN and intrinsic functions, which are given above. The programs poly_area.f (F) and vars.f (F) are also used. (To download programs, right click on link and "save link target as". With one-button mouse use <ctrl><click> on link). On Athena to use these programs:

ssh –X linerva.mit.edu
%add fortran
%f77 poly_area.f –o poly_area
% poly_area

To use the f90 compiler on Athena, use add sunsoft.

Other sources of information:

Safari Book Online - O'Reilly series of books on programming (available with MIT certificate)

FORTRAN Resources - useful link with lots of information on FORTRAN in its various forms

Lec #5

Continued with FORTRAN. Character strings, control statements if and do; other commands such as include, common, parameter. More programs will be developed in class including simple output and computing root-mean-square scatter of randomly generated numbers.

Lec #6

Finish up FORTRAN. Compile, linking and runtime errors and miscellaneous topics. Practice with using the language.

Lec #7

Examines the changes that were made in FORTRAN90 with the introductions on more modern concepts in programming languages.


C for scientific uses. Representation of data through arrays, pointers, and data structures. Function calls, argument passing and scoping rules, IO, profiling, system calls, and signals

C++ objects. Encapsulation and inheritance, polymorphic operators

Lec #8 (PDF)

Lec #9 (PDF)

Lec #10 (PDF)

Lec #11 (PDF)

Lec #8

Start of C-language programming. History, variables and executable statements.

Additional links for this class:

Basic C Lecture

Basic C: C and FORTRAN 77 Syntax

Basic C: New Features

Lec #08 Exercises.

Lec #9

Continuation of C. Covering Examined C-pointer; file Input/Output and the routines for formatted reads and write; compiling C routines; the C preprocessor cpp; structures in C; memory management.

Lec09_pnt.c (C) is demonstration of pointers

Lec #10

Finish structures and memory management in C. Start of C++. Inheritance and overloading in C++.

C and C++ routines used in class launch.c (C)

Ball.h (H) and launch.cc (CC)

C++ zip files:

ustring.zip (ZIP) (The ZIP file contains: 2 .h files, 1 .cc file, and 1 .txt file.)
launch.zip (ZIP) (The ZIP file contains: 1 .cc file, 1 .h file, and 1 .txt file.)
coord.zip (ZIP) (The ZIP file contains: 1 .cc file, 1 .h file, and 1 .txt file.)

Lec #11

Finish up of C++ looking at classes, inheritance and overloading. We will look more carefully at the code linked in Lec #10. Homework number 3 has been set.

Example pieces of code for C and comparison to FORTRAN:

C basics (PDF), area.c (C), hello.c (C)
C FORTRAN compare (PDF)
C pointers (PDF)


Mathematica. What it is and what it can do; structure of Mathematica; symbols, exact numbers, and machine numbers; lists, vectors, and matrices

Working with Mathematica: numerical calculations, symbolic calculations, and graphics. Importing and exporting information

Lec #12 (PDF)

Lec #13 (PDF)

Lec #12

Start of Mathematica. These lectures are accompanied by a Mathematica Notebook that shows example of concepts presented in the notes.

Lec 12 NB (NB)

Introductory screen casts from Wolfram:


Making Models

Use of the demonstrations site

Featured Demonstrations

Lec #13

Continuation of Mathematica. These lectures are accompanied by a Mathematica notebook that shows example of concepts presented in the notes.

Lec 13 NB (NB)


MATLAB®. "Matrix Laboratory". MATLAB syntax, workspace, variables. Script M-files, IO, control flow, debugging, and profiling tools. Object-oriented programming

MATLAB applications, polynomials, interpolation, integration, differentiation, ODE. Graphics, 2-D, 3-D, Graphical User Interface (GUI)

Lec #14 (PDF)

Lec #15 (PDF)

Lec #16 (PDF)

Lec #17 (PDF)

Lec #14

MATLAB: introductory lecture on MATLAB introducing system, variable types, control and functions. The following MATLAB M-files are used in the lecture:

Lec01_01.m (M)
Lec01_02.m (M)

Lec #15

MATLAB: path command, variables, file IO and dialog boxes. The following M-files are used:

Lec02_01_file.m (M)
Lec02_02_db.m (M)
Lec03_01_file.m (M)

The data for these M-files can be found in MatData. A tar file with the data is TSeries.tar (TAR) (The TAR file contains: 10 .dat1 files, 10 .dat2 files, and 10 .dat3 files.)

Lec #16

MATLAB: graphics handles and animation of figures. The following M-files are used in class:

Lec03_movie.m (M)
MATLAB/per_func.m (M)

Lec #17

MATLAB: final class on GUI construction and use. The following M-files are used (along with the data from MatData: a tar file with the data is TSeries.tar (TAR) (The TAR file contains: 10 .dat1 files, 10 .dat2 files, and 10 .dat3 files.)

Basic GUI layout:

GPSanal.m (M)
gpsguio.m (M)

18–19 Python scripting language program

Lec #18 (PDF)

Lec #19 (PDF)

Lec #18

Python I: Python Language Basics

Python Programming Language—Official Website
Python v2.7.3 documentation
The Python Tutorial

Lec #19

Python II: Python Advanced Usage

20 Advanced graphics in MATLAB, 3-D representation and exportable animations Lec #20 (PDF)

Lec #20

3-D graphics in MATLAB.

Examples are:

Lec20_3D.m (M)

Lec20_TotalANC.avi (AVI)

Lec20_RateANC.avi (AVI)

Dif_1006_0407.fig (FIG)

21 Ordinary differential equation (ODE) solutions used MATLAB and Mathematica Lec #21 (PDF)

Lec #21

Solution to differential equations in Mathematica and MATLAB.

Mathematic notebook: 12.010.Lec18_NDsolve.nb (NB)

MATLAB solutions are:

Lec21_ODE.m (M)

Lec21_animate.m (M)

Lec21_hit.m (M)

Lec21_bacc.m (M)


Advanced Topics: Parallel computing with large memory and large numbers of CPUs

Advanced topics: Parallel MATLAB

Discussion of final projects

Order of the presentations will be decided in the last class


Lec #22

Introduction of class project. Graphics formats and issues about vector and pixel based graphics.

GMT graphics package for mapping applications

Lec #23

Class projects: graphics processor unit (GPU) processing. Statistics and random number generators. M-file randtest.m (M) is implementation of an LCG random number generator.

Lec #24

Graphics: review of common graphics program. Graphics with spreadsheets, Kaleidagraph, Generic Mapping Tool (GMT). Numerical methods: introduction to numerical methods

Statistical analysis tools including generation random variables and correlated random numbers

The order of the class presentations will be decided in this class and posted after the class.

Cuda Zone

MATLAB Implementation

  Final Project Presentations