Department of 
Computer Science

Search our Site

Line

ON THIS PAGE:

Course Objectives

Prerequisites

Approach

Typical Text

Course Outline

Sample Programming Assignments

  COMP 116 [016]: Introduction to Scientific Programming
(3 hours)

Course Objectives
To teach problem analysis, algorithm design, and the elements of programming, with emphasis upon mastery of concepts, using a limited number of well-chosen language features and physically motivated driving problems. Although MATLAB and another imperative programming language (such as C) are used for instruction, the emphasis is on learning to program rather than learning specific languages.

Prerequisites
Math 231. We assume familiarity with univariate differential and integral calculus, and the ability to manually solve a system of simultaneous linear equations.

Approach
Substantial programming assignments, but not to exceed reasonable load for a 3-hour course. Emphasis on systematic development of programming ideas, driven by examples from physical sciences and mathematics.

It is expected that approximately the first 10-12 weeks of the semester will be taught using MATLAB, and the remainder of the semester will migrate the programming concepts to another imperative programming language (such as C).

Typical Text
The required text by Brian Hahn, Essential MATLAB for Scientists and Engineers, Wiley, is a good elementary introduction. We supplement with more advanced material from, for example, Chapra and Canale's Numerical Methods for Engineers.

The book Introduction to Scientific Programming by Joseph L. Zachary is a good example of the proposed approach, but it uses Mathematica rather than MATLAB.

Course Outline

  1. Introduction. Use of computers in computational science. The activity of programming: understanding and modeling the problem, design of algorithms, choice of data structures, coding, testing, debugging. Limits of computing.
  2. Elementary Programming Concepts. Variables, constants, values, declarations. Primitive data types. Input and output. Expressions and assignment. Control structures: sequencing, choice, iteration. Composition of control constructs.
  3. Intermediate Programming Concepts. Issues related to numeric types: representation, accuracy, error accumulation. Aggregate types: arrays and records. Composition of aggregate types. Encapsulation of control: functions and procedures; parameters, local variables, global variables; nested calls. Objects.
  4. Advanced Programming Concepts. Introduction to scientific visualization. Libraries and linking. Coverage may vary based on available time.

Sample Programming Assignments
Here are some initial ideas on sample programming assignments, at various stages of refinement. The pattern of assignments parallels current practice in COMP 110 and COMP 121.

  • Assignment 1 (1 week): Introduction to MATLAB environment; variables, types (integer, real, complex, character, boolean); simple I/O.

  • Assignment 2 (1 week): Expression evaluation, assignment to variables.

  • Assignment 3 (1 week): Conditionals, iteration (for and while loops).

    This would be a good place to introduce an example involving round-off error.

  • Assignment 4 (2 weeks): Array manipulation.

    Gaussian elimination: first do it with scalar operations and no pivoting; then introduce pivoting; finally do it all with array syntax.

  • Assignment 5 (2 weeks): Functions, both MATLAB's intrinsics and user-defined.

    Need something to talk about recursion. (Adaptive quadrature? That would again bring up numerical convergence issues.)

  • Assignment 6 (2 weeks): Structures.

  • Assignment 7 (3 weeks): Visualization and synthesis of previous ideas.

    This is the biggie. The idea is to have 5-6 client faculty members to line up for this assignment, and present problems that have the general flavor of a simulation and interactive data display. This requires a commitment of time from these faculty members, and will give students the opportunity to be exposed to "research."

    Possible topics: Fluid flow (Lagrangian particle tracer), heat equation or wave propagation, some sort of viewing of a 3D object.

  • Assignment 8 (2 weeks): Programming in an imperative language (such as C).

    Take an operation that is trivial in MATLAB, tell them how it works, and have them implement it in the imperative language. FFT would be a good example, because it involves both complex numbers and recursion.

Horizontal Line
Department of Computer Science
Campus Box 3175, Sitterson Hall
College of Arts & Sciences
The University of North Carolina at Chapel Hill
Chapel Hill, NC 27599-3175 USA
Phone: (919) 962-1700
Fax: (919) 962-1799
Content Manager: Associate Chairman for Academic Affairs
Server Manager: webmaster@cs.unc.edu
Last Content Review: 24 November 1999