CSE541 Homework #6
Answers
Due Date: Tuesday, Feb. 21
- Hardcopy written or typed answers are due at the beginning of class on the due date.
- Software (source files and single makefile) is to be submitted (via the 'submit' command) by 3:00 on the due date (before class)
GENERAL INSTRUCTIONS
-
Homework is due in lecture when I ask for it.
-
All work must be your own. You are not allowed to work in groups or use third party sources.
-
Computer problems must be done using C/C++. Turn in a hard copy of your code and print-outs of your sample runs. Please keep this concise, i.e. I don't want you to turn in a lot of pages.
-
All make-ups for homework must be accompanied by a documented and verifiable excuse well before the deadline. Given the severity of the emergency please inform me as soon as possible.
-
Please make sure your homework answers are legible, otherwise they will be marked wrong.
-
Staple your pages.
-
Homework submissions will NOT be accepted via email to me or the grader. No late homework will be accepted.
-
For each problem, SHOW ALL WORK in order to receive full credit. Just giving a final answer (correct or incorrect) will receive NO CREDIT. Thus, you will be graded on the work shown.
- Each problem is worth the same amount (including the program and associated explanation).
- Similarly, each of the n homework assignments will be worth 1/nth of the total for Assignments.
'n' is yet to be determined, but should be around 7.
PROGRAMMING ASSIGNMENT
Write a program that will:
- use the following arguments:
- id: is either 1 or 2. If '1', use f(x) = sin(x); if '2', use f(x) = (x*sin(x^2))/10
- epsilon: termination error criterion (used only in the adaptive algorithm)
- limit: maximum number of levels of recursion (used only in the adaptive algorithm)
- implement the following integration techniques:
- Trapezoid integration using one, two, and four intervals
- Romberg integration using the results above
- One segment of Simpson's 1/3 Rule (3 points)
- Two segments of Simpson's 1/3 Rule (5 points)
- One segment of Simpson's 3/8 Rule (4 points)
- Gaussian quadrature using 4 points
- An adaptive scheme for one of: Trapezoid, Simpson, Gaussian
- print the results for each of these techniques, 'a' through 'g' for each of the two functions.
To get you started, here is a program and makefile that implement one Trapezoidal segment and prints out the result.
QUESTIONS
Include a printout of the program results, as described above, and answer the following questions:
- For function '1', discuss the results.
Compare to the correct value.
Are there any surprises in how close or how far away some of the estimates are?
Compare and contrast the results from the various approaches.
Assume the function evaluation is very expensive and you want to get the best answer with the smallest number of function evaluations - what method would you choose and why?
-
Same questions and discussion for function '2'
-
Discuss the comparison of the results for the two functions.
Do their graphs (shown below) tell you anything about the similarities or differences of the results?
SPECIFIC INSTRUCTIONS
On the due date, at the beginning of class, hand in hardcopy of
- your analysis of the results of the lab assignment, including output from the program when and where appropriate.
With respect to the lab assignment,
-
Electronically 'submit' the makefile and source code files.
The assignment is called 'hw6':
submit hw6 integrate.c Makefile
-
Put all the integration methods in one executable;
call the executable 'integrate'.
-
DO NOT SUBMIT THE EXECUTABLE.
-
Modify the makefile that the grader can use to create your executables.
The grader should be able to go into your submit directory, make your executables and then run it, for example:
make
integrate 1 0.0001 1000
integrate 2 0.0001 1000
and the program should print out all of the output from the various methods in each case.
-
As before, you can capture the output to a file by:
integrate 1 0.0001 10000 > hw6.txt
integrate 2 0.0001 10000 >> hw6.txt
and then edit that file or include all of it in what you hand in in class.
In your discussions, refer to the printed output that you hand in.
NOTES