The main() function must solve two different equations f1(x) = 0 and f2(x) = 0, by reading in two different pairs of values a and b, one pair used for f1(x) = 0 and the other pair for f2(x) = 0
The main() function must be in a file "main.C" by itself
The double Solve(f, a, b, eps) function uses the bisection method to find a root of an equation.
The Solve() function must also be in a file "solve.C" by itself
I have written two functions in two separate files and your main program must solve the following two functions using the Solve (bisection method):
You must not change any of these function files; simply save a copy of these files in your project directory (cs561) and use the multi-file compilation technique discussed in class to link them into your program.
(The simplest command that will link all the files together is:
CC -o main main.C solve.C pj1f1.C pj1f2.Cbut that is not the most efficient way since it will recompile all files. You may use this for now, until we learn to use Makefiles...)
Before you can test your program, you must first figure out what initial interval you need to use in each function...
The function value at middle of the interval is computed and the next solution interval is either the "left" interval or the "right" interval, depending on the sign of the function value at the midpoint:
The bisection method terminsates when the length of the solution interval is less than a prescribed precision eps. The value returned is the middle of the current solution interval.
To test if the sign of f(a) and f(b) are different, you can use:
f(a) * f(b) < 0
/home/cs561000/turnin main.C pj1
/home/cs561000/turnin solve.C pj1a