Math 157: Assignment 1

Assigned Monday Jan. 5, 2009, due Friday, Jan. 9, 2009


Theory Work

  1. Read Chapters 1 and 2 in Blaha & Rumbaugh.

  2. Problem 2.2 on page 19. Use just one sentence for each item when explaining your answers.

  3. Suppose you are asked to construct a program to solve a linear system of equations ${\rm A} \vec x = \vec b$ where ${\rm A}$ is an $n \times n$ real matrix. You have several vector classes available for your use (vector class $\equiv$ a one dimensional array class with a linear index). Which of the following vector class characteristics would you need to consider for this task. Explain your answers. Use just one sentence for each item when explaining your answers.

    1. The vector class has a member function that sorts it's elements by numerical magnitude.

    2. Elements of the vector class can be arbitrary data types and objects (not just numeric data types).

    3. The vector class has member functions for individual element access (e.g. the setting and getting individual elements of a vector).

    4. The vector class has member functions that allow mathematical vector operations; vector addition/subtraction, vector assignment, scalar-vector multiplication, and vector dot product.

    5. The vector class has an associated matrix class, the latter possessing a member function for matrix-vector multiplication.

    6. The number of elements in a vector can be changed after it's initial instantiation.

  4. Review numerical methods for solving ordinary differential equations. The document "Euler's Method for the Approximation Solution of ODE's" contains a brief description of what you will need to know in order to do the computational part of this assignment. You should also look over the relevant sections in the textbook you used in your Numerical Analysis class.


Computational Problems

In addition to having you run and then extend the program EulerSample.cpp, the purpose of this assignment is to have you become familiar with the PIC computer lab in 2817 Boelter Hall and the Visual C++ Integrated Development Environment Version 8 (2005)* .

  1. Obtain and then run EulerSample.cpp:
    1. Activate your class account. Look for handouts in the lab to do this, the lab assistants can also help.
    2. Start your web browser and go the class page (http://www.math.ucla.edu/~anderson/157.1.09w).
    3. Open the Assignment #1 web page (so you can access the links associated with the assignment)
    4. Start Visual C++
    5. Following the instructions given in Using Visual C++ 8 (2005)
      1. Create a new project specifying that the solution name be the name of your course directory and that the project be named Assign1. In Visual Studio 2005, the solution is specified/created when creating the first project, so you won't need to create a solution first.
      2. Create a Win32 Console application for your first assignment. Specify an "empty" project.
    6. Download the program EulerSample.cpp into the directory for your first assignment. Add this file to your project.
    7. Compile and run EulerSample.cpp.
    8. Edit and then run the program to solve

      $\dfrac{dy}{dt} = \dfrac{3 t^2 + 4 t + 2}{2(y-1)} \qquad y(0) = -1$

      up to time $t = 2.0$, using 50 and 100 timesteps. Copy down the solution values; you will be turning them in.
    9. Describe a technique that one could use to determine if the solution computed in (viii) is correct.


What You Should Turn In

(*) You are not required to do the computational assignments using the PIC lab. However, you should still familiarize yourself with the PIC lab computing facilities since the grading of assignments 2-10 will be done on PIC lab machines. For each assignment you will need to make sure that your codes compile and run on the PIC lab machines before turning them in.