Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Exercise 1 In this programming exercise we will use PYTHON to implement the root finding algorithms taught in class. Write a PYTHON program to

Programming Exercise 1
In this programming exercise we will use PYTHON to implement the root finding algorithms taught in class.
Write a PYTHON program to implement the false position method to find the roots of equation
f(x)=2xcos(2x)-(x-2)2,
accurate up to four significant digits.
a) First, define a PYTHON function in the following manner:
def falsepos(func, a, b, es):
where func represents f(x),a,b the bracket and es is the stopping criteria. Thereafter, call this function
for different brackets to find the roots. Report their values.
b) Make a plot of f(x) vs.x and identify these roots via markers.
c) Verify your solutions using the in-built PYTHON function brentq for Brent's method. Note that you need
to import scipy to access this function.
Now write a PYTHON function to implement the secant method:
def falsepos(func, x0, x1, es):
where x0,x1 are the two starting points.
a) Use the function to find roots of f(x)=x4+65x3+86x+128, accurate up to 4 significant digits. Report
their values.
b) Again make a plot of the above function to and mark all the roots.
c) Verify your solutions using the in-built PYTHON function roots, which is available in numpy.
Utilizing the above functions, find the shortest distance between the curve y=x2+1 and the point (1,0).
Report the shortest distance. Which method converges faster, the false position or the secant method? (report
the number of iterations in both cases). In this programming exercise we will use PYTHON to implement the root finding algorithms taught in class.
Write a PYTHON program to implement the false position method to find the roots of equation
f(x)=2xcos(2x)-(x-2)2,
accurate up to four significant digits.
a) First, define a PYTHON function in the following manner:
def falsepos(func, a, b, es):
where func represents f(x),a,b the bracket and es is the stopping criteria. Thereafter, call this function
for different brackets to find the roots. Report their values.
b) Make a plot of f(x) vs.x and identify these roots via markers.
c) Verify your solutions using the in-built PYTHON function brentq for Brent's method. Note that you need
to import scipy to access this function.
Now write a PYTHON function to implement the secant method:
def falsepos(func, x0, x1, es):
where x0,x1 are the two starting points.
a) Use the function to find roots of f(x)=x4+65x3+86x+128, accurate up to 4 significant digits. Report
their values.
b) Again make a plot of the above function to and mark all the roots.
c) Verify your solutions using the in-built PYTHON function roots, which is available in numpy.
Utilizing the above functions, find the shortest distance between the curve y=x2+1 and the point (1,0).
Report the shortest distance. Which method converges faster, the false position or the secant method ?(report
the number of iterations in both cases).
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

List the common methods used in selecting human resources. page 254

Answered: 1 week ago