Está en la página 1de 7

b.

>> syms x;
𝑿 >> x= -1.6:0.0001:-1.2;
𝒚 = 𝒄𝒐𝒔(𝒙 + √𝟐) + 𝒙( 𝟐 + √𝟐 )
>> syms x; >> y = cos(x + sqrt(2)) + x.*(x/2 + sqrt(2));
>> x= -10:0.0001:10; >> plot(x,y,'r'), grid on, title 'y = cos(x + sqrt(2)) +
>> y = cos(x + sqrt(2)) + x.*(x/2 + sqrt(2)); x.*(x/2 + sqrt(2))'
>> plot(x,y,'r'), grid on, title 'y = cos(x + sqrt(2)) +
x.*(x/2 + sqrt(2))'

𝑿
>> syms x; la ecuacion 𝒚 = 𝒄𝒐𝒔(𝒙 + √𝟐) + 𝒙( + √𝟐 )
𝟐
>> x= -2:0.0001:2; posee una raiz en los intervalos [-1.6;-1,3]
>> y = cos(x + sqrt(2)) + x.*(x/2 + sqrt(2));
>> plot(x,y,'r'), grid on, title 'y = cos(x + sqrt(2)) +
x.*(x/2 + sqrt(2))'
C
𝒚 = 𝒆𝟔𝒙 + 𝟑𝒍𝒏(𝟐)𝒆𝟐𝒙 − 𝒍𝒏(𝟖)𝒆𝟒𝒙 − 𝒍𝒏𝟐𝟑
>> syms x ;
>> x = -5:0.00001:5;
>> y= exp(6.*x) + 3*log(2)*exp(2.*x) - log(8)*exp(4.*x)
- (log(2)).^3;
>> plot(x,y,'r'), grid on, title 'y= exp(6.*x) +
3*log(2)*exp(2.*x) - log(8)*exp(4.*x) - (log(2)).^3'

La ecuación 𝒚 = 𝒆𝟔𝒙 + 𝟑𝒍𝒏(𝟐)𝒆𝟐𝒙 − 𝒍𝒏(𝟖)𝒆𝟒𝒙 −


𝒍𝒏𝟐𝟑 posee una raíz en los intervalos [-1;0]

>> syms x ;
>> x = -1:0.00001:0;
>> y= exp(6.*x) + 3*log(2)*exp(2.*x) - log(8)*exp(4.*x)
- (log(2)).^2;
>> plot(x,y,'r'), grid on, title 'y= exp(6.*x) +
3*log(2)*exp(2.*x) - log(8)*exp(4.*x) - (log(2)).^3'
1. Encuentre el o los intervalos donde existe al menos una
raíz en a cada una de las siguientes ecuaciones. (Describa
muy bien el intervalo que se escoja para mostrar la raíz)

a. 𝒚 = 𝒙𝟐 − 𝟐𝒙𝒆−𝒙 + 𝒆−𝟐𝒙 +

>> syms x;
>> x= -10:0.0001:10;
>> y= x.^2 - 2*x.*exp(-x) + exp(-2*x);
>> plot(x,y,'r'), grid on, title ' y= x.^2 - 2*x.*exp(-x) +
exp(-2*x)'

>> syms x;
>> x= -2:0.0001:2;
>> y= x.^2 - 2*x.*exp(-x) + exp(-2*x);
>> plot(x,y,'r'), grid on, title ' y= x.^2 - 2*x.*exp(-x) +
exp(-2*x)'
2. Aplique los métodos siguientes para obtener una
solución con exactitud de 𝟏𝟎−𝟒 para los problemas:

a. 𝑓(𝑥) = 600𝑥 4 − 550𝑥 3 + 200𝑥 2 − 20𝑥 − 1


