Documentos de Académico
Documentos de Profesional
Documentos de Cultura
FACULTAD DE INGENIERÍA
INGENIERÍA QUÍMICA, AMBIENTAL, ALIMENTOS Y PETROQUIMICA
TAREA No. 6
PRQ404 – ECUACIONES IMPLICITAS
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.
función f(x) = tanh (x2 – 9) para evaluar su raíz
1.- a) Aplique el método de Newton-Raphson a la función
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?
r eal? 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
disp( 'NO EXISTE SOLUCIÓN EN
Nit')
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
t anque 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
8. Hacer x=x1
9. FIN Error=1
X1=1
10. Leer R=3
11. Leer V=30
12. syms h
13. Hacer
fsym=pi*h^2*(3*R-h)/3-V NO x1=x0-f(x0)/df(x0)
14. Hacer dfsym=diff(fsym) x0=x1
15. Hacer f=inline(fsym)
16. Hacer df=inline(dfsym)
17. Hacer x0=5
Error>tol SI
18. Hacer tol=0.0001
19. [x] =
NewtonR(f,df,x0,tol);
20. Imprimir('La altura
es: %4.f [m]',x) x=x1
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
R=3; %m
V=30;%m^3
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
fprintf( 'La altura es: %4.f
[m]',x)
[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
x0=input( ')
'Introducir valor: ')
'Introducir valor: '
x1=input('Introducir
x1=input( ')
)
x2=input('Introducir
x2=input( 'Introducir valor: '
')
)
tol=10^-10
[x] = Muller(f,x0,x1,x2,tol)
'La solución es: ',x)
fprintf('La
fprintf( ',x)
%b) f(x)=2*x^4+6*x^2+10
f=@(x)2*x^4+6*x^2+10
x0=input('Introducir
x0=input( ')
'Introducir valor: ')
x1=input('Introducir
x1=input( 'Introducir valor: '
')
)
'Introducir valor: '
x2=input('Introducir
x2=input( ')
)
tol=10^-10
[x] = Muller(f,x0,x1,x2,tol)
fprintf(
fprintf('La ',x)
'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
'Introducir valor: '
x0=input('Introducir
x0=input( ')
)
x1=input('Introducir
x1=input( 'Introducir valor: '
')
)
'Introducir valor: '
x2=input('Introducir
x2=input( ')
)
tol=10^-10
[x] = Muller(f,x0,x1,x2,tol)
fprintf('La
fprintf( ',x)
'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
durante 24 horas si el metano produce
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
cilindros deben ser
mantenidos en reservas ? Obtener predicciones
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
método y programe
pr ograme
en GUIDE.
Datos:
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
fprintf( '%d \t %1.7f \t \t %f \n'
\n',i,kx,Ea);
,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'
fprintf('La %f\n',i,kx,Ea);
,i,kx,Ea);
end
%P6-E4
%DATOS
Qnec=25200;%kcal/horas
Qnec=25200; %kcal/horas
tiempo=24;%horas
tiempo=24; %horas
PC=97200;%kcal/kmol
PC=97200; %kcal/kmol
%Cilindros
Vcil=56.62; %Litros
Vcil=56.62;%Litros
P=204;%atm
P=204; %atm
T=294;%K
T=294; %K
R=0.082;%atm*L/K*mol
R=0.082; %atm*L/K*mol
a=2.25;%atm*L^2/mol^2
a=2.25; %atm*L^2/mol^2
b=0.0428;%L/mol
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) gas (m3/kg). Los parámetros a y b se
(kPa) y v = volumen de un kg de gas
calculan mediante:
3.
4. Hacer error=1;
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. tol=0.0001;
25.
x1=5;
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
R=0.518; %KJ/KgK
T=223;%K
T=223; %K
P=65;%KPa
P=65; %KPa
V=3;%m^3
V=3; %m^3
Pc=4580;%KPa
Pc=4580; %KPa
Tc=191;%K
Tc=191; %K
%Calculo a y b
a=0.427*(R^2*Tc^2)/Pc;
a=0.427*(R^2*Tc^2)/Pc;%Kpa(m^3/Kg)^2
%Kpa(m^3/Kg)^2
b=0.0866*R*Tc/Pc;%m^3/Kg
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;
m=V/x;%Kg
%Kg
fprintf('La
fprintf( [Kg]' ,m)
'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,...)
P6_E5GUIDE('CALLBACK',hObj ect,eventData,handles,...) calls the local
% function named CALLBACK in P6_E5GUIDE.M with the given input
arguments.
%
% P6_E5GUIDE('Property','Value',...)
P6_E5GUIDE('Property','Valu e',...) 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
eventdata handle to-figure
reserved to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
end set(hObject,
set(hObject,'BackgroundColor'
'BackgroundColor',
,'white'
'white');
);
% Hint: See
editISPC
controls usually have a white background on Windows.
and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'
isequal(get(hObject,'BackgroundColor'),
),
'defaultUicontrolBackgroundColor'))
get(0,'defaultUicontrolBackgroundColor'
get(0, ))
set(hObject,'BackgroundColor'
set(hObject, 'BackgroundColor',
,'white'
'white');
);
end
INICIO
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*T
b=0.0866*R*Tc/Pc
c/Pc
f=@(V) R*T/(V-b)-a/(V*(V+b)*sqrt(T))-P
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