Mathematics">
Tarea 6 QMC - FLORES - SANTOS - AYRTON - TADEO
Tarea 6 QMC - FLORES - SANTOS - AYRTON - TADEO
Tarea 6 QMC - FLORES - SANTOS - AYRTON - TADEO
FACULTAD DE INGENIERÍA
INGENIERÍA QUÍMICA, AMBIENTAL, ALIMENTOS Y PETROQUIMICA
TAREA No. 6
PRQ404 – ECUACIONES IMPLICITAS
LOS SIGUIENTES PROBLEMAS DEBEN RESOLVERSE ELABORANDO: 1) ALGORITMO, 2) DF Ó
PSEUDOCÓDIGO, 3) PROGRAMA EN MATLAB.
EN CADA EJERCICIO DEBE ENTREGARSE CON LOS 3 PUNTOS ANTES EXPLICADOS, ADEMÁS,
INCLUYENDO EL RESULTADO DE CADA PROGRAMA. DEBE SER PRESENTADO EN UN ARCHIVO .doc
o .docx.
1.- a) Aplique el método de Newton-Raphson a la función f(x) = tanh (x2 – 9) para evaluar su raíz
real conocida en x = 3. Use un valor inicial de x0 = 3.2 y haga un mínimo de cuatro iteraciones. b)
¿Converge el método a su raíz real? Bosqueja la gráfica con los resultados para cada iteración que
obtenga. Elabore un programa en MATLAB.
%P6-E1
%MÉTODO DE NEWTON RHAPSON
%f=tanh(x^2-9) FIN
syms x
fsym=tanh(x^2-9);
dfsym=diff(fsym);
f=inline(fsym);
df=inline(dfsym);
x0=3.2;
Nit=4;
TOL=10^-10;
x1=x0-f(x0)/(df(x0));
i=1;
for i=1:1:Nit
[x] = NewtonR(f,df,x0,tol);
end
if i>Nit
disp('NO EXISTE SOLUCIÓN EN
Nit')
end
>> f
f=
Inline function:
f(x) = tanh(x.^2-9.0)
INICIO
>> x=1:0.01:10
g=f(h)
>> plot(h,g)
syms x
>> grid on fsym=tanh(x^2-9)
dfsym=diff(fsym)
f=inline(fsym)
df=inline(dfsym)
x0=3.2
Nit=4
TOL=10^-10
x1=x0-f(x0)/(df(x0))
i=1; i=i+1;i<=Nit
[x] = NewtonR(f,df,x0,tol)
i>Nit
NO EXISTE
SOLUCIÓN EN
Nit
GRAFICAR
FIN
2.- Suponga el lector que está diseñando un tanque esférico (véase la figura P6.26 – Libro: Chapra)
de almacenamiento de agua para un poblado pequeño de un país en desarrollo. El volumen del
líquido que puede contener se calcula con
donde V = volumen [pie3 ], h = profundidad del agua en el tanque [pies], y R = radio del tanque
[pies]. Si R = 3 m, ¿a qué profundidad debe llenarse el tanque de modo que contenga 30 m 3 ?
Resuelva utilizando el método de Newton-Raphson. Encuentre el error relativo aproximado
después de cada iteración. Observe que el valor inicial de R convergerá siempre.
PROGRAMA EN MATLAB
function [x] = x
NewtonR(f,df,x0,tol)
error=1;
x1=1
while error>tol FIN
x1=x0-f(x0)/df(x0);
error=abs(x1-x0);
x0=x1
end
x=x1;
end
%P6-E2
%Parametros
R=3;%m
V=30;%m^3
%V=pi*h^2*(3R-h)/3
syms h
fsym=pi*h^2*(3*R-h)/3-V;
dfsym=diff(fsym);
f=inline(fsym);
df=inline(dfsym);
x0=5;
tol=0.0001;
[x] = NewtonR(f,df,x0,tol);
fprintf('La altura es: %4.f
[m]',x)
>> f
f=
INICIO
Inline function:
f(h) = h.^2.*pi.*(h-9.0).*(-1.0./3.0)-3.0e+1
R=3
>> h=1:0.01:10 V=30
x0=5
>> g=f(h) tol=0.0001
>> plot(h,g)
>> grid on Syms h
>> title('GRAFICA f(h)')
xlabel('Eje x')
fsym=pi*h^2*(3*R-h)/3-V
ylabel('Eje y') dfsym=diff(fsym)
f=inline(fsym)
df=inline(dfsym)
[x] = NewtonR(f,df,x0,tol)
FIN
3.- Emplee el método de Müller para determinar las raíces reales y complejas de
a) ƒ(x) = x3 – x2 + 3x – 2
%P6-E3
%a) f(x)=x^3-x^2+3*x-2 FIN
f=@(x)x^3-x^2+3*x-2
x0=input('Introducir valor: ')
x1=input('Introducir valor: ')
x2=input('Introducir valor: ')
tol=10^-10
[x] = Muller(f,x0,x1,x2,tol)
fprintf('La solución es: ',x)
%b) f(x)=2*x^4+6*x^2+10
f=@(x)2*x^4+6*x^2+10
x0=input('Introducir valor: ')
x1=input('Introducir valor: ')
x2=input('Introducir valor: ')
tol=10^-10
[x] = Muller(f,x0,x1,x2,tol)
fprintf('La solución es: ',x)
%c) f(x)=x^4-2*x^3+6*x^2-8*x+8
f=@(x)x^4-2*x^3+6*x^2-8*x+8
x0=input('Introducir valor: ')
x1=input('Introducir valor: ')
x2=input('Introducir valor: ')
tol=10^-10
[x] = Muller(f,x0,x1,x2,tol)
fprintf('La solución es: ',x)
4.- Se ha sumergido el uso del metano, en un cilindro como un combustible de emergencia para el
sistema de calefacción de una planta que normalmente usa gas natural (compuesto por gran parte
por metano) . Se ha de mantener en reserva una cantidad suficiente de cilindros de gas para
suministrar 25,200 kcal/h durante 24 horas si el metano produce 97,200 kcal/kmol al quemarse y
se entrega en un cilindro de 56.62 litros a 204 atm y 21°C . ¿Cuantos cilindros deben ser
mantenidos en reservas ? Obtener predicciones con el método numérico de Punto Fijo y Newton-
Raphson, derive en forma numérica la función. Use un menú de selección del método y programe
en GUIDE.
Datos:
a
Ecuación de Van Der Waals: P + (V − b) = RT
V2
a = 2.25 atm*lt^2/mol^2
b = 0.0428 lt/mol
R = 0.082 atm*lt/°k*mol
PROGRAMA EN MATLAB
function [x] = Punto_fijo(f,kx,Ea,Nit)
error=1
i=1
while i<Nit
x=kx;
kx=f(x);
Ea=abs(kx-x);
fprintf('%d \t %1.7f \t \t %f \n',i,kx,Ea);
if Ea<=error
i=Nit+1;
break
end
i=i+1
end
fprintf('La aproximación es: %1.7 con un error de: %f\n',i,kx,Ea);
end
%P6-E4
%DATOS
Qnec=25200;%kcal/horas
tiempo=24;%horas
PC=97200;%kcal/kmol
%Cilindros
Vcil=56.62;%Litros
P=204;%atm
T=294;%K
R=0.082;%atm*L/K*mol
a=2.25;%atm*L^2/mol^2
b=0.0428;%L/mol
dV=0.0000001;
%La iteración
f=@(V) P*V^3-(P*b+R*T)*V^2+a*V-a*b;
donde R = la constante universal de los gases [= 0.518 kJ/(kg K)], T = temperatura absoluta (K),
p = presión absoluta (kPa) y v = volumen de un kg de gas (m3/kg). Los parámetros a y b se
calculan mediante:
donde pc = 4 580 kPa y Tc = 191 K. Como ingeniero químico, se le pide determinar la cantidad de
combustible metano que se puede almacenar en un tanque de 3 m3 a una temperatura de –50 °C
con una presión de 65 000 kPa. Emplee el método de la secante para calcular v y luego determine
la masa de metano contenida en el tanque. Programe en GUIDE.
PSEUDOCÓDIGO
1. INICIO
2. function [x] = secante(f,x0,x1,tol)
3. Hacer error=1;
4. Hacer x2=1
5. Mientras error>tol
6. Hacer x2=x1-(f(x1)*(x0-x1))/(f(x0)-f(x1));
7. Hacer error=abs(x2-x1);
8. Hacer x0=x1;
9. Hacer x1=x2;
10. Fin Mientras
11. x=x2;
12. FIN
13. INICIO
14. Leer R=0.518
15. Leer T=223
16. Leer P=65
17. Leer V=3
18. Leer Pc=4580
19. Leer Tc=191
20. a=0.427*(R^2*Tc^2)/Pc
21. b=0.0866*R*Tc/Pc
22. f=@(V) R*T/(V-b)-a/(V*(V+b)*sqrt(T))-P;
23. x0=1;
24. x1=5;
25. tol=0.0001;
26. [x] = secante(f,x0,x1,tol)
27. m=V/x;
28. IMPRIMIR('La masa contenida de metano es: %4.3f [Kg]',m)
29. FIN
PROGRAMA EN MATLAB
function [x] = secante(f,x0,x1,tol)
error=1;
x2=1
while error>tol
x2=x1-(f(x1)*(x0-x1))/(f(x0)-f(x1));
error=abs(x2-x1);
x0=x1;
x1=x2;
end
x=x2;
end
%P6-E5
%Parametros
R=0.518;%KJ/KgK
T=223;%K
P=65;%KPa
V=3;%m^3
Pc=4580;%KPa
Tc=191;%K
%Calculo a y b
a=0.427*(R^2*Tc^2)/Pc;%Kpa(m^3/Kg)^2
b=0.0866*R*Tc/Pc;%m^3/Kg
%P=RT/(V-b)-a/(V*(V+B)*sqrt(T))
%0=RT/(V-b)-a/(V*(V+B)*sqrt(T))-P
f=@(V) R*T/(V-b)-a/(V*(V+b)*sqrt(T))-P;
x0=5;
x1=7;
tol=0.0001;
[x] = secante(f,x0,x1,tol);
%x=Vol especifico(m^3/Kg)
m=V/x;%Kg
fprintf('La masa contenida de metano es: %4.3f [Kg]',m)
PROGRAMA EN GUIDE
function varargout = P6_E5guide(varargin)
% P6_E5GUIDE MATLAB code for P6_E5guide.fig
% P6_E5GUIDE, by itself, creates a new P6_E5GUIDE or raises the existing
% singleton*.
%
% H = P6_E5GUIDE returns the handle to a new P6_E5GUIDE or the handle to
% the existing singleton*.
%
% P6_E5GUIDE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in P6_E5GUIDE.M with the given input
arguments.
%
% P6_E5GUIDE('Property','Value',...) creates a new P6_E5GUIDE or raises
the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before P6_E5guide_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to P6_E5guide_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = P6_E5guide_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x2=x1-(f(x1)*(x0-x1))/(f(x0)-f(x1))
error=abs(x2-x1)
x0=x1
x1=x2
error>tol
x=x2
FIN
INICIO
R=0.518
T=223
P=65
V=3
Pc=4580
Tc=191
a=0.427*(R^2*Tc^2)/Pc
b=0.0866*R*Tc/Pc
f=@(V) R*T/(V-b)-a/(V*(V+b)*sqrt(T))-P
x0=1
x1=5
tol=0.0001
[x] = secante(f,x0,x1,tol)
m=V/x
FIN