>> ezplot( 'y=600*x.^4 - 550*x.^3 + 200*x.^2 - 20*x -
1',[-0.5,0.5,-3,3]) , grid on

b. >> ezplot( 'y=exp(x) - x.^2 + 3*x -2') , grid on

c >> ezplot( 'y=(1-0.6*x)/x') , grid on


CODIGO BISECCION x0=input('Ingrese el valor inicial: ');
xai=input('Ingrese el intervalo tol=input('Ingrese el porcentaje de
inferior: '); error: ');
xbi=input('Ingrese el intervalo f=input('Ingrese la función: ');
i=1;
superior: ');
fx(i)=x0;
tol=input('Ingrese el porcentaje de
error: ');
syms x; syms x;
f=input('Ingrese la funciòn: '); f1=subs(f,x,fx(i));
z=diff(f);
i=1;
d=subs(z,x,fx(i));
f1=subs(f,x,xai);
f2=subs(f,x,xbi); ea(1)=100;

ea(i)=100; while abs(ea(i))>=tol;


if f1*f2 < 0 fx(i+1)=fx(i)-f1/d;
xa(i)=xai; f1=subs(f,x,xa(i)); f1=subs(f,x,fx(i+1));
xb(i)=xbi; f2=subs(f,x,xb(i)); d=subs(z,x,fx(i+1));
xr(i)=(xa(i)+xb(i))/2; ea(i+1)=abs((fx(i+1)-
fx(i))/fx(i+1)*100);
f3=subs(f,x,xr(i));
i=i+1;
end
fprintf('It. Xa fprintf('i fx(i) Error aprox
Xr Xb Error (i) \n');
aprox \n'); for j=1:i;
fprintf('%2d \t %11.7f \t %11.7f fprintf('%2d \t %11.7f \t %7.3f
\t %11.7f \n',i,xa(i),xr(i),xb(i)); \n',j-1,fx(j),ea(j));
while abs(ea(i)) >= tol, end
if f1*f3<0 fx(1)=input('Ingrese el intervalo
inferior: ');
xa(i+1)=xa(i);f1=subs(f,x,xa(i+1)); fx(2)=input('Ingrese el intervalo
superior: ');
tol=input('Ingrese el porcentaje de
xb(i+1)=xr(i);f2=subs(f,x,xb(i+1));
error: ');
end
syms x;
if f1*f3> 0 f=input('Ingrese la funciòn: ');

xa(i+1)=xr(i);f1=subs(f,x,xa(i+1));
f1=subs(f,x,fx(1));
f2=subs(f,x,fx(2));
xb(i+1)=xb(i);f2=subs(f,x,xb(i+1));
end
xr(i+1)=(xa(i+1)+xb(i+1))/2; ea(1)=100;
f3=subs(f,x,xr(i+1));
ea(i+1)=abs((xr(i+1)- i=1;
xr(i))/(xr(i+1))*100); j=2;
fprintf('%2d \t %11.7f \t
%11.7f \t %11.7f \t %7.3f \n',... while abs(ea(i))>=tol
xf(j+1)=(xf(j-1)*f2-xf(j)*f1)/(f2-
i+1,xa(i+1),xr(i+1),xb(i+1),ea(i+1)); f1); f1=f2; f2=subs(f,x,xf(j+1));
i=i+1; ea(i+1)=(xf(j+1)-xf(j))/xf(j+1)*100;
end j=j+1;
else i=i+1;
fprintf('No existe una raíz en ese end
intervalo');
end
fprintf(' i xf(i) Error xb(i+1)=xr(i);f2=subs(f,x,xb(i+
aprox (i) \n'); 1));
%fprintf('%2d\t%11.7f\t\n',0,x(1)); end
for k=2:j; if f1*f3> 0
fprintf('%2d\t%11.7f\t%7.3f\n',k- xa(1)=xr(i);
1,xf(k),ea(k-1)); xb(1)=xb(i);
end end
xf(1)=input('Ingrese el valor inicial: xr(i+1)=xa(i+1)-f1*(xb(i+1)-
'); xa(i+1))/(f2-f1);
tol=input('Ingrese el porcentaje de ea(i+1)=abs((xr(i+1)-
error: '); xr(i))/(xr(i+1)))*100;
syms x; fprintf('%2d \t %11.7f \t %11.7f
f=input('Ingrese la función f(x), \t %11.7f \t %7.3f \n',...
despejada g(f(x)): '); i+1,xa(i+1),xr(i+1),xb(i+1
),ea(i+1));
i=1; i=i+1;
ea(1)=100; end
while abs(ea(i))>=tol, else
xf(i+1) = subs(f,x,xf(i)); fprintf('No existe una raíz en ese
ea(i+1) = abs((xf(i+1)- intervalo');
xf(i))/xf(i+1))*100; end
i=i+1;
end
fprintf('i xf(i) Error aprox
(i) \n');
for j=1:i;
fprintf('%2d \t %11.7f \t %7.3f
\n',j-1,xf(j),ea(j));
end

CODIGO REGLA FALSA


xai=input('Ingrese limite inferior: ');
xbi=input('Ingrese limite superior: ');
tol=input('Ingrese el porcentaje de
Error: ');
syms x;
f=input('Ingrese la Funcion: ');
f1=subs(f,x,xai);
f2=subs(f,x,xbi);
i=1;
ea(1)=100;
if f1*f2 < 0
xa(1)=xai;f1=subs(f,x,xa(1));
xb(1)=xbi;f2=subs(f,x,xb(1));
xr(1)=xa(1)-f1*(xb(1)-xa(1))/(f2-
f1); f3=subs(f,x,xr(1));
fprintf('It. Xa
Xr Xb Error
aprox \n');
fprintf('%2d \t %11.7f \t %11.7f \t
%11.7f \n',i,xa(i),xr(i),xb(i));
while abs(ea(i))>=tol,
if f1*f3 < 0
xa(i+1)=xa(i);f1=subs(f,x,xa(i+
1));

También podría gustarte