CE 5225: Numerical Techniques in Civil Engineering Tutorial 4
Tutorial 4: Roots and optimization part 1
(Total = 100 points)
Due date: 01-09-2021 (end of the class)
Submit as one file with file name: T04CE5225 2021 CE******.zip
(****** denotes the last 6 alpha-numeric of your roll number)
√
1. (50 Points) This problem is designed to approximate the value of 5 using the bisection
method through a series of steps. We defined√a function√ f (x) = x2 −√
√ 5, and find the
positive root of this equation. We know that 4 < 5 < 9; i.e. 2 < 5 < 3. Hence,
we will use xleft,1 = 2, and xright,1 = 3 for our problem.
(a) Write a function ‘callBisection1.m’ which sequentially calculates xleft,5 , and xright,5 ,
and returns xnew,5 , given by:
xleft,5 + xright,5
xnew,5 = (1)
2
The function should have the following input and output arguments:
[xBisection5] = callBisection1(fx,xLeft,xRight)
where; ‘fx’ is a function, ‘xLeft’, and ‘xRight’ are scalars representing the left and
right bracket, and ‘xBisection5’ is the solution to the 5th iteration. Show that
‘xBisection5’ = XXX. You must use for loop in your function. Note that the total
number of function evaluations should be n + 1, where n = 5 in this case.
(b) Write a function ‘callBisection2.m’ which additionally calculates the relative er-
ror in x for each iteration. This function will have the same input and output
arguments as ‘callBisection1.m’. The relative error is given as:
xnew,i − xnew,i-1
ϵx,i% = 100% (2)
xnew,i
Show that ϵx,5% = XXX%.
(c) Write a function ‘callBisection3.m’ that approximates the root of a function ‘fx’
such that the relative error is less than 0.1%. You should use a do-while loop
to accomplish this and complete your calculations using the minimum number of
function evaluations (f (x) evaluations). The ‘callBisection3.m’ function should
have the following input and output arguments:
[xBisection] = callBisection3(fx,xLeft,xRight,xTol)
where; ‘xTol’ is the error tolerance percentage = 0.1%.
Submit the main file as ‘t04p01.m’.
2. (50 points) Repeat problem 1 (parts a, b, and c) using the Newton-Raphson method
instead of bisection method. The three functions corresponding to parts (a), (b), and
(c) should have the following input and output arguments:
[xNewton5] = callNewton1(fx,xGuess)
[xNewton5] = callNewton2(fx,xGuess)
[xNewton] = callNewton3(fx,xGuess,xTol)
where, ‘xGuess’ = 5 is the initial guess of the root.
Submit the main file as ‘t04p02.m’.
Dr. Venkatraman Srinivasan and Dr. Alagappan Ponnalagu, IIT Madras Page 1 of 1