Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

20 If a second order polynomial is written in the general form: ax+bx+e=0 then the roots (ie the values of x that satisfy the equation)

image text in transcribed
image text in transcribed
image text in transcribed
20 If a second order polynomial is written in the general form: ax+bx+e=0 then the roots (ie the values of x that satisfy the equation) can be determined using the quadratic formula - V - 4ac You will be given a 3-elemont row vector a, b,cl as an input. The goal is to write a function that does the following 1. Check if the roots of the polynomial defined by a, b, and e aro real and distinct. Note that the roots will be roat 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 (uits datatype) valun to the output variable rootCondition you may choose a different namo) as follows: The value 2 If the roots are real and distinct . The value 1 if the two roots are the same The value of the roots are not real (o complex because the value under the square root is less than o) Assign the solution to the quadratic to the cutput variable rootValues (you may choose a different name) 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 two-clement row vector, - In cases where the two roots are the same, compute the root and assign this value to both elements in a two-olomont row vector . In cases where the roots are complex, output assign the toxt complex roots output variable rootValues Task Write a function quadratic Solver that takes one 3-element array input and returns two outputs (root condition and roof values). Use an if-elseif-else structure in your code. Is rootCondition output correct for the example input [245]? Is rootValues output correct for the example input [2 -4 5]? 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 if-elseif-else structure

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

=+ c. a company president deciding whether to open a new factory

Answered: 1 week ago