Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Integrantes:
Pa Reyes Gonzalez
Mario Guerra Murua
2704197-3
2823034-6
1.
1.1.
ELI-213 Simulaci
on en Ingeniera Electrica
Desarrollo
Parte 1
a. Considere la funci
on
1
1x
Desarrolle una expresion usando series de Taylor para aproximar para valores en torno
a x=0.
C
odigo:
1
2
3
4
5
6
7
8
9
%%
clc
% % nm
clear a l l
syms x
f =1/(1x ) ;
y=t a y l o r ( f , 10 , 0 ) ;
y
%%
La expresi
on obtenida para f(x) en torno a cero es:
x4 + x3 + x2 + x + 1
.
Usando solo terminos de primer orden de la aproximacion en torno a x=0, muestre
graficamente como se comporta la aproximacion en la medida que el valor de x se aleja
de 0.
C
odigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
%%
clc
clear a l l
syms x
f =1/(1x ) ;
y=t a y l o r ( f , 2 , 0 ) ;
hold on
e z p l o t ( y ,[ 1 1 ] )
e z p l o t ( f ,[ 1 1 ] )
xlabel ( x )
ylabel ( f ( x ) ) ;
grid on ;
title ( Serie
;
;
% pone t ? t u l o s a l e j e y
% agregamos una g r i l l a
Taylor de Primer Orden ) ;
14
15
16
17
PRG MGM
hold o f
y
% %
p
agina 2
ELI-213 Simulaci
on en Ingeniera Electrica
1
2
3
%%
clc
clear a l l
4
5
6
7
8
9
10
f o r i =1:10
syms x
f =1/(1x ) ;
y=t a y l o r ( f , i , 0 ) ;
z=e z p l o t ( f ,[ 5 , 5 ] ) ; set ( z , c o l o r , k , l i n e s t y l e , ) ;
legend ( f ( x ) )
11
12
13
14
15
16
17
18
hold on
y1=e z p l o t ( y ,[ 5 , 5 ] ) ; set ( y1 , c o l o r , m )
legend ( TAYLOR f ( x ) )
xlabel ( x )
ylabel ( f ( x ) ) ;
% pone t ? t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
title ( ) ;
19
20
21
end
22
23
PRG MGM
p
agina 3
ELI-213 Simulaci
on en Ingeniera Electrica
%%
clc
clear a l l
4
5
6
7
8
9
10
11
f o r i =1:10
syms x
f c o s=cos ( x ) ;
y c o s=t a y l o r ( f c o s , i , 0 ) ;
e r r o r c o s=abs ( f c o s y c o s ) ;
e r e l c o s=abs ( f c o s y c o s ) / f c o s 1 0 0 ;
12
13
14
15
16
f s e n=sin ( x ) ;
ysen=t a y l o r ( f s e n , i , 0 ) ;
e r r o r s e n=abs ( f s e n ysen ) ;
e r e l s e n=abs ( f s e n ysen ) / f s e n 1 0 0 ;
17
18
19
20
21
f e x=exp ( x ) ;
yex=t a y l o r ( f e x , i , 0 ) ;
e r r o r e x=abs ( f e x yex ) ;
e r e l e x=abs ( f e x yex ) / f e x 1 0 0 ;
22
23
24
25
26
27
28
hold on
subplot ( 3 , 2 , 1 ) , e z p l o t ( e r r o r c o s ,[ 5 5 ] )
xlabel ( x )
ylabel ( ERROR ABSOLUTO ) ;
% pone t ? t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
PRG MGM
p
agina 4
29
30
31
32
33
34
35
ELI-213 Simulaci
on en Ingeniera Electrica
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
hold on
subplot ( 3 , 2 , 3 ) , e z p l o t ( e r r o r s e n ,[ 5 5 ] )
xlabel ( x )
ylabel ( ERROR ABSOLUTO ) ;
% pone t ? t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
t i t l e ( ERROR ABSOLUTO FUNCION SIN (X) ) ;
hold on
subplot ( 3 , 2 , 4 ) , e z p l o t ( e r e l s e n ,[ 5 5 ] )
xlabel ( x )
ylabel ( ERROR RELATIVO ) ;
% pone t ? t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
t i t l e ( ERROR RELATIVO FUNCION SIN (X) ) ;
51
52
hold on
subplot ( 3 , 2 , 5 ) , e z p l o t ( e r r o r e x ,[ 5 5 ] )
55 xlabel ( x )
56 ylabel ( ERROR ABSOLUTO ) ;
% pone t ? t u l o s a l e j e y
57
grid on ;
% agregamos una g r i l l a
58
t i t l e ( ERROR ABSOLUTO FUNCION EXP(X) ) ;
59 hold on
60 subplot ( 3 , 2 , 6 ) , e z p l o t ( e r e l e x ,[ 5 5 ] )
61 xlabel ( x )
62 ylabel ( ERROR RELATIVO ) ;
% pone t ? t u l o s a l e j e y
63
grid on ;
% agregamos una g r i l l a
64
t i t l e ( ERROR RELATIVO FUNCION EXP(X) ) ;
65 end
66%%
53
54
PRG MGM
p
agina 5
ELI-213 Simulaci
on en Ingeniera Electrica
1
2
3
4
5
%%
clc
clear a l l
f =[];
i i =[];
6
7
8
9
10
11
12
13
14
15
16
17
18
f o r i=logspace ( 1 2 , 0 , 1 3 )
f x=exp ( 1 ) ;
d i =(exp(1+ i )exp ( 1 ) ) / i ;
error=abs ( ( fxd i ) / f x ) 1 0 0 ;
f =[ f error ] ;
i i =[ i i i ] ;
end
loglog ( i i , f )
xlabel ( LOG( x ) )
ylabel ( ERROR RELATIVO ) ;
% pone t i t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
t i t l e ( ERROR RELATIVO FUNCION DIFF EXP(X) ) ;
19
20
%%
PRG MGM
p
agina 6
ELI-213 Simulaci
on en Ingeniera Electrica
1.2.
Parte 2
a. Muestre gr
aficamente que tan bien se puede aproximar la funcion sen(x) por un polinomio de
Taylor de grado 1.
C
odigo:
1
2
3
4
5
6
%%
% a)
clear a l l
clc
format l o n g
syms x
7
8
9
10
11
12
f x=sin ( x ) ;
f y=t a y l o r ( fx , 2 , 0 ) ;
hold on
t 1=e z p l o t ( fx ,[ 2 pi /3 2 pi / 3 ] ) ; set ( t1 , c o l o r , k ) ;
t 2=e z p l o t ( fy ,[ 2 pi /3 2 pi / 3 ] ) ; set ( t2 , c o l o r , m ) ;
13
14
15
16
17
18
19
legend ( f ( x ) , TAYLOR f ( x ) )
xlabel ( x )
ylabel ( f ( x ) ) ;
% pone t ? t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
t i t l e ( APROXIMACION FUNCION SIN (X) POR POLINOMIO DE TAYLOR ) ;
hold o f f
PRG MGM
p
agina 7
ELI-213 Simulaci
on en Ingeniera Electrica
1
2
3
4
5
6
7
8
9
10
11
% b)
clc
clear a l l
format l o n g
v2 =1; v1 = 1 . 0 5 ; d e l=pi / 9 0 ; b = 9 . 9 ; g = 0 . 9 9 ;
p=(v1 v2 ( g cos ( d e l )+b sin ( d e l ) )g v2 2 ) 1 0 0 ;
p 1 =(v1 v2 ( 0 cos ( d e l )+b sin ( d e l ) ) 0v2 2 ) 1 0 0 ;
p 2 =(( g cos ( d e l )+b sin ( d e l ) )g sin ( d e l ) ) 1 0 0 ;
p 3 =(v1 v2 ( g cos ( 0 )+b d e l )g v2 2 d e l ) 1 0 0 ;
p 4 =(b d e l ) 1 0 0 ;
12
13
14
15
16
17
18
19
20
21
22
error absoluto
error relativo
aprox 1
4.88
11.87 %
aprox 2
88.87
2.1 %
aprox 3
95.61
2.3 %
todas
6.6
16 %
c. Eval
ue la sensibilidad del error relativo a cada una de las aproximaciones (grafique el error para
un rango de valores). Para que rangos de valores recomendara usar las aproximaciones?
PRG MGM
p
agina 8
ELI-213 Simulaci
on en Ingeniera Electrica
C
odigo:
1
2
% c)
3
4
5
6
7
8
9
10
11
12
13
14
clc
clear a l l
format l o n g
v2 =1; v1 = 1 . 0 5 ;
x= 2 : 0 . 0 0 1 : 2 ;
b=9.9; g =0.99;
p=(v1 v2 ( g cos ( x )+b sin ( x ) )g v2 2 ) 1 0 0 ;
p 1 =(v1 v2 ( 0 cos ( x )+b sin ( x ) ) 0v2 2 ) 1 0 0 ;
p 2 =(( g cos ( x )+b sin ( x ) )g sin ( x ) ) 1 0 0 ;
p 3 =(v1 v2 ( g cos ( 0 )+bx )g v2 2 x ) 1 0 0 ;
p 4 =(bx ) 1 0 0 ;
15
16
17
18
19
subplot ( 2 , 1 , 1 ) ;
20
21
22
23
24
25
26
plot ( x , e r a b s 1 , r , x , e r a b s 2 , b , x , e r a b s 3 , k , x , e r a b s 4 , y ) ;
legend ( Aproximacion i , Aproximacion i i , Aproximacion i i i , Aproximacion i ,
ii y iii );
xlabel ( x )
ylabel ( ERROR ABSOLUTO ) ;
% pone t ? t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
t i t l e ( ERROR ABSOLUTO FUNCION POTENCIA BARRA 2 ) ;
27
28
29
30
31
32
33
34
subplot ( 2 , 1 , 2 ) ;
plot ( x , e r r e l 1 , r , x , e r r e l 2 , b , x , e r r e l 3 , k , x , e r r e l 4 , y ) ;
legend ( Aproximacion i , Aproximacion i i , Aproximacion i i i , Aproximacion i ,
ii y iii );
xlabel ( x )
ylabel ( ERROR RELATIVO ) ;
% pone t ? t u l o s a l e j e y
grid on ;
% agregamos una g r i l l a
t i t l e ( ERROR RELATIVO FUNCION POTENCIA BARRA 2 ) ;
PRG MGM
p
agina 9
ELI-213 Simulaci
on en Ingeniera Electrica
1
2
3
% %
clc
clear a l l
4
5
6
a=r u n o p f ( c a s e 5 7 ) ;
b=r u n d c o p f ( c a s e 5 7 ) ;
7
8
9
pac=a . branch ( : , 1 4 ) ;
pdc=b . branch ( : , 1 4 ) ;
10
11
12
angac=a . bus ( : , 9 ) ;
angdc=a . bus ( : , 9 ) ;
13
14
15
16
17
18
19
20
21
22
PRG MGM
p
agina 10
23
24
ELI-213 Simulaci
on en Ingeniera Electrica
grid on ;
% agregamos una g r i l l a
t i t l e ( COMPARACION DE ANGULOS PARA 57 BARRAS ) ;
PRG MGM
p
agina 11