Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help fixing Matlab code for Bisection method. Also it need to have an error test to make sure a root is inside interval (a,b)
Need help fixing Matlab code for Bisection method. Also it need to have an error test to make sure a root is inside interval (a,b)
MATLAB grader problems: HW 2_2 Write code to approximate V25 by applying the a) bisection method and b) false position method to the equation x3 = 25. Code the algorithms on your own and submit to the grader website. The endpoints of the initial interval are the inputs. Determine the result accurate to at least to 5 sig figs. Coding problems: 1 function x = mybisectcuberoot25(a,b) %compute cube root of 25 using the bisection method %root = mybisectcuberoot25(a,b) mo 6 %INPUT a,b: two guesses that bracket the solution of x^3-25 = 0 7 %OUTPUT root: the solution (cube root of 25) 8 f=@(x) x^3-25; 9 % lower and upper limits 10 a=0; 11 b=8; % tolerance 13 tol=1e-5; 14 x=(a+b)/2; Er=Inf; iteration=0; while Er> xold=x; if f(a)*f(x) Test 1 (Pretest) > Test 2 (Pretest) > Test 3 (Pretest) > Test 4 (Pretest) Assertion failed. % Test 5 (Pretest) Assertion failed > Test 6 (Pretest) error checking: test for a,b must bracket a root > Test 7 (Pretest) MATLAB grader problems: HW 2_2 Write code to approximate V25 by applying the a) bisection method and b) false position method to the equation x3 = 25. Code the algorithms on your own and submit to the grader website. The endpoints of the initial interval are the inputs. Determine the result accurate to at least to 5 sig figs. Coding problems: 1 function x = mybisectcuberoot25(a,b) %compute cube root of 25 using the bisection method %root = mybisectcuberoot25(a,b) mo 6 %INPUT a,b: two guesses that bracket the solution of x^3-25 = 0 7 %OUTPUT root: the solution (cube root of 25) 8 f=@(x) x^3-25; 9 % lower and upper limits 10 a=0; 11 b=8; % tolerance 13 tol=1e-5; 14 x=(a+b)/2; Er=Inf; iteration=0; while Er> xold=x; if f(a)*f(x) Test 1 (Pretest) > Test 2 (Pretest) > Test 3 (Pretest) > Test 4 (Pretest) Assertion failed. % Test 5 (Pretest) Assertion failed > Test 6 (Pretest) error checking: test for a,b must bracket a root > Test 7 (Pretest)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started