Question: Create a function that solves a quadratic equation. The first line of your function should be: function [ x 1 , x 2 ] =

Create a function that solves a quadratic equation. The first line of your function should be:
function [x1,x2]=quadratic_solver(a,b,c)
The inputs are a, b and c which must return all solutions such that ax2+bx+c=0. Use
conditional statements for the following cases:
If a and b are both equal to zero, then no solution exists.
Otherwise, if a is zero, the problem becomes linear and there is only one solution.
If solution is complex, assume no solution and inform the user.
If a double root exists, return same solution twice and inform the user.
Otherwise, return both solutions.
In any cases where there is no solution, return x1=0 and x2=0 with an error message. If there
is only one solution, set both x1 and x2 to this solution.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!