mÉtodos numÉricos - metnum2011iscmetnum2011isc.wikispaces.com/file/view/problema+21.1.pdf · n=3...

15
INSTITU 096 096 096 096 096 Título Carrera: Semestre: Docente: Periodo: Matehuala, S.L.P. UTO TECNOLÓGICO D MATEHUALA Equipo # 1 660064 Beltrán Cruz Zoar Rubí 660318 Iñiguez Álvarez Narcizo Alejandro 660085 Navarro Romo Mónica 660093 Rocha Uresti Emilio 660097 Rosas Reyes Javier ÉTODOS NUMÉRICO o del Trabajo:”Problema 2 Ing. en Sistemas Computacional Quinto Ing. Martín Luis Ledezma Hernán Agosto-Diciembre 2011 08 de Diciemb DE OS 21.1” les ndez bre del 2011

Upload: vutram

Post on 07-Feb-2018

224 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

INSTITUTO TECNOLÓGICO DE

09660064

09660318

09660085

09660093

09660097

MÉTODOS NUMÉRICOS

Título del Trabajo

Carrera:

Semestre:

Docente:

Periodo:

Matehuala, S.L.P.

INSTITUTO TECNOLÓGICO DE MATEHUALA

Equipo # 1

09660064 Beltrán Cruz Zoar Rubí

09660318 Iñiguez Álvarez Narcizo Alejandro

09660085 Navarro Romo Mónica

09660093 Rocha Uresti Emilio

09660097 Rosas Reyes Javier

MÉTODOS NUMÉRICOS

Título del Trabajo :”Problema 21.1”

Ing. en Sistemas C omputacionales

Quinto

Ing. Martín Luis Ledezma Hernández

Agosto-Diciembre 2011

08 de Diciembre del 2011

INSTITUTO TECNOLÓGICO DE

MÉTODOS NUMÉRICOS

:”Problema 21.1”

omputacionales

Ing. Martín Luis Ledezma Hernández

08 de Diciembre del 2011

Page 2: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

PROBLEMA 21.1

21.1 Use medios analíticos para evaluar a) j* (1 - e-x)dx b) J4 (1 - x - A¿ + x5) dx c) J (8 + 4senx)<¿x 21.2 Emplee una sola aplicación de la regla trapezo idal para evaluar las integrales del problema 21.1. 21.3 Evalúe las integrales del problema 21.1 con un a regla trapezoidal de aplicación múltiple, con n = 2,4 y 6. 21.4 Evalúe las integrales del problema 21.1 con un a sola aplicación de la regla de Simpson 1/3. 21.5 Evalúe las integrales del problema 21.1 con un a aplicación múltiple de la regla de Simpson 1/3, con n = 4 y 6. 21.6Evalúe las integrales del problema 21.1 con una sola aplicación de la regla de Simpson 3/8.

CODIGO DE MATLAB

clear; format long fprintf('\n\t::::::::::Instituto Tecnologico de Matehuala::::::::::\n'); fprintf('\t::::::::::::::::::METODOS NUMERICOS:::::::::::::::::\n'); fprintf('\n:::::::::::::::::::::::ING. EN SISTEMAS::::::::::::::::::::::\n'); fprintf('\n\t::::::::::Equipo 4::::::::::\n'); fprintf('\n\t::::::::::Paulina del Carmen Alvarez Garcia::::::::::\n'); fprintf('\n\t::::::::::Alma Rosa Medrano Licea::::::::::\n'); fprintf('\n\t::::::::::Maribel Molina Herrera::::::::::\n'); fprintf('\n\t::::::::::Gerardo Gonzalez Barajas::::::::::\n'); while 1 disp('[1] TRAPECIO SIMPLE (h>0)') disp('[2] TRAPECIO COMPUESTO(h<0)') disp('[3] FORMULA DE SIMPSON SIMPLE') disp('[4] FORMULA DE LOS TRES OCTAVOS DE SIMPSON') disp('[5] FORMULA DE SIMPSON COMPUESTO') disp('[6] INTEGRACION DE ROMBERG') disp('[7] ROMBERG MODIFICADO') disp('[8] VOLVER') elecc3 = input('ELIGA OPCION '); switch elecc3 case 1 clc; clear; fprintf('\t\tTRAPECIO SIMPLE\n') funcion=input('ingrese la funcion \n f(x)=','s'); b=input('ingrese el limite superior de la integral\n'); a=input('ingrese el limite inferior de la integral\n'); h=b-a; x=a; f=eval(funcion); x=b; f= (f+eval(funcion))*(h/2);

