Welcome to Applied Mathematics 2120
Introduction to Mathematical Programming
Fall 2004
Instructor: |
Dr. Sergey Sadov, HH-3009 |
Slot: |
03 and R11: MWF 10:00 a.m., Thur. 11:00 a.m. |
Classroom: |
Monday and Wednesday: SN-2036, Thursday and Friday: C-2003 |
Term marks
Final marks (Unoficially)
Why did I get that mark for my program?
Your floppies left in the lab are in Math General Office.
Passing guaranteed policy.
You are guaranteed the course mark of at least 50% if
you write a compilable program that
produces the mathematically correct
answer for a non-special (generic) initial data (even for a hard-coded sample
data set). All other aspects of evaluation follow from the
policy set in course syllabus and weights assigned to exam
questions.
List of
course material
with references
A level of the exam programming question will be similar to that
of the sample questions in Lab12.
Please review solutions to all asstignments and quizes.
Assignment N+1
[Corrections to handouts: 1) ignore a note about "makefiles";
2) should be no backslash in #include ]
Course Outline:
- Rudimentary overview of the UNIX system
- Programming in C
- Elements of programming style
- Introduction to C++ and object-oriented programming
- Symbolic calculator Maple as a tool
- Textbook:
- Gary J. Bronson, ``A First Book of ANSI C'',
3rd edition, Brooks/Cole, 2001.
- Reference materials:
- M. Barrett and C. Wagner, C and UNIX: Tools for Software Design
Wiley, 1997.
- B. Kernighan, D. Ritchie, ``The C Programming Language'',
Second edition, 1988 (QA 76.73 C15 K47)
and
Kernighan's old (read the disclaimer!) C tutorial
Online Maple tutorial from MapleSoft
Phil's C course
(Contains all proper historical references; advanced in the technical sense)
Or else, you can find a Google of
other useful and informative (as well as useless and misleading) references.
Assignments
(If your internet browser doesn't display pdf files,
save the file to your hard drive, then open with Adobe Acrobat Reader.
On our Unix systems, type the command acroread followed by the filename.)
Supplementary materials
Functions in C as arguments of other functions (Nov.3):
an example.
(C++ provides another mechanism, function overloading, to avoid rewriting
large portions of code when only few details may vary.)
An universal sorting library function qsort:
an example.
The (void*) type used in qsort is a generic ("type-free") pointer type.
Universal functions, such as qsort, can
process data of different types in a literally same way.
An explicit cast from (void*) to a typed pointer is required
in the appropriate place.
There is much about qsort
on the Internet,
here is one not
too expert-oriented link.
(The textbook discusses some sorting algorithms( Sect.7.7), but doesn't mention
the qsort function, even among the members of <stdlib.h> library
in App.D. The algorithm used in qsort belongs to the so called
divide and conquer method and recursion. Sample code can be found in
[Kernighan,Ritchie].)
Labs
Lab 7
(Oct 21-22): continuation of Lab6's project.
Version 3:
lab6_3.c
inp.c
outp.c
zeta.c
(Friday's Ver.4 turned out to be less complete.)
Remark: The file zeta.c uses function pow
of C's standard
math library (file math.h). Despite the presense of
#include <math.h> in the preamble
of the file zeta.c, the gcc compiler doesn't inlcude
it. To force it to include <math.h>, compile as follows:
gcc -Wall -lm lab6.c
The option -lm means
load math
library.
As an alternative, a more tolerant C++ compiler can be used:
g++ -Wall lab6.c
However, it allows the programmer not to conform to some other strictest
C rules, which is not very desirable for us at this stage.
Lab 8
(Oct 28-29): Finishing the Series Summation project.
Version 5: (Thursday Oct.28)
lab6_5.c
inp.c
zeta.c
Version 6: (Friday Oct.29)
lab6_5.c
inp.c
zeta.c
(outp. in VV 5,6 is same as in Ver.3).
Most important new elements: Command line argument in main;
accuracy-controlled loop condition in zeta.
Lab 9
(Nov 4):
A sample C++ program is here.
Lab 10
(Nov 18): Sample program:
I/o from/to files whose names are given as command line arguments
Explanation of a strange effect observed at the very end of the lab
(the program didn't report an error when reading from a file with invalid
numbers): The initialization of variable validnumber was missing
and the loop was immediately exited without being run at least once.
Lab 12
Dec.2:
The problem (Approximation
of a definite integral using the Rule of Rectangles).
Incomplete and not perfect, but straightforward, working and
Passing Guaranteed version
Shannon Sullivan brought to my attention that there was a mistake
in the mathematical formula for the Rule of Rectangles
and induced mistake in this program. I missed the factor (b-a)
in front of the final sum. The program passed the test mentioned
in the code only because b-a=1 in that case. Which means my
data was not exactly "non-special"!.
A 99% worth C program
A 101% worth C program
C++ programs with classes:
A passing guaranteed,
and a 102% worth version.
This program is easier to generalize and modify, then a corresponding C program.
Dec.3:
The problem (Find coordinates
of the Center of Mass of a system of point masses).
Here
is what I myself have completed in the lab by 10:50.
While this program demonstrates a sound approach,
it doesn't produce a mathematically correct answer for
a sample set of data and therefore doesn't automatically
meet the "Passing Guaranteed" criterion.
Replace the stubs by performing member functions and one gets a
passing guaranteed version of a C++ program.
Here is a functionally equivalent
passing guaranteed C program
and a
99%-worth C version.
(1% is taken out for lengthy main())
Midterm Test
Quizes with answers and comments
Mathematics and Statistics Department
Homepage
Last Modified: