answersLogoWhite

0

array=input('Specify the coefficients of the quadratic as a row array "[a,b,c]":');

a=array(1);

b=array(2);

c=array(3);

if (a==0) && (b==0)

fprintf('The equation is degenerate');

end

if (a==0) && (b~=0)

fprintf('There is a single root at %g.\n', -c/b);

end

if (a~=0) && (c==0)

fprintf('There are two real roots at 0 and %g.\n', -b/a);

end

if (a~=0) && (c~=0)

root1=((-b+sqrt(b*b-4*a*c))/(2*a));

root2=((-b-sqrt(b*b-4*a*c))/(2*a));

if isreal(root1)

fprintf('There are two real roots at %g and %g.\n.', root1, root2);

else

fprintf('The roots are complex:\n');

fprintf(' ');

disp(root1);

fprintf(' and ');

disp(root2);

end

end

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Write an algorithm to find the root of quadratic equation?

Write an algorithm to find the root of quadratic equation


Algorithm to find the roots of a quadratic equation?

The easiest way to write a generic algorithm is to simply use the quadratic formula. If it is a computer program, ask the user for the coefficients a, b, and c of the generic equation ax2 + bx + c = 0, then just replace them in the quadratic formula.


How did you write each quadratic equation in standard form?

readuse the answer


How do you write a poem on the roots of the quadratic equation?

2000X=Y2KoverZzz?


Can you write an equation that includes the keyword "quadratic"?

An example of a quadratic equation is ( ax2 bx c 0 ), where ( a ), ( b ), and ( c ) are constants and ( x ) is the variable.


Write a program in C programming language that computes the roots of the quadratic equation ax2 plus bx plus c?

Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.


How do you write a quadratic equation in standard form?

ax2 + bx + c


How do you write a pseudo code for find the quadratic equation?

computer scince


How would you go about solving a quadratic equation?

Write the quadratic equation in the form ax2 + bx + c = 0 then the roots (solutions) of the equation are: [-b ± √(b2 - 4*a*c)]/(2*a)


When the roots are equal of a quadratic equation?

Write the quadratic equation in the form ax2 + bx + c = 0 The roots are equal if and only if b2 - 4ac = 0. The expression, b2-4ac is called the [quadratic] discriminant.


Write an algorithm and draw a flowchart that will calculate the roots of quadratic equation?

dejene


What are the difference between matlab and c language?

Matlab is a scripting and mathematical language processor for working with mathematical equations. C is a structured programming language for writing programs. Those programs can contain mathematical equations, but they won't be in quite the same format that you're used to from math class. Matlab will solve and equation for you. C will allow you to write a program that solves the equation. C++ is an object-oriented version of C. matlab and simulink let us design,simulate,implement & test a variety of time varying system