Page 3: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

fprintf('El valor aproximado es: %10.15f\n\n',f) case 2 clc; clear; fprintf('\t\tTRAPECIO COMPUESTO\n') funcion=input('ingrese la funcion \n f(x)=','s'); b=input('ingrese el limite superior de la integral\n'); a=input('ingrese el limite inferior de la integral\n'); n=input('ingrese el numero de intervalos\n'); vv=input('ingrese el valor verdadero\n'); h=(b-a)/n; f=0; for k=1:n-1 x=a+h*k; f=f+eval(funcion); end f=2*f; x=a; f=f+eval(funcion); x=b; f=f+eval(funcion); f=(h/2)*(f); err=((vv-f)/vv)*100; fprintf('El valor aproximado es: %10.15f\n\n',f) fprintf('Error relativo porcentual: %10.15f\n\n',err) case 3 clc; clear; fprintf('\t\tFORMULA DE SIMPSON SIMPLE\n') funcion=input('ingrese la funcion \n f(x)=','s'); b=input('ingrese el limite superior de la funcion\n'); a=input('ingrese el limite inferior de la integral\n'); h=(b-a)/2; x=a; f=eval(funcion); x=b; f=f+eval(funcion); x=a+h; f=f+ 4*(eval(funcion)); f=(h/3)*f; fprintf('El valor aproximado de la integral es: %10.15f\n\n',f) case 4 clc; clear; fprintf('\t\tFORMULA DE LOS TRES OCTAVOS DE SIMPSON\n') funcion=input('ingrese la funcion \n f(x)=','s'); b=input('ingrese el limite superior de la funcion\n'); a=input('ingrese el limite inferior de la integral\n'); h=(b-a)/3; x=a; f=eval(funcion);x=a+h; f=f+3*(eval(funcion)); x=a+2*h; f=f+3*(eval(funcion)); x=b; f=f+eval(funcion); f=(3*h/8)*f; fprintf('El valor aproximado de la integral es: %10.15f\n\n',f) case 5 clc; clear; fprintf('\t\tFORMULA DE SIMPSON COMPUESTO\n') funcion=input('ingrese la funcion \n f(x)=','s'); b=input('ingrese el limite superior de la integral\n');

Page 4: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

a=input('ingrese el limite inferior de la integral\n'); n=input('ingrese el numero de intervalos\n'); h=(b-a)/(2*n); f=0; for k=1:n-1 x=a+h*(2*k); f=f+eval(funcion); end f1=0; for k=1:n x=a+h*(2*k-1); f1=f1+eval(funcion); end f=2*f+4*f1; x=a; f=f+eval(funcion); x=b; f=f+eval(funcion); f=(h/3)*f; fprintf('el valor aproximado de la integral es: %10.15f\n\n',f) case 6 clc; clear; fprintf('\t\tINTEGRACION DE ROMBERG\n') funcion=input('ingrese la funcion \n f(x)=','s'); b= input('ingrese el l�mite superior de la integral \n'); a= input('ingrese el l�mite inferior de la integral \n'); n= input('ingrese el n�mero de intervalos\n'); h=(b-a); M=1; J=0; R=zeros(n,n); x=a; f1=eval(funcion); x=b; f2=eval(funcion); R(1,1)=h*(f1+f2)/2; while (J<(n-1)) J=J+1; h=h/2; s=0; for p=1:M x=a+h*(2*p-1); f3=eval(funcion); s=s+f3; end R(J+1,1)=(1/2)*(R(J,1))+h*s; M=2*M; for k =1:J R(J+1,k+1)=R(J+1,k)+(R(J+1,k)-R(J,k))/(4^k-1); end end R fprintf('La aproximacion buscada es: %10.15f\n\n', R(J+1,J+1)) case 7

