Vous êtes sur la page 1sur 8

Índice

1. Ejercicio 1 2
1.1. CODIGO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2. CORRIDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2. Ejercicio 2 3
2.1. CODIGO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2. CORRIDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3. Ejercicio 3 4
3.1. CODIGO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2. CORRIDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1
1. Ejercicio 1
.

1.1. CODIGO
Funcion:
f (x) = x3
0
f (x) =√3x2 √
g (x) = 1 + 9x4 2πsin(x) ∗ 1 + 9x4
LONGITUD Y AREA CON TRAPECIOS COMPUESTO.
clc ;
f p r i n t f ( ’ Metodo d e l t r a p e c i o \n ’ ) ;
f=i n p u t ( ’ i n g r e s e l a f u n c i o n \n f ( x ) = ’ , ’ s ’ ) ;
b=i n p u t ( ’ i n g r e s e l i m i t e s u p e r i o r \n ’ ) ;
a=i n p u t ( ’ i n g r e s e l i m i t e i n f e r i o r \n ’ ) ;
n=i n p u t ( ’ i n g r e s e e l numero de i n t e r v a l o s \n ’ ) ;
m=i n p u t ( ’ i n g r e s e e l numero de i n t e g r a l e s \n ’ ) ;

g=i n l i n e ( f ) ;
s=0
aux=(b−a ) /m;
h o l d on
f o r i =1:m
b=a+aux ;
s;
h=(b−a ) / n ;
f o r i =1:n
s=h /2∗( g ( a+( i −1)∗h)+g ( a+( i )∗ h))+ s ;
f p r i n t f ( ’ El a r e a aproximada e s : %10.15 f \n\n ’ , s ) ;
end
a=b ;
end
1
LONGITUD Y AREA CON SIMPSON 3
COMPUESTO.
clear all :
f p r i n t f ( ’CALCULO DE LLA INTEGRAL POR EL METODO DE SIMPSON 1/3 COMPUESTO \n ’ ) ;
f=i n p u t ( ’INTRODUCE LA FUNCION: \ n ’ , ’ s ’ ) ;
a=i n p u t ( ’ LIMITE INFERIOR : \n ’ ) ;
b=i n p u t ( ’ LIMITE SUPERIOR : \ n ’ ) ;
c=i n p u t ( ’NUMERO DE DIVISIONES SOLO PAR : \ n ’ ) ;
h=(b−a ) / c ;
Aprox =0;
x=a ;
f o r i =1: c ;
i f ( −1)ˆ i==1
k=e v a l ( f ) ;
Aprox=Aprox+k ;
end
x=h∗ i ;

2
end
AproxAprox =0;
x=a ;
f o r i =2: c ;
i f ( −1)ˆ i==−1
k=e v a l ( f ) ;
AproxAprox=AproxAprox+k ;
end
x=h∗ i ;
end
x=a ;
i f x==a
d=e v a l ( f ) ;
end
x=b ;
i f x==b
e=e v a l ( f ) ;
end
Aprox=Aprox ∗ 4 ;
v=AproxAprox ∗ 2 ;
Aprox=Aprox+v+d+e ;
Aprox=Aprox /(3∗ c ) ;
Aprox=Aprox ∗( b−a )
3
LONGITUD Y AREA CON SIMPSON 8
COMPUESTO.
format l o n g
syms x
d i s p ( ’METODO SIMPSON 3/8 COMPUESTO’ )
fun=i n p u t ( ’ I n g r e s a l a f u n c i ó n f ( x ) : ’ ) ;
f=i n l i n e ( fun ) ;
n=1;
w h i l e mod( n ,3)˜=0
n=i n p u t ( ’ I n g r e s e e l número de s u b i n t e r v a l o s : ’ ) ;
i f mod( n ,3)˜=0
d i s p ( ’ El número de s u b i n t e r v a l o s debe s e r impar ’ )
end
end
a=i n p u t ( ’ L i m i t e i n f e r i o r : ’ ) ;
b=i n p u t ( ’ L i m i t e s u p e r i o r : ’ ) ;
h=(b−a ) / n ;
sumai =0;sumap=0; sumar =0;
f o r i = 1 : 3 : n−2
sumai=sumai+f e v a l ( f , h∗ i+a ) ;
end
f o r i = 2 : 3 : n−1
sumap=sumap+f e v a l ( f , h∗ i+a ) ;
end
f o r i = 3 : 3 : n−3
sumar=sumar+f e v a l ( f , h∗ i+a ) ;
end
d i s p ( ’VALOR APROXIMADO DE LA INTEGRAL : ’ )

