Description
Write a computer program for finding a root of the non-linear equation f(x) = 0. The program should have the following feature:
First screen should ask, if the equation is a polynomial and take the answer in ‘Y/N’.
I. If the answer is ‘N’, next screen should ask for the choice of the following methods of solution:
(1) Bisection (if chosen, asks for f(x) and two starting points)
(2) False-position (if chosen, asks for f(x) and two starting points)
(3) Fixed-Point (if chosen, asks for g(x) such that, f(x) is expressed as x = g(x) and one starting point)
(4) Newton-Raphson (if chosen, asks for f(x), f’(x) and one starting point)
(5) Secant (if chosen, asks for f(x) and two starting points)
II. If the answer is ‘Y’, next screen should read the order of the polynomial (n) and the vector of the polynomial coefficients {a0, … an}. It should then ask for choice of the methods as follows:
(1) Muller (if chosen, asks for 3 starting points)
(2) Bairstow (if chosen, asks for starting points for r and s)
Once all the input is read out, the program should ask for 3 stopping criteria:
(ii) Convergence criteria for the function value, i.e., how close f(x) is to zero
(iii) Maximum iteration number (an integer)
The program should stop when any one of the three stopping criteria is met but indicate with a flag number, which one is met while stopping the program.
Output of the program should consist of the following:
• Value(s) of the root and the flag for the stopping criteria. All the roots of the polynomial for the Bairstow method and only one root for all other methods
• A plot of f(x) vs. x
• A plot of the approximate relative error vs. iteration number
Test functions for your program:
Here are test functions you need to include in your report. You can also use the tutorial problems for your test function while developing the program.
f(x) = x – cos x
Use the initial bracket as (0,1) or the initial guess as 0; maximum iterations 50; and maximum relative approximate error as 0.01%. For Fixed-Point method, use g(x)=cos x.
f(x) = e-x – x = 0
Use the initial bracket as (0,1) or the initial guess as 0; maximum iterations 50; and maximum relative approximate error as 0.05%. For Fixed-Point method, use g(x) = e-x.
f(x) = x4 7.4×3 + 20.44×2 24.184x + 9.6448 = 0
For Muller method, start with (−1, 0, 1). For Bairstow method, start with (s = −5, r = 4) and then (s = −2, r = 2). Use maximum iteration number as 50 and maximum relative approximate error in r and s as 0.01%
Use your judgement for the convergence criteria mentioned in (ii) for all problems.
Submission
Make a single zip folder with all your program file(s) name it roll number.zip (e.g., If your roll number is 123456, the folder name should be ‘123456.zip’). The folder should include –
(i) All the computer program file(s), input file(s) and output file(s)
(ii) A PDF file of the plots and the solution of the test cases given in this assignment.
Send the zip file by e-mail to: eso208.sec*@gmail.com, where * is section number 1-10. Example: for section O5, it is eso208.sec5@gmail.com; for section O10, it is eso208.sec10@gmail.com




Reviews
There are no reviews yet.