Mon. Nov 29th, 2021

Quadratic equation

In algebra, a quadratic equation (from the Latin quadratus for “square“) is any equation that can be rearranged in standard form as:

ax^{2}+bx+c=0

where x represents an unknown, and a, b, and c represent known numbers, where a ≠ 0. If a = 0, then the equation is linear, not quadratic, as there is no ax^2 term. The numbers a, b, and c are the coefficients of the equation and may be distinguished by calling them, respectively, the quadratic coefficient, the linear coefficient and the constant or free term.[1]

The values of x that satisfy the equation are called solutions of the equation, and roots or zeros of its left-hand side. A quadratic equation has at most two solutions. If there is no real solution, there are two complex solutions. If there is only one solution, one says that it is a double root. A quadratic equation always has two roots, if complex roots are included and a double root is counted for two. A quadratic equation can be factored into an equivalent equation:

{\displaystyle ax^{2}+bx+c=a(x-r)(x-s)=0}

where r and s are the solutions for x. Completing the square on a quadratic equation in standard form results in the quadratic formula, which expresses the solutions in terms of a, b, and c. Solutions to problems that can be expressed in terms of quadratic equations were known as early as 2000 BC.

Because the quadratic equation involves only one unknown, it is called “univariate“. The quadratic equation only contains powers of x that are non-negative integers, and therefore it is a polynomial equation. In particular, it is a second-degree polynomial equation, since the greatest power is two.

#include <stdio.h>
#include <math.h>

void main(void)
{
	float a,b,c,x1,x2,delta,real,imag;

	printf("a=");scanf("%f",&a);
	printf("b=");scanf("%f",&b);
	printf("c=");scanf("%f",&c);

	if (a == 0)
	 printf ("Ecuatie de gradul I \n");
	else
	 {
	  delta = b*b - 4*a*c;
	  if (delta >= 0)
	   {
		  printf("Radacini reale : \n");
		  x1 = (-b + sqrt(delta))/(2*a);
		  x2 = (-b - sqrt(delta))/(2*a);
		  printf ("x1 = %f,x2 = %f\n",x1,x2);
	   }
	  else
	   {
		  printf("Radacini complexe : ");
		  delta = -delta;
		  real = -b/(2*a);
		  imag = sqrt(delta)/(2*a);
		  printf("x1 = %f + i*%f x2 = %f - i*%f\n",real,imag,real,imag);
	   }
	 }
}

545 total views, 1 views today