[go: up one dir, main page]

0% found this document useful (0 votes)
39 views1 page

(Xbisection5) Callbisection1 (FX, Xleft, Xright) : Ce 5225: Numerical Techniques in Civil Engineering Tutorial 4

This document provides instructions for a tutorial assignment on root finding and optimization using numerical techniques in MATLAB. Students are asked to write MATLAB functions to approximate the value of the square root of 5 using (1) the bisection method and (2) the Newton-Raphson method. For each method, they must write functions to (a) perform the calculations through a specified number of iterations, (b) calculate the relative error at each iteration, and (c) continue iterating until the relative error is less than 0.1%. Main files submitting the bisection and Newton-Raphson solutions are to be named 't04p01.m' and 't04p02.m' respectively. The assignment is worth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

(Xbisection5) Callbisection1 (FX, Xleft, Xright) : Ce 5225: Numerical Techniques in Civil Engineering Tutorial 4

This document provides instructions for a tutorial assignment on root finding and optimization using numerical techniques in MATLAB. Students are asked to write MATLAB functions to approximate the value of the square root of 5 using (1) the bisection method and (2) the Newton-Raphson method. For each method, they must write functions to (a) perform the calculations through a specified number of iterations, (b) calculate the relative error at each iteration, and (c) continue iterating until the relative error is less than 0.1%. Main files submitting the bisection and Newton-Raphson solutions are to be named 't04p01.m' and 't04p02.m' respectively. The assignment is worth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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

You might also like