Question: 3. Write MATLAB code that calculate the three roots of a cubic equation of state using MATLAB's roots function. After determining the three roots, your

3. Write MATLAB code that calculate the three roots of a cubic equation of state using MATLAB's roots function. After determining the three roots, your code should display the number of distinct values of the roots: ("Three identical roots," "Two identical roots," or "Three distinct roots"). Your code should then state if the roots are real or complex ("All roots are real" or "Two roots are complex"). Hints: MATLAB is solving for the roots numerically, not symbolically, so the result is a (very precise) numerical approximation. Determining if roots are identical using rl--r2 may not work. To determine if floating point values of the roots are equal, define a tolerance (tol-0.0001, for example) and determine if abs(r1-r2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
