Está en la página 1de 1

%PEDIR LOS COEFICIENTES DE UNA ECUACION DE 2DO GRADO ax^2+bx+c, muestre

%susu soluciones x1 y x2, x puede tewbere soluciones reales e


imaginarias.
%luego debe visualizar lo valores de las coordenadaws (x,y) comprendidas
%entre el dominio [A, B] QUE LO DEFINIRA EL USUARIO. CONSIDERE QUE LOS
%VALORES DEL DOMINIO PUEDE SER MAXIMO EL DOBLE DEL VALOR DE LAS RAICES X1
Y
%X2. AL FINALIZAR PREGUNTAR AL USUARIO SI DESE REALIZAR OTRO CALCULO
%INGRESABDO S=SI O N=NO.
clc
fprintf ('Ingrese valores\n');
a=input ('ingrese valor de a:');
b=input ('ingrese valor de b:');
c=input ('ingrese valor de c:');
d=(b^2)-(4*a*c);
if d>=0
x1=(-b+(d)^1/2)/(2*a);
x2=(-b-(d)^1/2)/(2*a);
fprintf('los valores son\n x1=%1.0f\n x2=%1.0f\n',x1,x2);
end
if d<0
fprintf ('Raiz Imaginaria');
d=d*(-1)
x1=(-b+(d)^1/2)/(2*a);
x2=(-b-(d)^1/2)/(2*a);
fprintf('los valores son\n x1=%1.0f\n x2=%1.0f\n',x1,x2);
end
A=x1*2;
B=x2*2;
dmin=input ('ingrese dominio min:\n');
dmax=input ('ingrese dominio max\n');
if dmin>dmax
aux=dmin
dmin=dmax
dmax=aux
end
while dmin<A
dmin=input ('ingrese el valor');
end
while dmax>B
dmax=input ('ingrese el valor');
end
fprintf ('y=ax^2+bx+c');
if dmin>dmax
for i=dmax:dmin
fprintf('(');
y=a*(i^2)+b*i+c
fprintf ('el par ordenado es:%1.0f',i);
fprintf(';')
fprintf('%1.0f',y);
fprintf(')\n');
end
s=input ('desea realizar otro calculo sí o no\n','s')
end

También podría gustarte