Sorting, Finding Root of A Function Using Bisection and Regula Falsi Methods
Sorting, Finding Root of A Function Using Bisection and Regula Falsi Methods
Sorting, Finding root of a function using bisection and regula falsi methods
General Instructions: Create a folder using your ID number as the name of the folder. Keep all your files
within this folder. At the end of the work session, you tar and gzip this folder using tar cvfz <your
idnumber>.tgz <folder name> command and upload the zipped file. For nth problem, the program names
should be probn.py. If you need to create a text file to write your answers for nth problem, use probn.txt file
name. If multiple programs are to be submitted for nth problem, use the convention probnA.py, probnB.py
and so on. AND do not panic!
Instructions for the program: You must have the comments describing what the subsequent python codes
do in your program.
C
L R x L C R x
Problems
1. Sorting: You know from the class that the sorting of a list can easily be performed using the swaping of
values. Write a program which will sort the following list in ascending order:
A = [4, 3, 1, 2, 7, 3, 8, 9] .
Your program must print the list after sorting along with the number of iterations it used.
2. Bisection: Find the root of a function of the form x2 16x + 15 using the bisection method using
a tolerance of 106 . The bracketing interval is [-20,14]. Your program should print the number of
iteractions needed, the exact root (you can easily solve the equation), the computed root (using bisection)
and their difference. Your program must have the following features:
It must check whether any of the bracketing points are root of the given function (check with
[15,20].
It must check whether you have a good bracketing interval (check with [2,4]).
It must check whether during iterations it has accidentally reached the exact root (check with
[0,2]).
4. From the number of iterations and the difference between the exact and the computed value of the root,
comment on the speed and the accuracy of these methods.
IISER Kolkata 1