PHYS 5P10 - Introduction to Scientific Computing

  • Also offered as MATH 5P69 and PHYS 4P10; the expectations for assignments and projects are different.
  • See for administrative details
  • This course covers
    • A common toolbox
      • interacting with the OS; CLI vs GUI
      • Linux as a collection of small tools + pipes between them
      • the basics of programming: shell, C, scripting languages
      • code development: edit, compile, run, make and Makefile structure, elementary debugging, linking to program libraries
      • visualization with gnuplot and other graphing tools
    • Numerical methods
    • Case studies/projects
Most problem solving in science and engineering uses scientific computing. A scientist might devise a system of differential equations to model a physical system, then use a computer to calculate their solutions. An engineer might develop a formula to predict cost as a function of several variables, then use a computer to find the combination of variables that minimizes that cost. A scientist or engineer needs to know science or engineering to make the models. He or she needs the principles of scientific computing to find out what the models predict.

Scientific computing is challenging partly because it draws on many parts of mathematics and computer science. Beyond this knowledge, it also takes discipline and practice. A problem-solving code is built and tested procedure by procedure. Algorithms and program design are chosen based on considerations of accuracy, stability, robustness, and performance. Modern software development tools include programming environments and debuggers, visualization, profiling, and performance tools, and high-quality libraries. The training, as opposed to just teaching, is in integrating all the knowledge and the tools and the habits to create high quality computing software “solutions.”

Principles of Scientific Computing, by David Bindel and Jonathan Goodman

Linux is the (invisible) operating system layer

  • Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs.
  • Most of the world’s servers run some variant of Unix or Linux. The Android phone and the Kindle run Linux.
  • Linux is an OS core written from scratch by Linus Torvalds and others, and ...
  • ... a set of small programs (the GNU utilities, written by Richard Stallman and others.
  • We use RedHat, Enterprise Edition v.7 (RHEL 7) [Linux flavours]

Linux has a hierarchical architecture

[Linux architecture]


  • Kernel: the heart of the operating system
    • interacts with hardware
    • performs memory management, task scheduling and file management
  • Shell: the utility that processes user requests
    • the shell interprets the command and calls the program that you want
  • Commands and Utilities: cp, mv, cat and grep etc.
  • Files and Directories:
    • all data in UNIX is organized into files
    • all files are organized into directories
    • these directories are organized into a tree-like structure called the filesystem
  • All commands are files, somewhere in the filesystem

Linux is a "collection of small programs that do one thing well"

  • Network: ssh, sftp, scp, ping, ifconfig, nslookup, wget
  • Shells: bash, tcsh, alias, watch, clear, history, chsh, echo, set, setenv, xargs
  • System Information: w, whoami, man, info, which, free, echo, date, cal, df, free, man, info
  • Command Help/Information: man, info
  • Special Characters & Pipes:
    |, >, >>, <, &, >&, 2>&1, ;, ~, ., .., $!, !:<n>, !<n> 
  • Filters: grep, more, less, head, tail, sed
  • Hotkeys: ctrl-c, ctrl-d
  • File System: ls, mkdir, cd, pwd, mv, ln, touch, cat, file, find, diff, cmp, mount, du, df, chmod, chown
  • File Editors: vi (vim), gedit

Open a terminal window to interact with Linux [Linux architecture]

  • "shell" is just another program
  • comes in flavours: sh (Bourne shell), ksh (Korn shell), csh (C-like shell), etc.
  • we use bash (Bourne Again shell, an enhanced sh), it's in /usr/bin/bash
In [8]:
whereis bash
bash: /usr/bin/bash /usr/share/man/man1/bash.1.gz
In [9]:
ls -la /usr/bin/bash
-rwxr-xr-x. 1 root root 960632 Aug  3 09:36 /usr/bin/bash

Linux file system [Linux filesystem]

  • file system is a hierarchical directory structure, resembles an upside-down tree
  • directories are collections of files and other directories
  • the structure is recursive with many levels
  • every directory has a parent except for the root directory
  • many directories have children directories

Typical Linux directories

  • / - "root" of the filesystem
  • /bin - System binaries, including the command shell
  • /boot - Boot-up routines
  • /dev - Device files for all your peripherals
  • /etc - System configuration files
  • /home - User directories
  • /lib, /lib64 - Shared libraries and modules
  • /lost+found - Lost-cluster files, recovered from a disk-check
  • /mnt - Mounted file-systems (other disks, network drives)
  • /opt - Optional software
  • /proc - Kernel-processes pseudo file-system
  • /root - Administrator’s home directory
  • /sbin - System administration binaries
  • /usr - User-oriented software
  • /var - Various other files: mail, spooling and logging

  • ~ - user's home directory, e.g. /home/pstudent
  • . - this (current) directory
  • .. - parent of the current directory

A tutorial on basic shell commands

By next Thursday:

  • cover all sections until the "Advanced Unix/Linux" from
  • develop a personal "cheat sheet" of useful commands
  • choose an editor (vi or gedit) and learn its basics
  • optional: use "jupyter notebook" to keep notes in this class