3
I =(3∗h / 8 ) ∗ ( f e v a l ( f , a)+3∗ sumai+3∗sumap+2∗sumar+f e v a l ( f , b ) )

1.2. CORRIDA

2. Ejercicio 2
f (x) = sin(x)
0
f (x) =p cos(x)
g (x) = 1 + (cos(x))2
p
h (x) = 2πsin(x) 1 + (cos(x))2
.

2.1. CODIGO
LONGITUD Y AREA CON TRAPECIOS COMPUESTO.
clc ;
f p r i n t f ( ’ Metodo d e l t r a p e c i o \n ’ ) ;
f=i n p u t ( ’ i n g r e s e l a f u n c i o n \n f ( x ) = ’ , ’ s ’ ) ;
b=i n p u t ( ’ i n g r e s e l i m i t e s u p e r i o r \n ’ ) ;
a=i n p u t ( ’ i n g r e s e l i m i t e i n f e r i o r \n ’ ) ;
n=i n p u t ( ’ i n g r e s e e l numero de i n t e r v a l o s \n ’ ) ;
m=i n p u t ( ’ i n g r e s e e l numero de i n t e g r a l e s \n ’ ) ;

g=i n l i n e ( f ) ;
s=0
aux=(b−a ) /m;
h o l d on
f o r i =1:m
b=a+aux ;
s;
h=(b−a ) / n ;
f o r i =1:n
s=h /2∗( g ( a+( i −1)∗h)+g ( a+( i )∗ h))+ s ;
f p r i n t f ( ’ El a r e a aproximada e s : %10.15 f \n\n ’ , s ) ;
end
a=b ;
end
1
LONGITUD Y AREA CON SIMPSON 3
COMPUESTO.
clear all :
f p r i n t f ( ’CALCULO DE LLA INTEGRAL POR EL METODO DE SIMPSON 1/3 COMPUESTO \n ’ ) ;
f=i n p u t ( ’INTRODUCE LA FUNCION: \ n ’ , ’ s ’ ) ;
a=i n p u t ( ’ LIMITE INFERIOR : \n ’ ) ;
b=i n p u t ( ’ LIMITE SUPERIOR : \ n ’ ) ;
c=i n p u t ( ’NUMERO DE DIVISIONES SOLO PAR : \ n ’ ) ;
h=(b−a ) / c ;
Aprox =0;
x=a ;
f o r i =1: c ;

4
i f ( −1)ˆ i==1
k=e v a l ( f ) ;
Aprox=Aprox+k ;
end
x=h∗ i ;
end
AproxAprox =0;
x=a ;
f o r i =2: c ;
i f ( −1)ˆ i==−1
k=e v a l ( f ) ;
AproxAprox=AproxAprox+k ;
end
x=h∗ i ;
end
x=a ;
i f x==a
d=e v a l ( f ) ;
end
x=b ;
i f x==b
e=e v a l ( f ) ;
end
Aprox=Aprox ∗ 4 ;
v=AproxAprox ∗ 2 ;
Aprox=Aprox+v+d+e ;
Aprox=Aprox /(3∗ c ) ;
Aprox=Aprox ∗( b−a )
3
LONGITUD Y AREA CON SIMPSON 8
COMPUESTO.
format l o n g
syms x
d i s p ( ’METODO SIMPSON 3/8 COMPUESTO’ )
fun=i n p u t ( ’ I n g r e s a l a f u n c i ó n f ( x ) : ’ ) ;
f=i n l i n e ( fun ) ;
n=1;
w h i l e mod( n ,3)˜=0
n=i n p u t ( ’ I n g r e s e e l número de s u b i n t e r v a l o s : ’ ) ;
i f mod( n ,3)˜=0
d i s p ( ’ El número de s u b i n t e r v a l o s debe s e r impar ’ )
end
end
a=i n p u t ( ’ L i m i t e i n f e r i o r : ’ ) ;
b=i n p u t ( ’ L i m i t e s u p e r i o r : ’ ) ;
h=(b−a ) / n ;
sumai =0;sumap=0; sumar =0;
f o r i = 1 : 3 : n−2
sumai=sumai+f e v a l ( f , h∗ i+a ) ;
end
f o r i = 2 : 3 : n−1
sumap=sumap+f e v a l ( f , h∗ i+a ) ;

5
end
f o r i = 3 : 3 : n−3
sumar=sumar+f e v a l ( f , h∗ i+a ) ;
end
d i s p ( ’VALOR APROXIMADO DE LA INTEGRAL : ’ )
I =(3∗h / 8 ) ∗ ( f e v a l ( f , a)+3∗ sumai+3∗sumap+2∗sumar+f e v a l ( f , b ) )

