Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions