You are on page 1of 2

CE 206 (Engineering Computation Sessional)

Assignment #2
Instructor: Dr. Tanvir Ahmed

Q1. (a) Determine the real roots of f(x) = - 1 +5.5x 4x
2
+ 0.5x
3
using MATLABs roots
function.
(b) Using your newtraph.m code solve for these roots using initial guesses of 0, 2 and 6
and a stopping criteria of
s
< 0.01%. How many iterations are required in each of these
cases?
(c) Redo part (b) using an initial guess of 4.52 and 4.54 (and the same stopping criteria).
How many iterations are required in each of these cases? Why do they converge on
different roots and why so many iterations? Explain graphically.

Q2. (a) Write a function M-file to implement the secant method of root finding. [Hint:
try modifying the newtraph.m code shown in class]
(b) Apply the developed code to find the first positive root of f(x) = sinx + cos(1+x
2
) 1
where x is in radians. Use four iterations with initial guesses of (i) 1.0 and 3.0 (ii) 1.5
and 2.5, and (iii) 1.5 and 2.25
(c) Provide a plot of the function to get an idea of where the first positive root may be.
Compare with the results you found in part (b). Are there any discrepancies? If so,
why?

Q3. (a) Water is flowing in a trapezoidal channel at a rate of Q = 20 m
3
/s. The critical
depth y for such a channel must satisfy the equation:
u = 1 -

gA
c
3
2
B
Where g = 9.81 m
2
/s, A
c
= channel cross-sectional area (m
2
) = 3y + y
2
/2 and B = width
of the channel at the surface (m) = 3 + y.
Solve for the critical depth (y) using both bisection and method of false position using
the initial guesses 0.5 and 2.5 and iterate until the approximate error falls below 1% or
the number of iterations exceed 10. Compare your results from both methods [ You may
use fzero function to get an idea of where the root should be]
(b) Graphically explain why regula falsi may not be the best option to solve the problem
described in part (a).
(c) One way of alleviating the problem in regula falsi method is to detect whether there
are any stagnant bounds in the problem and if this occurs, the bound can be divided
in half. This is called modified false position method. Write a MATLAB code
(modifying your regulafalsi.m) to implement this algorithm (say, halve the bound when
it is stagnant for two iterations) and apply it to the problem in part (a). Does this
improve your solution?

You might also like