Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Need help in C++ Program Problem 1. (20 points) Write a computer program to implement the following algorithm combin- ing the bisection and Newton's method

Need help in C++ Program

image text in transcribed

Problem 1. (20 points) Write a computer program to implement the following algorithm combin- ing the bisection and Newton's method for solving f(r) 0. the function f() and its derivative f (x) as two subroutines input two positive parameters epsl and eps2, and the values of a, b (a, b being the initial interval containing a root); check f(a) and f(b) have opposite signs; starting with a, b], apply the bisection algorithm until an approximation xapp with the absolute error less than eps1 is obtained; print the sequence of intervals obtained and the error estimate for each iteration; use the approximation xapp obtained above as the initial approximation, apply Newton's method until an approximation xapp with the absolute error less than eps2 is obtained; print the sequence of approximations and the error estimates; . Set the maximal number of Newton's iterations to 50 (i.e. stop if it fails to obtain an accurate result after 50 iterations) Run your program to find a root of. (r) = z+e-50 rcos(r) on the interval [a, = [-r/2.0] coS on the interval l with the following different sets of parameters 12 10-2, eps2 +2. eps 1 10- 12 12 3. eps 1 = 10. eps2 10 Problem 2: (bonus, 5 points) Given an approximation ro, Newton's method is derived by solving /(20 + h) = 0 with the approximation f(x + h) f(ro) + f,(20)h (Taylor polynormal of degree Now, we can improve Newton's method by using the more accurate approximation f(r +h) f(zo) + f, (m)h+ "(zo) h2 (Taylor polynomial of degree 2), and solve Then ro h can be used as a new approximation and a new method is obtained . There are two solutions for h in the above equation. Determine which one should be used Your choice should work for a general equation, rather than just the particular one below . Write a computer program to implement this method and use it to find a root of - 5x + 1 0 with an error less than 10-15 starting with xo = 0.5. Discuss the convergence behavior in comparison with Newton's method Problem 1. (20 points) Write a computer program to implement the following algorithm combin- ing the bisection and Newton's method for solving f(r) 0. the function f() and its derivative f (x) as two subroutines input two positive parameters epsl and eps2, and the values of a, b (a, b being the initial interval containing a root); check f(a) and f(b) have opposite signs; starting with a, b], apply the bisection algorithm until an approximation xapp with the absolute error less than eps1 is obtained; print the sequence of intervals obtained and the error estimate for each iteration; use the approximation xapp obtained above as the initial approximation, apply Newton's method until an approximation xapp with the absolute error less than eps2 is obtained; print the sequence of approximations and the error estimates; . Set the maximal number of Newton's iterations to 50 (i.e. stop if it fails to obtain an accurate result after 50 iterations) Run your program to find a root of. (r) = z+e-50 rcos(r) on the interval [a, = [-r/2.0] coS on the interval l with the following different sets of parameters 12 10-2, eps2 +2. eps 1 10- 12 12 3. eps 1 = 10. eps2 10 Problem 2: (bonus, 5 points) Given an approximation ro, Newton's method is derived by solving /(20 + h) = 0 with the approximation f(x + h) f(ro) + f,(20)h (Taylor polynormal of degree Now, we can improve Newton's method by using the more accurate approximation f(r +h) f(zo) + f, (m)h+ "(zo) h2 (Taylor polynomial of degree 2), and solve Then ro h can be used as a new approximation and a new method is obtained . There are two solutions for h in the above equation. Determine which one should be used Your choice should work for a general equation, rather than just the particular one below . Write a computer program to implement this method and use it to find a root of - 5x + 1 0 with an error less than 10-15 starting with xo = 0.5. Discuss the convergence behavior in comparison with Newton's method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions