NC-Assignment No 3
NC-Assignment No 3
Numerical Computing
T0
Mr.Umer Hayat
BY
Hannan Khalid
(20014119-0026)
Submission Date:24-June-2024
BS Computer Science (A)
UNIVERSITY OF GUJRAT
Q1) Implement the bisection method to find a root of
f(x)=x3−2x−in the interval [1,3].
SOLUTION:
Q2) Implement Newton-Raphson method to find a
root of the same equation, starting from x0=2.
SOLUTION:
Q3)Compare the convergence rates of both methods and discuss
their strengths and weaknesses.
ANSWER:
❖ Bisection Method
The Bisection Method is a root-finding algorithm that repeatedly divides an interval in half and
then selects the subinterval in which a root must lie. It is based on the Intermediate Value
Theorem, which states that if a continuous function changes sign over an interval, then it has a
root in that interval.
Convergence Rate:
Strengths:
• Guaranteed convergence if the function is continuous and the initial interval is chosen
such that the function values at the endpoints have opposite signs.
• Simple to understand and implement.
Weaknesses:
Convergence Rate:
Strengths:
Weaknesses:
ANSWER:
❖ Numerical Results:
Consider finding the root of f(x) = x^2 - 2.
• Bisection Method: Starting with an interval of [-2, 2], it takes several iterations to get
close to the root (sqrt(2)). Each iteration halves the interval size.
• Newton-Raphson Method: Starting with an initial guess close to the root (e.g., x = 1), it
takes fewer iterations to converge to the root due to its quadratic convergence.
❖ Convergence Analysis:
❖ Computational Complexity: