Equações do Segundo Grau - raízes (MATLAB)

 Dada a equação do segundo grau: ax^2 + bx + c = 0

-  Digitar os coeficientes da equação do segundo grau, e obter as raízes dessa equação.

         


ALGORITMO


a = input('Enter the value of a: ');
b = input('Enter the value of b: ');
c = input('Enter the value of c: ');
p = [a b c];
r = roots(p);
disp('As raízes da equação são:');
disp(r);

SOLUÇÃO


Equação: x^2 - 5*x + 6 = 0

Enter the value of a: 1 Enter the value of b: -5 Enter the value of c: 6 As raízes da equação são: 3.0000 2.0000

SOLUÇÃO


Equação: x^2 +2*x + 6 = 0

Enter the value of a: 1 Enter the value of b: 2 Enter the value of c: 6 As raízes da equação são: -1.0000 + 2.2361i -1.0000 - 2.2361i












Postar um comentário

Postagem Anterior Próxima Postagem