1 MTODO DE LA SECANTE
Un problema potencial en la implementacin del mtodo de Newton-Raphson es la evaluacin de la
derivada. Aunque esto no es un inconveniente para los polinomios ni para muchas otras funciones,
existen algunas funciones cuyas derivadas en ocasiones resultan muy difciles de calcular. En dichos
casos, la derivada se puede aproximar mediante una diferencia finita dividida hacia atrs, como
f xi 1 f xi
f ' xi
xi 1 xi
f xi xi 1 xi
xi 1 xi
f xi 1 f xi
Esta es la ecuacin que utilizaremos para el desarrollo de las ecuaciones aplicado a flujo crtico y flujo
normal, el algoritmo de flujo para este propsito es como sigue
Funcin [Y,k,er]=secante(fy,y0,y1,n,error)
i=1:n
3
eri=/Yi+1-Yi/; k=k+1;
si
eri<=error Break
no
si
k==n No converge
no
Converge
V
Fr 1
A
g
T
4
Q 2 A3
g T
A b z y y
T b 2 zy
Q 2 b z y y
3
0
g b 2 zy
Q 2 b z y y
3
F y
g b 2 zy
3
Q 5m b 1m g 9.81 m z 0 .5
s s
Graficando para definir el intervalo donde puede encontrarse la solucin, puntos utilizados son 1.5 y 2.0
Funcin F(y)
5
Valores de la Funcin F(y)
0
-5
-10
-15
-20
0 0.5 1 1.5 2
Tirante y (m)
clc; clear;
global Q g b z
Q=input('ingrese el caudal [m3/s]: ');
g=9.81; %Gravedad m/s2
b=input('Ingrese el ancho del canal [m]: ');
z=input('Ingrese el talud del canal [z:1=H:v]: ');
y0=input('Ingrese punto de aproximacin y0: ');
y1=input('Ingrese punto de aproximacin y1: ');
n=input('Ingrese numero de interacciones: ');
error=input('Ingrese error maximo: ');
[Y,k,er]=feval('secante_c','critico',y0,y1,n,error,Q,g,b,z);
disp('numero de interacciones');
5
disp(k);
disp('Error maximo');
disp(er(end));
disp('tirante calculado');
disp(Y(end));
function F=critico(y,Q,g,b,z)
F=Q^2/g-(((b+z*y)*y )^3)/(b+2*z*y);
function [Y,k,er]=secante_c(fy,y0,y1,n,error,Q,g,b,z)
%Programa general para calcular la raiz por metodo de la secante
k=0;
Y(1)=y0;
Y(2)=y1;
er(1)=abs(Y(2)-Y(1));
for i=1:n
k=k+1;
Fun(i)=feval(fy,Y(i),Q,g,b,z);
Fun(i+1)=feval(fy,Y(i+1),Q,g,b,z);
Y(i+2)=Y(i+1)-Fun(i+1)*(Y(i)-Y(i+1))/(Fun(i)-Fun(i+1));
er(i+1)=abs(Y(i+2)-Y(i+1));
if er(i+1)<=error
break;
end
end
if k==n
disp('el metodo no converge');
Y=0;
er=0;
end
6
3 APLICACIN PARA FLUJO NORMAL
Para el clculo en flujo permanente en canal abierto utilizaremos la ecuacin descrita por Chezy -
Manning, entonces la siguiente ecuacin a resolver.
1 2 1
Q R 3 S 2 A
n
Qn 2
1
R 3A
S 2
A b z y y
T b 2 zy
P b 2 y 1 z2
R
A b z y y
P b 2 y 1 z2
2
Qn b z y y 3
1
b z y y 0
b 2 y 1 z
2 2
S
2
Qn b z y y 3
F y 1
b z y y
b 2 y 1 z
2 2
S
3
Q 5m b 1m g 9.81 m z 0 .5 S 0 .001 n 0 .015
s s
Funcin F(y)
2.5
Valores de la Funcin F(y)
1.5
0.5
-0.5
-1.5
-2.5
0.5 1 1.5 2 2.5
Tirante y (m)
7
3.1 PROGRAMACIN GENERAL
Nombre de archivo guardado normal_sec
clc; clear;
global Q g b z n_m S
Q=input('ingrese el caudal [m3/s]: ');
g=9.81; %Gravedad m/s2
b=input('Ingrese el ancho del canal [m]: ');
z=input('Ingrese el talud del canal [z:1=H:v]: ');
n_m=input('Ingrese rugosidad de Manning: ');
S=input('Ingrese pendiente longitudinal del canal: ');
y0=input('Ingrese punto de aproximacin y0: ');
y1=input('Ingrese punto de aproximacin y1: ');
n=input('Ingrese numero de interacciones: ');
error=input('Ingrese error maximo: ');
[Y,k,er]=feval('secante_n','normal',y0,y1,n,error,Q,g,b,z,S,n_m);
disp('numero de interacciones');
disp(k);
disp('Error maximo');
disp(er(end));
disp('tirante calculado');
disp(Y(end));
function F=normal(y,Q,g,b,z,S,n_m)
F=Q*n_m/(S^0.5)-
(((b+z*y)*y)/(b+2*y*(1+z^2)^0.5))^(2/3)*((b+z*y)*y);
function [Y,k,er]=secante_n(fy,y0,y1,n,error,Q,g,b,z,S,n_m)
%Programa general para calcular la raiz por metodo de la secante
k=0;
Y(1)=y0;
Y(2)=y1;
er(1)=abs(Y(2)-Y(1));
for i=1:n
k=k+1;
Fun(i)=feval(fy,Y(i),Q,g,b,z,S,n_m);
Fun(i+1)=feval(fy,Y(i+1),Q,g,b,z,S,n_m);
Y(i+2)=Y(i+1)-Fun(i+1)*(Y(i)-Y(i+1))/(Fun(i)-Fun(i+1));
er(i+1)=abs(Y(i+2)-Y(i+1));
if er(i+1)<=error
break;
end
end
if k==n
disp('el metodo no converge');
Y=0;
er=0;
8
end
9
CAPITULO II
MTODO DEL PUNTO FIJO EN SISTEMA DE ECUACIONES
x g x
F x 0
O su equivalente
f1 x1 , x 2 , x3 ,..., x n f1 x1 , x 2 , x3 ,..., x n 0
F x
Equivalente
f n x1 , x 2 , x3 ,..., x n f x , x , x ,..., x 0
n 1 2 3 n
x10
x 0
X 0 2
x n0
x1 1 x1 , x 2 , x3 ,..., x n
x 2 x1 , x 2 , x3 ,..., x n
2
X X Equivalente x3 3 x1 , x 2 , x3 ,..., x n
x n n x1 , x 2 , x3 ,..., x n
10
x1k 1 1 x , x , x ,..., x
k
1
k
2
k
3
k
n
k 1
x 2 2 x , x , x ,..., x
k k k k
1 2 3 n
X k X k Equivalente k 1
x3 3 x , x , x ,..., x
1
k k
2
k
3
k
n
x nk 1 n x , x 2k , x3k ,..., x nk
k
1
Funcin [X,k,er]=punt_fijo(F,x,n,error)
k=0; X(:,1)=x';
i=1:n
eri=/Xi+1-Xi/; k=k+1;
si
eri<=error Break
no
si
k==n No converge
no
Converge
11
k=k+1;
X(:,i+1)=feval(F,X(:,i));
er(i)=norm(X(:,i+1)-X(:,i));
if er(i)<=error
break;
end
end
if k==n
disp('El metodo no converge');
end
3x1 cos( x2 x3 ) 12 0
x12 81( x2 0.1) 2 sen( x3 1.06 0
e x1 x2 20 x3 10 / 3 1 0
Transformado las ecuaciones para dar la forma por el mtodo de punto fijo.
x1k 1 1 x , x , x ,..., x
k
1
k
2
k
3
k
n
k 1
x 2 2 x , x , x ,..., x
1
k k
2
k
3
k
n
x1 cos( x2 x3 ) / 3 16
k 1
x3 3 x , x , x ,..., x
1
k k
2
k
3
k
n
Entonces tenemos x2 19 x1 senx3 1.06 0.1
2
x x
x3 120 (1 e 1 2 ) / 6
x nk 1 n xk
1 , x 2k , x3k ,..., x nk
Defuncin de la funcin de ingreso en Matlab
function F=ejm1(x)
F(1)=cos(x(2)*x(3))/3+1/6;
F(2)=1/9*(x(1)^2+sin(x(3))+1.06)^0.5-0.1;
F(3)=1/20*(1-exp(-x(1)*x(2)))-pi/6;
F=F';
12