Question: C++ Implement the Newton's method (xo = 1) and Secant Algorithm (x_1 = 0.1, Xo = 1) in C++ to solve an arbitrary nonlinear function
C++

Implement the Newton's method (xo = 1) and Secant Algorithm (x_1 = 0.1, Xo = 1) in C++ to solve an arbitrary nonlinear function (find its zero(s)). The target function can be defined as anonymous, inline or a file. Stop condition: (1) The maximum n-iterations = 1000 (2) For Newton's method: 5104,10-16 For Secant Method: Significant digit = 3. Testing data: Try this function 3x? sin x +et 25x and report the results. Output: (1) For Secant method, your program should print all intermediate results following this format: Iteration# Xi-1 X; f(x+1) & (2) For Newton' Method, your program should print all intermediate results following this format: Xitl Iteration# Xi-1 X; Ea Secant Method Iteration# x_(i-1) x_i x_(i+1) f(x_(i+1)) Tepsilon_al 1 2 3 4 5 0.100000000000000 1.000000000000000 0.029351536008628 0.042166730328956 0.040230441652067 1.000000000000000 0.029351536008628 0.042166730328956 0.040230441652067 0.040227425919289 0.029351536008628 0.042166730328956 0.040230441652067 0.040227425919289 0.040227426757222 0.269235353948278 -0.047920019196283 -0.000074518457171 0.000000020710980 -0.000000000000009 2.406976724168881 22.715379214814501 0.270414770424975 0.048208513603559 0.000074946251556 Newton's Method (Tol: 1.0e-004) Iteration# x_(i-1) x_i epsilon_a Tepsilon_al 1 2 3 4 5 1.00000000000000000000 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 0.04022742675722132399 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 Newton's Method (Tol: 1.0-016) Iteration x_(i-1) x_i epsilon_a Tepsilon_al 1 2 3 4 1.00000000000000000000 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 0.04022742675722132399 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 0.04022742675722132399 0.04022742675722132399 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 0.00000000000000000000 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 0.00000000000000000000 6 Implement the Newton's method (xo = 1) and Secant Algorithm (x_1 = 0.1, Xo = 1) in C++ to solve an arbitrary nonlinear function (find its zero(s)). The target function can be defined as anonymous, inline or a file. Stop condition: (1) The maximum n-iterations = 1000 (2) For Newton's method: 5104,10-16 For Secant Method: Significant digit = 3. Testing data: Try this function 3x? sin x +et 25x and report the results. Output: (1) For Secant method, your program should print all intermediate results following this format: Iteration# Xi-1 X; f(x+1) & (2) For Newton' Method, your program should print all intermediate results following this format: Xitl Iteration# Xi-1 X; Ea Secant Method Iteration# x_(i-1) x_i x_(i+1) f(x_(i+1)) Tepsilon_al 1 2 3 4 5 0.100000000000000 1.000000000000000 0.029351536008628 0.042166730328956 0.040230441652067 1.000000000000000 0.029351536008628 0.042166730328956 0.040230441652067 0.040227425919289 0.029351536008628 0.042166730328956 0.040230441652067 0.040227425919289 0.040227426757222 0.269235353948278 -0.047920019196283 -0.000074518457171 0.000000020710980 -0.000000000000009 2.406976724168881 22.715379214814501 0.270414770424975 0.048208513603559 0.000074946251556 Newton's Method (Tol: 1.0e-004) Iteration# x_(i-1) x_i epsilon_a Tepsilon_al 1 2 3 4 5 1.00000000000000000000 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 0.04022742675722132399 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 Newton's Method (Tol: 1.0-016) Iteration x_(i-1) x_i epsilon_a Tepsilon_al 1 2 3 4 1.00000000000000000000 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 0.04022742675722132399 -0.19624091430473600273 0.03303657625052105334 0.04022004504511444978 0.04022742674941580387 0.04022742675722132399 0.04022742675722132399 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 0.00000000000000000000 6.09577731811386236416 6.94011052527396454792 0.17860419565755747406 0.00018349929135005625 0.00000000019403478543 0.00000000000000000000 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
