Question: Explanation and correct answer gets thumbs up. Thank you Problem statement The objective of the assignment is to implement a robust and efficient root finding

Explanation and correct answer gets thumbs up. Thank youExplanation and correct answer gets thumbs up. Thank you Problem statement The

objective of the assignment is to implement a robust and efficient root

Problem statement The objective of the assignment is to implement a robust and efficient root finding algorithm. In this assignment, you will code the bisection algorithm, the modified secant algorithm and a hybrid algorithm that combines the bisection and modified secant algorithms. To test the properties of your root-finding algorithms, you will solve the equation:

f(x) = 0 where f(x) = 0.1x3 +x2 +0.5 (1) Applying this algorithm to this function should illustrate that:

The bisection algorithm is robust but slow

The modified secant algorithm is generally fast but sometimes slower than expected

The hybrid algorithm is both robust and fast.

Tasks

Create a MATLAB m file named LastnameFirstnameCP1.m, where Lastname is your last name and Firstname is your first name. This m file should include four functions: LastnameFirstnameCP1, bisection, modifiedSecant and hybridRootFinding.

In the function LastnameFirstnameCP1, plot the function f as a function of x from x = 15 to x = 5. Display the grid lines and include axis labels.

Write a function called bisection for the bisection algorithm. The inputs should be: a function

f (as an anonymous function handle); the lower bound, xl; the upper bound, xu; and the

maximum allowable approximate percent relative error, max. The outputs of the function a

should be the value of the root, xr, the value of the approximate percent relative error, a, and the number of iterations, Niter.

4. Call your function bisection in your LastnameFirstnameCP1 function using the following inputs:thefunctionffromEq.1,x=15,x =5andmax=108%.Insideyour

lua LastnameFirstnameCP1 function, include commands to display the value of xr, a and

Niter to the screen using fprintf (properly format your output).

Write a function called modifiedSecant for the modified secant algorithm (see section 6.3.3 of the Textbook). The inputs should be the function f (as an anonymous function handle), the initial guess x0, the perturbation fraction, , and the maximum allowable approximate percent relative error, max.

Within your LastnameFirstnameCP1 function , call your function modifiedSecant three

different times: using (1) x0 = 1 (2) x0 = 4 and (3) x0 = 10. For each call, use = 0.01

and max = 1108 %; display the value of the outputs to the screen using fprintf (properly a

format your output).

a

1

Write a function called hybridRootFinding that combines the bisection and modified secant

algorithms. The function should run your bisection algorithm until the approximate relative

error is less than max1. It should then run your Newton-Raphson algorithm using the value of a

the root found using the bisection algorithm as initial guess; the Newton-Raphson algorithm should run until the error is below max2. This function should have 6 inputs (a function f,

x , x , , max1 and max2) and 4 outputs ( x ; the number of iterations for the bisection luaar

algorithm, Niter1; the number of iterations for the modified secant algorithm, Niter2; the final value of a).

Call your function hydridRootFinding in your LastnameFirstnameCP1 function. Use the followinginputs:ffromEq.1,x =15,x =5,=0.01,max1=1%,andmax1=108%.

a

luaa

Display the value of the outputs to the screen using fprintf to properly format your output.

Problem statement The objective of the assignment is to implement a robust and efficient root finding algorithm. In this assignment, you will code the bisection algorithm, the modified secant algorithm and a hybrid algorithm that combines the bisection and modified secant algorithms. To test the properties of your root-finding algorithms, you will solve the equation f(x) 0 where f(x) 0.1x3 +x2 +0.5 Applying this algorithm to this function should illustrate that The bisection algorithm is robust but slow The modified secant algorithm is generally fast but sometimes slower than expected The hybrid algorithm is both robust and fast Tasks 1. Create a MATLAB m file named LastnameFirstnameCP1.m, where Lastname is your last name and Firstname is your first name. This m file should include four functions LastnameFirstnameCP1, bisection, modifiedSecant and hybridRootFinding 2. In the function LastrameFirstnameCPI, plot the function f as a function of x from x =-15 to z = 5' Display the grid lines and include axis labels 3. Write a function called bisection for the bisection algorithm. The inputs should be: a function f (as an anonymous function handle); the lower bound, xi; the upper bound, xu; and the maximum allowable approximate percent relative error, cmar. The outputs of the functiorn should be the value of the root, xr, the value of the approximate percent relative error, Ea, and the number of iterations, Niter 4. Call your function bisection in your LastnameFirstnameCP1 function using the following inputs: the function f from Eq. 1, =-15, xu-5 and Emaz 10-8 % . Inside your LastnameFirstnameCP1 function, include commands to display the value of xr, ea and Niter to the screen using fprintf (properly format your output) 5. Write a function called modifiedSecant for the modified secant algorithm (see section 6.3.3 of the Textbook). The inputs should be the function f (as an anonymous function handle), the initial guess xo, the perturbation fraction, , and the maximum allowable approximate percent relative error, ea". 6. Within your LastnameFirstnameCP1 function , call your function modifiedSecant three 1 (2) xo 4 and (3) TO different times: using (1) xo - and Emaz-1 10-8 %; display the value of the outputs to the screen using fprintf (properly format your output) 10. For each call, use 0.01 Problem statement The objective of the assignment is to implement a robust and efficient root finding algorithm. In this assignment, you will code the bisection algorithm, the modified secant algorithm and a hybrid algorithm that combines the bisection and modified secant algorithms. To test the properties of your root-finding algorithms, you will solve the equation f(x) 0 where f(x) 0.1x3 +x2 +0.5 Applying this algorithm to this function should illustrate that The bisection algorithm is robust but slow The modified secant algorithm is generally fast but sometimes slower than expected The hybrid algorithm is both robust and fast Tasks 1. Create a MATLAB m file named LastnameFirstnameCP1.m, where Lastname is your last name and Firstname is your first name. This m file should include four functions LastnameFirstnameCP1, bisection, modifiedSecant and hybridRootFinding 2. In the function LastrameFirstnameCPI, plot the function f as a function of x from x =-15 to z = 5' Display the grid lines and include axis labels 3. Write a function called bisection for the bisection algorithm. The inputs should be: a function f (as an anonymous function handle); the lower bound, xi; the upper bound, xu; and the maximum allowable approximate percent relative error, cmar. The outputs of the functiorn should be the value of the root, xr, the value of the approximate percent relative error, Ea, and the number of iterations, Niter 4. Call your function bisection in your LastnameFirstnameCP1 function using the following inputs: the function f from Eq. 1, =-15, xu-5 and Emaz 10-8 % . Inside your LastnameFirstnameCP1 function, include commands to display the value of xr, ea and Niter to the screen using fprintf (properly format your output) 5. Write a function called modifiedSecant for the modified secant algorithm (see section 6.3.3 of the Textbook). The inputs should be the function f (as an anonymous function handle), the initial guess xo, the perturbation fraction, , and the maximum allowable approximate percent relative error, ea". 6. Within your LastnameFirstnameCP1 function , call your function modifiedSecant three 1 (2) xo 4 and (3) TO different times: using (1) xo - and Emaz-1 10-8 %; display the value of the outputs to the screen using fprintf (properly format your output) 10. For each call, use 0.01

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!