Professional Documents
Culture Documents
reConfigurable@IITD
Home
Lab 6
Bisection Method
Your program should output the final approximate root AND the number of iterations taken to reach there on separate lines.
The functions f1, f2, f3 have already been defined in your code file and will be referred as strings.
Use MATLAB function feval to evaluate a named function on some parameter. Read its documentation to understand.
NOTES
Newton Method
Write a program to find the roots of a given function using Newton's method (involving derivatives.)
Initial Guess
Tolerance c
The function whose root is to be found and its derivative.
Your program should output the final approximate root AND the number of iterations taken to reach there on separate lines.
The functions f1, f2, f3 and their derivatives f1p, f2p, f3p have already been defined in your code file and will be referred as strings.
Use Octave
function feval to evaluate a named function on some parameter. Read its documentation to understand.
http://karnali.cse.iitd.ac.in/drupal/?q=node/45 Page 1 of 3
Lab 6 | reConfigurable@IITD 20/12/22, 7:57 PM
NOTES
Input format:
"function_name"
"function_derivative_name"
#initial_guess
#tolerance
Examples:
Input:
f1
f1p
1.4
0.0001
Output:
1.1656
Explanation:
In the range [1, 1.4] the root of function f1, (with a tolerance of 0.0001) is 1.1656 and it takes 5 iterations for Newton's method to reach there.
Notice that for the same problem it took bisection method to reach 12 iterations.
Input format:
"function_name"
#a
#b
#tolerance
Examples:
http://karnali.cse.iitd.ac.in/drupal/?q=node/45 Page 2 of 3
Lab 6 | reConfigurable@IITD 20/12/22, 7:57 PM
Input:
f1
1.4
0.0001
Output:
1.1655
12
Explanation:
In the range [1, 1.4] the root of function f1, (with a tolerance of 0.0001) is 1.1655 and it takes 12 iterations for bisection method to reach there.
http://karnali.cse.iitd.ac.in/drupal/?q=node/45 Page 3 of 3