There are several methods to determine the roots of a polynomial numerically. Two of the most...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
There are several methods to determine the roots of a polynomial numerically. Two of the most popular methods is the Newton-Raphson Method and the Bisection Method. Below is the Pseudo code as well as the Python program to determine the roots using these two methods. You need to understand how these two methods work. For the assignment, you are required to do the following: 1) Discuss the mathematics underpinning these two methods. 2) Using the PYTHON program given, draw up the flow diagram. 3) Do not copy the pseudocode given but redo the pseudocode in your own words. 4) Write down the PYTHON program given. Newton-Raphson Method: Pseudocode for Newton Raphson Method 1. Start 2. Define function as f(x) 3. Define derivative of function as g(x) Pseudocode for Newton Raphson Method 1. Start 2. Define function as f(x) 3. Define derivative of function as g(x) 4. Input: a. Initial guess x0 b. Tolerable Error e c. Maximum Iteration N 5. Initialize iteration counter step = 1 6. Do If g(x0) = 0 Print "Mathematical Error" Stop End If x1 = x0 - f(x0) / g(x0) x0 = x1 step = step + 1 If step > N Print "Not Convergent" Stop End If While abs f(x1) > e 7. Print root as x1 8. Stop E * Accessibility: Investigate D Focus 目 to search 21°C Mostl Python Source Code: Newton Raphson Method Function whose root is to be determined: f(x) = x - 5x -9 # Defining Function def f(x): return x*3 - 5x -9 # Defining derivative of function def g(x): return 3*x**2 - 5 # Implementing Newton Raphson Method def newtenRachson x0 e N) print inn*** NEWTON RAPHSON METHOD IMPLEMENTATION ****) step = 1 flag = 1 condition = True while condition: if g(x0) == 0.0 print 'Divide by zero error!") break x1 = x0 - f(x0/g(x0) print'Iteration-%d, x1 = %0.6f and f(x1) = %0.6f % (step, x1, f(x1)) x0 = x1 step = step + 1 if step > N: flag = 0 break condition = abs(fx1)) > e Paragraph Styles Editing flag = 0 break condition = abs(fx1)) > e if flag==1: print"nReauired root is: %0.8f % x1) else print aNat Convergent') # Input Section x0 = input('Enter Guess: ) e = input"Tolerable Error: ") N= input('Maximum Step: ') # Converting x0 and e to float x0 = float(x0) e = float(e) # Converting N to integer N = int(N) Paragraph Styles Editi Bisection Method Algorithm (Step Wise) 1. start 2. Define function f(x) 3. Choose initial guesses x0 and x1 such that f(x0)f(x1) < 0 4. Choose pre-specified tolerable error e. 5. Calculate new approximated root as x2 = (x0 + x1)/2 6. Calculate f(xOlf(x2) a. if f(x0)f(x2) < 0 then x0 = x0 and x1 = x2 b. if f(x0)f(x2) > 0 then x0 = x2 and x1 = x1 c.if f(x0)f(x2) = 0 then goto (8) !! 7. if If(x2)] > e then goto (5) otherwise goto (8) 8. Display x2 as root. 9. Stop Python Source Code: Bisection Method # Defining Function def f(x) return x**3-5*x-9 # Implementing Bisection Method def bisection(x0 x1,e): cton - 1 12 Paragraph Styles Editing # Defining Function def f(x): return x**3-5*x-9 # implementing Bisection Method def bisection(x0 x1.e). step = 1 print\nin** BISECTION METHOD IMPLEMENTATION ***) condition = True while condition: x2 = (x0 + x1)/2 print Iteration-%d, x2 = %0.6f and f(x2) = %0.6f % (step, x2, f(x2)) if fx0) * f(x2) < 0: x1 = x2 else: x0 = x2 step = step + 1 condition = abs(fx2)) > e printaReauiced Root is : %0.8f % x2) # Input Section x0 = input"First Guess: ') x1 = inputt Second Guess: ") e = input("Tolerable Error. ") # Converting input to float x0 = float(x0) x1 = float(x1) e = float(e) Pseudocode for Newton Raphson Method 1. Start 2. Define function as f(x) 3. Define derivative of function as g(x) 4. Input: a. Initial guess x0 b. Tolerable Error e c. Maximum Iteration N 5. Initialize iteration counter step = 1 6. Do If g(x0) = 0 Print "Mathematical Error" Stop End If x1 = x0 - f(x0) / g(x0) x0 = x1 step = step + 1 If step > N Print "Not Convergent" Stop End If While abs f(x1) > e 7. Print root as x1 8. Stop E * Accessibility: Investigate D Focus 目 to search 21°C Mostl There are several methods to determine the roots of a polynomial numerically. Two of the most popular methods is the Newton-Raphson Method and the Bisection Method. Below is the Pseudo code as well as the Python program to determine the roots using these two methods. You need to understand how these two methods work. For the assignment, you are required to do the following: 1) Discuss the mathematics underpinning these two methods. 2) Using the PYTHON program given, draw up the flow diagram. 3) Do not copy the pseudocode given but redo the pseudocode in your own words. 4) Write down the PYTHON program given. Newton-Raphson Method: Pseudocode for Newton Raphson Method 1. Start 2. Define function as f(x) 3. Define derivative of function as g(x) Pseudocode for Newton Raphson Method 1. Start 2. Define function as f(x) 3. Define derivative of function as g(x) 4. Input: a. Initial guess x0 b. Tolerable Error e c. Maximum Iteration N 5. Initialize iteration counter step = 1 6. Do If g(x0) = 0 Print "Mathematical Error" Stop End If x1 = x0 - f(x0) / g(x0) x0 = x1 step = step + 1 If step > N Print "Not Convergent" Stop End If While abs f(x1) > e 7. Print root as x1 8. Stop E * Accessibility: Investigate D Focus 目 to search 21°C Mostl Python Source Code: Newton Raphson Method Function whose root is to be determined: f(x) = x - 5x -9 # Defining Function def f(x): return x*3 - 5x -9 # Defining derivative of function def g(x): return 3*x**2 - 5 # Implementing Newton Raphson Method def newtenRachson x0 e N) print inn*** NEWTON RAPHSON METHOD IMPLEMENTATION ****) step = 1 flag = 1 condition = True while condition: if g(x0) == 0.0 print 'Divide by zero error!") break x1 = x0 - f(x0/g(x0) print'Iteration-%d, x1 = %0.6f and f(x1) = %0.6f % (step, x1, f(x1)) x0 = x1 step = step + 1 if step > N: flag = 0 break condition = abs(fx1)) > e Paragraph Styles Editing flag = 0 break condition = abs(fx1)) > e if flag==1: print"nReauired root is: %0.8f % x1) else print aNat Convergent') # Input Section x0 = input('Enter Guess: ) e = input"Tolerable Error: ") N= input('Maximum Step: ') # Converting x0 and e to float x0 = float(x0) e = float(e) # Converting N to integer N = int(N) Paragraph Styles Editi Bisection Method Algorithm (Step Wise) 1. start 2. Define function f(x) 3. Choose initial guesses x0 and x1 such that f(x0)f(x1) < 0 4. Choose pre-specified tolerable error e. 5. Calculate new approximated root as x2 = (x0 + x1)/2 6. Calculate f(xOlf(x2) a. if f(x0)f(x2) < 0 then x0 = x0 and x1 = x2 b. if f(x0)f(x2) > 0 then x0 = x2 and x1 = x1 c.if f(x0)f(x2) = 0 then goto (8) !! 7. if If(x2)] > e then goto (5) otherwise goto (8) 8. Display x2 as root. 9. Stop Python Source Code: Bisection Method # Defining Function def f(x) return x**3-5*x-9 # Implementing Bisection Method def bisection(x0 x1,e): cton - 1 12 Paragraph Styles Editing # Defining Function def f(x): return x**3-5*x-9 # implementing Bisection Method def bisection(x0 x1.e). step = 1 print\nin** BISECTION METHOD IMPLEMENTATION ***) condition = True while condition: x2 = (x0 + x1)/2 print Iteration-%d, x2 = %0.6f and f(x2) = %0.6f % (step, x2, f(x2)) if fx0) * f(x2) < 0: x1 = x2 else: x0 = x2 step = step + 1 condition = abs(fx2)) > e printaReauiced Root is : %0.8f % x2) # Input Section x0 = input"First Guess: ') x1 = inputt Second Guess: ") e = input("Tolerable Error. ") # Converting input to float x0 = float(x0) x1 = float(x1) e = float(e) Pseudocode for Newton Raphson Method 1. Start 2. Define function as f(x) 3. Define derivative of function as g(x) 4. Input: a. Initial guess x0 b. Tolerable Error e c. Maximum Iteration N 5. Initialize iteration counter step = 1 6. Do If g(x0) = 0 Print "Mathematical Error" Stop End If x1 = x0 - f(x0) / g(x0) x0 = x1 step = step + 1 If step > N Print "Not Convergent" Stop End If While abs f(x1) > e 7. Print root as x1 8. Stop E * Accessibility: Investigate D Focus 目 to search 21°C Mostl
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
1. Presented below are selected amounts from the separate unconsolidated financial statements of Poe Corp. and its 90%-owned subsidiary, Shaw Co., at December 31,2002. Additional information as...
-
Consider a 60-Hz radial three-phase distribution feeder having the following characteristics: Substation three-phase transformer: wye-wye grounded 132 kV-13.2 kV, 10 MVA, Zeq = (0.5 + j9) % (on the...
-
Comprehensive Problem On July 31, 2020, the end of its most recent fiscal year, Elizabeth River Business Consultants' post- closing trial balance was as follows: Accounts Debit Credit Cash $ 26,150...
-
An automobile is traveling at 60.0 km/h. Its tires have a radius of 33.0 cm. (a) Find the angular speed of the tires (in rad/s). (b) Find the angular displacement of the tires in 30.0 s. (c) Find the...
-
Distinguish policies on external competitiveness from policies on internal alignment. Why is external competitiveness so important?
-
Companies must decide whose rate of return (i.e., local vs. parent currency returns) to use when evaluating foreign direct investment opportunities. Discuss the internal reporting dimensions of this...
-
If in Figure P29.40 \(R=0.25 \mathrm{~m}\) and the magnetic field magnitude is decreasing at a rate of \(0.30 \mathrm{~T} / \mathrm{s}\), what is the magnitude of the electric field created by this...
-
The three accounts shown below appear in the general ledger of Lauber Corp. during 2014. Instructions From the postings in the accounts, indicate how the information is reported on a statement of...
-
1. Define ADT (Abstract Data Type)? 2. Mention the features of ADT.? 3. Define List ADT? 4. What are the ways of implementing linked list? 5. What are the types of linked lists?
-
You are trying to evaluate whether an existing, idle distillation column can be used for a separation for which it was not originally designed. Answer the following questions about this column: a....
-
A production manager is concerned about low output levels of his employees. The articles he has read on job performance frequently mention four variables as being important to job performance; (1)...
-
On 1 January 2010, an entity issued EUR 400,000 of 7 per cent bond at par. Interest on this loan stock is payable on 31 December each year. The stock is due for redemption at par on 31 December 2013...
-
Write a simple loop that lets you exercise the cache. By changing the number of statements in the loop body, you can vary the cache hit rate of the loop as it executes. You should be able to observe...
-
One of the easiest things to determine about a company by looking at its organization chart is its span of control. This exercise will allow you to learn about and compare span of control within...
-
Derive an expression showing that when an elastic collision between two objects is viewed from the zero momentum reference frame, the direction of the momentum of each object is reversed and the...
-
Consider an exponential utility function , with a strictly positive . An investor characterised by this exponential utility has to allocate an initial wealth \(W_{0}\) between a risk-free and a risky...
-
how will you Extract relevant features from multimodal data using techniques like CNN or pre - trained models ( ( e . . g . , . , VGG 1 6 , 1 6 , ResNet ) ) in fake news detection using NLP
-
In the series connection below, what are the respective power consumptions of R, R2, and R3? R R www 4 V=6V P1-3 W; P2=3W; and P3= 3 W OP10.5 W; P2-1 W; and P3= 1.5 W P1=1.5 W; P2=1 W; and P3= 0.5 W...
-
Lincoln Park Zoo in Chicago is considering a renovation that will improve some physical facilities at a cost of \(\$ 1,800,000\). Addition of new species will cost another \(\$ 310,000\). Additional...
-
For the heritage center described in Problem 32, note that a survey that has determined that annual benefits of \(\$ 3\) each are now received by 12,000 visitors, \(\$ 5\) each by 14,000 visitors,...
-
The federal government is planning a hydroelectric project for a river basin. The project will provide electrical energy to the local area and to the grid. With some enhancements to the basic plan,...
Study smarter with the SolutionInn App