
102 Numerical Methods and Optimization: An Introduction
Algorithm 4.4 Newton’s method for solving f(x)=0.
Input: f,f
,x
0
(f
(x
0
) =0),,δ,N
Output: ¯x such that |f (¯x)| <(unless another stopping criterion is satisfied)
1: k =0
2: repeat
3: k = k +1
4: x
k
= x
k−1
−
f(x
k−1
)
f
(x
k−1
)
5: if (k ≥ N)or(f
(x
k
)=0)then
6: STOP
7: end if
8: until (|f(x
k
)| <)or(|x
k
− x
k−1
| <δ)
9: return ¯x = x
k
Denote by
f(r)=p
1+
r
12
n
− 1
−
Ar
12
,
then
f
(r)=
pn
12
1+
r
12
n−1
−
A
12
,
and an iteration of Newton’s method is
r
k
= r
k−1
−
12p
$$
1+
r
k−1
12
%
n
− 1
%
− Ar
k−1
pn
$
1+
r
k−1
12
%
n−1
− A
,k≥ 1. (4.15)
Like in Example 4.5, assume that the monthly payment is $300, and we want
to find an interest rate r which would