Question
The roots of a quadratic function ax2 + bx + c = 0 can be calculated using the quadratic formula The discriminant of the formula,
The roots of a quadratic function ax2 + bx + c = 0 can be calculated using the quadratic formula
The discriminant of the formula, b 2 4ac, indicates whether the roots are real or imaginary.
a. Write a function in MATLAB to calculate the discriminant. What are the inputs it needs? What is the desired output from the function?
b. Write a function in MATLAB that calculates the roots of a quadratic function given a, b, and c as inputs to the function. What is the desired output of the function? The function to calculate the roots will call the function to calculate the discriminant that you have written and use the result from that function to calculate the roots. Test your function by using the following sets of coefficients.
(a, b, c) = (2, 10, 12) 2x^2 + 10x + 12 = 0
(a, b, c) = (1, 0 ,1) x^2 + 1 = 0
Submit your .m file and the contents of the Command Window.
21,2 = -b62 - 4ac 2a
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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