Академический Документы
Профессиональный Документы
Культура Документы
LABORATORIO 1
Edwin Callejas Pinto
3 de diciembre de 2015
INFORME
LABORATORIO 1
1.
de matrices en funcion
de la
Implementar los seis algoritmos de multiplicacion
n de una matriz cuadrada que debe generar aleatoriamente y calcular
dimension
de cada uno de los mismos con tic y toc y presentar un
los tiempos de ejecucion
grafico comparativo de los tiempos estimados para n = 100; 200; 300; 400; 500; 600.
matxmat.m es:
el programa de la funcion
%Sintaxis: [tp_ejec]=matxmat(n,op)
%Calcula el tiempo de ejecuci
on de los agoritmos de multiplicaci
on de
%matrices op=1: ijk, op=2: jik, op=3: ikj, op=4: jki, op=5: kij, op=6: kji
%op>=7: Comando MATLAB, n=dimensi
on de la matriz cuadrada.
%Maestria en Modelaje Matem
atico 1ra version 2015-2016 Carrera Matem
atica
%Autor: Dr. Porfirio Su~
nagua S. M
odulo: An
alisis Num
erico
function [tp_ejec]=matxmat(n,op)
if nargin<1
Lab 1
Lab 1
end
end
end
case 6 %version outer product columna kji
for k = 1:n
for j=1:n
bkj=B(k,j);
for i = 1:n
C(i,j)=C(i,j)+A(i,k)*bkj;
end
end
end
otherwise
C=A*B;
end %switch
tp_ejec=toc;
if nargin<1
disp(C);
end
0.025
0.025
ijk
jik
ikj
jki
kij
kji
cmd MATLAB
0.02
0.015
0.02
0.015
0.01
0.01
0.005
0.005
0
10
15
20
25
ijk
jik
ikj
jki
kij
kji
cmd MATLAB
30
35
40
45
50
55
0
10
60
15
20
25
30
35
40
45
50
55
60
Lab 1
0.0651
0.5198
2.0277
4.9600
9.8255
18.4805
0.0921
0.7489
2.9488
7.5394
17.0247
29.8210
0.0941
0.7323
2.4572
5.8426
11.3513
19.6858
0.0925
0.7483
2.9166
7.5418
16.7801
29.8428
0.0979
0.7435
2.4883
5.8981
11.4755
19.8160
0.0022
0.0088
0.0219
0.0668
0.1104
0.1864
25
20
15
10
0
100
2.
150
200
250
300
350
400
450
500
550
600
Para cada matriz dada u otra generada, calcular los autovalores y autovectores
y comprobar si genera suficientes autovectores para autovalores repetidos.
Solucion.A=rand(10);
[V1,D1]=eig(A)
B=pascal(10);
[V2,D2]=eig(A)
C=diag([1 2 3 3 3 5 10 -1 2]);
[V3,D3]=eig(A)
Lo que proporciona el resultado
A =
0.5822
0.5407
0.8699
0.5447
0.6473
0.5439
0.4046
0.4484
0.3658
0.6963
0.0938
0.5254
0.3477
0.1500
0.5861
0.7363
0.3947
0.6834
0.8217
0.4299
0.8878
0.7904
0.9493
0.3276
0.5144
0.8843
0.5880
0.5341
0.0900
0.1117
Lab 1
0.2648
0.3181
0.1192
0.9398
0.6456
0.4795
0.6393
0.7210
0.5225
0.9937
0.2187
0.1058
0.1097
0.0636
0.7635
0.6279
0.7720
0.9329
0.9727
0.1920
0.1389
0.5303
0.8611
0.4849
0.3935
0.6714
0.7413
0.5201
0.2621
0.0445
0.7549
0.2428
0.4424
0.6878
0.3592
0.7040
0.4423
0.0196
0.3309
0.4243
0.2703
0.1971
0.3912
0.7691
0.3968
0.8085
0.7551
0.3774
0.2160
0.6713
0.4386
0.8335
0.7689
0.1673
0.8620
0.9899
0.1548
0.1999
0.4070
0.7487
0.8256
0.7900
0.3185
0.1363
0.6787
0.4952
0.1897
0.4950
0.1476
0.0550
V1 =
Columns 1 through 6
-0.3700
-0.2933
-0.3484
-0.2891
-0.2993
-0.3195
-0.3603
-0.3422
-0.2885
-0.2240
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0610
0.5336
0.0046
-0.2199
-0.1471
0.0844
0.1001
-0.1448
-0.1012
-0.1239
+
+
+
+
+
0.0218i
0.0000i
0.2371i
0.4114i
0.1420i
0.1610i
0.1113i
0.1731i
0.4311i
0.2787i
0.0610
0.5336
0.0046
-0.2199
-0.1471
0.0844
0.1001
-0.1448
-0.1012
-0.1239
+
+
+
+
+
+
-
0.0218i
0.0000i
0.2371i
0.4114i
0.1420i
0.1610i
0.1113i
0.1731i
0.4311i
0.2787i
-0.1860
0.0617
0.0426
0.0635
-0.5054
0.2216
0.0693
-0.4467
0.3540
0.5671
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
+
+
+
+
+
+
0.1639i
0.1305i
0.1289i
0.2249i
0.2722i
0.0000i
0.0671i
0.0849i
0.0504i
0.0745i
-0.0279
0.3559
-0.1269
0.3642
-0.1039
0.2203
-0.7036
-0.1588
0.3793
-0.0163
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.4355
0.1326
-0.1343
-0.0481
0.0317
0.1845
-0.6515
-0.0734
-0.0104
0.5544
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000
0.3300
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
+
+
+
+
+
+
+
+
+
+
0.0000i
0.7064i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000
0.0000
0.3300
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.7064i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000
0.0000
0.0000
-0.8767
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
-0.3482
0.0000
0.0000
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.2559i
0.0000i
0.0000i
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.4063
0.0000
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.1888
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0978
-0.2559
0.5035
-0.1307
-0.0536
-0.0074
-0.3067
0.0623
0.0734
-0.1215
+
+
+
+
+
+
+
0.3509i
0.0554i
0.0000i
0.0050i
0.3823i
0.1152i
0.2849i
0.4069i
0.0255i
0.0151i
0.0978
-0.2559
0.5035
-0.1307
-0.0536
-0.0074
-0.3067
0.0623
0.0734
-0.1215
+
+
+
+
-
0.3509i
0.0554i
0.0000i
0.0050i
0.3823i
0.1152i
0.2849i
0.4069i
0.0255i
0.0151i
0.0000
0.0000
0.0000
0.0000
-0.3918
0.0000
0.0000
0.0000
0.0000
0.0000
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.5283i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000
0.0000
0.0000
0.0000
0.0000
-0.3918
0.0000
0.0000
0.0000
0.0000
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.5283i
0.0000i
0.0000i
0.0000i
0.0000i
Columns 7 through 10
0.3802
0.2714
0.0550
0.3116
-0.0124
-0.6274
-0.1350
-0.2536
-0.0175
0.0073
+
+
+
+
+
-
0.1639i
0.1305i
0.1289i
0.2249i
0.2722i
0.0000i
0.0671i
0.0849i
0.0504i
0.0745i
0.3802
0.2714
0.0550
0.3116
-0.0124
-0.6274
-0.1350
-0.2536
-0.0175
0.0073
D1 =
Columns 1 through 6
5.1121
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
Columns 7 through 10
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
-0.3482
0.0000
0.0000
0.0000
+
+
+
+
+
+
+
+
+
+
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.0000i
0.2559i
0.0000i
0.0000i
0.0000i
B =
Lab 1
1
1
1
1
1
1
1
1
1
1
1
2
3
4
5
6
7
8
9
10
1
3
6
10
15
21
28
36
45
55
1
4
10
20
35
56
84
120
165
220
1
5
15
35
70
126
210
330
495
715
1
6
21
56
126
252
462
792
1287
2002
1
7
28
84
210
462
924
1716
3003
5005
1
8
36
120
330
792
1716
3432
6435
11440
1
9
45
165
495
1287
3003
6435
12870
24310
1
10
55
220
715
2002
5005
11440
24310
48620
V2 =
0.0066
-0.0538
0.1965
-0.4223
0.5870
-0.5469
0.3413
-0.1375
0.0324
-0.0034
0.0385
-0.2125
0.4820
-0.5188
0.1232
0.3562
-0.4742
0.2790
-0.0840
0.0105
0.1458
-0.4778
0.5010
0.0488
-0.4232
0.0787
0.3806
-0.3795
0.1495
-0.0224
-0.4003
0.5734
0.0607
-0.3974
-0.1335
0.3297
0.1503
-0.3941
0.2089
-0.0372
0.7240
-0.0252
-0.3851
-0.2144
0.1792
0.2936
-0.0514
-0.3223
0.2321
-0.0483
0.5261
0.5444
0.2829
-0.1026
-0.3262
-0.1851
0.1897
0.2790
-0.2783
0.0664
-0.1259
-0.3063
-0.4676
-0.4848
-0.2748
0.0996
0.3736
0.1951
-0.3996
0.1182
0.0149
0.0639
0.1641
0.3106
0.4551
0.4978
0.3185
-0.1148
-0.5050
0.2184
-0.0010
-0.0062
-0.0234
-0.0654
-0.1482
-0.2817
-0.4500
-0.5710
-0.4305
0.4242
0.0000
0.0002
0.0012
0.0046
0.0145
0.0392
0.0951
0.2121
0.4411
0.8658
0
0.0000
0
0
0
0
0
0
0
0
0
0
0.0000
0
0
0
0
0
0
0
0
0
0
0.0000
0
0
0
0
0
0
0
0
0
0
0.0001
0
0
0
0
0
0
0
0
0
0
0.0002
0
0
0
0
0
0
0
0
0
0
0.0010
0
0
0
0
0
0
0
0
0
0
0.0095
0
0
0
0
0
0
0
0
0
0
0.1628
0
0
0
0
0
0
0
0
0
0
6.4461
D2 =
1.0e+04 *
0.0000
0
0
0
0
0
0
0
0
0
C =
1
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
5
0
0
0
0
0
0
0
0
0
10
0
0
0
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
V3 =
D3 =
Lab 1
-1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
5
0
0
0
0
0
0
0
0
0
10
De los resultados se puede observar que a pesar de que en ciertos casos, tales
como el ultimo
que el autovalor = 2 tiene multiplidad 2 y el autovalor = 3
de la
tiene multiplicidad 3, la cantidad de autovectores corresponde al tamano
matriz, es decir los autovectores son linealmente independientes.
3.
+
+
+
+
+
+
+
0.0000i
0.0000i
0.2932i
0.2932i
0.6297i
0.6297i
0.3706i
0.3706i
0.0000i
0.0000i
5.2145
-1.1326
0.7957
0.7957
-0.1098
-0.1098
0.1692
0.1692
-0.1618
-0.4251
+
+
+
+
+
+
+
0.0000i
0.0000i
0.2932i
0.2932i
0.6297i
0.6297i
0.3706i
0.3706i
0.0000i
0.0000i
genera dos columnas en las que se puede observar los autovalores de la matriz A
y de su transpuesta, comparando ambos se observa que son los mismos.
Lab 1
4.
Verificar que los autovectores correspondientes a autovalores distintos son linealmente independientes.
0
1
1
0
1
1
V =
[ 0, 1, -1]
[ -1, 1, 0]
[ 1, 0, 1]
D =
[ 0, 0, 0]
[ 0, 2, 0]
[ 0, 0, 2]
la independencia lineal se verifica mediante:
a V1 + b V2 + c V3 = 0
0
1
1
a 1 + b 1 + c 0 = 0
1
0
1
Genere una matriz simetrica que tenga autovalores repetidos y verifique la matriz
tiene n autovectores linealmente independientes.
Se han realizado pruebas y general las matrices con vectores columna o
Solucion.fila ordenados mayores a 3, son simetricas y tienen autovalores repetidos, ademas
generan autovectores linealmente independientes, por ejemplo:
A=[0:4;1:5;2:6;3:7;4:8]
[V,D]=eig((A))
>>
Lab 1
A =
0
1
2
3
4
1
2
3
4
5
2
3
4
5
6
3
4
5
6
7
4
5
6
7
8
V =
0.7382
0.4368
0.1355
-0.1659
-0.4673
0.5759
-0.7950
0.0465
-0.0116
0.1842
0.2539
0.2477
-0.7926
-0.1736
0.4646
0.0620
-0.0809
-0.4118
0.8184
-0.3876
0.2346
0.3304
0.4262
0.5220
0.6178
D =
-2.2474
0
0
0
0
0
0.0000
0
0
0
0
0
0.0000
0
0
0
0
0
0.0000
0
0
0
0
0
22.2474
2
3
4
5
6
7
3
4
5
6
7
8
4
5
6
7
8
9
5
6
7
8
9
10
9
6
7
8
9
10
11
7
8
9
10
11
12
Lab 1
10
11
12
13
V =
6.
0.6450
0.4623
0.2797
0.0970
-0.0856
-0.2683
-0.4509
0.3788
0.1948
-0.8199
-0.1734
0.1164
0.3201
-0.0168
0.5330
-0.8025
-0.0019
0.2679
0.0127
-0.0069
-0.0023
-0.2029
0.1459
-0.3325
0.8486
-0.2968
-0.1341
-0.0281
-0.1444
-0.0343
-0.1495
0.1307
0.8399
-0.4366
-0.2059
0.2148
0.0997
-0.1278
-0.1345
-0.1189
-0.6349
0.7016
0.2198
0.2683
0.3168
0.3653
0.4138
0.4623
0.5108
D =
-3.7179
0
0
0
0
0
0
0
-0.0000
0
0
0
0
0
0
0
-0.0000
0
0
0
0
0
0
0
0.0000
0
0
0
0
0
0
0
0.0000
0
0
0
0
0
0
0
0.0000
0
0
0
0
0
0
0
52.7179
4.2284
5.4787
9.4274
4.1774
9.8305
3.0145
7.0110
6.6634
5.3913
6.9811
6.6653
1.7813
1.2801
9.9908
1.7112
0.3260
5.6120
8.8187
6.6918
1.9043
B =
-41.4827
-35.7251
-37.8470
-42.7950
-31.3732
10
Lab 1
-66.4118
4.4905
90.0798
45.4264
-40.2534
0.1533
66.2238
34.3489
-50.9012
-3.2697
78.2393
35.1604
-62.9559
0.4686
87.2882
42.6034
-25.8552
2.7521
57.9315
31.2711
VA =
-0.4029
-0.4521
-0.4174
-0.5646
-0.3745
-0.2771
0.4736
0.1749
0.2776
-0.7689
-0.0600
-0.4237
0.8259
0.0177
-0.3668
-0.6511
-0.2540
0.6406
0.2578
0.1862
-0.6670
-0.0694
0.6644
-0.1731
0.2809
DA =
27.0268
0
0
0
0
0
-5.3857
0
0
0
0
0
-2.1007
0
0
0
0
0
5.4679
0
0
0
0
0
8.5452
VB =
-0.3869
-0.4296
-0.0165
0.7380
0.3475
0.1816
0.7019
0.0063
-0.6604
-0.1957
0.3635
0.5219
0.0806
-0.7282
-0.2423
-0.2997
-0.5350
-0.2215
0.6935
0.3066
-0.3032
-0.7057
0.0628
0.4950
0.4014
DB =
27.0268
0
0
0
0
0
8.5452
0
0
0
0
0
5.4679
0
0
0
0
0
-2.1007
0
0
0
0
0
-5.3857
se puede observar los autovalores generados son los mismos, aunque vienen desordenados uno respecto del otro. Otras propiedades que cumplen las matrices
simetricas son:
Poseen el mismo rango.
Tienen el mismo determinante.
Tienen la misma traza.
Tienen los mismos valores propios (aunque los vectores propios, en general,
seran distintos).
Tienen el mismo polinomio caracterstico.
Tienen el mismo polinomio mnimo.
7.
11
Lab 1
Solucion.Transcribiendo el programa:
%---------------Pregunta7
function circulogersh(A)
n=size(A);
if n(1) ~= n(2)
error(Solo matrices cuadradas);
else
n=n(1);
circler=zeros(n,201);
circlec=circler;
end
center=diag(A);
radiic=sum(abs(A-diag(center)));
radiir=sum(abs(A-diag(center)));
one=ones(1,201);
cosisin=exp(1i*(0:pi/100:2*pi));
figure(1);
title(Circulos por Filas);
xlabel(Re); ylabel(Im); figure(2);
title(Circulos por Columnas);
xlabel(Re); ylabel(Im);
for k=1:n
circlec(k,:)=center(k)*one + radiic(k)*cosisin;
circler(k,:)=center(k)*one + radiir(k)*cosisin;
figure(1);
patch(real(circler(k,:)),imag(circler(k,:)),cyan);
hold on;
plot(real(circler(k,:)),imag(circler(k,:)),k-,...
real(circler(k,:)),imag(circler(k,:)),kx);
figure(2);
patch(real(circlec(k,:)),imag(circlec(k,:)),green);
hold on;
plot(real(circlec(k,:)),imag(circlec(k,:)),k-,...
real(circlec(k,:)),imag(circlec(k,:)),kx);
end
for k=1:n
figure(1);
plot(real(circler(k,:)),imag(circler(k,:)),k-,...
real(circler(k,:)),imag(circler(k,:)),kx);
figure(2);
plot(real(circlec(k,:)),imag(circlec(k,:)),k-,...
real(circlec(k,:)),imag(circlec(k,:)),kx);
end
figure(1); axis image; hold off;
12
Lab 1
10
10
Im
Im
5
0
5
10
10
10
15
Re
20
25
30
10
35
10
15
Re
20
25
30
35
10
10
Im
Im
10
10
5
10
15
Re
10
15
Re
13