Académique Documents
Professionnel Documents
Culture Documents
F(X)=4X^2+2X-4
G(x)=X^2+4X+2
INTERVALO:
PUNTO DE CORTE:
Pn=-1.10
R3=8.12
'INGRESE g(x)'
%ingresar el gardo del grado
g=input('INGRESE EL GRADO DEL POLINOMIO= n')
if g==4
h=input('INGRESE COEFICINETE DE X^4= ')
i=input('INGRESECOEFICINETE DE X^3= ')
j=input('INGRESE COEFICINETE DE X^2= ')
k=input('INGRESECOEFICINETE DE X= ')
l=input('INGRESE CONSTANTE= ')
elseif g==3
i=input('INGRESECOEFICINETE DE X^3= ')
j=input('INGRESE COEFICINETE DE X^2= ')
k=input('INGRESECOEFICINETE DE X= ')
l=input('INGRESE CONSTANTE= ')
else
j=input('INGRESE COEFICINETE DE X^2= ')
k=input('INGRESECOEFICINETE DE X= ')
l=input('INGRESE CONSTANTE= ')
end
'INGRESE INTREVALOS'
nm=input('INGRESE A(intervalo mayor)= ')
m=input('INGRESE B(intervalo menor)= ')
o=4;
p=3;
q=2;
r=1;
s=0;
t=(nm+m)/2;
%puntos de corte
%grafiacar
'grafica f(x)'
grid on
hold on
x=m:nm
if a==4
y=b*x.^4+c*x.^3+d*x.^2+e*x+f
elseif a==3
y=c*x.^3+d*x.^2+e*x+f
else
y=d*x.^2+e*x+f
end
plot(x,y)
'grafica g(x)'
x=m:nm
if g==4
y=h*x.^4+i*x.^3+j*x.^2+k*x+l
else if g==3
y= i*x.^3+j*x.^2+k*x+l
else
y=j*x.^2+k*x+l
end
end
plot(x,y)
if (qm==1)
elseif a==3
FA= (c*(nm^(p+1))/(p+1))+(d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (c*(pn^(p+1))/(p+1))+(d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
else
FA= (d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
end
%solucion
if a==48
Q=FA-FB;
elseif a==3
Q=FA-FB;
else
Q=FA-FB;
end
%funcion 2
if g==4
FC= (h*(nm^(o+1))/(o+1))+(i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+
(l*(nm^(s+1))/(s+1));
FD= (h*(pn^(o+1))/(o+1))+(i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+
(l*(pn^(s+1))/(s+1));
elseif g==3
FC= (i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
else
FC= (j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
end
%solucion
if a==4
O=FC-FD;
elseif a==3
O=FC-FD;
else
O=FC-FD;
end
oo=(nm+pn)/2;
elseif a==3
FE= (c*(oo^p))+(d*(oo^q))+ (e*(oo^r))+(f);
else
FE= (d*(oo^q))+ (e*(oo^r))+(f);
end
%funcion 2
if g==4
FF= (h*(oo^o))+(i*(oo^p))+(j*(oo^q))+ (k*(oo^r))+(l);
elseif g==3
FF= (i*(oo^p))+(j*(oo^q))+ (k*(oo^r))+(l);
else
FF= (j*(oo^q))+ (k*(oo^r))+(l);
end
%comparar
if (FE>FF)
R1=Q-O;
else
R1=O-Q;
end
%INTERVALO 2
if a==4
FQ= (b*(pn^(o+1))/(o+1))+(c*(pn^(p+1))/(p+1))+(d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+
(f*(pn^(s+1))/(s+1));
FR= (b*(m^(o+1))/(o+1))+(c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/
(s+1));
elseif a==3
FQ= (c*(pn^(p+1))/(p+1))+(d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
FR= (c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
else
FQ= (d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
FR= (d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
end
%solucion
if a==48
V=FQ-FR;
elseif a==3
V=FQ-FR;
else
V=FQ-FR;
end
%funcion 2
if g==4
FP= (h*(pn^(o+1))/(o+1))+(i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+
(l*(pn^(s+1))/(s+1));
FL= (h*(m^(o+1))/(o+1))+(i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+
(k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
elseif g==3
FP= (i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
FL= (i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
else
FP= (j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
FL= (j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
end
%solucion
if a==4
W=FP-FL;
elseif a==3
W=FP-FL;
else
W=FP-FL;
end
pp=(pn+m)/2;
%COMPARAR FUNCION SUPERIOR
%funcion 1
if a==4
FC= (b*(pp^o))+(c*(pp^p))+(d*(pp^q))+ (e*(pp^r))+(f);
elseif a==3
FC= (c*(pp^p))+(d*(pp^q))+ (e*(pp^r))+(f);
else
FC= (d*(pp^q))+ (e*(pp^r))+(f);
end
%funcion 2
if g==4
FZ= (h*(pp^o))+(i*(pp^p))+(j*(pp^q))+ (k*(pp^r))+(l);
elseif g==3
FZ= (i*(pp^p))+(j*(pp^q))+ (k*(pp^r))+(l);
else
FZ= (j*(pp^q))+ (k*(pp^r))+(l);
end
%comparar
if (FC>FZ)
R2=V-W;
else
R2=W-V;
end
R3=R1+R2
else
%integra
%funcion 1
if a==4
FA= (b*(nm^(o+1))/(o+1))+(c*(nm^(p+1))/(p+1))+(d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+
(f*(nm^(s+1))/(s+1));
FB= (b*(m^(o+1))/(o+1))+(c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/
(s+1));
elseif a==3
FA= (c*(nm^(p+1))/(p+1))+(d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
else
FA= (d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
end
%solucion
if a==48
Q=FA-FB;
elseif a==3
Q=FA-FB;
else
Q=FA-FB;
end
%funcion 2
if g==4
FC= (h*(nm^(o+1))/(o+1))+(i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+
(l*(nm^(s+1))/(s+1));
FD= (h*(m^(o+1))/(o+1))+(i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+
(k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
elseif g==3
FC= (i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
else
FC= (j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
end
%solucion
if a==4
O=FC-FD;
elseif a==3
O=FC-FD;
else
O=FC-FD;
end
elseif a==3
FE= (c*(t^p))+(d*(t^q))+ (e*(t^r))+(f);
else
FE= (d*(t^q))+ (e*(t^r))+(f);
end
%funcion 2
if g==4
FF= (h*(t^o))+(i*(t^p))+(j*(t^q))+ (k*(t^r))+(l);
elseif g==3
FF= (i*(t^p))+(j*(t^q))+ (k*(t^r))+(l);
else
FF= (j*(t^q))+ (k*(t^r))+(l);
end
%comparar
if (FE>FF)
R=Q-O
else
R=O-Q
end
end
ans =
ans =
INGRESE f(x)
a=
d=
INGRESECOEFICINETE DE X= 2
e=
INGRESE CONSTANTE= -4
f=
-4
ans =
INGRESE g(x)
g=
j=
INGRESECOEFICINETE DE X= 4
k=
INGRESE CONSTANTE= 2
l=
ans =
INGRESE INTREVALOS
nm =
-2
ans =
grafica f(x)
x=
-2 -1 0
y=
8 -2 -4
ans =
grafica g(x)
x=
-2 -1 0
y=
-2 -1 2
ans =
ans =
ans =
1=SI
ans =
0=NO
si corta/no corta = 1
qm =
pn =
-1.1000
R3 =
8.1180
ECUACIONES:
F(X)=X^3+4X^2+2X+3
G(x)= 4X^2+2X-4
INTERVALO:
PUNTO DE CORTE:
Pn=N/A
R3=15.6360
'INGRESE g(x)'
%ingresar el gardo del grado
g=input('INGRESE EL GRADO DEL POLINOMIO= n')
if g==4
h=input('INGRESE COEFICINETE DE X^4= ')
i=input('INGRESECOEFICINETE DE X^3= ')
j=input('INGRESE COEFICINETE DE X^2= ')
k=input('INGRESECOEFICINETE DE X= ')
l=input('INGRESE CONSTANTE= ')
elseif g==3
i=input('INGRESECOEFICINETE DE X^3= ')
j=input('INGRESE COEFICINETE DE X^2= ')
k=input('INGRESECOEFICINETE DE X= ')
l=input('INGRESE CONSTANTE= ')
else
j=input('INGRESE COEFICINETE DE X^2= ')
k=input('INGRESECOEFICINETE DE X= ')
l=input('INGRESE CONSTANTE= ')
end
'INGRESE INTREVALOS'
nm=input('INGRESE A(intervalo mayor)= ')
m=input('INGRESE B(intervalo menor)= ')
o=4;
p=3;
q=2;
r=1;
s=0;
t=(nm+m)/2;
%puntos de corte
%grafiacar
'grafica f(x)'
grid on
hold on
x=m:nm
if a==4
y=b*x.^4+c*x.^3+d*x.^2+e*x+f
elseif a==3
y=c*x.^3+d*x.^2+e*x+f
else
y=d*x.^2+e*x+f
end
plot(x,y)
'grafica g(x)'
x=m:nm
if g==4
y=h*x.^4+i*x.^3+j*x.^2+k*x+l
else if g==3
y= i*x.^3+j*x.^2+k*x+l
else
y=j*x.^2+k*x+l
end
end
plot(x,y)
if (qm==1)
elseif a==3
FA= (c*(nm^(p+1))/(p+1))+(d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (c*(pn^(p+1))/(p+1))+(d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
else
FA= (d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
end
%solucion
if a==48
Q=FA-FB;
elseif a==3
Q=FA-FB;
else
Q=FA-FB;
end
%funcion 2
if g==4
FC= (h*(nm^(o+1))/(o+1))+(i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+
(l*(nm^(s+1))/(s+1));
FD= (h*(pn^(o+1))/(o+1))+(i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+
(l*(pn^(s+1))/(s+1));
elseif g==3
FC= (i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
else
FC= (j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
end
%solucion
if a==4
O=FC-FD;
elseif a==3
O=FC-FD;
else
O=FC-FD;
end
oo=(nm+pn)/2;
elseif a==3
FE= (c*(oo^p))+(d*(oo^q))+ (e*(oo^r))+(f);
else
FE= (d*(oo^q))+ (e*(oo^r))+(f);
end
%funcion 2
if g==4
FF= (h*(oo^o))+(i*(oo^p))+(j*(oo^q))+ (k*(oo^r))+(l);
elseif g==3
FF= (i*(oo^p))+(j*(oo^q))+ (k*(oo^r))+(l);
else
FF= (j*(oo^q))+ (k*(oo^r))+(l);
end
%comparar
if (FE>FF)
R1=Q-O;
else
R1=O-Q;
end
%INTERVALO 2
if a==4
FQ= (b*(pn^(o+1))/(o+1))+(c*(pn^(p+1))/(p+1))+(d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+
(f*(pn^(s+1))/(s+1));
FR= (b*(m^(o+1))/(o+1))+(c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/
(s+1));
elseif a==3
FQ= (c*(pn^(p+1))/(p+1))+(d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
FR= (c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
else
FQ= (d*(pn^(q+1))/(q+1))+ (e*(pn^(r+1))/(r+1))+(f*(pn^(s+1))/(s+1));
FR= (d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
end
%solucion
if a==48
V=FQ-FR;
elseif a==3
V=FQ-FR;
else
V=FQ-FR;
end
%funcion 2
if g==4
FP= (h*(pn^(o+1))/(o+1))+(i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+
(l*(pn^(s+1))/(s+1));
FL= (h*(m^(o+1))/(o+1))+(i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+
(k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
elseif g==3
FP= (i*(pn^(p+1))/(p+1))+(j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
FL= (i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
else
FP= (j*(pn^(q+1))/(q+1))+ (k*(pn^(r+1))/(r+1))+(l*(pn^(s+1))/(s+1));
FL= (j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
end
%solucion
if a==4
W=FP-FL;
elseif a==3
W=FP-FL;
else
W=FP-FL;
end
pp=(pn+m)/2;
elseif a==3
FC= (c*(pp^p))+(d*(pp^q))+ (e*(pp^r))+(f);
else
FC= (d*(pp^q))+ (e*(pp^r))+(f);
end
%funcion 2
if g==4
FZ= (h*(pp^o))+(i*(pp^p))+(j*(pp^q))+ (k*(pp^r))+(l);
elseif g==3
FZ= (i*(pp^p))+(j*(pp^q))+ (k*(pp^r))+(l);
else
FZ= (j*(pp^q))+ (k*(pp^r))+(l);
end
%comparar
if (FC>FZ)
R2=V-W;
else
R2=W-V;
end
R3=R1+R2
else
%integra
%funcion 1
if a==4
FA= (b*(nm^(o+1))/(o+1))+(c*(nm^(p+1))/(p+1))+(d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+
(f*(nm^(s+1))/(s+1));
FB= (b*(m^(o+1))/(o+1))+(c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/
(s+1));
elseif a==3
FA= (c*(nm^(p+1))/(p+1))+(d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (c*(m^(p+1))/(p+1))+(d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
else
FA= (d*(nm^(q+1))/(q+1))+ (e*(nm^(r+1))/(r+1))+(f*(nm^(s+1))/(s+1));
FB= (d*(m^(q+1))/(q+1))+ (e*(m^(r+1))/(r+1))+(f*(m^(s+1))/(s+1));
end
%solucion
if a==48
Q=FA-FB;
elseif a==3
Q=FA-FB;
else
Q=FA-FB;
end
%funcion 2
if g==4
FC= (h*(nm^(o+1))/(o+1))+(i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+
(l*(nm^(s+1))/(s+1));
FD= (h*(m^(o+1))/(o+1))+(i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+
(k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
elseif g==3
FC= (i*(nm^(p+1))/(p+1))+(j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (i*(m^(p+1))/(p+1))+(j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
else
FC= (j*(nm^(q+1))/(q+1))+ (k*(nm^(r+1))/(r+1))+(l*(nm^(s+1))/(s+1));
FD= (j*(m^(q+1))/(q+1))+ (k*(m^(r+1))/(r+1))+(l*(m^(s+1))/(s+1));
end
%solucion
if a==4
O=FC-FD;
elseif a==3
O=FC-FD;
else
O=FC-FD;
end
elseif a==3
FE= (c*(t^p))+(d*(t^q))+ (e*(t^r))+(f);
else
FE= (d*(t^q))+ (e*(t^r))+(f);
end
%funcion 2
if g==4
FF= (h*(t^o))+(i*(t^p))+(j*(t^q))+ (k*(t^r))+(l);
elseif g==3
FF= (i*(t^p))+(j*(t^q))+ (k*(t^r))+(l);
else
FF= (j*(t^q))+ (k*(t^r))+(l);
end
%comparar
if (FE>FF)
R=Q-O
else
R=O-Q
end
end
Untitled78
ans =
ans =
INGRESE f(x)
a=
INGRESECOEFICINETE DE X^3= 1
c=
d=
INGRESECOEFICINETE DE X= 2
e=
INGRESE CONSTANTE= 3
f=
ans =
INGRESE g(x)
g=
INGRESECOEFICINETE DE X= 2
k=
INGRESE CONSTANTE= -4
l=
-4
ans =
INGRESE INTREVALOS
nm =
m=
-1.3000
ans =
grafica f(x)
x=
y=
ans =
grafica g(x)
x=
y=
ans =
ans =
1=SI
ans =
0=NO
si corta/no corta = 0
qm =
R=
15.6360
RAICES
ECUACION A LA CUARTA:
32X^4+16X^3+8X^2+4X+2
Tol=0.10
Intervalo=(0;5)
N=20
Resp: 2R ; 2 I
ECUACION CUBICA:
12X^3+6X^2+3X+1
Tol=0.10
N=20
Intervalo=(0;5)
Resp= 2I ; 1R
'raices'
m=input('ingrese grado de ecuacion = ')
if m==4
a=input('ingrese coeficiente de x^4= ')
b=input('ingrese valor coeficiente de x^3= ')
c= input('ingrese valor coeficiente de x^2= ')
d= input('ingrese valor coeficiente de x^1= ')
e= input('ingrese valores del termino constante c= ')
else if m==3
b=input('ingrese valor coeficiente de x^3= ')
c= input('ingrese valor coeficiente de x^2= ')
d= input('ingrese valor coeficiente de x^1= ')
e= input('ingrese valores del termino constante c= ')
else
c= input('ingrese valor coeficiente de x^2= ')
d= input('ingrese valor coeficiente de x^1= ')
e= input('ingrese valores del termino constante c= ')
end
end
%grafiacar
'grafica f(x)'
grid on
hold on
x=xi:0.001:xf
if m==4
y=a*x.^4+b*x.^3+c*x.^2+d*x+e
elseif m==3
y=b*x.^3+c*x.^2+d*x+e
else
y=c*x.^2+d*x+e
end
plot(x,y)
if m==4
fxi= a*xi^4+b*xi^3+c*xi^2+d*xi+e
fxf= a*xf^4+b*xf^3+c*xf^2+d*xf+e
else if m==3 a==0
fxi= b*xi^3+c*xi^2+d*xi+e
fxf= b*xf^3+c*xf^2+d*xf+e
else if m==2 b==0
fxi= c*xi^2+d*xi+e
fxf= c*xf^2+d*xf+e
else if m==1 c==0
fxi= d*xi+e
fxf= d*xf+e
%terorema de resto
for i=1:n
t=1;
x4=a;
x3=b+(a*t);
x2=c+(x3*t);
x=d+(x2*t);
co=e+(x*t);
if(co<tol)
dip('Baja de gardo')
x7=a
x6=b+(a*t)
x5=c+(x3*t)
co3=d+(x2*t)
else
x4=a;
x3=b+(a*t);
x2=c+(x3*t);
x=d+(x2*t);
co=e+(x*t);
end
if (co<tol)
dip('Baja de gardo')
x9=x7
x8=x6+(x7*t)
co2=x5+(x8*t)
else
x4=a;
x3=b+(a*t);
x2=c+(x3*t);
x=d+(x2*t);
co=e+(x*t);
end
end
end
end
end
end
%comparar que fxi*fxf<0
if (fxi*fxf)<0
disp('existe una solucion')
else
disp('no hay solucion')
end
%buscamos solucion .
for i=1:n
xi
i
if m==4
m
fxi= a*xi^4+b*xi^3+c*xi^2+d*xi+e
fxf= a*xf^4+b*xf^3+c*xf^2+d*xf+e
else if m==3 a==0
m
fxi= b*xi^3+c*xi^2+d*xi+e
fxf= b*xf^3+c*xf^2+d*xf+e
else if m==2 b==0
m
fxi= c*xi^2+d*xi+e
fxf= c*xf^2+d*xf+e
else if m==1 c==0
m
fxi= d*xi+e
fxf= d*xf+e
end
end
end
end
if abs(fxi)< tol
disp('la solucion del polinomio es ')
xi
else
disp('intente nuevamente ')
xi= xi+inc
end
end
d= b^2-4*a*c
if d>=0
disp ('real')
x1=((-b+(b^2-4*a*c)^0.5)/(2*a))
x2=((-b-(b^2-4*a*c)^0.5)/(2*a))
else if b==0
disp ('imaginario')
x1=((((b^2-4*a*c))^0.5)/(2*a))
x2=-((((b^2-4*a*c))^0.5)/(2*a))
else
disp('complejo')
x1=((-b+(b^2-4*a*c)^0.5)/(2*a))
x2=((-b-(b^2-4*a*c)^0.5)/(2*a))
end
end