Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This code is for c++ coding Root-finding is a common problem in engineering: we have a function f(x) that we know, and we want to

image text in transcribedThis code is for c++ coding image text in transcribed

Root-finding is a common problem in engineering: we have a function f(x) that we know, and we want to find the root x* which solves this equation, i.e., for which f(x*) = 0. In high school you probably only learned how to find roots of quadratic polynomials and the ba- sic exponential and trigonometric functions. Alas, there do exist some engineering applications that don't fall in those categories... so in reality we generally must resort to approximately finding the roots. This is almost al- ways done in an iterative way, successively getting closer to the true root. We previously came across the bisec- tion method, and now we'll try the Newton-Raphson method. 1.5 The principle of Newton-Raphson is illustrated in the figure. The blue curve shows f(x), and the blue + shows the root x* which we want to find. The red + shows our initial (or current) guess or approximation - let's call this ^n (so our initial guess is then xo). We see that f(zn) > 0 and therefore that it is not the root. The idea in the Newton-Raphson method is to use a Taylor expansion of f(a) around our current approximation In. This yields This approximation to f(x) is linear and shown as a red line in the figure. Since we want to find the that produces f(a) 0, we set the left hand side to zero and solve for x. Let's call our solution n+1, which is shown as a black + in the figure. We get f'(n) The Newton-Raphson method is then to guess an initial xo and repeatedly use Eqn. (1) to get a sequence of improved approximations to the true root x*. We would terminate when our approxi mations don't change by much any more. i.e., when |xn+1-wnl is less than some tolerance. Your job is to write a program that uses the Newton-Raphson method to solve the equation f(x)-0. The function f(x) and its derivative f'(x) must both be implemented in separate C++ functions with prototypes float f(float); float fprime(float); Root-finding is a common problem in engineering: we have a function f(x) that we know, and we want to find the root x* which solves this equation, i.e., for which f(x*) = 0. In high school you probably only learned how to find roots of quadratic polynomials and the ba- sic exponential and trigonometric functions. Alas, there do exist some engineering applications that don't fall in those categories... so in reality we generally must resort to approximately finding the roots. This is almost al- ways done in an iterative way, successively getting closer to the true root. We previously came across the bisec- tion method, and now we'll try the Newton-Raphson method. 1.5 The principle of Newton-Raphson is illustrated in the figure. The blue curve shows f(x), and the blue + shows the root x* which we want to find. The red + shows our initial (or current) guess or approximation - let's call this ^n (so our initial guess is then xo). We see that f(zn) > 0 and therefore that it is not the root. The idea in the Newton-Raphson method is to use a Taylor expansion of f(a) around our current approximation In. This yields This approximation to f(x) is linear and shown as a red line in the figure. Since we want to find the that produces f(a) 0, we set the left hand side to zero and solve for x. Let's call our solution n+1, which is shown as a black + in the figure. We get f'(n) The Newton-Raphson method is then to guess an initial xo and repeatedly use Eqn. (1) to get a sequence of improved approximations to the true root x*. We would terminate when our approxi mations don't change by much any more. i.e., when |xn+1-wnl is less than some tolerance. Your job is to write a program that uses the Newton-Raphson method to solve the equation f(x)-0. The function f(x) and its derivative f'(x) must both be implemented in separate C++ functions with prototypes float f(float); float fprime(float)

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions