Question: Note: Use MATLAB to solve all of the tasks. For each task, TOL is the required tolerance, and Nmax is the maximum number of iterations
Note: Use MATLAB to solve all of the tasks. For each task, TOL is the required tolerance, and Nmax is the maximum number of iterations allowed. You must print if the function executed successfully or not, where success is defined as TOL being satisfied at or before Nmax. Your function must print the values of pn and f(pn) at each iteration n. Each MATLAB function must be saved as a separate .m file. Use format long to print numbers with a higher number of decimal places. Please do not give me incorrect or incomplete code. Also explain your code with comments in line to ease understanding. Furthermore, give answer to the question asked in the last 2 questions as a comment at the end of the code. Thanks.
Task 5 Given a continuous function f on the interval [p0, p1] where f(p0) and f(p1) have opposite signs, implement the false position method as a MATLAB function falsePos(f, p0, p1, TOL, Nmax) to find a solution to the equation f(x) = 0, where f is an inline function; p0, p1 are initial approximations.
Task 6 Use the Fixed-Point iteration method fixedPt(g, p0, TOL, Nmax) to solve a) x = 0.5(sin(x) cos(x)) b) x = 6 x For both equations, use p0 = 0.5, TOL = 108 , Nmax = 80.
Task 7 Let f(x) = tan(x) 6. Solve f(x) = 0 using a) bisection(f, a, b, TOL, Nmax) with a = 0, b = 0.48 b) newton(f, p0, TOL, Nmax) with p0 = 0.2 c) secant(f, p0, p1, TOL, Nmax) with p0 = 0, p1 = 0.48 d) falsePos(f, p0, p1, TOL, Nmax) with p0 = 0, p1 = 0.48 Use TOL = 1010 , Nmax = 100 in all four methods. Which method uses the least amount of iterations to satisfy the tolerance?
Task 8 Let f(x) = 230x 4 + 18x 3 + 9x 2 221x 9. Solve f(x) = 0 using a) bisection(f, a, b, TOL, Nmax) with a = -1, b = 0 b) newton(f, p0, TOL, Nmax) with p0 = -0.5 c) secant(f, p0, p1, TOL, Nmax) with p0 = -1, p1 = 0 d) falsePos(f, p0, p1, TOL, Nmax) with p0 = -1, p1 = 0 Use TOL = 1015 , Nmax = 100 in all four methods. Which method uses the least amount of iterations to satisfy the tolerance?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
