integracion scilab
DESCRIPTION
Teoría de como generar los scripts en Scilab para metodos numéricos de integracion, con ejemplos, sencillo de entenderTRANSCRIPT
-
2
0
5.02
3
sen5.01
)1cos(2dxe
x
x x
x f(x)0,25 2,727
0,75 2,811
1,25 2,605
1,75 2,863
0,000
0,500
1,000
1,500
2,000
2,500
3,000
3,500
4,000
0 0,25 0,5 0,75 1 1,25 1,5 1,75 2 2,25 2,5 2,75 3
Integracin Casos en los cuales se utilizan mtodos numricos en lugar de los analticos
Las integrales surgen cuando se desea determinar el cambio en una cantidad y cuya razn de cambio con respecto a otra variable x
es descripta por la relacin:
el cambio en y desde ya hasta yb es:
b
a
b
a
x
x
y
y
dxxfdy )(
)(xfdx
dy
-
xb xa
ya
yb
f(x)
a
b
x dx
dy y
Magnitud del
cambio
Area bajo
la curva
Integracin
b
a
x
x
ab dxxfyy )(
Area infinitesimalmente
pequea
Suma de reas
-
b
a
b
a
x
x
n
x
x
dxxfdxxf )()(
Frmulas cerradas de Newton-Cotes
Trapecios Simpson 1/3
Polinomio de orden 1
Polinomio de orden 2
Polinomio de orden 3
Simpson 3/8
Espaciamiento constante entre valores
de la variable independiente
Incluyen los puntos
extremos en los clculos
-
Regla del trapecio
2
)()()( baab
xfxfxxI
b
a
b
a
x
x
x
x
dxxfdxxf )()( 1
f(0.5) = 2.817
f(3.5) = 13.419
I (3.5-0.5)(2.817+13.419)/2 = 24.353 I = 19.262938
Er% = ?
0,000
2,000
4,000
6,000
8,000
10,000
12,000
14,000
16,000
0 0,5 1 1,5 2 2,5 3 3,5 4
f(xa)
f(xb)
xb xa
Error
-
Regla del trapecio mltiple
El intervalo se divide en n segmentos de igual ancho
n
xxh n 1
2
)()(...
2
)()(
2
)()( 12312
nnxfxf
hxfxf
hxfxf
hI
2
)()()( baab
xfxfxxI
1
2
1 )()(2)(2
n
i
ni xfxfxfh
In
xfxfxf
xxI
n
i
ni
n2
)()(2)(
)(
1
2
1
1
0,000
2,000
4,000
6,000
8,000
10,000
12,000
14,000
16,000
0 0,5 1 1,5 2 2,5 3 3,5 4
f(x1)
f(xn)
xn x1
Error
-
Regla de Simpson 1/3
3
1
3
1
)()( 2
x
x
x
x
dxxfdxxf
)()(4)(3
321 xfxfxfh
I
2
)( 13 xxh
6
)()(4)()( 32113
xfxfxfxxI
dxxxxx
xxxxxf
xxxx
xxxxxf
xxxx
xxxxxfI
x
x
3
1 2313
213
3212
312
3121
321
))((
))(()(
))((
))(()(
))((
))(()(
Polinomio de Lagrange
Cantidad de segmentos
0,000
2,000
4,000
6,000
8,000
10,000
12,000
14,000
16,000
0 0,5 1 1,5 2 2,5 3 3,5 4
f(x0)
f(x2)
x2 x0
Error
x1
f(x1)
-
Regla de Simpson 1/3 mltiple
6
)()(4)()( 32113
xfxfxfxxI
5
3 2
3
1
)(...)()(
x
x
x
x
x
x
n
n
dxxfdxxfdxxfI
n
xxh n
)( 1
n
xfxfxfxf
xxI
n
n
j
j
n
i
i
n3
)()(2)(4)(
)(
2
7,5,3
1
6,4,2
1
1
6
)()(4)(2...
6
)()(4)(2
6
)()(4)(2 12543321 nnn
xfxfxfh
xfxfxfh
xfxfxfhI
Se utiliza cuando hay una cantidad impar de puntos Cantidad de
segmentos
2
)( 13 xxh
-
Regla de Simpson 3/8
4
1
4
1
)()( 3
x
x
x
x
dxxfdxxf
3
)( 14 xxh
)()(3)(3)(8
34321 xfxfxfxf
hI
8
)()(3)(3)()( 432114
xfxfxfxfxxI
Se utiliza cuando hay 4 puntos
0,000
2,000
4,000
6,000
8,000
10,000
12,000
14,000
16,000
0 0,5 1 1,5 2 2,5 3 3,5 4
f(x4)
f(x1)
f(x3)
x3 x1
Error
x2
f(x2)
x4
-
1,6405
puntos Trapecio Error% Simpson Error%
3 1,0688 35 1,3675 17
4 1,3696 17 1,5192 7 (3/8)
5 1,4848 9 1,6235 1
6 1,5399 6 1,6451 0,28 (1/3 + 3/8)
7 1,5703 4 1,6372 0,20
9 1,6008 2 1,6395 0,06
9 1,6381 0,15 (1/3 + 3/8)
Comparacin de errores
-
Clculo del trabajo que vara con la distancia
F = cte
W=F*d
xa xb xa xb
W
F
xa xb
F
W
xa xb
F cte
W=F(x)cos((x))dx
F
F
-
DATOS x(ft) F(x) (lb) ang (rad) F(x)*cos(ang)
0 0 0 0,0000 119,0892 TRAPEZOIDAL MULT
5 9 1,4 1,5297
10 13 0,75 9,5120 117,1271 SIMPSON 1/3 MULT
15 14 0,9 8,7025
20 10,5 1,3 2,8087
25 12 1,48 1,0881
30 5 1,5 0,3537
0,0
2,0
4,0
6,0
8,0
10,0
12,0
0 5 10 15 20 25 30 35
Clculo del trabajo que vara con la distancia
W=F(x)cos((x))dx
7 puntos equidistantes
Trapecio mltiple = 119,0892
Simpson 1/3 mltiple = 117,1271
F(x)cos(ang)
-
0,0
2,0
4,0
6,0
8,0
10,0
12,0
0 10 20 30 40 50
Clculo del trabajo que vara con la distancia
x(ft) F(x) (lb) ang (rad) F(x)*cos(ang) 104,603 Simpson 1/3 m
0 0 0 0,0000 25,049 Simpson 1/3
5 9 1,4 1,5297 129,652
10 13 0,75 9,5120
15 14 0,9 8,7025
20 10,5 1,3 2,8087
30 12 1,48 1,0881
40 5 1,5 0,3537
5
3
W=F(x)cos((x))dx
7 puntos no equidistantes
Simpson 1/3 mltiple = 104,603
Simpson 1/3 = 25,049
129,652
F(x)cos(ang)
-
Datos: xn, x1, ptos, funcin
1
2
)(n
i
ixfn
xxh n
)( 1
segmentos
function [y]=f(x) y = evstr(funcion) endfunction
funcion=input('f(x)= ','s')
h = (xn-x1)/(n-1) //paso for x = (x1+h):h:(xn-h) I = I + f(x) end //for
I = h*(f(x1) + 2*I + f(xn))/2
n
xfxfxf
xxI
n
i
ni
n2
)()(2)(
)(
1
2
1
1
-
Datos: xn, x1, v
segmentos
h = (xn-x1)/(n-1) //paso for i = 2:n-1 I = I + v(i) end //for
I = h*(v(1)+2*I + v(n))/2
n= length(v)
n
xxh n
)( 1
1
2
)(n
i
ixf
n
xfxfxf
xxI
n
i
ni
n2
)()(2)(
)(
1
2
1
1
-
Valor similar al obtenido con PlanMaker
-->deff('y=f(x)','y=(2+cos(1+x.^1.5)/sqrt(1+0.5*sin(x)))*exp(0.5*x)') -->I=intg(0.5,3.5,f) I = 19.262938
5.3
5.0
5.02
3
5.01
)1cos(2dxe
senx
x x
x f(x)
0.5 2.817
0.75 2.811
1 2.722
1.25 2.605
1.5 2.584
1.75 2.863
2 3.694
2.25 5.295
2.5 7.710
2.75 10.628
3 13.278
3.25 14.536
3.5 13.419
19.2639582