03 Roots of Equations II
03 Roots of Equations II
Outline
• Open Methods
• Fixed-point Iteration
• Newton-Raphson Method
Open Methods
• Some information about open methods:
• Need an initial guess where to start looking for the root.
• Will only give the closest root to the initial guess, in case there are multiple
roots.
• Need to know the first derivative of the function.
• Does not always converge, depends on how the function is manipulated.
• Convergence for these methods is relatively fast.
Fixed-point Iteration
• Fixed-point Iteration – also known as successive substitution
• Simple method, needs only an initial guess to compute for the solution.
• Instead of turning the function into a problem of 𝑓 𝑥 = 0, you need to turn
the function into 𝒙 = 𝒈(𝒙), such that the variable we want to solve for is also
on the other side of the equation.
• Can be accomplished by algebraic manipulation or by simply adding 𝑥 to both
sides of the original equation.
• Example:
𝑥 2 +3
𝑥2 − 2𝑥 + 3 = 0 → 𝑥 =
2
sin 𝑥 = 0 → 𝑥 = sin 𝑥 + 𝑥
Fixed-point Iteration
1. Isolate 𝒙 on one side of the equation (for consistency, let’s use the
left side). Let 𝒇(𝒙) be the remaining part of the equation such that
𝒙 = 𝒇(𝒙).
2. Make an initial guess 𝑥0.
3. Iterate using 𝒙𝒊+𝟏 = 𝒇(𝒙𝒊).
4. Identify the exit criterion and set a tolerance then repeat step 3
until the solution converges.
5. The answer is 𝒙𝒊+𝟏 upon convergence.
Fixed-point Iteration
• Example: Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
1. Isolate 𝒙 on one side of the equation (for consistency, let’s use the
left side). Let 𝒇(𝒙) be the remaining part of the equation such that
𝒙 = 𝒇(𝒙).
Option 1: 𝑥 = 2𝑥 − 2 𝑓1 (𝑥) = 2𝑥 − 2
Option 2: 𝑥 = log2(𝑥2 + 2) 𝑓2 𝑥 = log2(𝑥2 + 2)
Option 3: 𝑥 = 2𝑥 − 𝑥 2 − 2 + 𝑥 𝑓3 𝑥 = 2𝑥 − 𝑥2 − 2 + 𝑥
Fixed-point Iteration
• Example: Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
2. Make an initial guess 𝑥0.
𝑥0 = 3
Option 1: 𝑥 = 2𝑥 − 2 𝑓1 (𝑥) = 2𝑥 − 2
Option 2: 𝑥 = log2(𝑥2 + 2) 𝑓2 𝑥 = log2(𝑥2 + 2)
Option 3: 𝑥 = 2𝑥 − 𝑥2 − 2 + 𝑥 𝑓3 𝑥 = 2𝑥 − 𝑥 2 − 2 + 𝑥
Fixed-point Iteration
• Example: Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
3. Iterate using 𝒙𝒊+𝟏 = 𝒇(𝒙𝒊).
𝑥0 = 3
Fixed-point Iteration
• Example:
• Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
4. Identify the exit criterion and set
a tolerance then repeat step 3
until the solution converges.
• Let’s use the approximate error as the
exit criterion.
• Set 𝑡𝑜𝑙 = 1𝑒 − 3
𝑥𝑖+1 − 𝑥𝑖
If < 𝑡𝑜𝑙,
𝑥𝑖+1
stop the iteration
Fixed-point Iteration
• Example:
• Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
4. Identify the exit criterion and set
a tolerance then repeat step 3
until the solution converges.
• Let’s use the approximate error as the
exit criterion.
• Set 𝑡𝑜𝑙 = 1𝑒 − 3
𝑥𝑖+1 − 𝑥𝑖
If < 𝑡𝑜𝑙,
𝑥𝑖+1
stop the iteration
Fixed-point Iteration
• Example:
• Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
4. Identify the exit criterion and set
a tolerance then repeat step 3
until the solution converges.
• Let’s use the approximate error as the
exit criterion.
• Set 𝑡𝑜𝑙 = 1𝑒 − 3
𝑥𝑖+1 − 𝑥𝑖
If < 𝑡𝑜𝑙,
𝑥𝑖+1
stop the iteration
Fixed-point Iteration
• Example: Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
5. The answer is 𝒙𝒊+𝟏 upon convergence.
• Only option 2 converged to a value of 𝟒. 𝟒𝟑𝟕𝟒𝟗𝟒𝟒𝟎𝟐.
Option 1: 𝑥 = 2𝑥 − 2 𝑓1 (𝑥) = 2𝑥 − 2
Option 2: 𝑥 = log2(𝑥2 + 2) 𝑓2 𝑥 = log2(𝑥2 + 2)
Option 3: 𝑥 = 2𝑥 − 𝑥2 − 2 + 𝑥 𝑓3 𝑥 = 2𝑥 − 𝑥 2 − 2 + 𝑥
Fixed-point Iteration
• Convergence
• As we can see, not all the options converged when used with fixed-
point iteration.
• Let 𝑓(𝑥) be continuous and 𝑓′(𝑥) exists on an interval 𝑥 ϵ [𝑎, 𝑏].
𝒇′ 𝒙 ≤ 𝟏, for all 𝑥 ϵ [𝑎, 𝑏]
• Then for any number 𝒙𝟎 in the interval [𝑎, 𝑏], the sequence defined
by:
𝒙𝒏+𝟏 = 𝒇(𝒙𝒏)
• Converges to the unique fixed point 𝒙𝒎 which is the root between the
interval [𝑎, 𝑏].
Fixed-point Iteration
• Convergence
• Let’s look at the example we discussed: Solve for 𝑥 in 𝒙𝟐 + 𝟐 = 𝟐𝒙
• We already know from solving that the root is somewhere in the interval [𝟑, 𝟓].
• Let’s plot the derivatives in the given interval [3,5] to see if there exists a 𝑘 such
that 𝑓 ′ 𝑥 ≤ 1.
ln 2 (2𝑥)
Option 1: 𝑥 = 2𝑥 − 2 𝑓1(𝑥) = 2𝑥 − 2 𝑓1′(𝑥) =
2 2𝑥 − 2
2𝑥
Option 2: 𝑥 = log2(𝑥2 + 2) 𝑓2 𝑥 = log2(𝑥2 + 2) 𝑓2′ 𝑥 =
(ln 2)(𝑥2 + 2)
Option 3: 𝑥 = 2𝑥 − 𝑥2 − 2 + 𝑥 𝑓3 𝑥 = 2𝑥 − 𝑥2 − 2 + 𝑥 𝑓′(𝑥) = 2𝑥 ln 2 − 2𝑥 + 1
3
Fixed-point Iteration
• Convergence
• Let’s look at the example we
discussed: Solve for 𝑥 in 𝒙𝟐 +
𝟐 = 𝟐𝒙
• We already know from solving
that the root is somewhere in
the interval [𝟑, 𝟓].
• Let’s plot the derivatives in the
given interval [3,5] to see if
there exists a 𝑘 such that
𝑓 ′ 𝑥 ≤ 1.
Newton-Raphson Method
• Newton-Raphson Method
• Most widely used root-finding method
• Named after Isaac Newton and Joseph Raphson
• The problem we need to solve is again 𝑓 𝑥 = 0, no need to isolate 𝑥 like in
fixed-point iteration
• Needs the derivative of the function.
• Number of iterations can greatly vary depending on the initial guess.
Newton-Raphson Method
1. Turn the equation to a function of the variable we want to solve
such that 𝑓 𝑥 = 0.
2. Make an initial guess 𝑥0.
𝒇 𝒙𝒊
3. Iterate using 𝒙𝒊+𝟏 = 𝒙𝒊 −
𝒇′(𝒙𝒊)
4. Identify the exit criterion and set a tolerance then repeat step 3
until the solution converges.
5. The answer is 𝒙𝒊+𝟏 upon convergence.
Newton-Raphson Method
• Example: Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
1. Turn the equation to a function of the variable we want to solve
such that 𝑓 𝑥 = 0.
𝑥 2 + 2 = 2𝑥
2𝑥 − 𝑥2 − 2 = 0
𝑓 𝑥 =0
𝑓 𝑥 = 2𝑥 − 𝑥2 − 2
Newton-Raphson Method
• Example: Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
𝑓 𝑥 = 2𝑥 − 𝑥2 − 2
2. Make an initial guess 𝑥0.
Option 1: 𝑥0 =1
Option 2: 𝑥0 =2
Option 3: 𝑥0 =3
Option 4: 𝑥0 =4
Newton-Raphson Method
• Example: Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
𝑓 𝑥 = 2𝑥 − 𝑥2 − 2
𝒇 𝒙𝒊
3. Iterate using 𝒙 𝒊+𝟏 = 𝒙𝒊 − .
𝒇 ′ 𝒙𝒊
𝑓 ′ 𝑥 = 2𝑥 ln 2 − 2𝑥
Newton-Raphson Method
• Example:
• Solve for 𝑥 in 𝑥 2 + 2 = 2𝑥
𝑓 𝑥 = 2𝑥 − 𝑥2 − 2
𝑓 ′ 𝑥 = 2 𝑥 ln 2 − 2𝑥
4. Identify the exit criterion and set a tolerance then repeat step 3 until the solution converges.