b. π = πππ(π + βπ) +
πΏ π( π
+ βπ )
>> syms x; >> x= -10:0.0001:10; >> 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))'
>> syms x; >> x= -2:0.0001:2; >> 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))'
>> syms x; >> x= -1.6:0.0001:-1.2; >> 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))'
πΏ
la ecuacion π = πππ(π + βπ) + π( + βπ ) π posee una raiz en los intervalos [-1.6;-1,3]
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 xai=input('Ingrese el intervalo inferior: '); xbi=input('Ingrese el intervalo superior: '); tol=input('Ingrese el porcentaje de error: '); syms x; f=input('Ingrese la funciΓ²n: '); i=1; f1=subs(f,x,xai); f2=subs(f,x,xbi); ea(i)=100; if f1*f2 < 0 xa(i)=xai; f1=subs(f,x,xa(i)); xb(i)=xbi; f2=subs(f,x,xb(i)); xr(i)=(xa(i)+xb(i))/2; f3=subs(f,x,xr(i)); 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)); xb(i+1)=xr(i);f2=subs(f,x,xb(i+1)); end if f1*f3> 0 xa(i+1)=xr(i);f1=subs(f,x,xa(i+1)); xb(i+1)=xb(i);f2=subs(f,x,xb(i+1)); end xr(i+1)=(xa(i+1)+xb(i+1))/2; f3=subs(f,x,xr(i+1)); ea(i+1)=abs((xr(i+1)xr(i))/(xr(i+1))*100); fprintf('%2d \t %11.7f \t %11.7f \t %11.7f \t %7.3f \n',... i+1,xa(i+1),xr(i+1),xb(i+1),ea(i+1)); i=i+1; end else fprintf('No existe una raΓz en ese intervalo'); end
x0=input('Ingrese el valor inicial: '); tol=input('Ingrese el porcentaje de error: '); f=input('Ingrese la funciΓ³n: '); i=1; fx(i)=x0; syms x; f1=subs(f,x,fx(i)); z=diff(f); d=subs(z,x,fx(i)); ea(1)=100; while abs(ea(i))>=tol; fx(i+1)=fx(i)-f1/d; f1=subs(f,x,fx(i+1)); d=subs(z,x,fx(i+1)); ea(i+1)=abs((fx(i+1)fx(i))/fx(i+1)*100); i=i+1; end fprintf('i fx(i) Error aprox (i) \n'); for j=1:i; fprintf('%2d \t %11.7f \t %7.3f \n',j-1,fx(j),ea(j)); end fx(1)=input('Ingrese el intervalo inferior: '); fx(2)=input('Ingrese el intervalo superior: '); tol=input('Ingrese el porcentaje de error: '); syms x; f=input('Ingrese la funciΓ²n: '); f1=subs(f,x,fx(1)); f2=subs(f,x,fx(2)); ea(1)=100; i=1; j=2; while abs(ea(i))>=tol xf(j+1)=(xf(j-1)*f2-xf(j)*f1)/(f2f1); f1=f2; f2=subs(f,x,xf(j+1)); ea(i+1)=(xf(j+1)-xf(j))/xf(j+1)*100; j=j+1; i=i+1; end
fprintf(' i xf(i) Error aprox (i) \n'); %fprintf('%2d\t%11.7f\t\n',0,x(1)); for k=2:j; fprintf('%2d\t%11.7f\t%7.3f\n',k1,xf(k),ea(k-1)); end xf(1)=input('Ingrese el valor inicial: '); tol=input('Ingrese el porcentaje de error: '); syms x; f=input('Ingrese la funciΓ³n f(x), despejada g(f(x)): '); i=1; ea(1)=100; while abs(ea(i))>=tol, xf(i+1) = subs(f,x,xf(i)); ea(i+1) = abs((xf(i+1)xf(i))/xf(i+1))*100; 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))/(f2f1); 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));
xb(i+1)=xr(i);f2=subs(f,x,xb(i+ 1)); end if f1*f3> 0 xa(1)=xr(i); xb(1)=xb(i); end xr(i+1)=xa(i+1)-f1*(xb(i+1)xa(i+1))/(f2-f1); ea(i+1)=abs((xr(i+1)xr(i))/(xr(i+1)))*100; fprintf('%2d \t %11.7f \t %11.7f \t %11.7f \t %7.3f \n',... i+1,xa(i+1),xr(i+1),xb(i+1 ),ea(i+1)); i=i+1; end else fprintf('No existe una raΓz en ese intervalo'); end