Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 3 - Quadratic Equation Solution 0 solutions submitted (max: Unlimited) If a second order polynomial is written in the general form: then the
Problem 3 - Quadratic Equation Solution 0 solutions submitted (max: Unlimited) If a second order polynomial is written in the general form: then the roots (i.e. the values of x that satisfy the equation) can be determined using the quadratic formula: -b b - 4ac 2a Some code has already been provided to semi-randomly define the variables a, b, and c. Add commands to do the following: 1. Check if the roots of the polynomial defined by a, b, and care real and distinct. Note that the roots will be real if the value under the square root is greater than or equal to zero. They will not be distinct; however, if the value under the square root (b-4ac) is exactly equal to zero. Assign an an integer value to the variable numRoots as follows: x= . The value 2 if the roots are real and distinct . The value 1 if the two roots are the same. The value 0 if the roots are not real (i.e. complex because the value under the square root is less than 0) 2. Assign the solution to the quadratic to the variable rootvalues according to the following guidelines: . In cases where there are two real and distinct roots, compute the two roots and assign them to a two-element row vector. The + value should be first and the value should be second (using the equation above) . In cases where the two roots are the same, compute the root and assign this value to both elements in a two-element row vector. In cases where the roots are complex, output assign the text 'complex roots' output variable rootvalues. The output text should be a character vector (this just means use single quotes around the text, as shown in the previous sentence). Use disp commands to show the number of roots and the root values. Use an if-elseif-else-end structure in your code. Do not overwrite the a, b, or c values in your code.
Step by Step Solution
★★★★★
3.46 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
Certainly heres the complete MATLAB code that includes the provided code along with the additional code to check the roots and display the results 1 Randomly Choose Coefficients Provided Code choice r...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