Page 5: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

clc; clear; fprintf('\t\tINTEGRACION DE ROMBERG\n') funcion=input('ingrese la funcion \n f(x)=','s'); b=input('Ingrese el limite superior:\n'); a=input('Ingrese el limite inferior:\n'); n=input('Ingrese el numero de particiones:\n'); tol=input('Ingrese la tolerancia:\n'); M=1; h=b-a; err=1; J=0; R=zeros(4,4); x=a; f_a=eval(funcion); x=b; f_b=eval(funcion); R(1,1)=h*(f_a+f_b)/2; disp(' quad err h') while((err>tol)&(J<n))|(J<4) J=J+1; h=h/2; s=0; for p=1:M x1=a+h*(2*p-1); x=x1; f_x1=eval(funcion); s=s+f_x1; end R(J+1,1)=R(J,1)/2+h*s; M=2*M; for K=1:J R(J+1,K+1)=R(J+1,K)+(R(J+1,K)-R(J,K))/(4^K-1); end err=abs(R(J,J)-R(J+1,K+1)); fprintf('%10.9f %10.9f %10.9f\n',R(J+1,J+1),err,h) end disp('LA MATRIZ TRIANGULAR INFERIOR ES:') disp(R) disp('El error es para el numero de particiones:') disp(err) disp('El tama�o de la ultima particion es:') disp(h) disp('La respuesta es:') disp(R(J+1,J+1)) otherwise clc fprintf('\n\t::::::::::ITMH::::::::::\n'); fprintf('\t::::::::::::::::::METODOS NUMERICOS:::::::::::::::::\n'); fprintf('\n :::::::::::::::::::::::ING. EN SISTEMAS::::::::::::::::::::::\n'); break end

Page 6: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

end RESELTADOS EN MATLAB

n=2

n=4

Page 7: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

N=6

N=5

Page 8: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

N=3

INTEGRACION DE ROMBERG

ingrese la funcion

f(x)=(1-x+(4*x.^3)+x.^5)

Ingrese el limite superior:

5

Ingrese el limite inferior:

-3

Ingrese el numero de particiones:

4

Ingrese la tolerancia:

0.5

quad err h

4392.000000000 8704.000000000 4.000000000

3026.666666667 1365.333333333 2.000000000

3026.666666667 0.000000000 1.000000000

3026.666666667 0.000000000 0.500000000

LA MATRIZ TRIANGULAR INFERIOR ES:

1.0e+004 *

Columns 1 through 3

1.309600000000000 0 0

0.656800000000000 0.439200000000000 0

0.397600000000000 0.311200000000000 0.302666666666667

0.326800000000000 0.303200000000000 0.302666666666667

0.308725000000000 0.302700000000000 0.302666666666667

Page 9: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite

Columns 4 through 5

0 0

0 0

0 0

0.302666666666667 0

0.302666666666667 0.302666666666667

El error es para el numero de particiones:

0

El tamao de la ultima particion es:

0.500000000000000

La respuesta es:

3.026666666666667e+003

[1] TRAPECIO SIMPLE (h>0)

[2] TRAPECIO COMPUESTO(h<0)

[3] FORMULA DE SIMPSON SIMPLE

[4] FORMULA DE LOS TRES OCTAVOS DE SIMPSON

[5] FORMULA DE SIMPSON COMPUESTO

[6] INTEGRACION DE ROMBERG

[7] ROMBERG MODIFICADO

[8] VOLVER

ELIGA OPCION

Page 10: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite
Page 11: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite
Page 12: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite
Page 13: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite
Page 14: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite
Page 15: MÉTODOS NUMÉRICOS - metnum2011iscmetnum2011isc.wikispaces.com/file/view/Problema+21.1.pdf · N=3 INTEGRACION DE ROMBERG ingrese la funcion f(x)=(1-x+(4*x.^3)+x.^5) Ingrese el limite