Question: Please write a C++ program. Programming tasks Your main programming task is to implement a nonlinear solver class with appropriate methods. The class should be

Please write a C++ program.

Please write a C++ program. Programming tasks Your main programming task isto implement a nonlinear solver class with appropriate methods. The class should

be able to solve using single and double precision variables. The first

method uses the regula falsi method to solve a nonlinear equation. It

Programming tasks Your main programming task is to implement a nonlinear solver class with appropriate methods. The class should be able to solve using single and double precision variables. The first method uses the regula falsi method to solve a nonlinear equation. It should have an interface that looks something like RegFal(f, a, b,abs Tol,rel Tol) where f is the function whose root is to be found, a and b are the left and right endpoints respectively of the interval containing a root, and absTol and relTol are the desired absolute and relative errors in the result. The second method uses Newton's method to solve a nonlinear equation. It should have an interface that looks something like Newton (f.fp,startValue,abs Tol,rel Tol) where f and fp are the function and its derivative, startValue is the initial guess at the root. The third method uses the secant method to solve a nonlinear equation. It should have an interface that looks something like Secant(f.start Value.abs Tol.rel Tol) where f is the function, startValue is the initial guess at the root. RegFal, Secant and Newton are to be stand-alone and reusable and should not need to be modified when changing problems to be solved. They should include no I/O and should not assume that the functions f and fp have particular names only that f = f(x) and fp = f'(x). You should return an error flag to indicate to the user if the iteration has completed successfully or not. These routines should be tested individually and your report must contain convincing evidence and arguments that the routines work correctly. You should base the test design and analysis on the theory that describes how the methods should behave. It should include a discussion of the convergence rates and behavior expected by the theory and observed in your experiments. You should use carefully chosen functions to make your points in this discussion. Include examples of the influence of the choice of initial condition on the behavior of the methods (especially for locally convergent Newton and Secant methods). The effect the multiplicity of the root on convergence behavior should also be investigated. You should also include in your examples to be analyzed elements from the set of Cheby- shev polynomials of the first kind that are defined using the recurrence: To(x) =1, T1(x) = x, and In+1(2) = 2xT () - Tn-1(x). where T:(x) is clearly a polynomial of degree i. For example, we have for the first three polynomials, To = 1, T = x, T, = 2x2 - 1, T3 = 4.23 - 30. It is known that all of the roots of these polynomials are contained in the closed interval [-1,1]. The roots of the degree m +1 Chebyshev polynomial Tm+1(x) are known to be (21+1) = cos 0 0-2 > 0 > 2 and = 0 >0 X 0 The function is antisymmetric around 0. So you can construct initial intervals of Regula Falsi or that contain xo (and x-1) for Newton (and Secant) based on, e.g. a > 0 and > 0, with various values and sign patterns. For example, a = -a and b = a or a = -a and b = -B or a = a and b = B with the specific values chosen based on the shape of the function. The effects of their values and the location of the initial guesses should be related to convergence behavior and rates that you observe. You should also apply your methods to the test problems from the notes and other simple functions for which you can use the shape to predict where the choice of the initial guesses for the roots must be in order to observe convergence to a particular root, divergence from all roots (if possible), very slow convergence etc. Essentially, these experiments should be part of the overall plan you use to show that the codes work as expected and that you have developed some characteristics of the shapes expected to influence the methods behaviors. Programming tasks Your main programming task is to implement a nonlinear solver class with appropriate methods. The class should be able to solve using single and double precision variables. The first method uses the regula falsi method to solve a nonlinear equation. It should have an interface that looks something like RegFal(f, a, b,abs Tol,rel Tol) where f is the function whose root is to be found, a and b are the left and right endpoints respectively of the interval containing a root, and absTol and relTol are the desired absolute and relative errors in the result. The second method uses Newton's method to solve a nonlinear equation. It should have an interface that looks something like Newton (f.fp,startValue,abs Tol,rel Tol) where f and fp are the function and its derivative, startValue is the initial guess at the root. The third method uses the secant method to solve a nonlinear equation. It should have an interface that looks something like Secant(f.start Value.abs Tol.rel Tol) where f is the function, startValue is the initial guess at the root. RegFal, Secant and Newton are to be stand-alone and reusable and should not need to be modified when changing problems to be solved. They should include no I/O and should not assume that the functions f and fp have particular names only that f = f(x) and fp = f'(x). You should return an error flag to indicate to the user if the iteration has completed successfully or not. These routines should be tested individually and your report must contain convincing evidence and arguments that the routines work correctly. You should base the test design and analysis on the theory that describes how the methods should behave. It should include a discussion of the convergence rates and behavior expected by the theory and observed in your experiments. You should use carefully chosen functions to make your points in this discussion. Include examples of the influence of the choice of initial condition on the behavior of the methods (especially for locally convergent Newton and Secant methods). The effect the multiplicity of the root on convergence behavior should also be investigated. You should also include in your examples to be analyzed elements from the set of Cheby- shev polynomials of the first kind that are defined using the recurrence: To(x) =1, T1(x) = x, and In+1(2) = 2xT () - Tn-1(x). where T:(x) is clearly a polynomial of degree i. For example, we have for the first three polynomials, To = 1, T = x, T, = 2x2 - 1, T3 = 4.23 - 30. It is known that all of the roots of these polynomials are contained in the closed interval [-1,1]. The roots of the degree m +1 Chebyshev polynomial Tm+1(x) are known to be (21+1) = cos 0 0-2 > 0 > 2 and = 0 >0 X 0 The function is antisymmetric around 0. So you can construct initial intervals of Regula Falsi or that contain xo (and x-1) for Newton (and Secant) based on, e.g. a > 0 and > 0, with various values and sign patterns. For example, a = -a and b = a or a = -a and b = -B or a = a and b = B with the specific values chosen based on the shape of the function. The effects of their values and the location of the initial guesses should be related to convergence behavior and rates that you observe. You should also apply your methods to the test problems from the notes and other simple functions for which you can use the shape to predict where the choice of the initial guesses for the roots must be in order to observe convergence to a particular root, divergence from all roots (if possible), very slow convergence etc. Essentially, these experiments should be part of the overall plan you use to show that the codes work as expected and that you have developed some characteristics of the shapes expected to influence the methods behaviors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!