Download - Practica 2
PRACTICA 21. Determinar la menor raz positiva de:
a) Con el mtodo de la Biseccin, e itere hasta que el error sea menor que el 1%.
Mtodo de la biseccin:
>> f=inline('8*2.7182^(-x)*sin(x)-1')
f =
Inline function: f(x) = 8*2.7182^(-x)*sin(x)-1
>> a=2;b=6;>> x1=(a+b)/2
x1 =
4
>> f(a)*f(x1)
ans =
0.0172
>> a=x1;>> x2=(a+b)/2
x2 =
5
>> a=x2;>> x3=(a+b)/2
x3 =
5.5000
>> a=x3;>> x4=(a+b)/2
x4 =
5.7500
CODIGO DEL PROGRAMA:function pushbutton1_Callback(hObject, eventdata, handles)f=inline(get(handles.edit1,'string'))a=str2double(get(handles.edit2,'string'))b=str2double(get(handles.edit3,'string'))E=str2double(get(handles.edit4,'string'))if f(a)*f(b)>0 while abs(b-a)>E x1=(a+b)/2 if f(a)*f(x1)>0 a=x1 else b=x1 if f(x1)==0 a=b end endendset(handles.edit5,'string',x1)elseset(handles.edit5,'string','no existe raiz')end
b) Con el mtodo de Newton Raphson (3 iteraciones, ) e itere hasta que el error sea menor que el 1%.
Mtodo de Newton Rapshon:
>> syms x;>> f=8*2.7182^(-x)*sin(x)-1 f = (8*sin(x))/(13591/5000)^x - 1 >> diff(f,x) ans = (8*cos(x))/(13591/5000)^x - (8*log(13591/5000)*sin(x))/(13591/5000)^x >> f=inline('8*2.7182^(-x)*sin(x)-1')
f =
Inline function: f(x) = 8*2.7182^(-x)*sin(x)-1
>> fd=inline('(8*cos(x))/(13591/5000)^x - (8*log(13591/5000)*sin(x))/(13591/5000)^x')
fd =
Inline function: fd(x) = (8*cos(x))/(13591/5000)^x - (8*log(13591/5000)*sin(x))/(13591/5000)^x
>> x0=0.3;f(x0);fd(x0);>> x1=x0-(f(x0)/fd(x0))
x1 = 0.1078
>> x2=x1-(f(x1)/fd(x1))
x2 =
0.1435
>> x3=x2-(f(x2)/fd(x2))
x3 =
0.1450
CODIGO DEL PROGRAMA:function pushbutton1_Callback(hObject, eventdata, handles)f=inline(get(handles.edit1,'string'));fd=inline(get(handles.edit2,'string'));x0=str2double(get(handles.edit3,'string'));E=str2double(get(handles.edit4,'string'));x1=x0-f(x0)/fd(x0);while abs(x1-x0)>E x0=x1; x1=x0-f(x0)/fd(x0);endset(handles.edit5,'string',x1)
c) Con el mtodo de la secante (tres iteraciones y ) e itere hasta que el error sea menor que el 1%.
Mtodo de la secante:
>> f=inline('8*2.7182^(-x)*sin(x)-1')
f =
Inline function: f(x) = 8*2.7182^(-x)*sin(x)-1
>> x0=0.5;x1=0.3;f(x0);f(x1);>> x2=x1-(((x1-x0)*f(x1))/(f(x1)-f(x0)))
x2 =
0.0386
>> x3=x2-(((x2-x1)*f(x2))/(f(x2)-f(x1)))
x3 =
0.1649
>> x4=x3-(((x3-x2)*f(x3))/(f(x3)-f(x2)))
x4 =
0.1473
x2 =
0.0386
x0 =
0.3000
x1 =
0.0386
x2 =
0.1649
x0 =
0.0386
x1 =
0.1649
x2 =
0.1473
x0 =
0.1649
x1 =
0.1473
x2 =
0.1450
x0 =
0.1473
x1 =
0.1450
x2 =
0.1450
x0 =
0.1450
x1 =
0.1450
CODIGO DEL PROGRAMA:f=inline(get(handles.edit1,'string'));x0=str2double(get(handles.edit2,'string'));x1=str2double(get(handles.edit3,'string'));E=str2double(get(handles.edit4,'string'));while abs(x1-x0)>E x2=x1-((x1-x0)*f(x1))/(f(x1)-f(x0)) x0=x1 x1=x2endset(handles.edit5,'string',x2)
2. El desplazamiento de una estructura est definido por la ecuacin siguiente para una oscilacin amortiguada:
Donde k=0.7 y w=4
a) Utilice el mtodo grafico para realizar una estimacin del tiempo que se requiere para que el desplazamiento disminuya a 3.5.
Mtodo grafico:
>> f=inline('9*2.7182^((-0.7)*x)*cos(4*x)')
f =
Inline function: f(x) = 9*2.7182^((-0.7)*x)*cos(4*x)
>> ezplot(f); grid on
b) Emplee el mtodo de la Biseccin para determinar la raz, e itere hasta que E.
Mtodo de la biseccin:
>> f=inline('9*2.7182^((-0.7)*x)*cos(4*x)')
f =
Inline function: f(x) = 9*2.7182^((-0.7)*x)*cos(4*x)
>> a=3;b=5;>> x1=(a+b)/2
x1 =
4
>> f(a)*f(x1)
ans =
-0.4875
>> b=x1;>> x2=(a+b)/2
x2 =
3.5000
>> b=x2;>> x3=(a+b)/2
x3 =
3.2500
>> b=x3;>> x4=(a+b)/2
x4 =
3.1250
>> b=x4;>> x5=(a+b)/2
x5 =
3.0625
>> f(a)*f(b)
ans =
0.9372
CODIGO DEL PROGRAMA:function pushbutton1_Callback(hObject, eventdata, handles)f=inline(get(handles.edit1,'string'))a=str2double(get(handles.edit2,'string'))b=str2double(get(handles.edit3,'string'))E=str2double(get(handles.edit4,'string'))if f(a)*f(b)>0 while abs(b-a)>E x1=(a+b)/2 if f(a)*f(x1)> syms x;>> f=(9*2.7182^((-0.7)*x)*cos(4*x)) f = (9*cos(4*x))/(13591/5000)^((7*x)/10) >> diff(f,x) ans = - (36*sin(4*x))/(13591/5000)^((7*x)/10) - (63*cos(4*x)*log(13591/5000))/(10*(13591/5000)^((7*x)/10)) >> f=inline('9*2.7182^((-0.7)*x)*cos(4*x)')
f =
Inline function: f(x) = 9*2.7182^((-0.7)*x)*cos(4*x)
>> df=inline('- (36*sin(4*x))/(13591/5000)^((7*x)/10) - (63*cos(4*x)*log(13591/5000))/(10*(13591/5000)^((7*x)/10))')
df =
Inline function:df(x) = - (36*sin(4*x))/(13591/5000)^((7*x)/10) - (63*cos(4*x)*log(13591/5000))/(10*(13591/5000)^((7*x)/10))
>> x0=3;f(x0);df(x0);>> x1=x0-(f(x0)/df(x0))
x1 =
2.4575
>> x2=x1-(f(x1)/df(x1))
x2 =
2.8713
>> x3=x2-(f(x2)/df(x2))
x3 =
2.7243
>> x4=x3-(f(x3)/df(x3))
x4 =
2.7486
CODIGO DEL PROGRAMA:function pushbutton1_Callback(hObject, eventdata, handles)f=inline(get(handles.edit1,'string'));df=inline(get(handles.edit2,'string'));x0=str2double(get(handles.edit3,'string'));E=str2double(get(handles.edit4,'string'));x1=x0-f(x0)/df(x0);while abs(x1-x0)>E x0=x1; x1=x0-f(x0)/df(x0);endset(handles.edit5,'string',x1)GRAFICA:d) Emplee el mtodo de la Secante para determinar la raz, e itere hasta que E.
Mtodo de la secante:
>> f=inline('9*2.7182^((-0.7)*x)*cos(4*x)')
f =
Inline function: f(x) = 9*2.7182^((-0.7)*x)*cos(4*x)
>> ezplot(f); grid on>> x0=0.7;x1=0.9;f(x0);f(x1);>> x2=x1-(((x1-x0)*f(x1))/(f(x1)-f(x0)))
x2 =
1.8588
>> x3=x2-(((x2-x1)*f(x2))/(f(x2)-f(x1)))
x3 =
1.6785
>> x4=x3-(((x3-x2)*f(x3))/(f(x3)-f(x2)))
x4 =
1.9763
>> x5=x4-(((x4-x3)*f(x4))/(f(x4)-f(x3)))
x5 =
1.9633
x2 =
1.8588
x0 =
0.9000
x1 =
1.8588
x2 =
1.6785
x0 =
1.8588
x1 =
1.6785
x2 =
1.9763
x0 =
1.6785
x1 =
1.9763
x2 =
1.9633
x0 =
1.9763
x1 =
1.9633
x2 =
1.9635
x0 =
1.9633
x1 =
1.9635
CODIGO DEL PROGRAMA:f=inline(get(handles.edit1,'string'));x0=str2double(get(handles.edit2,'string'));x1=str2double(get(handles.edit3,'string'));E=str2double(get(handles.edit4,'string'));while abs(x1-x0)>E x2=x1-((x1-x0)*f(x1))/(f(x1)-f(x0)) x0=x1 x1=x2endset(handles.edit5,'string',x2)
3. Para la circulacin de fluidos en tubos, se describe a la friccin por medio de un numero adimensional, que es el factor de fraccin de Fanning f. El factor de friccin de Fanning depende de ciertos nmeros de parmetros relacionados con el tamao del fluido que pueden representarse con otra cantidad adimensional, el nmero de Reynolds Re. Una frmula que pronostica el valor de f dado Re es la ecuacin de Von Karman.
Valores comunes del nmero de Reynolds para flujo turbulento son: 10000 a 500000, y del factor fe friccin de Fanning son 0.001 a 0.01. Desarrolle una funcin que utilice el mtodo de la biseccin con objeto de resolver cual sera el factor de friccin de Fanning f, dado un valor de Re proporcionado por el usuario que este entre 2500 y 1000000. Disee la funcin de modo que se garantice que el error absoluto en el resultado sea de Ea,d