Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
like power, voltage, angle, status etc. let us name the matrix as x
x=[
1 2 0.01938 0.05917 0.0528 9900 1 1 1 0 1;
1 5 0.05403 0.22304 0.0492 9900 1 1 1 0 1;
2 3 0.04699 0.19797 0.0438 9900 1 1 1 0 1;
2 4 0.05811 0.17632 0.034 9900 1 1 1 0 1;
2 5 0.05695 0.17388 0.0346 9900 1 1 1 0 1;
3 4 0.06701 0.17103 0.0128 9900 1 1 1 0 1;
4 5 0.01335 0.04211 0 9900 0 1 1 1 1;
4 7 0 0.20912 0 9900 0 0 0.978 0 1;
4 9 0 0.55618 0 9900 0 0 0.969 0 1;
5 6 0 0.25202 0 9900 0 0 0.932 0 1;
6 11 0.09498 0.1989 0 9900 0 1 1 0 1;
6 12 0.12291 0.25581 0 9900 0 1 1 0 1;
6 13 0.06615 0.13027 0 9900 0 1 1 0 1;
7 8 0 0.17615 0 9900 0 0 1 1 1;
7 9 0 0.11001 0 9900 0 0 1 1 1;
9 10 0.03181 0.0845 0 9900 0 1 1 0 1;
9 14 0.12711 0.27038 0 9900 0 0 1 0 1;
10 11 0.08205 0.19207 0 9900 0 0 1 0 1;
12 13 0.22092 0.19988 0 9900 0 0 1 0 1;
13 14 0.17093 0.34802 0 9900 0 0 1 0 1;
];
LU Factorization
The lu function expresses a matrix A as the product of two essentially triangular matrices, one of them a permutation
of a lower triangular matrix and the other an upper triangular matrix. The factorization is often called the LU, or
sometimes the LR, factorization.
[L,U,P] = lu(X) returns an upper triangular matrix in U, a lower triangular matrix L with a unit diagonal,
and a permutation matrix P, such that L*U = P*X. The statement lu(X,'matrix') returns identical
output values.
L=
1.0000
0.4615
1.0000
0.5385
0.0706
1.0000
0.3077
0.7176
0.4767
1.0000
0.0769
0.1412 -0.0881
0.0755
1.0000
0.2308
0.1176 -0.3189
0.1923
0.2424
1.0000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.3077
0.1059
0.4158 -0.1220
0.6923
0.0471
0.9428 -0.3081
0 -0.1396 -0.1800
0.3846
0.0941
0.7082
0.2682
0.3893
0.5020 -0.2941
1.0000
0.3077
0.4118
0.5195
0.2510
0.3689
0.4757 -0.6282
0.3100
1.0000
0.1538
0.4353 -0.3972
0.2734
0.6553
0.4615
0.8471 -0.6014
0.2429
0.0769
0.6000 -0.5324
0.4411
0.1538
0.1294 -0.2451
0.3075
0.8295
0.5385
0.2235
0.1538
0.2824 -0.3885
0.2690
0.6439
0.6923
0.6588 -0.1884
0.1004
0.7692
0.0353
0.9231
0.4615
0.9786 -0.1298
0.7755
1.0000
1.0000
0.1992 -0.0333
1.0000
0.0554 -0.8985
0.0981
0.0045
0.5067
0.0586
0.4211
0.3120
0.0918
0.6529
0.9691
0.6452
0.8319 -0.9822
0.2502
0.6111 -0.3957
0.6941 -0.2736
0.1196
0.4407
0.1832 -0.4067
0.0140
0.0003
9.9000
0.5375 -0.1466
0.0366
U=
1.0e+03 *
0.0130
0.0002
0 -0.0001 -0.0000
0.0005
0
0
5.3308
4.1929
0.0010
0.0010
0.0010
0.0005
0.0005
0.0010
0.0004
0 -0.0001
1.0293
0.0001
8.6776
0 -0.0006
0 -0.0001 -0.0011
0 -0.0009 -0.0000
6.0237
0 -0.0007
0.0004
0.0010
0.0008
0.0009
0.0008
0.0001 -0.0005
0.0009
0.0006
0.0002 -0.0000
0.0001
0.0001
0.0004
0.0002
0.0006
0.0000
0.0000
0.0000
0.0000
0.0009
P=
Columns 1 through 18
Columns 19 through 20
Columns 1 through 11
0.0226
0.2111
0.0050 -0.0820
0.0074 -0.1887
0.1625 -0.0862
0.0391
0.2505 -0.0672
-0.1351
0.0095
0.0245
0.1392
0.0754 -0.1149
0.0667
-0.1351 -0.1556
-0.0082
0.2387 -0.0707
0.5819
-0.1351 -0.3358
0.0678
0.2740 -0.6338
0.3005
0.0465
-0.1688
-0.0282
0.2500 -0.2666
0.0532
0.1530 -0.0344
0.1499 -0.1778
0.8002 -0.2094
0.1440
0.2195 -0.0410
0.0941
-0.2026 -0.4586
0.0344
0.0835
0.4330
0.0263
0.0245
-0.2364
-0.0061
0.1105
-0.2364
0.0034
0.0204
0.3605
0.1641 -0.1435
0.0325
-0.3039
0.0600
0.1678
0.2826
0.2077 -0.1836
0.0886
0.1697
0.0967
0.1180
0.2002
0.0148
-0.3377
0.2408
0.0134 -0.0586
0.1097
0.3817 -
0.1965
0.0870
0.0972
0.1633
0.5616
0.0920
0.2251 -0.0465
0.1762
0.2518 -
-0.4052
-0.1106
0.2538 -0.4890
0.0390
-0.4390
0.3194
0.2919
0.0546
0.0261 -0.0116
Columns 12 through 20
0.1383
-0.2475 -0.3358
0.2065
0.0918
0.3216 -0.0864
0.3908
0.2528
0.2566
-0.1790
0.1572
0.0196
0.0847
0.1754
0.3406
0.3264
0.5386 -0.2732
0.3196 -0.1283
0.2837
0.0238
0.0395 -0.1898
0.2252
0.3138
0.1619 -0.1322
-0.1392
0.0674
0.2397
0.0213
0.1894
0.0872
0.0395
0.4350
-0.0932
0.0973
0.0533
0.3291
0.0143 -0.0748
0.0793
0.0014 -0.0821
-0.4142 -0.4090
0.0824
0.6985 -0.1843
0.0868
0.0741
0.1041 -0.1289
-0.1965
0.0403 -0.1236
0.0260 -0.2339
0.5821
0.0758 -0.0305
0.0440
0.2503 -0.2568
0.0658
0.0230 -0.1211
0.4801
0.0513 -0.1773
0.0283
0.3230
0.1464 -0.1872
0.1588
0.0049
-0.1305
0.0642
0.1800 -0.0473
R=
0.2641 -0.0853
0.4194 -0.2746
0.5108
1.0e+04 *
-0.0030 -0.0039 -0.0000 -0.0001 -0.0000 -3.7776 -0.0000 -0.0001 -0.0004 -0.0001
-0.0004
0 -0.0011 -0.0000 -0.0000 -0.0000 -1.4314 -0.0001 -0.0002 -0.0001
0.0001
0
0.0000
0 -0.0000
0.0000 -0.0000
0.0000
0.0000 -0.0001
0.0000 -
0.0001
0.0001
0 -0.0000 -0.0001
0 -0.0001
0.0000
0.0000
0.0001
0.0000 -0.0001
0.0000
0.0000
0.0000
QR decomposition returns an upper triangular matrix R and a unitary matrix Q, such that x = Q*R.
0.0000
0.0003
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000 -0.0000
0.0000
0.0000 -0.0000
0.0000 -0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0728
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0364
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0364
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0546
0.0000 -0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0364
0.0000
0.0000
0.0000 -0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0728
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000 -0.0000
0.0546 -0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000 -0.0000
0.0364 -0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000 -0.0000
0.0546 -0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000
0.0000
0.0728
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000
0.0000
0.0728
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000
0.0000
0.0909
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000
0.0000
0.1091
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000
0.0000
0.1091
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0001
0.0000
0.0000
0.0000
0.1273
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.3092
0.0000
0.0000
0.0182 -0.0000
0
0.0000
0 -0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0 -0.0000 -0.0000
0.0728
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
So it is proved x=Q*R
SVD factorization
s = svd(x) returns the of matrix x in descending order.
s=
1.0e+04 *
4.4274
0.0022
0.0006
0.0002
0.0002
0.0001
0.0000
0.0000
0.0000
0.0000
0.0000
[U,S,V] = svd(x) performs a singular value decomposition of matrix x, such that x = U*S*V
U=
Columns 1 through 11
-0.2236
0.0695
0.2847
0.0122
0.3025
0.3160
0.5574
-0.2236
0.2517
0.0036
0.0441
0.3652
0.0663
0.2105 -0.0965
0.0336
-0.2236
0.0069
-0.2236
-0.2236
0.2217
0.0625 -0.2320
-0.2236
-0.2236
0.1584 -0.1577
0.1818 -0.6093
0.1901 -0.1488
0.3428
0.0707 -0.0241
-0.2236
0.0891
0.0541
0.3296
0.2659
0.3040
0.0884
-0.2236
0.0222
0.2721
0.3581
0.3041
-0.2236
0.0924 -0.1734
0.2585
0.2599
0.4288
0.0911 -0.1616
0.1844
0.1560 -0.5358
0.3425
0.0609
0.1616 -0.0501
0.0486 -0.6782
0.2154 -0.0517
0.1444
0.0788 -0.0473
-0.2236 -0.1357
0.1165 -0.1654
0.2689
0.0051
-0.2236 -0.1690
0.0254
0.0095
0.0678
0.2983 -0.0282
-0.2236 -0.1023
0.2839
0.0434
0.0057 -0.0274
0.0316
0.0344
0.0294 -0.0034
0.0076 -0.5378
0.0568
0.0350 -0.0600
0.1862 -0.2491
0.2064
0.0002 -0.0386
0.1686
0.1770 -0.1669
0.1385 -0.0800
0.2167
0.0725
0.3967
0.0703
0.1094
0.0343
0.5656 -0.0066
Columns 12 through 20
0.1383
0.2528
-0.2475 -0.3358
0.2065
0.0918
0.3216 -0.0864
-0.1790
0.1572
0.0196
0.0847
0.1754
0.3406
0.3264
0.5386 -0.2732
0.3196 -0.1283
0.2837
0.0238
0.0395 -0.1898
0.2252
0.3138
0.2566
0.1619 -0.1322
-0.1392
0.0674
0.2397
0.0213
0.1894
0.0872
0.0395
0.4350
-0.0932
0.0973
0.0533
0.3291
0.0440
0.2503 -0.2568
0.0143 -0.0748
0.0793
0.0014 -0.0821
-0.4142 -0.4090
0.0824
0.0104
0.0477 -0.1106
0.1642
0.3194
0.6985 -0.1843
0.0868
0.0741
0.1041 -0.1289
-0.1965
0.0403 -0.1236
0.0260 -0.2339
0.5821
0.0758 -0.0305
0.0230 -0.1211
0.4801
0.0513 -0.1773
0.0283
0.3230
0.1464 -0.1872
0.1588
0.0049
-0.1305
0.0642
0.1800 -0.0473
0.2641 -0.0853
0.4194 -0.2746
0.5108
S=
1.0e+04 *
4.4274
0.0022
0.0006
0.0002
0.0002
0.0001
0.0000
0.0000
0.0000
0.0000
0.0000
V=
0.0000
0.0013
0.0000
-0.0008 -0.7400
0.6663
-0.0000 -0.0076
0.0004 -0.0715
-0.0000 -0.0056
0.0226
0.0309
0.0047
0.3923
0.9190 -0.0000
0.0000 -0.0001
0.0000 -0.0001
0.0593
0.0014
-0.0000
0.0102 -0.0298
0.0180 -0.0003
-1.0000
0.0010 -0.0001
0.0001
0.0000
-0.0000
-0.0001
0.0535
-0.0001 -0.0004
0.0001
0.0001
0.2582 -0.8266
0.0221
0.0017
0.0000
0.0000
0.0084 -0.0000
-0.0000
0.0025 -0.0756
0.0169 -0.0232
0.0124
0.0000
-0.0001
0.0000 -0.0000
0.0000
0.0000 -0.0000
0.0000
1.0000
0.0000
0.0000
0.0000
X=u*s*v
x = cgs(A,b) attempts to solve the system of linear equations A*x = b for x. The n-by-n coefficient
matrix A must be square and should be large and sparse. The column vector b must have length n. You
can specify A as a function handle, afun, such that afun(x) returns A*x.
In this A is our 13x13 matrix and b is the 13x1 matrix that gives the information of the generated power in
the 13 buses
A=[
1
2
3
4
5
6
7
8
9
10
11
12
13
];
3
2
2
1
1
2
1
2
1
1
1
1
1
0
0
21.7
94.2
47.8
7.6 1.6
11.2
0
0
0
0
29.5
9
5.8
3.5 1.8
6.1 1.6
13.5
0
0
12.7
19 0
-3.9
0
0
7.5 0
0
0
0
0
16.6
0
0
0
0
0
0
5.8 0
1
0
0
0
1
0
1
1
0
1
1
1
0
1.06
0
0
1
1.06
0.94;
0
1
1.045
-4.98
0
1
1.06
0.94;
1
1.01
-12.72 0
1
1.06
0.94;
0
1
1.019
-10.33 0
1
1.06
0.94;
1.02
-8.78
0
1
1.06
0.94;
1
1.07
-14.22 0
1
1.06
0.94;
1.062
-13.37 0
1
1.06
0.94;
1.09
-13.36 0
1
1.06
0.94;
19 1
1.056
-14.94 0
1
1.06
0.94;
1.051
-15.1
0
1
1.06
0.94;
1.057
-14.79 0
1
1.06
0.94;
1.055
-15.07 0
1
1.06
0.94;
1
1.05
-15.16 0
1
1.06
0.94;
b=[230.4;40;0;0;0;0;0;0;0;0;0;0;0]
cgs(A,b,tol,maxit) is the command used in matlab to find the conjugate gragient
where tol is the tolerance allowed and maxit is the number of iterations
we shall consider 20 iterations and tolerance allowed is equal to 1e-12
MAtlab command
>>cgs(A,b,maxit,tol)
Matlab output
ans =
15.9498
105.9868
1.0407
-4.6725
30.0581
4.8353
-52.8783
57.0922
12.7519
-65.7614
-42.2389
-36.7071
-31.9099
The behaviour of the conjugate gradient is plotted by using the matlab command below and the plot is
shown below
Command
>>[x0,fl0,rr0,it0,rv0] = cgs(A,b,tol,maxit);
semilogy(0:maxit,rv0/norm(b),'-o');
xlabel('Iteration number');
ylabel('Relative residual');
The plot shows that the solution does not converge. You can use a preconditioner to improve the
outcome
nrm =
120.6892
It is estimated as 120.6892