0% found this document useful (0 votes)
45 views

Assignment 6

For any one the following polynomials: • Plot any of the functions to choose root guesses appropriately. • Apply the Muller's method and the Bairstow's method to find all real or complex roots, • Analyze and contrast performance between the two methods, • You can apply any simplifications you deem appropriate prior to applying the numerical methods. 1. f(x) = x3 - x2 + 2x – 2

Uploaded by

monica2897monica
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Assignment 6

For any one the following polynomials: • Plot any of the functions to choose root guesses appropriately. • Apply the Muller's method and the Bairstow's method to find all real or complex roots, • Analyze and contrast performance between the two methods, • You can apply any simplifications you deem appropriate prior to applying the numerical methods. 1. f(x) = x3 - x2 + 2x – 2

Uploaded by

monica2897monica
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Assignment 6

For any one the following polynomials:

 Plot any of the functions to choose root guesses appropriately.


 Apply the Muller's method and the Bairstow's method to find all real or complex
roots,
 Analyze and contrast performance between the two methods,
 You can apply any simplifications you deem appropriate prior to applying the
numerical methods.

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.

Python code to plot the function:


Plot of the function f(x) = x3 - x2 + 2x – 2:

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:

 f(x1,x0) = (f(x1)- f(x0))/(x1-x0) = 2


 f(x2,x1) = (f(x2)- f(x1))/(x2-x1) = 2
 f(x2, x0) = (f(x2,x1) - f(x1,x0))/(x2-x0) = 0

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)):

 P2(x) = ,f(x0) + f(x0,x1)(x-x0) + f(x0,x1, x2)(x-x0)( x-x1)


 P2(x) = 2x-2

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

The next approximation x3= 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:

 f(x2,x1) = (f(x2)- f(x1))/(x2-x1) = 2


 f(x3, x2) = = (f(x3)- f(x2))/(x3-x2) = 0

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)),

 P2(x) = ,f(x1) + f(x1,x2)(x-x1) + f(x1,x2, x2)(x-x1)( x-x2)


 P2(x) = 2x-2
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

The next approximation x4= 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

Let's choose the following initial guesses:

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)

f= -2(constant term on right hand side of equation)

Using these coefficient lets calculate Δ, Δp, Δq as follows:


Δ=b2−4ac = -7

Δp= -c – (b/2) = -(3/2)

Δq= -f/ Δp = 4/3

Now lets update p and q using the formulas:

p1 = p0 + Δp = -(1/2)

q1 = q0 + Δq = 7/3

Iteration 2:

p1 = -(1/2)

q1 = 7/3

Δ=b2−4ac = -(25/3)

Δp= -c – (b/2) = -(13/6)

Δq= -f/ Δp = 12/13

Now lets update p and q

p2 = p1 + Δp = -(8/3)

q2 = q1 + Δq = 91/39

Iteration 3:

p2 = -(8/3)

q2 = 91/39

Δ=b2−4ac = -(325/39)

Δp= -c – (b/2) = 35/39

Δq= -f/ Δp = 156/35

Now lets update p and q

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.

In our case, the quadratic equation is x2-(104/39)x + (91/39) + (156/35) = 0

Let's calculate the discriminant and then find the roots of the quadratic equation:

a=1

b = -(104/39)

c = (91/39) + (156/35)

Δ = b2-4ac = (-(104/39))2 -4 * 1 * ((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

x2 = (104/78) - (416/78)i = (52/39) - (208/39)i

Therefore complex roots of quadratic equation is x2-(104/39)x + (91/39) + (156/35) = 0 are

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

Therefore, the roots of the cubic polynomial are:

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.

You might also like