Question: Is rootCondition output correct for the example input [ 2 - 4 5 ] ? ( Pretest ) Is rootValues output correct for the example
Is rootCondition output correct for the example input Pretest
Is rootValues output correct for the example input Pretest
Is rootCondition output correct for complex roots?
Is rootCondition output correct for indistinct repeated roots?
Is rootValues output correct for complex roots?
Is rootValues output correct for indistinct repeated roots?
Are both outputs correct for randomly generated coefficients unknown root condition
Does your solution use an ifelseifelse structure?
Quadratic Solver ifelseifelse
My Solutions
If a second order polynomial is written in the general form:
then the roots ie the values of that satisfy the equation can be determined using the quadratic formula:
Code has already been provided to define a function named quadraticSolver that accepts a element row vector and assigns it to the input variable abc, with values for and in the first, second, and third column respectively. Add commands to do the following:
Check if the roots of the polynomial defined by and are 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 is exactly equal to zero. Assign an an integer uint datatype value to the output variable rootCondition as follows:
The value if the roots are real and distinct
The value if the two roots are the same.
The value if the roots are not real ie complex because the value under the square root is less than
Assign the solution to the quadratic to the output variable rootValues according to the following guidelines:
In cases where there are two real and distinct roots, compute the two roots and assign them in ascending order to a twoelement row vector.
In cases where the two roots are the same, compute the root and assign this value to both elements in a twoelement row vector.
In cases where the roots are complex, output assign the text 'complex roots' output variable rootValues.
Note the value of abc is defined as a function input. Do not overwrite this value in your code. Be sure to assign values to each of the function output variables.
Use an ifelseifelse structure in your code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
