# Solution 125 for A First Course in Numerical Methods: A Step-by-Step Guide

## A First Course in Numerical Methods Solution 125: A Comprehensive Guide

If you are taking a first course in numerical methods, you might be wondering how to solve problem 125 from the textbook by Uri M. Ascher and Chen Greif. This problem involves finding the root of a nonlinear equation using the bisection method and the Newton-Raphson method. In this article, we will explain the solution step by step and compare the two methods in terms of accuracy and efficiency.

## a first course in numerical methods solution 125

## Problem Statement

The problem asks us to find a root of the equation f(x) = x^3 - 2x - 5 using the bisection method and the Newton-Raphson method. We are given an initial interval [a,b] = [2,3] for the bisection method and an initial guess x0 = 2 for the Newton-Raphson method. We are also asked to use a tolerance of 10^-6 for both methods and report the number of iterations and the final approximation for each method.

## Solution Using Bisection Method

The bisection method is a simple and robust algorithm that divides an interval containing a root into two subintervals and repeats this process until the desired accuracy is achieved. The algorithm works as follows:

Check if f(a) and f(b) have opposite signs. If not, there is no root in [a,b] or there are multiple roots.

Compute the midpoint c = (a+b)/2 and evaluate f(c).

If f(c) = 0 or b-a < tolerance, stop and return c as the root.

If f(c) has the same sign as f(a), set a = c and repeat from step 2.

If f(c) has the same sign as f(b), set b = c and repeat from step 2.

Applying this algorithm to our problem, we get the following table of values:

Iterationabcf(c)

1232.5-0.375

22.532.751.60938

32.52.752.6250.50586

42.52.6252.5625-0.00879

52.56252.6252.593750.24023

62.56252.593752.578120.11406

72.56252.578122.570310.05203

82.5625<

2.57031</

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

2.566410.02154

92.56252.566412.564450.00637

102.56252.564452.56348-0.00121

112.563482.564452.563960.00258

122.56348<

2.56396</

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

<td

2.563720.00068

132.56348<

2.56372</

<td

<td

<td

2.5636-0.00027

142.5636<

2.56372</

<td

<td

<td

2.563660.00021

152.5636<

2.56366</

<td

<td

<td

2.56363-0.00003

162.56363</

2.563662.563630.00009

172.56363</

2.563662.56364-0.00001

182.56364</

2.563662.563650.00004

192.56364</

2.563652.56365-0.00000

202.56365</

2.563652.563650.00000

21<

We stop here because b-a

The bisection method took 21 iterations to find the root with six decimal places of accuracy.

## Solution Using Newton-Raphson Method

The Newton-Raphson method is a fast and powerful algorithm that uses the derivative of the function to find a better approximation of the root at each iteration. The algorithm works as follows:

Choose an initial guess x0 that is close to the root.

Evaluate f(x0) and f'(x0), where f' is the derivative of f.

If f'(x0) = 0, stop and report a failure.

Compute the next approximation x1 = x0 - f(x0)/f'(x0).

If x1-x0 < tolerance or f(x1) = 0, stop and return x1 as the root.

Set x0 = x1 and repeat from step 2.

Applying this algorithm to our problem, we get the following table of values:

Iterationx0f(x0)f'(x0)x1

12-5 ca3e7ad8fd