Assignment 6
Assignment 6
1. f(x) = x3 - x2 + 2x – 2
Answer:
To apply Muller's method and Bairstow's method to find the roots of the function f(x) = x3 -
x2 + 2x – 2 , we first need to plot the function to choose appropriate initial guesses for the
roots. Then, we can proceed with applying both numerical methods.
Let's start by plotting the function f(x) = x3 - x2 + 2x – 2 to visualize its behaviour and choose
initial guesses for the roots.
Muller’s Method
From the plot, we can see that there are three distinct real roots for the function f(x) = x3 - x2 + 2x – 2
Let's choose the following initial guesses for the roots:
X0 = -1
X1 = 0
X2 = 1
These initial guesses are chosen to be close to the locations where the function crosses the x-axis
based on the plot. We will use these initial guesses to apply Muller's method.
Iteration 1:
Compute Function Values: Calculate the function values f(x0), f(x1), f(x2) for the given initial guesses.
f(x0) = f(-1) = -4
f(x1) = f(0) = -2
f(x2) = f(1) = 0
Compute Divided Differences: Compute the divided differences f(x1,x0), f(x2,x1), f(x2, x0) using function
values:
Compute Quadratic Interpolating Polynomial: Using the divided differences, construct the quadratic
interpolating polynomial P2(x) through the points (x0,f(x0)), (x1f(x1)), (x2,f(x2)):
Find the Next Approximation: Solve for the next approximation by finding the root of the quadratic
interpolating polynomial P2(x). This can be done by setting P2(x)=0 and solving for x:
2x-2 = 0
2x=2
X=1
Iteration 2:
X1 = 0
X2 = 1
X3 = 1
Compute Function Values: Calculate the function values f(x1), f(x2), f(x3) for the given initial guesses.
f(x1) = f(-1) = -2
f(x2) = f(0) = 0
f(x3) = f(1) = 0
Compute Divided Differences: Compute the divided differences f(x2,x1), f(x3, x2) using function values:
Compute Quadratic Interpolating Polynomial: Using the divided differences, construct the quadratic
interpolating polynomial P2(x) through the points (x1f(x1)), (x2,f(x2)), (x3,f(x3)),
2x-2 = 0
2x=2
X=1
Iteration 3:
X2 = 1
X3 = 1
X4 = 1
Compute Function Values: Calculate the function values f(x1), f(x2), f(x3) for the given initial guesses.
f(x1) = f(1) = 0
f(x2) = f(1) = 0
f(x3) = f(1) = 0
Since all function values are zero, we have converged to the root x = 1.
Therefore, the roots of the polynomial f(x) = x3 - x2 + 2x – 2 using Muller's method with initial
guesses X0 = -1, X1 = 0, X2 = 1 is x=1(Single root)
Python code:
Python output:
Bairstow's method
p=1
q=1
These initial guesses are chosen somewhat arbitrarily and might need adjustment based on the
behavior of the method during the iterative process.
Now, let's start the iterative process of Bairstow's method by updating the coefficients of the
quadratic factor and refining the approximation of the roots. We'll perform the calculations step by
step to find the roots of the polynomial.
Iteration 1:
p0 = 1
q0 = 1
Δ=b2−4ac
Δp= -c – (b/2)
Δq= -f/ Δp
Where
a=1(coefficient of x2)
b= -1(coefficient of x)
c =2(constant term)
p1 = p0 + Δp = -(1/2)
q1 = q0 + Δq = 7/3
Iteration 2:
p1 = -(1/2)
q1 = 7/3
Δ=b2−4ac = -(25/3)
p2 = p1 + Δp = -(8/3)
q2 = q1 + Δq = 91/39
Iteration 3:
p2 = -(8/3)
q2 = 91/39
Δ=b2−4ac = -(325/39)
p3 = p2 + Δp = -(104/39)
q3 = q2 + Δq = (91/39) + (156/35)
Given the values p3 = -(104/39) q3 = (91/39) + (156/35) we can proceed to calculate the roots using
Bairstow's method. However, since Δ is negative, indicating that we are dealing with complex roots,
we need to handle complex arithmetic to find the roots.
Let's calculate the discriminant and then find the roots of the quadratic equation:
a=1
b = -(104/39)
c = (91/39) + (156/35)
Δ = -(172288/2081685)
Let's proceed to calculate the roots using the quadratic formula with the complex discriminant:
Let's calculate the complex roots of the quadratic equation using the quadratic formula and then use
them to approximate the roots of the cubic polynomial.
The square root of -(172288/2081685) is a complex number with a real part and an imaginary part.
Let's calculate the square root:
√−172288/2081685 = 416i
x1 = (104/78) + (416/78)i = (52/39) + (208/39)i
x1 = (52/39) + (208/39)i
x2 = (52/39) - (208/39)i
These complex roots correspond to the roots of the original cubic polynomial f(x) = x3 - x2 + 2x – 2
x1 = (52/39) + (208/39)i
x2 = (52/39) - (208/39)i
x3 = 8/3
The first two roots are complex conjugates, while the third root is real.
Muller's Method:
Strengths:
Simple to implement and understand.
Effective for well-behaved functions with close initial guesses.
Does not require derivatives.
Weaknesses:
Can suffer from convergence issues with distant initial guesses.
May require more iterations for convergence.
Bairstow's Method:
Strengths:
Effective for finding complex roots of polynomials with real coefficients.
Suitable for higher-degree polynomials and complex roots.
Can handle multiple roots well.
Weaknesses:
May not always converge with poorly chosen initial guesses.
Computationally intensive due to solving a system of nonlinear equations.
Contrast:
Muller's method is versatile but sensitive to initial guesses.
Bairstow's method is specifically designed for real-coefficient polynomials and complex roots.
The choice depends on the polynomial's characteristics and computational considerations.