-
Notifications
You must be signed in to change notification settings - Fork 51
/
L10MatrixInverse.html
1082 lines (925 loc) · 72.4 KB
/
L10MatrixInverse.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" data-content_root="" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<title>The Inverse of a Matrix — Linear Algebra, Geometry, and Computation</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
<!-- Loaded before other Sphinx assets -->
<link href="_static/styles/theme.css?digest=5b4479735964841361fd" rel="stylesheet" />
<link href="_static/styles/bootstrap.css?digest=5b4479735964841361fd" rel="stylesheet" />
<link href="_static/styles/pydata-sphinx-theme.css?digest=5b4479735964841361fd" rel="stylesheet" />
<link href="_static/vendor/fontawesome/6.1.2/css/all.min.css?digest=5b4479735964841361fd" rel="stylesheet" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-solid-900.woff2" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-brands-400.woff2" />
<link rel="preload" as="font" type="font/woff2" crossorigin href="_static/vendor/fontawesome/6.1.2/webfonts/fa-regular-400.woff2" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" href="_static/styles/sphinx-book-theme.css?digest=14f4ca6b54d191a8c7657f6c759bf11a5fb86285" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/togglebutton.css" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-thebe.css" />
<link rel="stylesheet" type="text/css" href="_static/design-style.4045f2051d55cab465a707391d5b2007.min.css" />
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="_static/scripts/bootstrap.js?digest=5b4479735964841361fd" />
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=5b4479735964841361fd" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=5b4479735964841361fd"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/clipboard.min.js"></script>
<script src="_static/copybutton.js"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
<script>let toggleHintShow = 'Click to show';</script>
<script>let toggleHintHide = 'Click to hide';</script>
<script>let toggleOpenOnPrint = 'true';</script>
<script src="_static/togglebutton.js"></script>
<script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
<script src="_static/design-tabs.js"></script>
<script>const THEBE_JS_URL = "https://unpkg.com/thebe@0.8.2/lib/index.js"
const thebe_selector = ".thebe,.cell"
const thebe_selector_input = "pre"
const thebe_selector_output = ".output, .cell_output"
</script>
<script async="async" src="_static/sphinx-thebe.js"></script>
<script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'L10MatrixInverse';</script>
<link rel="shortcut icon" href="_static/DiagramAR-icon.png"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Markov Chains" href="L11MarkovChains.html" />
<link rel="prev" title="Matrix Algebra" href="L09MatrixOperations.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
</head>
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">
<a class="skip-link" href="#main-content">Skip to main content</a>
<div id="pst-scroll-pixel-helper"></div>
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
<i class="fa-solid fa-arrow-up"></i>
Back to top
</button>
<input type="checkbox"
class="sidebar-toggle"
name="__primary"
id="__primary"/>
<label class="overlay overlay-primary" for="__primary"></label>
<input type="checkbox"
class="sidebar-toggle"
name="__secondary"
id="__secondary"/>
<label class="overlay overlay-secondary" for="__secondary"></label>
<div class="search-button__wrapper">
<div class="search-button__overlay"></div>
<div class="search-button__search-container">
<form class="bd-search d-flex align-items-center"
action="search.html"
method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search"
class="form-control"
name="q"
id="search-input"
placeholder="Search this book..."
aria-label="Search this book..."
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form></div>
</div>
<nav class="bd-header navbar navbar-expand-lg bd-navbar">
</nav>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<div class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
</div>
<div class="sidebar-primary-items__start sidebar-primary__section">
<div class="sidebar-primary-item">
<a class="navbar-brand logo" href="landing-page.html">
<img src="_static/DiagramAR-icon.png" class="logo__image only-light" alt="Linear Algebra, Geometry, and Computation - Home"/>
<script>document.write(`<img src="_static/DiagramAR-icon.png" class="logo__image only-dark" alt="Linear Algebra, Geometry, and Computation - Home"/>`);</script>
</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
<div class="bd-toc-item navbar-nav active">
<ul class="nav bd-sidenav bd-sidenav__home-link">
<li class="toctree-l1">
<a class="reference internal" href="landing-page.html">
Preface
</a>
</li>
</ul>
<ul class="current nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="L01LinearEquations.html">Linear Equations</a></li>
<li class="toctree-l1"><a class="reference internal" href="L02Numerics.html">(Getting Serious About) Numbers</a></li>
<li class="toctree-l1"><a class="reference internal" href="L03RowReductions.html">Gaussian Elimination</a></li>
<li class="toctree-l1"><a class="reference internal" href="L04VectorEquations.html">Vector Equations</a></li>
<li class="toctree-l1"><a class="reference internal" href="L05Axb.html"><span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span></a></li>
<li class="toctree-l1"><a class="reference internal" href="L06LinearIndependence.html">Linear Independence</a></li>
<li class="toctree-l1"><a class="reference internal" href="L07LinearTransformations.html">Linear Transformations</a></li>
<li class="toctree-l1"><a class="reference internal" href="L08MatrixofLinearTranformation.html">The Matrix of a Linear Transformation</a></li>
<li class="toctree-l1"><a class="reference internal" href="L09MatrixOperations.html">Matrix Algebra</a></li>
<li class="toctree-l1 current active"><a class="current reference internal" href="#">The Inverse of a Matrix</a></li>
<li class="toctree-l1"><a class="reference internal" href="L11MarkovChains.html">Markov Chains</a></li>
<li class="toctree-l1"><a class="reference internal" href="L12MatrixFactorizations.html">Matrix Factorizations</a></li>
<li class="toctree-l1"><a class="reference internal" href="L13ComputerGraphics.html">Computer Graphics</a></li>
<li class="toctree-l1"><a class="reference internal" href="L14Subspaces.html">Subspaces</a></li>
<li class="toctree-l1"><a class="reference internal" href="L15DimensionRank.html">Dimension and Rank</a></li>
<li class="toctree-l1"><a class="reference internal" href="L16Eigenvectors.html">Eigenvectors and Eigenvalues</a></li>
<li class="toctree-l1"><a class="reference internal" href="L17CharacteristicEqn.html">The Characteristic Equation</a></li>
<li class="toctree-l1"><a class="reference internal" href="L18Diagonalization.html">Diagonalization</a></li>
<li class="toctree-l1"><a class="reference internal" href="L19PageRank.html">PageRank</a></li>
<li class="toctree-l1"><a class="reference internal" href="L20Orthogonality.html">Analytic Geometry in <span class="math notranslate nohighlight">\(\mathbb{R}^n\)</span></a></li>
<li class="toctree-l1"><a class="reference internal" href="L21OrthogonalSets.html">Orthogonal Sets and Projection</a></li>
<li class="toctree-l1"><a class="reference internal" href="L22LeastSquares.html">Least Squares</a></li>
<li class="toctree-l1"><a class="reference internal" href="L23LinearModels.html">Linear Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="L24SymmetricMatrices.html">Symmetric Matrices</a></li>
<li class="toctree-l1"><a class="reference internal" href="L25SVD.html">The Singular Value Decomposition</a></li>
<li class="toctree-l1"><a class="reference internal" href="L26ApplicationsOfSVD.html">Applications of the SVD</a></li>
</ul>
</div>
</nav></div>
</div>
<div class="sidebar-primary-items__end sidebar-primary__section">
</div>
<div id="rtd-footer-container"></div>
</div>
<main id="main-content" class="bd-main">
<div class="sbt-scroll-pixel-helper"></div>
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article">
<div class="header-article-items header-article__inner">
<div class="header-article-items__start">
<div class="header-article-item"><label class="sidebar-toggle primary-toggle btn btn-sm" for="__primary" title="Toggle primary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="fa-solid fa-bars"></span>
</label></div>
</div>
<div class="header-article-items__end">
<div class="header-article-item">
<div class="article-header-buttons">
<a href="https://github.com/mcrovella/CS132-Geometric-Algorithms" target="_blank"
class="btn btn-sm btn-source-repository-button"
title="Source repository"
data-bs-placement="bottom" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fab fa-github"></i>
</span>
</a>
<div class="dropdown dropdown-download-buttons">
<button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Download this page">
<i class="fas fa-download"></i>
</button>
<ul class="dropdown-menu">
<li><a href="_sources/L10MatrixInverse.ipynb" target="_blank"
class="btn btn-sm btn-download-source-button dropdown-item"
title="Download source file"
data-bs-placement="left" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fas fa-file"></i>
</span>
<span class="btn__text-container">.ipynb</span>
</a>
</li>
<li>
<button onclick="window.print()"
class="btn btn-sm btn-download-pdf-button dropdown-item"
title="Print to PDF"
data-bs-placement="left" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fas fa-file-pdf"></i>
</span>
<span class="btn__text-container">.pdf</span>
</button>
</li>
</ul>
</div>
<button onclick="toggleFullScreen()"
class="btn btn-sm btn-fullscreen-button"
title="Fullscreen mode"
data-bs-placement="bottom" data-bs-toggle="tooltip"
>
<span class="btn__icon-container">
<i class="fas fa-expand"></i>
</span>
</button>
<script>
document.write(`
<button class="btn btn-sm navbar-btn theme-switch-button" title="light/dark" aria-label="light/dark" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="theme-switch nav-link" data-mode="light"><i class="fa-solid fa-sun fa-lg"></i></span>
<span class="theme-switch nav-link" data-mode="dark"><i class="fa-solid fa-moon fa-lg"></i></span>
<span class="theme-switch nav-link" data-mode="auto"><i class="fa-solid fa-circle-half-stroke fa-lg"></i></span>
</button>
`);
</script>
<script>
document.write(`
<button class="btn btn-sm navbar-btn search-button search-button__button" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass fa-lg"></i>
</button>
`);
</script>
<label class="sidebar-toggle secondary-toggle btn btn-sm" for="__secondary"title="Toggle secondary sidebar" data-bs-placement="bottom" data-bs-toggle="tooltip">
<span class="fa-solid fa-list"></span>
</label>
</div></div>
</div>
</div>
</div>
<div id="jb-print-docs-body" class="onlyprint">
<h1>The Inverse of a Matrix</h1>
<!-- Table of contents -->
<div id="print-main-content">
<div id="jb-print-toc">
<div>
<h2> Contents </h2>
</div>
<nav aria-label="Page">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#computing-the-matrix-inverse">Computing the Matrix Inverse</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#the-2-times-2-case">The <span class="math notranslate nohighlight">\(2\times 2\)</span> case</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#matrices-larger-than-2-times-2">Matrices larger than <span class="math notranslate nohighlight">\(2 \times 2\)</span>.</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#the-computational-view">The Computational View</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#using-the-matrix-inverse-to-solve-a-linear-system">Using the Matrix Inverse to Solve a Linear System</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#algebra-of-matrix-inverses">Algebra of Matrix Inverses</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#the-invertible-matrix-theorem">The Invertible Matrix Theorem</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#invertible-linear-transformations">Invertible Linear Transformations</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#font-color-blue-further-reading-font"><font color="blue"> Further Reading </font></a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#ill-conditioned-matrices">Ill-Conditioned Matrices</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#demonstration-of-ill-conditioning">Demonstration of Ill-Conditioning</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div id="searchbox"></div>
<article class="bd-article" role="main">
<section class="tex2jax_ignore mathjax_ignore" id="the-inverse-of-a-matrix">
<h1>The Inverse of a Matrix<a class="headerlink" href="#the-inverse-of-a-matrix" title="Permalink to this heading">#</a></h1>
<p>Today we investigate the idea of the <font color=blue>”reciprocal”</font> of a matrix.</p>
<p>For reasons that will become clear, we will think about this way:</p>
<p>The reciprocal of any nonzero number <span class="math notranslate nohighlight">\(r\)</span> is its multiplicative inverse.</p>
<p>That is, <span class="math notranslate nohighlight">\(1/r = r^{-1}\)</span> such that <span class="math notranslate nohighlight">\(r \cdot r^{-1} = 1.\)</span></p>
<p>This gives a way to define what is called the <font color = blue>inverse</font> of a matrix.</p>
<p>Importantly: we have to recognize that this inverse does not exist for all matrices.</p>
<ul class="simple">
<li><p>It only exists for square matrices</p></li>
<li><p>And not even for all square matrices – only those that are “invertible.”</p></li>
</ul>
<p><strong>Definition.</strong> An <span class="math notranslate nohighlight">\(n\times n\)</span> matrix <span class="math notranslate nohighlight">\(A\)</span> is called <strong>invertible</strong> if there exists an <span class="math notranslate nohighlight">\(n\times n\)</span> matrix <span class="math notranslate nohighlight">\(C\)</span> such that</p>
<div class="math notranslate nohighlight">
\[ AC = I \;\;\text{ and }\;\; CA = I. \]</div>
<p>In that case <span class="math notranslate nohighlight">\(C\)</span> is called the <em>inverse</em> of <span class="math notranslate nohighlight">\(A\)</span>.</p>
<p>Clearly, <span class="math notranslate nohighlight">\(C\)</span> must also be square and the same size as <span class="math notranslate nohighlight">\(A\)</span>.</p>
<p>The inverse of <span class="math notranslate nohighlight">\(A\)</span> is denoted <span class="math notranslate nohighlight">\(A^{-1}.\)</span></p>
<p>A matrix that is not invertible is called a <strong>singular</strong> matrix.</p>
<p>A strange term, but you just have to memorize and get used to it.</p>
<p><strong>Example.</strong></p>
<p>If <span class="math notranslate nohighlight">\(A = \left[\begin{array}{rr}2&5\\-3&-7\end{array}\right]\)</span> and <span class="math notranslate nohighlight">\(C = \left[\begin{array}{rr}-7&-5\\3&2\end{array}\right]\)</span>, then:</p>
<div class="math notranslate nohighlight">
\[\begin{split} AC = \left[\begin{array}{rr}2&5\\-3&-7\end{array}\right]\left[\begin{array}{rr}-7&-5\\3&2\end{array}\right] = \left[\begin{array}{rr}1&0\\0&1\end{array}\right],\end{split}\]</div>
<p>and:</p>
<div class="math notranslate nohighlight">
\[\begin{split} CA = \left[\begin{array}{rr}-7&-5\\3&2\end{array}\right]\left[\begin{array}{rr}2&5\\-3&-7\end{array}\right] = \left[\begin{array}{rr}1&0\\0&1\end{array}\right],\end{split}\]</div>
<p>so we conclude that <span class="math notranslate nohighlight">\(C = A^{-1}.\)</span></p>
<p>Let’s think about what a matrix inverse does in a linear equation.</p>
<p>Take a standard linear equation:</p>
<div class="math notranslate nohighlight">
\[ A{\bf x} = {\bf b}. \]</div>
<p>Then:</p>
<div class="math notranslate nohighlight">
\[A^{-1}(A{\bf x}) = A^{-1}{\bf b}\]</div>
<div class="math notranslate nohighlight">
\[(A^{-1}A){\bf x} = A^{-1}{\bf b}\]</div>
<div class="math notranslate nohighlight">
\[I{\bf x} = A^{-1}{\bf b}\]</div>
<div class="math notranslate nohighlight">
\[{\bf x} = A^{-1}{\bf b}\]</div>
<p><strong>Theorem.</strong> If <span class="math notranslate nohighlight">\(A\)</span> is an invertible <span class="math notranslate nohighlight">\(n\times n\)</span> matrix, then for each <span class="math notranslate nohighlight">\({\bf b}\)</span> in <span class="math notranslate nohighlight">\(\mathbb{R}^n,\)</span> the equation <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span> has the unique solution <span class="math notranslate nohighlight">\(A^{-1}{\bf b}.\)</span></p>
<p><strong>Proof.</strong> Follows directly from the definition of <span class="math notranslate nohighlight">\(A^{-1}.\)</span></p>
<p>This very simple, powerful theorem gives us a new way to solve a linear system.</p>
<p>Furthermore, this theorem connects the matrix inverse to certain kinds of linear systems.</p>
<p>We know that not all linear systems of <span class="math notranslate nohighlight">\(n\)</span> equations in <span class="math notranslate nohighlight">\(n\)</span> variables have a unique solution.</p>
<p>Such systems may have no solutions (inconsistent) or an infinite number of solutions.</p>
<p>But this theorem says that <strong>if <span class="math notranslate nohighlight">\(A\)</span> is invertible, then the system has a unique solution.</strong></p>
<section id="computing-the-matrix-inverse">
<h2>Computing the Matrix Inverse<a class="headerlink" href="#computing-the-matrix-inverse" title="Permalink to this heading">#</a></h2>
<p>Wonderful - so to solve a linear system, we simply need to compute the inverse of <span class="math notranslate nohighlight">\(A\)</span> (if it exists)!</p>
<p>Well … how do we do that?</p>
<section id="the-2-times-2-case">
<h3>The <span class="math notranslate nohighlight">\(2\times 2\)</span> case<a class="headerlink" href="#the-2-times-2-case" title="Permalink to this heading">#</a></h3>
<p>Before answering this question for arbitrary matices, I will answer it for the special case of <span class="math notranslate nohighlight">\(2 \times 2\)</span> matrices.</p>
<p><strong>Theorem.</strong> Let <span class="math notranslate nohighlight">\(A\)</span> = <span class="math notranslate nohighlight">\(\left[\begin{array}{rr}a&b\\c&d\end{array}\right].\)</span></p>
<ul class="simple">
<li><p>If <span class="math notranslate nohighlight">\(ad-bc \neq 0\)</span>, then <span class="math notranslate nohighlight">\(A\)</span> is invertible and <span class="math notranslate nohighlight">\(A^{-1} = \frac{1}{ad-bc}\left[\begin{array}{rr}d&-b\\-c&a\end{array}\right].\)</span></p></li>
<li><p>If <span class="math notranslate nohighlight">\(ad-bc = 0\)</span>, then <span class="math notranslate nohighlight">\(A\)</span> is not invertible.</p></li>
</ul>
<p>Notice that this theorem tells us, for <span class="math notranslate nohighlight">\(2\times 2\)</span> matrices, exactly <em>which ones</em> are invertible.</p>
<p>Namely: those which have <span class="math notranslate nohighlight">\(ad-bc \neq 0\)</span>.</p>
<p>Of course, we recognize the quantity <span class="math notranslate nohighlight">\(ad-bc\)</span>!</p>
<p>It is the <strong>determinant</strong> of <span class="math notranslate nohighlight">\(A\)</span>.</p>
<p><strong>Example.</strong> Given a <span class="math notranslate nohighlight">\(2\times 2\)</span> matrix <span class="math notranslate nohighlight">\(A\)</span>, if the columns of <span class="math notranslate nohighlight">\(A\)</span> are linearly dependent, is <span class="math notranslate nohighlight">\(A\)</span> invertible?</p>
<p><strong>Solution.</strong> If the columns of <span class="math notranslate nohighlight">\(A\)</span> are linearly dependent, then at least one of the columns is a multiple of the other.</p>
<p>Let the multiplier be <span class="math notranslate nohighlight">\(m.\)</span></p>
<p>Then we can express <span class="math notranslate nohighlight">\(A\)</span> as:
<span class="math notranslate nohighlight">\(\left[\begin{array}{rr}a&ma\\b&mb\end{array}\right].\)</span></p>
<p>The determinant of <span class="math notranslate nohighlight">\(A\)</span> is <span class="math notranslate nohighlight">\(a(mb) - b(ma) = 0.\)</span></p>
<p>So a <span class="math notranslate nohighlight">\(2\times 2\)</span> matrix with linearly dependent columns is <strong>not invertible.</strong></p>
</section>
<section id="matrices-larger-than-2-times-2">
<h3>Matrices larger than <span class="math notranslate nohighlight">\(2 \times 2\)</span>.<a class="headerlink" href="#matrices-larger-than-2-times-2" title="Permalink to this heading">#</a></h3>
<p>OK, now let’s look at a general method for computing the inverse of <span class="math notranslate nohighlight">\(A\)</span>.</p>
<p>Recall our definition of matrix multiplication: <span class="math notranslate nohighlight">\(AB\)</span> is the matrix formed by multiplying <span class="math notranslate nohighlight">\(A\)</span> times each column of <span class="math notranslate nohighlight">\(B\)</span>.</p>
<div class="math notranslate nohighlight">
\[ AB = [A{\bf b_1} \; \dots \; A{\bf b_n}]. \]</div>
<p>Let’s look at the equation</p>
<div class="math notranslate nohighlight">
\[AA^{-1} = I.\]</div>
<p>Let’s call the columns of <span class="math notranslate nohighlight">\(A^{-1}\)</span> = <span class="math notranslate nohighlight">\([{\bf x_1}, {\bf x_2}, \dots, {\bf x_n}].\)</span></p>
<p>We know what the columns of <span class="math notranslate nohighlight">\(I\)</span> are: <span class="math notranslate nohighlight">\([{\bf e_1}, {\bf e_2}, \dots, {\bf e_n}].\)</span></p>
<p>So:</p>
<div class="math notranslate nohighlight">
\[ AA^{-1} = A[{\bf x_1}, {\bf x_2}, \dots, {\bf x_n}] = [{\bf e_1}, {\bf e_2}, \dots, {\bf e_n}].\]</div>
<p>Notice that we can break this up into <span class="math notranslate nohighlight">\(n\)</span> separate problems:</p>
<div class="math notranslate nohighlight">
\[ A{\bf x_1} = {\bf e_1} \]</div>
<div class="math notranslate nohighlight">
\[ A{\bf x_2} = {\bf e_2} \]</div>
<div class="math notranslate nohighlight">
\[ \vdots \]</div>
<div class="math notranslate nohighlight">
\[ A{\bf x_n} = {\bf e_n} \]</div>
<p>(This is a common trick … make sure you understand why it works!)</p>
<p>So here is a general way to compute the inverse of <span class="math notranslate nohighlight">\(A\)</span>:</p>
<ul class="simple">
<li><p>Solve the linear system <span class="math notranslate nohighlight">\(A{\bf x_1} = {\bf e_1}\)</span> to get the first column of <span class="math notranslate nohighlight">\(A^{-1}.\)</span></p></li>
<li><p>Solve the linear system <span class="math notranslate nohighlight">\(A{\bf x_2} = {\bf e_2}\)</span> to get the second column of <span class="math notranslate nohighlight">\(A^{-1}.\)</span></p></li>
<li><p><span class="math notranslate nohighlight">\(\dots\)</span></p></li>
<li><p>Solve the linear system <span class="math notranslate nohighlight">\(A{\bf x_n} = {\bf e_n}\)</span> to get the last column of <span class="math notranslate nohighlight">\(A^{-1}.\)</span></p></li>
</ul>
<p>If any of the systems are inconsistent or has an infinite solution set, then <span class="math notranslate nohighlight">\(A^{-1}\)</span> does not exist.</p>
<p>In fact, the above procedure is equivalent to the following:</p>
<ol class="arabic simple">
<li><p>Construct the <span class="math notranslate nohighlight">\(n \times 2n\)</span> matrix <span class="math notranslate nohighlight">\(B = [A \;I]\)</span></p></li>
<li><p>Find the <span class="math notranslate nohighlight">\(C\)</span> = the reduced echelon form of <span class="math notranslate nohighlight">\(B\)</span></p></li>
<li><p>In the resulting matrix <span class="math notranslate nohighlight">\(C\)</span>:</p>
<ul class="simple">
<li><p>if the columns on the left half are <span class="math notranslate nohighlight">\(I\)</span>, then</p>
<ul>
<li><p>the columns in the right half of <span class="math notranslate nohighlight">\(C\)</span> will be <span class="math notranslate nohighlight">\(A^{-1}\)</span>.</p></li>
</ul>
</li>
<li><p>Otherwise, <span class="math notranslate nohighlight">\(A\)</span> is not invertible.</p></li>
</ul>
</li>
</ol>
<p><strong>The operation count of Matrix Inversion.</strong></p>
<p>Thus, when we perform Matrix Inversion on an <span class="math notranslate nohighlight">\(n\times n\)</span> matrix, we are row reducing a <span class="math notranslate nohighlight">\(n\times 2n\)</span> matrix.</p>
<p>This increased size results in the operation count of matrix inversion being <span class="math notranslate nohighlight">\(\sim 2n^3.\)</span></p>
<p>(To see a derivation of this, check the lecture notes.)</p>
<p>This fact will be important!</p>
<div class="admonition-optional-material admonition">
<p class="admonition-title">Optional Material</p>
<p>Here is more detail on the operation count of Matrix Inversion.</p>
<p>To do Matrix inversion, we perform row reduction on <span class="math notranslate nohighlight">\([A I]\)</span> to obtain <span class="math notranslate nohighlight">\([I A^{-1}]\)</span> as just described. Since <span class="math notranslate nohighlight">\([A I]\)</span> is <span class="math notranslate nohighlight">\(n\times 2n\)</span>, the forward elimination step is <span class="math notranslate nohighlight">\(\sim\frac{5}{3}n^3\)</span> and the backsubstitution step is <span class="math notranslate nohighlight">\(\sim\frac{1}{3}n^3\)</span>.</p>
<p>In more detail:</p>
<p>If you go back to the derivation of the cost of Gaussian Elimination in Lecture 3, you need to extend the diagram. It is no longer <span class="math notranslate nohighlight">\(n\times(n+1)\)</span> but now is <span class="math notranslate nohighlight">\(n\times 2n\)</span>. Then for the forward elimination phase of matrix inversion, you get:</p>
<div class="math notranslate nohighlight">
\[ 2\sum_{k=1}^n (k-1)(k+n) = 2\sum_{k=1}^n k^2 + (n-1)k - n\]</div>
<p>flops.</p>
<p>If you expand this out, and use standard formulas for sums (eg, see <a class="reference external" href="https://brilliant.org/wiki/sum-of-n-n2-or-n3/">https://brilliant.org/wiki/sum-of-n-n2-or-n3/</a>), you will get the high order term of <span class="math notranslate nohighlight">\(\sim\frac{5}{3}n^3.\)</span></p>
<p>Now, for the back substitution phase, at the start you have a matrix that is <span class="math notranslate nohighlight">\([U L]\)</span> where <span class="math notranslate nohighlight">\(U\)</span> is upper triangular and <span class="math notranslate nohighlight">\(L\)</span> is lower triangular. To backsubstitute row <span class="math notranslate nohighlight">\(k\)</span> in this matrix, you need</p>
<div class="math notranslate nohighlight">
\[2 \sum_{i=1}^{k} i = 2\frac{(k-1)k}{2}\]</div>
<p>flops. So the total for back substitution is</p>
<div class="math notranslate nohighlight">
\[ \sum_{k=1}^n k^2 - k \]</div>
<p>whose highest order term is <span class="math notranslate nohighlight">\(\frac{1}{3}n^3\)</span>.</p>
<p>So the total operation count of Matrix Inversion is</p>
<div class="math notranslate nohighlight">
\[\sim \frac{5}{3}n^3 + \frac{1}{3}n^3 = 2n^3\]</div>
</div>
</section>
<section id="the-computational-view">
<h3>The Computational View<a class="headerlink" href="#the-computational-view" title="Permalink to this heading">#</a></h3>
<p>This general strategy leads to an algorithm for inverting any matrix.</p>
<p>However, in this course I will not ask you invert matrices larger than <span class="math notranslate nohighlight">\(2\times 2\)</span> by hand.</p>
<p>Any time you need to invert a matrix larger than <span class="math notranslate nohighlight">\(2\times 2,\)</span> you may use a calculator or computer.</p>
<p>To invert a matrix in <code class="docutils literal notranslate"><span class="pre">Python/numpy,</span></code> use the function <code class="docutils literal notranslate"><span class="pre">np.linalg.inv().</span></code> For example:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="p">[[</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">5.0</span><span class="p">],</span>
<span class="p">[</span><span class="o">-</span><span class="mf">3.0</span><span class="p">,</span><span class="o">-</span><span class="mf">7.0</span><span class="p">]])</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">'A =</span><span class="se">\n</span><span class="s1">'</span><span class="p">,</span><span class="n">A</span><span class="p">)</span>
<span class="n">B</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">inv</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">'B = </span><span class="se">\n</span><span class="s1">'</span><span class="p">,</span><span class="n">B</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>A =
[[ 2. 5.]
[-3. -7.]]
B =
[[-7. -5.]
[ 3. 2.]]
</pre></div>
</div>
</div>
</div>
<p>What do you think happens if you call <code class="docutils literal notranslate"><span class="pre">np.linalg.inv()</span></code> on a matrix that is not invertible?</p>
<div class="cell tag_raises-exception docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mf">2.</span><span class="p">,</span><span class="mf">4.</span><span class="p">],[</span><span class="mf">2.</span><span class="p">,</span><span class="mf">4.</span><span class="p">]])</span>
<span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">inv</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">LinAlgError</span><span class="g g-Whitespace"> </span>Traceback (most recent call last)
<span class="n">Cell</span> <span class="n">In</span><span class="p">[</span><span class="mi">4</span><span class="p">],</span> <span class="n">line</span> <span class="mi">2</span>
<span class="g g-Whitespace"> </span><span class="mi">1</span> <span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mf">2.</span><span class="p">,</span><span class="mf">4.</span><span class="p">],[</span><span class="mf">2.</span><span class="p">,</span><span class="mf">4.</span><span class="p">]])</span>
<span class="ne">----> </span><span class="mi">2</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">inv</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>
<span class="nn">File ~/anaconda3/envs/CS132-legacy/lib/python3.9/site-packages/numpy/linalg/linalg.py:561,</span> in <span class="ni">inv</span><span class="nt">(a)</span>
<span class="g g-Whitespace"> </span><span class="mi">559</span> <span class="n">signature</span> <span class="o">=</span> <span class="s1">'D->D'</span> <span class="k">if</span> <span class="n">isComplexType</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="k">else</span> <span class="s1">'d->d'</span>
<span class="g g-Whitespace"> </span><span class="mi">560</span> <span class="n">extobj</span> <span class="o">=</span> <span class="n">get_linalg_error_extobj</span><span class="p">(</span><span class="n">_raise_linalgerror_singular</span><span class="p">)</span>
<span class="ne">--> </span><span class="mi">561</span> <span class="n">ainv</span> <span class="o">=</span> <span class="n">_umath_linalg</span><span class="o">.</span><span class="n">inv</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">signature</span><span class="o">=</span><span class="n">signature</span><span class="p">,</span> <span class="n">extobj</span><span class="o">=</span><span class="n">extobj</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">562</span> <span class="k">return</span> <span class="n">wrap</span><span class="p">(</span><span class="n">ainv</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">result_t</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span>
<span class="nn">File ~/anaconda3/envs/CS132-legacy/lib/python3.9/site-packages/numpy/linalg/linalg.py:112,</span> in <span class="ni">_raise_linalgerror_singular</span><span class="nt">(err, flag)</span>
<span class="g g-Whitespace"> </span><span class="mi">111</span> <span class="k">def</span> <span class="nf">_raise_linalgerror_singular</span><span class="p">(</span><span class="n">err</span><span class="p">,</span> <span class="n">flag</span><span class="p">):</span>
<span class="ne">--> </span><span class="mi">112</span> <span class="k">raise</span> <span class="n">LinAlgError</span><span class="p">(</span><span class="s2">"Singular matrix"</span><span class="p">)</span>
<span class="ne">LinAlgError</span>: Singular matrix
</pre></div>
</div>
</div>
</div>
<p>The right way to handle this is:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mf">2.</span><span class="p">,</span><span class="mf">4.</span><span class="p">],[</span><span class="mf">2.</span><span class="p">,</span><span class="mf">4.</span><span class="p">]])</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">inv</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>
<span class="k">except</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">LinAlgError</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">'Oops, looks like A is singular!'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Oops, looks like A is singular!
</pre></div>
</div>
</div>
</div>
</section>
</section>
<section id="using-the-matrix-inverse-to-solve-a-linear-system">
<h2>Using the Matrix Inverse to Solve a Linear System<a class="headerlink" href="#using-the-matrix-inverse-to-solve-a-linear-system" title="Permalink to this heading">#</a></h2>
<p>Solve the system:</p>
<div class="math notranslate nohighlight">
\[\begin{split}\begin{array}{rcl}
3x_1 +4x_2 &=& 3\\
5x_1 +6x_2 &=& 7
\end{array}\end{split}\]</div>
<p>Rewrite this system as <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}:\)</span></p>
<div class="math notranslate nohighlight">
\[\begin{split} \left[\begin{array}{rr}3&4\\5&6\end{array}\right] {\bf x} = \left[\begin{array}{r}3\\7\end{array}\right].\end{split}\]</div>
<p>The determinant of <span class="math notranslate nohighlight">\(A\)</span> is <span class="math notranslate nohighlight">\(3(6)-4(5) = -2,\)</span> which is nonzero, so <span class="math notranslate nohighlight">\(A\)</span> has an inverse.</p>
<p>According to our <span class="math notranslate nohighlight">\(2\times 2\)</span> formula, the inverse of <span class="math notranslate nohighlight">\(A\)</span> is:</p>
<div class="math notranslate nohighlight">
\[\begin{split} A^{-1} = \frac{1}{-2}\left[\begin{array}{rr}6&-4\\-5&3\end{array}\right] = \left[\begin{array}{rr}-3&2\\5/2&-3/2\end{array}\right].\end{split}\]</div>
<p>So the solution is:</p>
<div class="math notranslate nohighlight">
\[\begin{split} {\bf x} = A^{-1}{\bf b} = \left[\begin{array}{rr}-3&2\\5/2&-3/2\end{array}\right]\left[\begin{array}{r}3\\7\end{array}\right] = \left[\begin{array}{r}5\\-3\end{array}\right].\end{split}\]</div>
</section>
<section id="algebra-of-matrix-inverses">
<h2>Algebra of Matrix Inverses<a class="headerlink" href="#algebra-of-matrix-inverses" title="Permalink to this heading">#</a></h2>
<p><strong>Theorem.</strong></p>
<ul class="simple">
<li><p>If <span class="math notranslate nohighlight">\(A\)</span> is an invertible matrix, then <span class="math notranslate nohighlight">\(A^{-1}\)</span> is invertible, and</p></li>
</ul>
<div class="math notranslate nohighlight">
\[(A^{-1})^{-1} = A.\]</div>
<ul class="simple">
<li><p>If <span class="math notranslate nohighlight">\(A\)</span> is an invertible matrix, then so is <span class="math notranslate nohighlight">\(A^T,\)</span> and the inverse of <span class="math notranslate nohighlight">\(A^T\)</span> is the transpose of <span class="math notranslate nohighlight">\(A^{-1}.\)</span></p></li>
</ul>
<div class="math notranslate nohighlight">
\[(A^T)^{-1} = (A^{-1})^T.\]</div>
<ul class="simple">
<li><p>If <span class="math notranslate nohighlight">\(A\)</span> and <span class="math notranslate nohighlight">\(B\)</span> are <span class="math notranslate nohighlight">\(n\times n\)</span> invertible matrices, then so is <span class="math notranslate nohighlight">\(AB,\)</span> and the inverse of <span class="math notranslate nohighlight">\(AB\)</span> is the product of the inverses of <span class="math notranslate nohighlight">\(A\)</span> and <span class="math notranslate nohighlight">\(B\)</span> in the reverse order.</p></li>
</ul>
<div class="math notranslate nohighlight">
\[(AB)^{-1} = B^{-1}A^{-1}.\]</div>
<p>The first two are straightforward. Let’s verify the last one because it shows some common calculation patterns:</p>
<div class="math notranslate nohighlight">
\[(AB)(B^{-1}A^{-1})\]</div>
<div class="math notranslate nohighlight">
\[=A(BB^{-1})A^{-1}\]</div>
<div class="math notranslate nohighlight">
\[=AIA^{-1}\]</div>
<div class="math notranslate nohighlight">
\[=AA^{-1}\]</div>
<div class="math notranslate nohighlight">
\[=I.\]</div>
</section>
<section id="the-invertible-matrix-theorem">
<h2>The Invertible Matrix Theorem<a class="headerlink" href="#the-invertible-matrix-theorem" title="Permalink to this heading">#</a></h2>
<p>Earlier we saw that if a matrix <span class="math notranslate nohighlight">\(A\)</span> is invertible, then <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span> has a unique solution for any <span class="math notranslate nohighlight">\({\bf b}\)</span>.</p>
<p>This suggests a deep connection between the invertibility of <span class="math notranslate nohighlight">\(A\)</span> and the nature of the linear system <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}.\)</span></p>
<p>In fact, we are now at the point where we can collect together in a fairly complete way much of what we have learned about matrices and linear systems.</p>
<p>This remarkable collection of ten interrelated properties is called the <strong>Invertible Matrix Theorem (IMT).</strong></p>
<p><strong>Invertible Matrix Theorem.</strong> Let <span class="math notranslate nohighlight">\(A\)</span> by a square <span class="math notranslate nohighlight">\(n\times n\)</span> matrix.</p>
<p>Then the following statements are equivalent; that is, they are either <strong>all true</strong> or <strong>all false</strong>:</p>
<ul class="simple">
<li><p><span class="math notranslate nohighlight">\(A\)</span> is an invertible matrix.</p></li>
</ul>
<ul class="simple">
<li><p><span class="math notranslate nohighlight">\(A^T\)</span> is an invertible matrix.</p>
<ul>
<li><p>Proof by direct construction: <span class="math notranslate nohighlight">\((A^T)^{-1} = (A^{-1})^T.\)</span></p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>The equation <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span> has a unique solution for each <span class="math notranslate nohighlight">\({\bf b}\)</span> in <span class="math notranslate nohighlight">\(\mathbb{R}^n.\)</span></p>
<ul>
<li><p>As already mentioned, we proved this above.</p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>A is row equivalent to the identity matrix.</p>
<ul>
<li><p>If <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span> has a unique solution for any <span class="math notranslate nohighlight">\({\bf b},\)</span> then the reduced row echelon form of <span class="math notranslate nohighlight">\(A\)</span> is <span class="math notranslate nohighlight">\(I\)</span>.</p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>A has <span class="math notranslate nohighlight">\(n\)</span> pivot positions.</p>
<ul>
<li><p>Follows directly from the previous statement.</p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>The equation <span class="math notranslate nohighlight">\(A{\bf x} = {\bf 0}\)</span> has only the trivial solution.</p>
<ul>
<li><p>If <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span> has a unique solution for any <span class="math notranslate nohighlight">\({\bf b},\)</span> then the unique solution for <span class="math notranslate nohighlight">\({\bf b} = {\bf 0}\)</span> must be <span class="math notranslate nohighlight">\({\bf 0.}\)</span></p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>The columns of <span class="math notranslate nohighlight">\(A\)</span> form a linearly independent set.</p>
<ul>
<li><p>Follows directly the previous statement and the definition of linear independence.</p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>The columns of <span class="math notranslate nohighlight">\(A\)</span> span <span class="math notranslate nohighlight">\(\mathbb{R}^n.\)</span></p>
<ul>
<li><p>For any <span class="math notranslate nohighlight">\({\bf b} \in \mathbb{R}^n,\)</span> there is a set of coefficients <span class="math notranslate nohighlight">\({\bf x}\)</span> which can be used to construct <span class="math notranslate nohighlight">\({\bf b}\)</span> from the columns of <span class="math notranslate nohighlight">\(A.\)</span></p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>The linear transformation <span class="math notranslate nohighlight">\({\bf x} \mapsto A{\bf x}\)</span> maps <span class="math notranslate nohighlight">\(\mathbb{R}^n\)</span> onto <span class="math notranslate nohighlight">\(\mathbb{R}^n.\)</span></p>
<ul>
<li><p>Follows directly from the previous statement.</p></li>
</ul>
</li>
</ul>
<ul class="simple">
<li><p>The linear transformation <span class="math notranslate nohighlight">\({\bf x} \mapsto A{\bf x}\)</span> is one-to-one.</p>
<ul>
<li><p>Follows directly from the fact that <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span> has a unique solution for any <span class="math notranslate nohighlight">\({\bf b}.\)</span></p></li>
</ul>
</li>
</ul>
<p>The arguments above show that if <span class="math notranslate nohighlight">\(A\)</span> is invertible, then all the other statements are true.</p>
<p>In fact, the converse holds as well: if <span class="math notranslate nohighlight">\(A\)</span> is not invertible, then all the other statements are false.</p>
<p>(We will skip the proof of the converse, but it’s not difficult.)</p>
<p>This theorem has wide-ranging implications.</p>
<p>It divides the set of all <span class="math notranslate nohighlight">\(n\times n\)</span> matrices into two disjoint classes:</p>
<ol class="arabic simple">
<li><p>the invertible (nonsingular) matrices, and</p></li>
<li><p>the noninvertible (singular) matrices.</p></li>
</ol>
<p>The power of the IMT lies in the conections it provides among so many important concepts.</p>
<p>For example, notice how it connects linear independence of the columns of a matrix <span class="math notranslate nohighlight">\(A\)</span> to the existence of solutions to equations of the form <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}.\)</span></p>
<p>This allows us to bring many tools to bear as needed to solve a problem.</p>
<p><strong>Example.</strong></p>
<p>Decide if <span class="math notranslate nohighlight">\(A\)</span> is invertible:</p>
<div class="math notranslate nohighlight">
\[\begin{split}A = \left[\begin{array}{rrr}1&0&-2\\3&1&-2\\-5&-1&9\end{array}\right].\end{split}\]</div>
<p><strong>Solution.</strong></p>
<div class="math notranslate nohighlight">
\[\begin{split}A \sim \left[\begin{array}{rrr}1&0&-2\\0&1&4\\0&-1&-1\end{array}\right] \sim \left[\begin{array}{rrr}1&0&-2\\0&1&4\\0&0&3\end{array}\right].\end{split}\]</div>
<p><span class="math notranslate nohighlight">\(A\)</span> has three pivot positions and hence is invertible, by the IMT.</p>
<p><strong>Example.</strong></p>
<p>Decide if <span class="math notranslate nohighlight">\(A\mathbf{x} = \mathbf{b}\)</span> has a solution for all <span class="math notranslate nohighlight">\(\mathbf{b}\)</span>:</p>
<div class="math notranslate nohighlight">
\[\begin{split} A = \left[\begin{array}{rr}3 & 7\\-6 & -14\end{array}\right].\end{split}\]</div>
<p><strong>Solution.</strong></p>
<p>The determinant of <span class="math notranslate nohighlight">\(A\)</span> is <span class="math notranslate nohighlight">\((3 \cdot -14) - (7 \cdot -6) = 0\)</span>.</p>
<p>So <span class="math notranslate nohighlight">\(A\)</span> is not invertible, so <span class="math notranslate nohighlight">\(A\mathbf{x} = \mathbf{b}\)</span> does <strong>not</strong> have a solution for all <span class="math notranslate nohighlight">\(\mathbf{b}\)</span>.</p>
<p><strong>Note.</strong></p>
<p>Keep in mind: while the IMT is quite powerful, it does not completely settle issues that arise with respect to <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}.\)</span></p>
<p>This is because <strong>it only applies to square matrices.</strong></p>
<p>So if <span class="math notranslate nohighlight">\(A\)</span> is nonsquare, then we can’t use the IMT to conclude anything about the existence or nonexistence of solutions to <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}.\)</span></p>
</section>
<section id="invertible-linear-transformations">
<h2>Invertible Linear Transformations<a class="headerlink" href="#invertible-linear-transformations" title="Permalink to this heading">#</a></h2>
<div class="cell tag_remove-input docutils container">
<div class="cell_output docutils container">
<img alt="_images/fd975e92d335fbb09ba2663273a45fb94514c38a196962d3f5a827dd3a118f60.png" src="_images/fd975e92d335fbb09ba2663273a45fb94514c38a196962d3f5a827dd3a118f60.png" />
</div>
</div>
<p>A linear transformation <span class="math notranslate nohighlight">\(T: \mathbb{R}^n \rightarrow \mathbb{R}^n\)</span> is <strong>invertible</strong> if there exists a function <span class="math notranslate nohighlight">\(S: \mathbb{R}^n \rightarrow \mathbb{R}^n\)</span> such that</p>
<div class="math notranslate nohighlight">
\[ S(T({\bf x})) = {\bf x}\;\;\;\mbox{for all}\;{\bf x}\in\mathbb{R}^n,\]</div>
<p>and</p>
<div class="math notranslate nohighlight">
\[ T(S({\bf x})) = {\bf x}\;\;\;\mbox{for all}\;{\bf x}\in\mathbb{R}^n.\]</div>
<p><strong>Theorem.</strong></p>
<p>Let <span class="math notranslate nohighlight">\(T: \mathbb{R}^n \rightarrow \mathbb{R}^n\)</span> be a linear transformation and let <span class="math notranslate nohighlight">\(A\)</span> be the standard matrix for <span class="math notranslate nohighlight">\(T\)</span>.</p>
<p>Then <span class="math notranslate nohighlight">\(T\)</span> is invertible if and only if <span class="math notranslate nohighlight">\(A\)</span> is an invertible matrix.</p>
<p>In that case the linear transformation <span class="math notranslate nohighlight">\(S\)</span> given by <span class="math notranslate nohighlight">\(S({\bf x}) = A^{-1}{\bf x}\)</span> is the unique function satisfying the definition.</p>
<p>Let’s look at some invertible and non-invertible linear transformations.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">square</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mf">0.0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">],[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]])</span>
<span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="p">[[</span><span class="mf">0.5</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span>
<span class="p">[</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]])</span>
<span class="nb">print</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>
<span class="n">dm</span><span class="o">.</span><span class="n">plotSetup</span><span class="p">()</span>
<span class="n">dm</span><span class="o">.</span><span class="n">plotSquare</span><span class="p">(</span><span class="n">square</span><span class="p">)</span>
<span class="n">dm</span><span class="o">.</span><span class="n">plotSquare</span><span class="p">(</span><span class="n">A</span> <span class="o">@</span> <span class="n">square</span><span class="p">,</span><span class="s1">'r'</span><span class="p">)</span>
<span class="n">Latex</span><span class="p">(</span><span class="sa">r</span><span class="s1">'Horizontal Contraction'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[0.5 0. ]
[0. 1. ]]
</pre></div>
</div>
<div class="output text_latex math notranslate nohighlight">
\[Horizontal Contraction\]</div>
<img alt="_images/7a57d8d048bdfed740f7d7dbd4385fc6a0d514e06c4fe2a032a2277bc67d0abd.png" src="_images/7a57d8d048bdfed740f7d7dbd4385fc6a0d514e06c4fe2a032a2277bc67d0abd.png" />
</div>
</div>
<p>Here <span class="math notranslate nohighlight">\(A = \left[\begin{array}{rr}0.5&0\\0&1\end{array}\right].\)</span> Its determinant is <span class="math notranslate nohighlight">\(1(0.5)-0(0) = 0.5,\)</span> so this linear transformation is invertible.</p>
<p>Its inverse is:</p>
<div class="math notranslate nohighlight">
\[\begin{split} \frac{1}{0.5}\left[\begin{array}{rr}1&0\\0&0.5\end{array}\right] = \left[\begin{array}{rr}2&0\\0&1\end{array}\right].\end{split}\]</div>
<p>Clearly, just as <span class="math notranslate nohighlight">\(A\)</span> contracted the <span class="math notranslate nohighlight">\(x_1\)</span> direction by 0.5, <span class="math notranslate nohighlight">\(A^{-1}\)</span> will expand the <span class="math notranslate nohighlight">\(x_1\)</span> direction by 2.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="p">[[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">],</span>
<span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]])</span>
<span class="n">dm</span><span class="o">.</span><span class="n">plotSetup</span><span class="p">()</span>
<span class="n">dm</span><span class="o">.</span><span class="n">plotSquare</span><span class="p">(</span><span class="n">A</span> <span class="o">@</span> <span class="n">square</span><span class="p">)</span>
<span class="n">Latex</span><span class="p">(</span><span class="sa">r</span><span class="s1">'Projection onto the $x_2$ axis'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_latex math notranslate nohighlight">
\[Projection onto the $x_2$ axis\]</div>
<img alt="_images/b5f3f961fc22139a567a5c670976a9215d151bd1878ed9f798bbf3cd1cfc1293.png" src="_images/b5f3f961fc22139a567a5c670976a9215d151bd1878ed9f798bbf3cd1cfc1293.png" />
</div>
</div>
<p>Here <span class="math notranslate nohighlight">\(A = \left[\begin{array}{rr}0&0\\0&1\end{array}\right].\)</span></p>
<p>Its determinant is zero, so this linear transformation is <strong>not</strong> invertible.</p>
<p>By the IMT, there are many equivalent ways to look at this:</p>
<ul class="simple">
<li><p>The mapping <span class="math notranslate nohighlight">\(T\)</span> is not onto <span class="math notranslate nohighlight">\(\mathbb{R}^2.\)</span> (Only a subset of <span class="math notranslate nohighlight">\(\mathbb{R}^2\)</span> can be output by <span class="math notranslate nohighlight">\(T\)</span>).</p></li>
<li><p>The mapping <span class="math notranslate nohighlight">\(T\)</span> is not one-to-one. (There are many values <span class="math notranslate nohighlight">\({\bf x}\)</span> that give the same <span class="math notranslate nohighlight">\(A{\bf x}.\)</span>)</p></li>
<li><p><span class="math notranslate nohighlight">\(A\)</span> does not have 2 pivots.</p></li>
<li><p>The columns of <span class="math notranslate nohighlight">\(A\)</span> do not span <span class="math notranslate nohighlight">\(\mathbb{R}^2.\)</span></p></li>
<li><p><span class="math notranslate nohighlight">\(A\mathbf{x} = 0\)</span> has a non-trivial solution.</p></li>
</ul>
<p>Here is another example:</p>
<div class="cell tag_remove-input docutils container">
<div class="cell_output docutils container">
<img alt="_images/dc4ce127b668adf95de0624dda83c05aa105c4417ddc59820f546414495dfca5.png" src="_images/dc4ce127b668adf95de0624dda83c05aa105c4417ddc59820f546414495dfca5.png" />
</div>
</div>
<p>In this figure, we are looking at how the red points <span class="math notranslate nohighlight">\((x_1, x_2)\)</span> are mapped to the green points under the transformation</p>
<div class="math notranslate nohighlight">
\[\begin{split} \left[\begin{array}{r} x_1 \\ x_2 \end{array}\right] \mapsto \left[\begin{array}{rr} 1.04 & 0.52 \\ 0.52 & 0.26 \end{array}\right]\left[\begin{array}{r} x_1 \\ x_2 \end{array}\right].\end{split}\]</div>
<p>We notice a few things:</p>
<ul class="simple">
<li><p>The green points appear to lie along a line</p></li>
<li><p>There are cases where more than one red point maps to the same green point</p></li>
</ul>
<p>How do these two facts relate to:</p>
<ul class="simple">
<li><p>The determinant of the matrix?</p></li>
<li><p>The invertibility of the transformation?</p></li>
</ul>
</section>
<section id="font-color-blue-further-reading-font">
<h2><font color = "blue"> Further Reading </font><a class="headerlink" href="#font-color-blue-further-reading-font" title="Permalink to this heading">#</a></h2>
<p>This material is not required, but may interest you.</p>
<section id="ill-conditioned-matrices">
<h3>Ill-Conditioned Matrices<a class="headerlink" href="#ill-conditioned-matrices" title="Permalink to this heading">#</a></h3>
<p>The notion of a matrix inverse has some complications when used in practice.</p>
<p>As we’ve noted, numerical computations are not always exact.</p>
<p>In particular, we often find that <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b(a/b)</span></code> does not evaluate to exactly zero on a computer.</p>
<p>For similar reasons, a matrix which is actually singular may not appear to be so when used in a computation.</p>
<p>This happens because, for example, the determinant does not evaluate to exactly zero, even though it should.</p>
<p>Recall that when we were implementing Gaussian elimination, we established a rule:</p>
<p>If <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b(a/b)</span> <span class="pre"><</span> <span class="pre">epsilon</span></code> for sufficiently small <code class="docutils literal notranslate"><span class="pre">epsilon</span></code>, we would treat that quantity as if it were zero.</p>
<p>We need an equivalent rule for matrices, so that we recognize when matrices are “effectively singular.”</p>
<p>When a matrix <span class="math notranslate nohighlight">\(A\)</span> is “effectively singular” we should not try to solve <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span>.</p>
<p>The value we use for this purpose is called the <strong>condition number.</strong></p>
<p>Every matrix has a condition number.</p>
<p>The larger the condition number of a matrix, the closer the matrix is to being singular.</p>
<p>A <strong>singular</strong> matrix has an <strong>infinite</strong> condition number.</p>
<p>At the other extreme, the condition number of the identity matrix is 1, which is the smallest possible value.</p>
<p><strong>Here is the point:</strong> a matrix with a very large condition number will <strong>behave much like a singular matrix</strong> in practice.</p>
<p>Specifically: one should not try to solve linear systems by computer when the matrix <span class="math notranslate nohighlight">\(A\)</span> has a very large condition number.</p>
<p>How large is large?</p>
<p>It depends, but as a rule of thumb a condition number of <span class="math notranslate nohighlight">\(10^8\)</span> or greater would be considered a large condition number.</p>
<p>If a matrix has a large condition number, we might say that it is “effectively singular.”</p>
<p>The most common way to put this is that the matrix is “ill-conditioned”.</p>
<p>A matrix that has a large condition number can behave almost like it is singular.</p>
<p>We know that if <span class="math notranslate nohighlight">\(A\)</span> is a singular matrix, then <span class="math notranslate nohighlight">\(A{\bf x}={\bf b}\)</span> does not have a unique solution.</p>
<p>If on the other hand <span class="math notranslate nohighlight">\(A\)</span> is not singular, but is ill-conditioned, then solving <span class="math notranslate nohighlight">\(A{\bf x}={\bf b}\)</span> can be very inaccurate.</p>
<p>A small change in <span class="math notranslate nohighlight">\({\bf b}\)</span> (such as might be introduced by limited precision in your computer) will result in a huge change to the solution, <span class="math notranslate nohighlight">\({\bf x}\)</span>.</p>
</section>
<section id="demonstration-of-ill-conditioning">
<h3>Demonstration of Ill-Conditioning<a class="headerlink" href="#demonstration-of-ill-conditioning" title="Permalink to this heading">#</a></h3>
<p>Here is a demonstration of why this is a problem.</p>
<p>Here is a matrix that is singular:</p>
<div class="math notranslate nohighlight">
\[\begin{split}M = \left[\begin{array}{rr}1&2\\2&4\end{array}\right].\end{split}\]</div>
<p>You can see that it is singular because the second column is a multiple of the first column, so</p>
<ul class="simple">
<li><p>the determinant is zero</p></li>
<li><p>the columns are linearly dependent</p></li>
<li><p>there is only one pivot position</p></li>
<li><p>etc. (see the IMT!)</p></li>
</ul>
<p>Here is a matrix that is <em>almost</em> singular:</p>
<div class="math notranslate nohighlight">
\[\begin{split}A = \left[\begin{array}{ll}1&2.0000000001\\2&4\end{array}\right].\end{split}\]</div>
<p>The second column is not a multiple of the first column, so technically this matrix is not singular.</p>
<p>But the second column is <em>almost</em> a multiple of the first column.</p>
<p>The determinant is -0.0000000002</p>
<p>You could say the determinant is “almost zero”.</p>
<p>This matrix is ill-conditioned.</p>
<p>Now let’s solve <span class="math notranslate nohighlight">\(A{\bf x} = {\bf b}\)</span> using the ill-conditioned matrix <span class="math notranslate nohighlight">\(A.\)</span></p>
<p>First, let’s consider when <span class="math notranslate nohighlight">\({\bf b} = \left[\begin{array}{r}1\\2\end{array}\right].\)</span></p>
<p>Solving <span class="math notranslate nohighlight">\(A{\bf x} = \left[\begin{array}{r}1\\2\end{array}\right]\)</span> we get <span class="math notranslate nohighlight">\({\bf x} = \left[\begin{array}{r}1\\0\end{array}\right].\)</span></p>
<p>Now, let’s change <span class="math notranslate nohighlight">\({\bf b}\)</span> just a <strong>little bit,</strong> and solved again.</p>
<p>Let’s set <span class="math notranslate nohighlight">\({\bf b} = \left[\begin{array}{l}1\\2.01\end{array}\right].\)</span></p>
<p>Solving <span class="math notranslate nohighlight">\(A{\bf x} = \left[\begin{array}{l}1\\2.01\end{array}\right]\)</span> we get <span class="math notranslate nohighlight">\({\bf x} = \left[\begin{array}{r}100000000\\-50000000\end{array}\right].\)</span></p>
<p>Notice how a small change in <span class="math notranslate nohighlight">\({\bf b}\)</span> resulted in a huge change in <span class="math notranslate nohighlight">\({\bf x}.\)</span></p>
<p>This is <strong>very bad!</strong></p>
<p>It means that we cannot trust the solution – it could be wildly wrong due to small errors in the input!</p>
<p>This is happening because the matrix <span class="math notranslate nohighlight">\(A\)</span> is ill-conditioned – it has a large condition number.</p>
<p>In fact the condition number of <span class="math notranslate nohighlight">\(A\)</span> is about 12,500,000,000.</p>
<p>Now, this situation would not be a problem … if you were always dealing with exact quantities in your computer.</p>
<p>But you are <font color=blue>not.</font></p>
<p>Every floating point number has limited precision – a limited number of digits that can be stored.</p>
<p>As a result, there can be a small error in the value of any number stored in the computer.</p>
<p>This is not normally a problem – you would not typically notice it.</p>
<p>But if you are solving a system with a large condition number, the small error in <span class="math notranslate nohighlight">\({\bf b}\)</span> can get expanded in a large error in <span class="math notranslate nohighlight">\({\bf x}\)</span>.</p>
<p>The error can be so large that the value you get for <span class="math notranslate nohighlight">\({\bf x}\)</span> is <strong>completely wrong.</strong></p>
<p>To compute the condition number of a matrix <code class="docutils literal notranslate"><span class="pre">A</span></code> in <code class="docutils literal notranslate"><span class="pre">Python/numpy</span></code>, use <code class="docutils literal notranslate"><span class="pre">np.linalg.cond(A)</span></code>.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mf">2.0000000001</span><span class="p">],[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
<span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">cond</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>125000145095.44151
</pre></div>
</div>
</div>
</div>
</section>
</section>
</section>
<script type="text/x-thebe-config">
{
requestKernel: true,
binderOptions: {
repo: "binder-examples/jupyter-stacks-datascience",
ref: "master",
},
codeMirrorConfig: {
theme: "abcdef",
mode: "python"
},
kernelOptions: {
name: "python3",
path: "./."
},
predefinedOutput: true
}
</script>
<script>kernelName = 'python3'</script>
</article>
<footer class="prev-next-footer">
<div class="prev-next-area">
<a class="left-prev"
href="L09MatrixOperations.html"
title="previous page">
<i class="fa-solid fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">Matrix Algebra</p>
</div>
</a>
<a class="right-next"
href="L11MarkovChains.html"
title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Markov Chains</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>
</div>
</footer>