2.2. CORRIDA

3. Ejercicio 3
f (x) = e−x
0
f (x) =p −e−x
g (x) = 1 + (−ep−x )2

h (x) = 2πsin(x) 1 + (−e−x )2


.

3.1. CODIGO
LONGITUD Y AREA CON TRAPECIOS COMPUESTO.
clc ;
f p r i n t f ( ’ Metodo d e l t r a p e c i o \n ’ ) ;
f=i n p u t ( ’ i n g r e s e l a f u n c i o n \n f ( x ) = ’ , ’ s ’ ) ;
b=i n p u t ( ’ i n g r e s e l i m i t e s u p e r i o r \n ’ ) ;
a=i n p u t ( ’ i n g r e s e l i m i t e i n f e r i o r \n ’ ) ;
n=i n p u t ( ’ i n g r e s e e l numero de i n t e r v a l o s \n ’ ) ;
m=i n p u t ( ’ i n g r e s e e l numero de i n t e g r a l e s \n ’ ) ;

g=i n l i n e ( f ) ;
s=0
aux=(b−a ) /m;
h o l d on
f o r i =1:m
b=a+aux ;
s;
h=(b−a ) / n ;
f o r i =1:n
s=h /2∗( g ( a+( i −1)∗h)+g ( a+( i )∗ h))+ s ;
f p r i n t f ( ’ El a r e a aproximada e s : %10.15 f \n\n ’ , s ) ;
end
a=b ;
end
1
LONGITUD Y AREA CON SIMPSON 3
COMPUESTO.
clear all :
f p r i n t f ( ’CALCULO DE LLA INTEGRAL POR EL METODO DE SIMPSON 1/3 COMPUESTO \n ’ ) ;
f=i n p u t ( ’INTRODUCE LA FUNCION: \ n ’ , ’ s ’ ) ;
a=i n p u t ( ’ LIMITE INFERIOR : \n ’ ) ;
b=i n p u t ( ’ LIMITE SUPERIOR : \ n ’ ) ;

6
c=i n p u t ( ’NUMERO DE DIVISIONES SOLO PAR : \ n ’ ) ;
h=(b−a ) / c ;
Aprox =0;
x=a ;
f o r i =1: c ;
i f ( −1)ˆ i==1
k=e v a l ( f ) ;
Aprox=Aprox+k ;
end
x=h∗ i ;
end
AproxAprox =0;
x=a ;
f o r i =2: c ;
i f ( −1)ˆ i==−1
k=e v a l ( f ) ;
AproxAprox=AproxAprox+k ;
end
x=h∗ i ;
end
x=a ;
i f x==a
d=e v a l ( f ) ;
end
x=b ;
i f x==b
e=e v a l ( f ) ;
end
Aprox=Aprox ∗ 4 ;
v=AproxAprox ∗ 2 ;
Aprox=Aprox+v+d+e ;
Aprox=Aprox /(3∗ c ) ;
Aprox=Aprox ∗( b−a )
3
LONGITUD Y AREA CON SIMPSON 8
COMPUESTO.
format l o n g
syms x
d i s p ( ’METODO SIMPSON 3/8 COMPUESTO’ )
fun=i n p u t ( ’ I n g r e s a l a f u n c i ó n f ( x ) : ’ ) ;
f=i n l i n e ( fun ) ;
n=1;
w h i l e mod( n ,3)˜=0
n=i n p u t ( ’ I n g r e s e e l número de s u b i n t e r v a l o s : ’ ) ;
i f mod( n ,3)˜=0
d i s p ( ’ El número de s u b i n t e r v a l o s debe s e r impar ’ )
end
end
a=i n p u t ( ’ L i m i t e i n f e r i o r : ’ ) ;
b=i n p u t ( ’ L i m i t e s u p e r i o r : ’ ) ;
h=(b−a ) / n ;
sumai =0;sumap=0; sumar =0;

7
f o r i = 1 : 3 : n−2
sumai=sumai+f e v a l ( f , h∗ i+a ) ;
end
f o r i = 2 : 3 : n−1
sumap=sumap+f e v a l ( f , h∗ i+a ) ;
end
f o r i = 3 : 3 : n−3
sumar=sumar+f e v a l ( f , h∗ i+a ) ;
end−
d i s p ( ’VALOR APROXIMADO DE LA INTEGRAL : ’ )
I =(3∗h / 8 ) ∗ ( f e v a l ( f , a)+3∗ sumai+3∗sumap+2∗sumar+f e v a l ( f , b ) )

3.2. CORRIDA

Vous aimerez peut-être aussi