Question: 4. Write a MATLAB function to solve the quadratic equation ar? +bx+c= 0, using the classical quadratic formula x = (-6 + 762 - 4ac)/(2a).

4. Write a MATLAB function to solve the quadratic equation ar? +bx+c= 0, using the classical quadratic formula x = (-6 + 762 - 4ac)/(2a). (a) Test your function on the following cases: (i) a = 2, b = 3, c = 1, (ii) a = 1, b = 3, c = 4. In each case and for each choice of sign, verify the accuracy of the numerical solution by comparing it with the exact solution. (b) Now consider the case (iii) a = 1, b = 3, c= 8-14 One solution is 2-3. Test your MATLAB script on case (iii). It should perform poorly, so modify it to obtain accurate approximate roots. Finally, use MATLAB to make a table which displays three sets of roots for case (iii), those calculated with your original function, your modified function, and MATLAB's internal roots function. 4. Write a MATLAB function to solve the quadratic equation ar? +bx+c= 0, using the classical quadratic formula x = (-6 + 762 - 4ac)/(2a). (a) Test your function on the following cases: (i) a = 2, b = 3, c = 1, (ii) a = 1, b = 3, c = 4. In each case and for each choice of sign, verify the accuracy of the numerical solution by comparing it with the exact solution. (b) Now consider the case (iii) a = 1, b = 3, c= 8-14 One solution is 2-3. Test your MATLAB script on case (iii). It should perform poorly, so modify it to obtain accurate approximate roots. Finally, use MATLAB to make a table which displays three sets of roots for case (iii), those calculated with your original function, your modified function, and MATLAB's internal roots function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
