Numerical Analysis, Fall 1999
Homework 2
Due September 27, 1999
Section 1.2
p27; 1c, 4d, 12, 13d
Section 1.3
p 37-38; 1a, 7a (Hint: Find P2 + R2 for sin x and find P1 and R1 for cos x, etc)
Programming Assignment We want to find as many roots as possible on an interval [a,b] of a function f(x).
Use either PC-Matlab, C++, or other language personally approved by me to accomplish this. Let f(x) = sin(1/x) for x not equal to zero and f(0) = 0 where f is defined on [0,1]. Let a = 0, b = 1 , N = 200, h = (b-a)/N. Use a for statement to check subintervals of [0,1] for a possible root where the subintervals are [0,h],[h,2h],[2h,3h],.....,[b-h,b]. Then proceeed to find such roots. See my files on the Web.
Regardless of the choice of the software, produce the output so it appears as 2 columns where root is in column 1 and f(root) is in column 2. For PC-Matlab, put solutions in a matrix as was done in B21.m. Cout statements will suffice for C++.
For PC-Matlab, you will need 3 m- files. File similar to my bisect.m, a file similar to my B21.m, and a file f.m which describes f(x) = sin(1/x) for x not equal to zero and f(0) = 0. Also use the command fplot('f',[0,1]) to exhibit the plot and submit to me.
For C++, just modify my biseceasy.cpp appropriately. However you may choose to break it into say 3 files which would include an h file, bisect.cpp describing contents of h file, and a main.cpp. Then build a project, etc.
You must turn in
(1) a labeled, virus free disk with directory hw# containing all the files relevant to the assignment, including
*.m and output files *.txt (if PC-matlab ) or *.h, *.cpp, etc. and output files *.txt (if C++ files)
and
(2) a hard copy of the source code files and output *.txt files.