Be sure you have read, or at least skimmed, the readings for 9/13, linked from the ``Lecture topics and assignments'' page.
Do the following programming problems. You will end up with at least one code file per problem. Submit your program source (and any other needed files) by sending mail to bmassing@cs.trinity.edu, with each file as an attachment. Please use a subject line that mentions the course number and the assignment (e.g., ``csci 1120 homework 2''). You can develop your programs on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.
Sample output for (which is sensible but not very interesting):
the 0-th Fibonacci number is 1 the 1-th Fibonacci number is 1 the 2-th Fibonacci number is 2 the 3-th Fibonacci number is 3 the 4-th Fibonacci number is 5 the 5-th Fibonacci number is 8
Repetition continues until the absolute value of - is less than some specified threshold value. An easy if not necessarily optimal initial guess is just .
Write a C program that implements this algorithm and compares its results to those obtained with the library function sqrt. Since we haven't talked yet about how to read values from a human user, hard-code inputs as we did for the program to compute the roots of a quadratic equation, but show what happens for different values of and different convergence thresholds. You might also find it interesting to print the number of iterations.
Sample output (for quickly-chosen inputs -- you may want different ones):
square root of 0: with newton's method (threshold 0.1): 0 (0 iterations) using library function: 0 difference: 0 square root of -4: unable to compute square root of negative number square root of 4: with newton's method (threshold 0.1): 2.00061 (3 iterations) using library function: 2 difference: 0.000609756 square root of 2: with newton's method (threshold 0.1): 1.41667 (2 iterations) using library function: 1.41421 difference: 0.0024531 square root of 2: with newton's method (threshold 0.01): 1.41667 (2 iterations) using library function: 1.41421 difference: 0.0024531 square root of 2: with newton's method (threshold 1e-06): 1.41421 (4 iterations) using library function: 1.41421 difference: 1.59482e-12
You may find the library function fabs (which computes the absolute value of a double) useful.