Question: MATLAB quadform: function [x1,x2] = quadform(a,b,c) d = sqrt(b^2 - 4*a*c); x1 = (-b + d) / (2*a); x2 = (-b - d) / (2*a);
MATLAB
quadform:
function [x1,x2] = quadform(a,b,c)
d = sqrt(b^2 - 4*a*c);
x1 = (-b + d) / (2*a);
x2 = (-b - d) / (2*a);
Write a function quadform2 that implements the quadratic formula differently from quadform above (page 19). First compute
x1 = (bsign(b)sqrt(b^2 - 4ac))/ 2a
which is the root of largest magnitude, and then use the identity x1x2 = c/a to find x2.
Apply both quadform and quadform2 to find the roots of x2 (10^7 + 10^7)x + 1. Do you see why quadform2 is better?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
