-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh05_GeometryOfVectorSpaces.tex
More file actions
1707 lines (1538 loc) · 76.6 KB
/
Ch05_GeometryOfVectorSpaces.tex
File metadata and controls
1707 lines (1538 loc) · 76.6 KB
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
\chapter{Geometry in Vector Spaces}
Vector spaces give a rich environment to explore the relationships between
objects and gives natural abstractions to other types of {\it vectors} (e.g. functions,
matrices, polynimials, etc). Most of the study of vector spaces involves abstraction
and making precise ideas that spanned many decades, or centuries, in many different fields
of science and mathematics. In this sense, the study of vector spaces leans heavily on
past mathematical results and seeks to give them order and structure. You
have seen that the study of vector spaces really acts as a unifying language to talk about
a wide variety of mathematical objects.
In this chapter we layer the language of abstract vector spaces and the language of
geometry. In particular, we will build and abstract the familiar ideas of angle,
othogonality, lengths of vectors, and distance in general vector spaces. We will make
precise the ideas of the {\it size of a function} or the {\it distance between two
matrices} or {\it polynomials}. These notions are likely second nature in our familiar
vector spaces
$\mathbb{R}^2$ and $\mathbb{R}^3$, but what about in spaces of matrices? spaces of
functions? spaces of polynomials? The notions of angle and distance can be abstracted in
a natural and beautiful way so that our intuitive ideas still hold, but we also get
something mathematically meaningful in the more abstract spaces. We'll start with an idea
that is probably familiar to you: the dot product\footnote{If you haven't had
multivariable calculus or calculus-based physics then maybe the idea of a dot product will
be new to you. Don't worry. We'll introduce everything from scratch here.}. From the
dot product we will build a similar idea is more general vector spaces so that the ideas
of angle and perpendicularity come along for the ride. Here we go!
\section{The Geometry of Euclidean Space}
At this point we have talked almost exclusively about linear combinations and the spaces
associated with them. We have not, however, discussed the geometry of vector spaces. So
far we haven't generalized the notions of angle and length of vectors to our large view of
vector spaces. You may recall things like projections, angles, norms (lengths) from
$\mathbb{R}^2$ or $\mathbb{R}^3$ as discussed in physics or in multivariable calculus but
you need to keep in mind that this is only a limited view of the world of vector spaces.
Let's jump right in by filling in some definitions and theorems that you likely already
know
\subsection{The Dot Product}
The following are two different familiar definitions of the dot product. The first gives
a purely algebraic formula for the dot product and the second gives a more geometric
definition. They are indeed equivalent definitions.
\begin{definition}[Algebraic Dot Product in $\mathbb{R}^n$]
Let $\bu, \bv \in \mathbb{R}^n$. The {\bf dot product} of $\bu$ and $\bv$ is defined
algebraically as
\[ \bu \cdot \bv = u_1 v_1 + u_2 v_2 + \cdots + u_n v_n = \sum_{j=1}^n u_j v_j. \]
Notice that this definition doesn't explicitly mention the angle between the vectors.
\end{definition}
% \solution{
% $\bu \cdot \bv = \sum_{j=1}^n u_j v_j$
% }
\begin{definition}[Geometric Dot Product in $\mathbb{R}^n$]
If $\bu,\bv\in\mathbb{R}^n$ then the relationship between the dot product of the
vectors and the angle between the vectors is
\[ \bu \cdot \bv = \|\bu\| \|\bv\| \cos \theta. \]
Notice that if you want the angle between two vectors then
\[ \theta = \cos^{-1} \left( \frac{\bu \cdot \bv}{\| \bu \| \|\bv\|} \right). \]
\end{definition}
One should note that the angle formula only holds if both $\|\bu\|\ne0$ and $\|\bv\|\ne0$.
Now we build the mathematical notation for orthogonality and length of vectors in
$\mathbb{R}^n$. Both of these geometric concepts are build upon the dot product.
\begin{definition}[Orthogonal Vectors]
Two vectors are said to be orthogonal (perpendicular) if their dot product is zero.
\end{definition}
\begin{problem}
Use the geometric definition of the dot product to prove that statements
\begin{itemize}
\item ``the dot product of two vectors is zero'', and
\item ``the vectors are perpendicular''
\end{itemize}
are indeed the same based on your familiar understanding of what ``perpendicular''
means.
\end{problem}
% \begin{thm}[Orthogonal Vectors in $\mathbb{R}^n$]
% If $\bu,\bv\in\mathbb{R}^n$ then $\bu$ is orthogonal (perpendicular) to $\bv$ if and
% only if \underline{\hspace{1in}}.
% \end{thm}
% \solution{
% $\bu \cdot \bv = 0$
% }
% \begin{proof}
% (prove this theorem)
% \end{proof}
\solution{
$\bu \cdot \bv = \|\bv \| \|\bu\| \cos \theta$ and if $\theta = \pi/2$ we know that
$\cos \theta = 0$. Hence $\bu \cdot \bv = 0$.
}
\begin{definition}[Length of Vectors in $\mathbb{R}^n$]
Let $\bu \in \mathbb{R}^n$. The {\bf length (norm)} of $\bu$ is
\[ \| \bu \| = \sqrt{\bu \cdot \bu} = \underline{\hspace{2in}} \]
(fill in the blank using the algebraic definition of the dot product)
\end{definition}
\solution{
$\|\bu\| = \sum_{j=1}^n u_j^2$
}
\begin{problem}
If $\bu,\bv \in \mathbb{R}^2$ then what familiar theorem do you see in the definition
of the length of a vector? Another way to put this is: the definition of the length
of a vector in $\mathbb{R}^n$ is a generalization of what familiar theorem?
\end{problem}
\solution{
This is just Pythagorean Theorem.
}
\begin{definition}[Distance Between Vectors in $\mathbb{R}^n$]
Let $\bu,\bv\in\mathbb{R}^n$. The {\bf distance between} $\bu$ and $\bv$ is
\[ \text{dist}(\bu,\bv) = \| \bu - \bv\| = \underline{\hspace{1in}} \]
(fill in the blank)
\end{definition}
\solution{
$\text{dist}(\bu,\bv) = \|\bu-\bv\|$
}
\begin{definition}[Unit Vectors in $\mathbb{R}^n$]
Let $\bv \in \mathbb{R}^n$. We say that $\bv$ is a unit vector if $\|\bv\| = 1$. If
you have a vector $\bv$ that is not a unit vector (has length other than 1) then you
can scale it to become a unit vector by dividing by its length
\[ (\text{unit vector in the direction of $\bv$}) = \bu = \frac{\bv}{\|\bv\|}. \]
\end{definition}
OK. Most of the geometric players are on the table: angle, distance, length, and
perpendicularity. Here we give a straight forward example showing how to use these ideas
in $\mathbb{R}^3$.
\begin{problem}
Let $\bu$ and $\bv$ be defined as. Find $\bu \cdot \bv$, $\|\bu\|$, $\|\bv\|$, and
the angle between them.
\[ \bu = \left( \begin{array}{c} 0 \\ 1 \\ -1 \end{array} \right) \]
\[ \bv = \left( \begin{array}{c} 4 \\ 2 \\ -3 \end{array} \right) \]
%
% \begin{enumerate}
% \item[(a)]
% $\left( \begin{array}{c} 0 \\ 2 \\ 3 \end{array} \right)$
% \item[(b)] 5
% \item[(c)] 0
% \item[(d)] The dot product cannot be computed for these vectors.
% \end{enumerate}
\end{problem}
% \begin{problem}
% \begin{itemize}
% \input{ClickerQuestions/LA.00.22.010}
% \end{itemize}
% \end{problem}
\solution{
The dot product is $(0)(4) + (1)(2) + (-1)(-3) = 2+3 = 5$
}
\begin{example}
Let $\bu, \bv \in \mathbb{R}^3$ be defined as
\[ \bu = \begin{pmatrix} 2 \\ -1 \\ 4 \end{pmatrix} \quad \text{and} \quad \bv =
\begin{pmatrix} 0 \\ 9 \\ -3 \end{pmatrix} \]
What are $\bu \cdot \bv$, $\|\bu\|$, $\|\bv\|$, and $\text{dist}(\bu,\bv)$? Are the
two vectors orthogonal? What is the angle between them? \\ {\bf
Solution:}
\begin{flalign*}
\bu \cdot \bv &= (2)(0) + (-1)(9) + (4)(-3) = -9 - 12 = -21 \\
\|\bu\| &= \sqrt{2^2 + (-1)^1 + 4^2} = \sqrt{4 + 1 + 16} = \sqrt{21} \\
\|\bv\| &= \sqrt{0^2 + 9^2 + (-3)^2} = \sqrt{81 + 9} = \sqrt{90} \\
\text{dist}(\bu,\bv) &= \| \bu - \bv\| = \| \begin{pmatrix} 2 \\ -10 \\ 7
\end{pmatrix} \| = \sqrt{4+100+49} = \sqrt{153}.
\end{flalign*}
The vectors are not orthogonal since $\bu \cdot \bv \ne 0$. The angle between the
vectors is
\[ \theta = \cos^{-1} \left( \frac{\bu \cdot \bv}{\|\bu\| \|\bv\|} \right) =
\cos^{-1}\left( \frac{-21}{\sqrt{21}\sqrt{90}} \right) \]
\end{example}
\subsection{Projections}
Finally we are going to discuss projections. When dealing with projections you should be
thinking about how shadows are cast between vectors. To solidify this notion (even though
you likely already know it) let's look at some projections in $\mathbb{R}^2$ before we
ramp up the dimension. Take a look at Figure \ref{fig:proj_R2}. We would like to project
vector $\bu$ onto vector $\bv$ and by that we mean that we would like to draw a vector
(depicted by the dashed vector $\bw$ in the figure) that is perpendicular to $\bv$ and meets the
head of $\bu$. This projection creates the vector $\hat{\bv}$ so that $\hat{\bv}$ points
in exactly the same direction as $\bv$ but $\hat{\bv} \perp \bw$. Since $\bv$ and
$\hat{\bv}$ point in the same direction we know that $\hat{\bv} = c\bv$ for some scalar
$c$. Furthermore, we know that $\bw + \hat{\bv} = \bu$ so $\bw = \bu - \hat{\bv}$. Therefore,
\begin{flalign*}
&0 = \hat{\bv} \cdot \bw = c\bv \cdot \left( \bu - c\bv \right) \\
&\implies c\bv \cdot \bu - c^2 \bv \cdot \bv = 0 \\
&\implies \bu \cdot \bv = c \bv \cdot \bv \\
&\implies c = \frac{\bu \cdot \bv}{\bv \cdot \bv}
\end{flalign*}
\begin{figure}[ht!]
\begin{center}
\begin{tikzpicture}
\draw[->,thick, blue] (0,0) -- (3,1) node[anchor=west]{$\bv$};
\draw[->,thick, red] (0,0) -- (1,3) node[anchor=south]{$\bu$};
\draw[->,thick, dashed, black] (1.8,0.6) -- (1,3);
\draw[black] (1.4,2) node[anchor=west]{$\bw$};
\draw[->,thick, dashed, blue] (0.1,-0.1) -- (1.9,0.5);
\draw[blue] (1,0.25) node[anchor=north]{$\hat{\bv}$};
\end{tikzpicture}
\end{center}
\caption{Depiction of vector projection in $\mathbb{R}^2$.}
\label{fig:proj_R2}
\end{figure}
All of the prior discuss proves the following theorem but notice that we never made any
mention explicitly about the vectors living in $\mathbb{R}^2$. In fact, the proof that we
gave works generally in $\mathbb{R}^n$.
\begin{thm}[Orthogonal Projection]
Let $\bu, \bv \in \mathbb{R}^n$. If we are to project $\bu$ onto $\bv$ as in Figure
\ref{fig:proj_R2} we get
\begin{flalign*}
\text{proj}_{\bv}(\bu) &= \hat{\bv} = \left( \frac{\bv \cdot \bu}{\bv \cdot \bv}
\right) \bv =
\text{projection of $\bu$ onto $\bv$} \\
\bw &= \bu - \hat{\bv} = \bu - \left( \frac{\bv \cdot \bu}{\bv \cdot \bv} \right)
\bv
= \text{projection error}
\end{flalign*}
The vector $\bw$ is often called the {\it error} in the projection.
\end{thm}
\begin{problem}
If $\bb = \left( \begin{array}{c} 3 \\ -1 \end{array} \right)$ and $y = \left(
\begin{array}{c} 2 \\ 1 \end{array} \right),$ then what is the orthogonal projection of $\bb$
onto $\by$? Find your solution analytically and draw of graph depicting your answer.
%
% \begin{enumerate}
% \item[(a)] $\left( \begin{array}{c} 2 \\ 1 \end{array} \right)$
% \item[(b)] $\left( \begin{array}{c} 3/2 \\ -1/2 \end{array} \right)$
% \item[(c)] $\left( \begin{array}{c} 10 \\ 5 \end{array} \right)$
% \item[(d)] $\left( \begin{array}{c} 1/10 \\ 3/10 \end{array} \right)$
% \end{enumerate}
%
\end{problem}
% \begin{problem}
% \begin{itemize}
% \input{ClickerQuestions/LA.00.24.010}
% \end{itemize}
% \end{problem}
\solution{
$\text{proj}_y b = \left( \frac{b \cdot y}{y \dot y} \right) y = \left(
\frac{5}{5}
\right) \begin{pmatrix} 2 \\ 1 \end{pmatrix} = \begin{pmatrix}2\\1\end{pmatrix}$
}
We know what a basis is and what know what orthogonal vectors are. If you think carefully
about it, all of your mathematical life you have been dealing with coordinate systems that have
orthogonal bases. Every time you graph in $\mathbb{R}^2$ or $\mathbb{R}^3$ you've used
the idea of othogonality without thinking much about it. Let's see why this is so
incredibly useful.
\begin{problem}
If $\mathcal{B} = \{\bv_1, \bv_2, \ldots, \bv_n\}$ is an orthogonal basis for a vector
space $\mathcal{V}$ then how do you write $\bx$ as a linear combination of the basis vectors?\\
(Why is it advantageous to have an orthogonal basis?)
Hint: Since $\bx = c_1 \bv_1 + c_2 \bv_2 + \cdots + c_n \bv_n$ how can you use
orthogonality to solve for $c_j$?
\end{problem}
\solution{
$c_j = \frac{\bx \cdot \bv_j}{\bv_j \cdot \bv_j}$
}
\begin{problem}
Implement your idea on the subspace spanned by the basis
\[ \mathcal{B} = \left\{ \begin{pmatrix} 1\\4\\-3 \end{pmatrix}\, , \, \begin{pmatrix}
3 \\ 0 \\ 1 \end{pmatrix} \right\} \]
where $\bx$ is in the subspace of $\mathbb{R}^3$ spanned by $\mathcal{B}$.
Specifically, let $\bx$ be defined as
\[ \bx = \begin{pmatrix} 2 \\ -4\\ 1 \end{pmatrix} \]
\end{problem}
\solution{
Since $\bx = c_1 \begin{pmatrix} 1 \\ 4 \\ -3 \end{pmatrix} + c_2 \begin{pmatrix} 3 \\ 0 \\
1 \end{pmatrix}$ so
\[ c_1 = \frac{\bx \cdot \bv_1}{\bv_1 \cdot \bv_1} = \frac{-17}{26} \]
\[ c_2 = \frac{\bx \cdot \bv_2}{\bv_2 \cdot \bv_2} = \frac{7}{10} \]
}
Now summarize the process that you built in the previous problem into the following
theorem.
\begin{thm}[Building Vectors from an Orthogonal Basis]\label{thm:orthogonal_basis}
If $\mathcal{B} = \{\bv_1, \bv_2, \ldots, \bv_n\}$ is an orthogonal basis for a vector
space $\mathcal{V}$ then for any vector $\bx \in \mathcal{V}$ we can write
\[ \bx = C_1 \bv_1 + C_2 \bv_2 + \cdots + C_n \bv_n \]
where
\[ C_k = \underline{\hspace{1in}}. \]
% \[ \bx = \underline{\hspace{0.25in}} \bv_1 + \underline{\hspace{0.25in}} \bv_2 +
% \underline{\hspace{0.25in}} \bv_3 + \cdots + \underline{\hspace{0.25in}} \bv_n \]
% (Fill in the blanks)
\end{thm}
\begin{proof}
(prove this theorem by leveraging the fact that we have an orthogonal basis)
\end{proof}
\solution{
$c_j = \frac{\bx \cdot \bv_j}{\bv_j \cdot \bv_j}$
}
\begin{thm}
If the nonzero vectors $\bu_1, \bu_2, \bu_3, \dots, \bu_k$ are mutually orthogonal
then they are linearly independent.
\end{thm}
\begin{proof}
(prove this theorem)
\end{proof}
\solution{
Consider $\bo = \sum_{j=1}^n c_j \bu_j$. From the previous theorem we know that $c_j
= (\bo \cdot \bu_j) / (\bu_j \cdot \bu_j) = 0$. Therefore the only solution is the
trivial solution and the vectors must be linearly independent.
}
\begin{problem}
Determine if the following set of vectors is linearly independent. Do this two
different ways.
\[ \left\{ \begin{pmatrix} 3 \\ 1 \\ 1 \end{pmatrix} \, , \, \begin{pmatrix} -1 \\ 2
\\ 1
\end{pmatrix} \, , \, \begin{pmatrix} -1 \\ -4 \\ 7 \end{pmatrix} \right\} \]
\end{problem}
\solution{
They are mutually orthogonal so they are linearly independent.
}
\begin{problem}
If we have two linearly independent vectors that are NOT orthogonal, how do
we find a set of two orthogonal vectors that span the same space?
For example, can we find two orthogonal vectors that span the same space as
\[ \begin{pmatrix} 2 \\ 0 \end{pmatrix} \quad \text{and} \quad \begin{pmatrix} 1
\\ 1 \end{pmatrix} \]
\end{problem}
\subsection{The Gram-Schmidt Process: Making Orthogonal Sets}
The previous theorems and problems give us good reason to think that having an orthogonal
(or orthonormal) basis for a vector space is advantageous both computationally and
geometrically. In fact, we have been used to an orthonormal basis all of our matheamtical
lives since that is what the regular Cartesian coordinate system is built from. The
question now is this: \\
Given a basis $\mathcal{B}$ for a vector space $\mathcal{V}$ how can we transform that
basis into a different basis for the same space but also gain orthogonality?
We will build your intuition to the process via a scaffolded problem.
\begin{problem}
Build a basis for $\mathbb{R}^2$ so that it contains two orthogonal unit vectors with
one of the vectors parallel to $\bv_1 = \begin{pmatrix} 1\\1\end{pmatrix}$.
\end{problem}
\begin{problem}
Consider the vector space $\mathbb{R}^3$ with the basis $\mathcal{B} = \{\bv_1, \bv_2,
\bv_3\}$ given by
\[ \bv_1 = \begin{pmatrix} 1\\1\\1\end{pmatrix}, \quad \bv_2 = \begin{pmatrix} 0
\\1\\1\end{pmatrix},\quad \bv_3 = \begin{pmatrix} 0\\0\\1\end{pmatrix} \]
We are going to build a basis $\mathcal{U} = \{\bu_1, \bu_2, \bu_3\}$ such that $\text{span}(\mathcal{U}) =
\mathbb{R}^3$ but the vectors are also mutually orthogonal and all have unit length.
(One should note here that the normalization step is optional but since unit vectors
are so nice to work with we are leaving it here.)
\begin{enumerate}
\item[(a)] Define $\bu_1$ as a unit vector that points in the same direction as
$\bv_1$.
\[ \bu_1 = \frac{1}{\|\bv_1\|} \bv_1 = \begin{pmatrix} \underline{\hspace{0.25in}} \\
\underline{\hspace{0.25in}} \\ \underline{\hspace{0.25in}} \end{pmatrix}
\]
\solution{
$\bu_1 = \frac{1}{\sqrt{3}} \begin{pmatrix} 1\\1\\1\end{pmatrix} = \begin{pmatrix}
1/\sqrt{3} \\ 1/\sqrt{3} \\ 1/\sqrt{3} \end{pmatrix}$
}
\item[(b)] Now we project $\bv_2$ onto $\bu_1$ and find the error in the
projection. This would be the vector $\bw$ in Figure \ref{fig:proj_R2}. Once
we have the error we should normalize it to get $\bu_2$.
\[ \bw_2 = \bv_2 - \text{proj}_{\bu}(\bv_2) = \bv_2 - \left( \bv_2 \cdot \bu_1
\right) \bu_1 \quad \text{and therefore} \quad \bu_2 =
\frac{1}{\|\bw_2\|}\bw_2. \]
Draw a picture of what we just did.
\[ \bu_2 = \frac{1}{\|\bv_1\|} \bv_1 = \begin{pmatrix}
\underline{\hspace{0.25in}} \\ \underline{\hspace{0.25in}} \\
\underline{\hspace{0.25in}} \end{pmatrix} \]
\solution{
$\bw_2 = \begin{pmatrix} 0\\1\\1\end{pmatrix} - \left( \frac{2}{\sqrt{3}}
\right)\begin{pmatrix} 1/\sqrt{3} \\ 1/\sqrt{3} \\ 1/\sqrt{3} \end{pmatrix} =
\begin{pmatrix}0\\1\\1\end{pmatrix} - \begin{pmatrix} 2/3 \\ 2/3 \\ 2/3
\end{pmatrix} = \begin{pmatrix} -2/3 \\ 1/3 \\ 1/3 \end{pmatrix}$. Therefore
$\bu_2 = \frac{1}{\|\bw_2\|}\bw_2 $ so
\[ \bu_2 = \frac{\sqrt{3}}{\sqrt{2}} \begin{pmatrix} -2/3 \\ 1/3 \\
1/3\end{pmatrix} = \frac{1}{\sqrt{6}} \begin{pmatrix}
-2\\1\\1\end{pmatrix} = \begin{pmatrix} -2/\sqrt{6} \\
1/\sqrt{6} \\ 1/\sqrt{6} \end{pmatrix} \]
}
\item[(c)] For $\bu_3$ we project $\bv_3$ onto both $\bu_1$ and $\bu_2$ and then
normalize.
\[ \bw_3 = \bv_3 - \left( \bv_3 \cdot \bu_1 \right)\bu_1 - \left( \bv_3 \cdot
\bu_2
\right) \bu_2 \quad \text{and therefore} \quad \bu_3 =
\frac{1}{\|\bw_3\|}\bw_3 \]
\[ \bu_3 = \frac{1}{\|\bv_1\|} \bv_1 = \begin{pmatrix}
\underline{\hspace{0.25in}} \\ \underline{\hspace{0.25in}} \\
\underline{\hspace{0.25in}} \end{pmatrix} \]
\solution{
\[ \bw_3 = \bv_3 - \left( \frac{1}{\sqrt{3}} \right)\begin{pmatrix} 1/\sqrt{3} \\
1/\sqrt{3} \\ 1/\sqrt{3} \end{pmatrix} - \left( \frac{1}{\sqrt{6}} \right)
\begin{pmatrix} -2/\sqrt{6} \\ 1/\sqrt{6} \\ 1/\sqrt{6} \end{pmatrix} =
\begin{pmatrix}0\\0\\1\end{pmatrix} - \begin{pmatrix}1/3 \\ 1/3 \\ 1/3
\end{pmatrix} - \begin{pmatrix} -2/6 \\ 1/6 \\ 1/6 \end{pmatrix} =
\begin{pmatrix} 0 \\ -1/2 \\ 1/2 \end{pmatrix} =
\frac{1}{2} \begin{pmatrix}0\\-1\\1\end{pmatrix} \]
Therefore, we can build $\bu_3$ by normalizing
\[ \bu_3 = \frac{\sqrt{2}}{2} \begin{pmatrix} 0\\-1\\1 \end{pmatrix} =
\frac{1}{\sqrt{2}} \begin{pmatrix} 0\\-1\\1\end{pmatrix} = \begin{pmatrix}
0\\-1/\sqrt{2} \\ 1/\sqrt{2} \end{pmatrix}\]
}
\item[(d)] Verify that indeed $\mathcal{U} = \{\bu_1, \bu_2, \bu_3\}$ is an
orthonormal basis for $\mathbb{R}^3$.
\solution{
The orthonormal basis is:
\[ \mathcal{U} = \left\{ \begin{pmatrix} 1/\sqrt{3} \\ 1/\sqrt{3} \\ 1/\sqrt{3}
\end{pmatrix} \, , \, \begin{pmatrix} -2/\sqrt{6} \\ 1/\sqrt{6} \\ 1/\sqrt{6}
\end{pmatrix} \, , \, \begin{pmatrix} 0 \\ -1/\sqrt{2} \\ 1/\sqrt{2} \end{pmatrix}
\right\} \]
and we leave it to the reader to verify that indeed the vectors are mutually
orthogonal.
}
\end{enumerate}
\end{problem}
\begin{problem}
Use the Gram-Schmidt process outlined in the previous problem to produce an orthogonal
basis $\mathcal{U}$ for the subspace spanned by
\[ \begin{pmatrix} 3\\0\\-1\end{pmatrix} \quad \text{and} \quad \begin{pmatrix}
8\\5\\-6\end{pmatrix}. \]
\end{problem}
\begin{problem}
Let's build an orthogonal basis $\mathcal{U}$ for $\mathbb{R}^3$. To get started let
$\bu_1 = \begin{pmatrix} 1\\0\\1\end{pmatrix}$. (notice that we are not
normalizing this time)
\begin{enumerate}
\item[(a)] Create a vector $\bu_2$ in $\mathbb{R}^3$ so that $\bu_1 \perp
\bu_2$.
\solution{
A simple choice is $\bu_2 = (0,1,0)^T$.
}
\item[(b)] Pick a vector $\bv_3 \in \mathbb{R}^3$ such that $\bv_3$ is
linearly independent of $\bu_1$ and $\bu_2$. Then use one step of the
Gram-Schmidt process to create $\bu_3$ out of $\bv_3$.
\solution{One choice is $\bv_3 = (2,0,1)^T$. Therefore
\[ \bu_3 = \bv_3 - \left( \frac{\bv_3 \cdot \bu_1}{\|\bu_1\|^2} \right)\bu_1 - \left(
\frac{\bv_3 \cdot \bu_2}{\|\bu_2\|^2}\right) \bu_2 = \begin{pmatrix}
2\\0\\1\end{pmatrix} - \frac{3}{2}\begin{pmatrix} 1\\0\\1\end{pmatrix} - 0
\begin{pmatrix} 0\\1\\0\end{pmatrix} = \begin{pmatrix} 1/2 \\ 0 \\
-1/2\end{pmatrix} \]
}
\item[(c)] Verify that the vectors in your proposed basis are indeed mutually
orthogonal. If so we can use one of the previous theorems (which one) to
say that the vectors are linearly independent and must therefore span
$\mathbb{R}^3$.
\solution{It is trivial to verify that the three vectors are indeed mutually orthogonal.
}
\end{enumerate}
\end{problem}
\newpage\section{Inner Product Spaces}
Now time for some more abstraction! In this section we take the notions of geometry and
abstract them to generalized vector spaces. You may have noticed that the dot product is
the basic computation necessary to understand angle in $\mathbb{R}^n$ so we first have to
provide a generalized version of the dot product.
\begin{definition}[The Inner Product]\label{def:inner_product}
An {\bf inner product} is the abstraction of a dot product to a general vector space.
If $\bu$, $\bv$, and $\bw$ are vectors in a vector space $\mathcal{V}$ and $c$ is some real
number then
\begin{enumerate}
\item $\left< \bu,\bv\right> = \left<\bv,\bu\right>$
\item $\left< \bu,\bv + \bw\right> = \left< \bu,\bv\right> + \left<
\bu,\bw\right>$
\item $\left< c\bu,\bv\right> = c \left< \bu,\bv\right>$
\item $\left< \bu,\bu\right> \ge 0$ and $\left<\bu,\bu\right>=0$ if and only if
$\bu=\bo$
\end{enumerate}
\end{definition}
\begin{problem}
Verify that the dot product is indeed an inner product on the vector space
$\mathbb{R}^n$.
\end{problem}
\solution{
\begin{enumerate}
\item The dot product is definitely symmetric: $\bu \cdot \bv = \bv \cdot \bu$.
Proof:
\[ \bu \cdot \bv = \sum_{j=1}^n u_j v_j = \sum_{j=1}^n v_j u_j = \bv \cdot \bu
\]
\item $\bu \cdot (\bv + \bw) = (\bu \cdot \bv) + (\bu + \bw)$ since
\[ \bu \cdot (\bv + \bw) = \sum_{j=1}^n u_j(v_j+w_j) = \sum_{j=1}^n u_j v_j + u_j
w_j = \sum_{j=1}^n u_j v_j + \sum_{j=1}^n u_j w_j = \bu \cdot \bv + \bu \cdot
\bw \]
\item $(c\bu) \cdot \bv = c (\bu \cdot \bv)$ since
\[ (c\bu) \cdot \bv = \sum_{j=1}^n (cu_j)v_j = c \sum_{j=1}^n u_j v_j = c (\bu
\cdot \bv) \]
\item If $\bu = \bo$ then $\bu \cdot \bu = \sum_{j=1}^n u_j = \sum_{j=1}^n 0 = 0$.
Furthermore, $\bu \cdot \bu = \sum_{j=1}^n u_j^2$ which is the sum on non-negative
real numbers which must clearly also be non-negative.
\end{enumerate}
}
\begin{problem}
An inner product on $\mathcal{P}_2$ (the space of all quadratic polynomials) is
\[ \left< p \,,\, q \right> = p_0 q_0 + p_1 q_1 + p_2 q_2 \]
where $p(x) = p_0 + p_1x + p_2 x^2$ and $q(x) = q_0 + q_1 x + q_2 x^2$. Verify that
this indeed is a proper inner product on $\mathcal{P}_2$. If it is then find the
inner product of $p(x) = x^2 + 1$ and $q(x) = 2x+x^2$ as well as the angle between
$p(x)$ and $q(x)$.
\end{problem}
\begin{problem}
Consider the vector space of quadratic polynomials on the interval $x \in [0,1]$.
\[ \mathcal{P}_2 = \{a_0 + a_1 x + a_2 x^2 \, : \, a_0, a_1, a_2 \in
\mathbb{R} \text{ and } x \in [0,1] \} \]
An inner product on this vector space is
\[ \left< f,g\right> =
\int_0^1 f(x) g(x) dx. \]
\begin{enumerate}
\item[(a)] Verify that this is indeed a proper inner product on $\mathcal{P}_2$
\item[(b)] Find the inner product of $f(x) = x^2+1$ and $g(x) =
2x+x^2$ in $\mathcal{P}_2$ under this inner product.
\item[(c)] Set up the necessary integrals to find the lengths of $f$ and $g$ in
$\mathcal{P}_2$ under this inner product.
\item[(d)] Set up the necessary integrals to find the angle between $f$ and $g$ in
$\mathcal{P}_2$ under this inner product.
\item[(e)] Is this the only inner product on $\mathcal{P}_2$?
\end{enumerate}
\end{problem}
\solution{
\begin{enumerate}
\item[(b)] $\left< f,g\right>= \int_0^1 (x^2+1)(2x+x^2) dx = \int_0^1 2x^3 + x^4 + 2x + x^2 dx = \frac{1}{2} +
\frac{1}{5} + 1 + \frac{1}{3} = \frac{61}{30}$
\item[(c)] $\|f\| = \left< f,f\right>^{1/2} = \sqrt{\int_0^1 (x^2+1)^2 dx}$, and
$\|g\| = \left<g,g\right>^{1/2} = \sqrt{\int_0^1 (2x+x^2)^2 dx}$.
\item[(d)] $\theta = \frac{\left< f,g\right>}{\|f\|\|g\|}$
\item[(e)] since these are polynomials we could take any finite bounds of
integration and we get a valid inner product.
\end{enumerate}
}
\begin{problem}
Consider the vector space of $2 \times 2$ real matrices
\[ \mathcal{V} = \left\{ \begin{pmatrix} a & b \\ c & d \end{pmatrix} \, : \,
a,b,c,d \in \mathbb{R} \right\} \]
along with the inner product $\left<A \,,\, B \right> = \text{trace}(AB^T)$.
Note: If $M$ is a matrix, the {\it trace} of the matrix, $tr(M)$, is the sum
of the entries on the main diagonal.
To
simplify your computations a bit we'll expand the definition of the inner product.
\[ \left<A\,,\,B\right> = \text{trace}(AB^T) = \text{trace}\left(
\begin{pmatrix} a_{11} & a_{12} \\
a_{21} & a_{22} \end{pmatrix}
\begin{pmatrix} b_{11} & b_{21} \\
b_{12} & b_{22} \end{pmatrix} \right) = \text{trace}\left(
\begin{pmatrix} a_{11} & a_{12} \\
a_{21} & a_{22} \end{pmatrix}
\begin{pmatrix} b_{11} & b_{12} \\
b_{21} & b_{22} \end{pmatrix}^T \right)\]
\[ = \text{trace}\left(
\begin{pmatrix} a_{11}b_{11} + a_{12} b_{12} & a_{11}b_{21} +
a_{12}b_{22} \\ a_{21}b_{11} + a_{22}b_{12} & a_{21} b_{21} +
a_{22} b_{22} \end{pmatrix} \right) \]
\[ = \left( a_{11}b_{11} + a_{12} b_{12} \right) + \left( a_{21} b_{21} + a_{22}
b_{22}\right) \]
\begin{enumerate}
\item[(a)] Why is this a natural choice for the inner product between $2 \times 2$ matrices?
\item[(b)] Find an orthogonal basis for $\mathcal{V}$. That's right \dots I'm asking you to find
angles between matrices!! AWESOME!!
\end{enumerate}
\end{problem}
\solution{
This is a natural choice since it is essentially equivalent to the dot product in
$\mathbb{R}^4$.
\[ \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix},
\begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix},
\begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix},
\begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} \]
}
% \begin{problem}[Geometry on Periodic Functions]
% Consider the vector space
% \[ \mathcal{V} = \{ f(x) \, : \, f(x) \text{ is } 2\pi \text{ periodic }\} \]
% along with the inner product
% \[ \left<f,g\right> = \int_0^{2\pi} f(x) g(x) dx \]
% Suggest a basis for $\mathcal{V}$ and determine if it is an orthogonal basis.
% \end{problem}
% \solution{
% \[ \mathcal{B} = \{\sin(kx),\cos(kx)\}_{k=0}^\infty \]
% \[ \int_0^{2\pi} \sin(kx) \sin(jx) dx = \left\{ \begin{array}{ll} \pi &
% j=k \\ 0 & j \ne k \end{array} \right. \]
% \[ \int_0^{2\pi} \sin(kx) \cos(jx) dx = 0 \quad \forall j,k \]
% \[ \int_0^{2\pi} \cos(kx) \sin(jx) dx = \left\{ \begin{array}{ll} \pi &
% j=k \\ 0 & j \ne k \end{array} \right. \]
% }
\newpage\section{Fourier Series}
In this section we will consider one of the most beautiful and useful
applications of inner product spaces. This application has, quite literally, changed the modern world in uncountably
many ways. This application, which will arise later in these notes (in the PDE's
chapter), is one of the most stunningly beautiful applications out there for everyone to
see: The Fourier Series.
Fourier series were first developed by Joseph Fourier (ca 1800) as part of the development
of the theory of heat transport. Since then the field of Fourier Analysis has taken over
physics, engineering, signal processing, computer science, \ldots and the list goes on and
on and on. Every signal that we transmit is touched in some way by the ideas developed by
Fourier in the 1800's. It is no exaggeration that every person in our technological world is impacted
daily by Fourier Analysis.
Let's get into it. Consider the vector space spanned by an infinite basis of sine functions
\[ \mathcal{B} = \left\{ \sin\left( k x\right) \, : \, k \in \mathbb{N} \right\} \]
equipped with the inner product
\begin{flalign}
\left< f , g \right> = \frac{1}{\pi} \int_0^{2\pi} f(x) g(x) dx.
\label{eqn:fourier_ip}
\end{flalign}
This particular basis is infinite dimensional since the natural numbers, $\mathbb{N}$, are
(countably) infinite, and if we consider the span we can build any periodic function
$f(x)$ where $f(0) = 0$ as a
linear combination of sine functions of different frequencies.
More specifically, since every periodic function can be written as a linear combination of the
basis functions we have the infinite sum
\begin{flalign}
f(x) = \sum_{k=1}^\infty C_k \sin\left( k x\right) \label{eqn:fourier_sine}
\end{flalign}
for all period functions $f$. The most important part of the basis $\mathcal{B}$ is that
it is an othonormal basis under the inner product: an orthogonal basis made entirely of
unit vectors.
\begin{thm}\label{thm:fourier_sine_ip}
If $j,k \in \mathbb{N}$ then
\begin{flalign}
\left< \sin(kx) \,,\, \sin(jx) \right> = \frac{1}{\pi} \int_0^{2\pi} \sin(kx)
\sin(jx) dx = \left\{ \begin{array}{ll} 0, & j \ne k \\ 1, & j=k \end{array}
\right.
\label{eqn:fourier_ip_1}
\end{flalign}
\end{thm}
\begin{problem}
What does Theorem \ref{thm:fourier_sine_ip} say about the functions $\sin(kx)$ and
$\sin(jx)$ under the inner product
\[ \left< f(x) \, , \, g(x) \right> = \frac{1}{\pi} \int_0^{2\pi} f(x) g(x) dx? \]
\end{problem}
\begin{proof}
Let's prove Theorem \ref{thm:fourier_sine_ip}. Notice that in Theorem
\ref{thm:fourier_sine_ip} if we let $k=j$ then the inner product shows that
\[ \| \sin(kx) \| = \sqrt{ \left< \sin(kx) \, , \, \sin(kx) \right>} =
\sqrt{\frac{1}{\pi} \int_0^{2\pi} \sin^2(kx) dx } = 1 \]
which implies that each of the sine functions is a unit vector in this inner product
space. Furthermore, if $j \ne k$ then $\left< \sin(kx) \,,\, \sin(jx)\right> = 0$,
which shows that $\sin(kx)$ and $\sin(jx)$ are orthogonal in this space.
Let's integrate directly to verify this. First, if recall the trig identity
\[ 2\sin(\theta)\sin(\phi) = \cos(\theta - \phi) - \cos(\theta + \phi) \]
we can rewrite \eqref{eqn:fourier_ip_1} as
\[ \left< \sin(kx) , \sin(jx) \right> = \frac{1}{\pi} \left[ \frac{1}{2} \int_0^{2\pi}
\cos\left( (k-j)x \right) - \cos\left( (k+j)x \right) dx \right]. \]
There are clearly two cases: when $k=j$ and when $k\ne j$.
In the case that $k=j$ we observe that $k-j=0$ so the integral becomes
\[ \frac{1}{2\pi} \int_0^{2\pi} 1 - \cos(2kx) dx \]
which we can integrate to
\[ \frac{1}{2\pi} \int_0^{2\pi} 1-\cos(2kx) dx = \frac{1}{2\pi} \left[ x -
\frac{1}{2k}\sin(2kx)
\right]_0^{2\pi} = \frac{1}{2\pi} \left[ 2\pi - \frac{\sin(4k\pi)}{2k} +
\frac{\sin(0)}{2k} \right] = 1 \]
since the sine of integer multiples of $\pi$ is zero.
In the case that $k \ne j$ we have
\[ \left< \sin(kx) \, , \, \sin(jx) \right> = \frac{1}{2\pi} \left[ \int_0^{2\pi} \cos\left(
(k-j)x \right) dx - \int_0^{2\pi} \cos\left( (k+j)x \right) dx \right] \]
which can be integrated to
\[ \frac{1}{2\pi} \left[ \frac{\sin\left( (k-j)x \right)}{k-j} - \frac{\sin\left(
(k+j)x \right)}{k+j} \right]_0^{2\pi} = \frac{1}{2\pi} \left[ \frac{\sin\left(2\pi (k-j) \right)}{k-j} - \frac{\sin\left(
2\pi(k+j) \right)}{k+j} \right] = 0 \]
where we again have used the fact that the sine of an integer multiple of $\pi$ is
zero along with the fact that $\sin(0) = 0$.
This concludes the proof and we see that the set $\mathcal{B} = \left\{ \sin(kx) \, : \, k
\in \mathbb{N} \right\}$ is indeed an orthonormal basis of functions under
inner product \eqref{eqn:fourier_ip}.
\end{proof}
If you aren't happy with the analytical proof you can at least {\it convince} yourself
that indeed Theorem \ref{thm:fourier_sine_ip} is true.
\begin{problem}
Open MATLAB (or any other symbolic calculus package) and verify that the basis
\[ \mathcal{B} = \left\{ \sin\left( k x\right) \, : \, k \in \mathbb{N} \right\} \]
is indeed an orthogonal basis. That is, compute
\[ \left< \sin\left( k x\right) \, , \, \sin\left( j x \right)
\right> = \frac{1}{\pi} \int_0^{2\pi} \sin\left( k x\right) \sin\left( j x\right) dx \]
for various values of $j$ and $k$ and verify that
\begin{itemize}
\item if $j=k$ then the inner produce is identically 1.
\item if $j \neq k$ then the inner product is zero.
\end{itemize}
\end{problem}
It is worth it to note that we could have defined the inner product for this space as an
integral from $-\pi$ to $\pi$ instead of $0$ to $2\pi$ and all of these results would
still hold. After all, the functions are periodic with period $2\pi$ so any domain with
length $2\pi$ would work just fine.
\begin{thm}
Any periodic function $f(x)$ with period $2\pi$ and $f(0) = 0$ can be written as a
linear combination of sine functions $\sin(kx)$. That is,
\[ f(x) = C_1 \sin(1x) + C_2 \sin(2x) + C_3 \sin(3x) + \cdots = \sum_{k=1}^\infty C_k
\sin(kx). \]
\end{thm}
\begin{proof}
Indeed, we have just expanded the periodic function as a linear combination of the
basis functions.
\end{proof}
\begin{problem}
Go to
\href{http://mathlets.org/mathlets/fourier-coefficients/}{http://mathlets.org/mathlets/fourier-coefficients/},
choose ``Target A'', ``Sine'', and ``All terms''. Then use the sliders on the right
to closely match the square wave with a Fourier sine series.
\end{problem}
\begin{problem}
If $f(x)$ is some periodic function then we can write it as a linear combination of
the basis vectors in $\mathcal{B}$:
\[ f(x) = \sum_{k=1}^{\infty} C_k \sin(k x). \]
Knowing that the sine functions in the sum form an orthonormal basis for the space of
periodic functions propose a way to find each $C_k$. Hint: Consider Theorem
\ref{thm:orthogonal_basis}.
\end{problem}
\begin{thm}[Fourier Sine Series Coefficients]
If $f(x)$ is a $2\pi$ periodic function with $f(0) =0$ then we can expand $f(x)$ as
the series
\[ f(x) = \sum_{k=1}^\infty C_k \sin(kx) \]
where
\[ C_k = \left< f(x) \, , \, \sin(kx) \right> = \frac{1}{\pi} \int_0^{2\pi} f(x)
\sin(kx) dx. \]
\end{thm}
\begin{proof}
This theorem is a special case of Theorem \ref{thm:orthogonal_basis}.
\end{proof}
\begin{center}
{\bf Now for some fun!}
\end{center}
\begin{problem}
Let's build a sound signal with some noise and then use the mathematics that we just
discussed to work some magic.
\begin{enumerate}
\item[(a)] We'll start by building a clean signal.
\begin{lstlisting}
clear; clc;
dt = 0.001; % set up a time step
t = 0:dt:2*pi % set up time from 0 to 2pi
% Now we'll buid a signal (like a dial tone)
% out of several sine waves with different amplitudes and
% different frequencies (make up your own)
signal = 2*sin(240*t) + 5*sin(380*t) + 2.5*sin(700*t);
soundsc(signal) % play the sound (turn up the volume a bit)
\end{lstlisting}
\item[(b)] Now let's add some noise to the signal
\begin{lstlisting}
clear; clc;
dt = 0.001; % set up a time step
t = 0:dt:2*pi % set up time from 0 to 2pi
NoiseLevel = 10;
signal = 2*sin(240*t) + 5*sin(380*t) + 2.5*sin(700*t) + ...
NoiseLevel*rand(size(t)) - NoiseLevel/2;
soundsc(signal) % play the sound (turn up the volume a bit)
\end{lstlisting}
\item[(c)] Now we'll pull the dominant frequencies out of the signal. We do this by
taking advatnage of the orthogonal basis for the vector space of periodic functions.
Read the code below carefully and be sure you know exactly what it happening. \\
Note: the \mcode{trapz} function does the trapezoidal rule to approximate the integral
(yeah MATLAB!!).
\begin{lstlisting}
frequences = 1:1000; % list the frequencies we will try
for n=frequencies % try every frequency
c(n) = (1/pi)*trapz(signal .* sin(n*t))*dt; % integrate
end
\end{lstlisting}
\newpage
\item[(d)] Let's see which frequencies it found.
\begin{lstlisting}
DominantFrequencies = frequencies( c > 1 )
\end{lstlisting}
\item[(e)] Let's make a plot of the signal and the Fourier weights.
\begin{lstlisting}
subplot(1,3,1)
plot(t,signal) % plot noisy signal
xlabel('time'), ylabel('intensity'), title('Noisy Signal')
axis([0,0.1,-NoiseLevel , NoiseLevel])
subplot(1,3,2)
plot(frequences, c, 'r')
xlabel('frequency'), ylabel('intensity'),
title('Fourier Transform of Signal')
\end{lstlisting}
\item[(f)] And finally for the coolest part!! Let's trim out the noise!! We know what
the dominant frequencies are, so we can build a signal directly from them. This is
EXACTLY how digital signal processing works!!
\begin{lstlisting}
CleanSignal = zeros(size(t)); % set up space for the clean signal
for n=DominantFrequencies
CleanSignal = CleanSignal + c(n) * sin(n*t);
end
pause(2) % let matlab finish playing the old sound
soundsc(CleanSignal)
subplot(1,3,3)
plot(t,CleanSignal)
axis([0,0.1,-NoiseLevel,NoiseLevel])
\end{lstlisting}
\item[(g)] Now go have some fun! Some explorations to consider:
\begin{itemize}
\item How much noise can you add and still reasonably recover the original signal?
\item How complex can you make the signal and still recover it?
\item Can you (audibly) hide a single note but recover it perfectly?
\item \ldots
\end{itemize}
\end{enumerate}
\end{problem}
\newpage
\begin{problem}
Consider the function
\[ f(x) = \left\{ \begin{array}{cl} 1 & \text{ if } 0 < x < \pi \\ -1 & \text{ if }
\pi < x < 2\pi \end{array} \right..\]
We'll define $f(x)$ to have the value 0 at $0, \pm \pi, \pm 2\pi, \cdots$ and extend
the function periodically with period $2\pi$ forever. This way $f(x)$ is defined on
all real numbers.
We want to build a Fourier Series for this function (called the {\it square wave})
\[ f(x) = \sum_{k=1}^\infty C_k \sin(kx). \]
\begin{enumerate}
\item[(a)] From the previous problem you should have found that taking the inner
product of $f(x)$ and $\sin(kx)$ for every value of $k$ will result in the
value of $C_k$. Use this idea to find $C_1$.
\[ C_1 = \left< f(x) \, , \, \sin(1x) \right> = \frac{1}{\pi} \int_0^{2\pi}
f(x) \sin(1x) dx = \underline{\hspace{0.5in}} \]
(Hint: The integral can be broken into two relatively easy integrals if you think carefully about
$f(x)$.)
\item[(b)] Now find a general formula for $C_k$ by examining the inner product
\[ C_k = \left< f(x) \, , \, \sin(kx) \right> = \frac{1}{\pi} \int_0^{2\pi} f(x)
\sin(kx) dx = \underline{\hspace{0.5in}} \]
\item[(c)] Write the first several terms of the Fourier sine series for the square
wave.
\item[(d)] Use MATLAB to build a plot showing successive approximations of the
square wave.
\end{enumerate}
\end{problem}
\begin{problem}
Repeat the previous problem to find the Fourier series for the function
\[ f(x) = -\frac{1}{\pi}x + 1 \]
for $x \in [0,2\pi]$ and extended periodically outside the domain.
\end{problem}
% The notion of
% expanding periodic functions in terms of an infinite series of sines and cosines
% subsequently changed the world. He gave birth to the mathematical field of harmonic
% analysis and is still used today in digital and analog signal processing.
We will return to the idea of Fourier series in Chapter \ref{ch:PDEs} where we'll use Fourier series to
solve problems in heat conduction. We have also presented a bit of a
limited view in this section in that we have only allowed for Fourier {\it sine} series.
We can generalize the idea to a general Fourier series,
\[ f(x) = a_0 + \sum_{k=1}^\infty a_k \cos(kx) + \sum_{k=0}^\infty b_k \sin(kx), \]
where using both sine and cosine functions allows for more flexibility in the types of
functions we can model. The choice of inner product doesn't change and the cosine terms
have all of the wonderful properties as we had before with the sine functions.
% For now it seems as if it is an
% exercise in inner products and may even still seem a bit esoteric. Let's do one more
% problem to illustrate how cool the Fourier series really is!
%
% \begin{problem}
%
% \end{problem}
%
%
% Open MATLAB and complete the following partial code to plot an approximation to the
% Fourier series of the square wave.
% \begin{lstlisting}
% clear; clc;
% syms x
% f(x) = 0*x; % this gives a placeholder for the function
% N = 20; % the top end of the finite Fourier series
% for k=1:N
% C(k) = ... some code to find C(k) ...
% f(x) = f(x) + C(k) * sin(k*x);
% end
% ezplot(f(x) , [0,2*pi])
% \end{lstlisting}
% Once you have the plot working, append the code
% \begin{lstlisting}
% x = 0:0.01:150;
% MySound = double(f(x));
% soundsc(MySound)
% \end{lstlisting}
% \ldots and turn the volume up.
% \end{problem}
%
\newpage\section{Linear Transformations}
\begin{problem}
Loosly speaking, a {\bf linear transformation} in $\mathbb{R}^n$ transforms one set of
basis vectors to another. Go to
\href{https://shad.io/MatVis/}{https://shad.io/MatVis/} and use the slider bar to
experiment with how the standard basis in $\mathbb{R}^2$ transitions to other bases.
Specifically experiment with:
\begin{itemize}
\item[(a)] Can you create a linear transformation that only scales the coordinate
system?
\item[(b)] Can you create a linear transformation that only rotates the coordinate
system?
\item[(c)] What appears to happen to the determinant of the $1 \times 1$ square
under your transformation? What does this tell you about how the
transformation changes areas in $\mathbb{R}^2$?
\end{itemize}
\end{problem}
\begin{definition}[Linear Transformation]
A {\bf linear transformation} $T$ from a vector space $\mathcal{V}$ into a vector
space $\mathcal{W}$ is a rule that assigns to each vector $\bv \in \mathcal{V}$ a
unique vector $\bw \in \mathcal{W}$, such that
\begin{enumerate}
\item[(a)] $T(\bv_1 + \bv_2) = T(\bv_1) + T(\bv_2)$ for all $\bv_1, \bv_2 \in \mathcal{V}$
\item[(b)] $T(c\bv) = c T(\bv)$ for all $\bv \in \mathcal{V}$ and all scalars
$c$.
\end{enumerate}
More simply, a linear transformation has the property that
\[ T(c_1 \bv_1 + c_2 \bv_2) = c_1 T(\bv_1) + c_2 T(\bv_2) \]
for all $\bv_1 ,\bv_2 \in \mathcal{V}$ and for all scalars $c_1$ and $c_2$.
\end{definition}
\subsection{Matrix Transformation}
\begin{problem}
Verify that if $A$ is an $n \times n$ matrix then the function $T$ defined as $T(\bx) =
A\bx$ is indeed a linear transformation.
\end{problem}
\solution{
Yep. Matrix multiplication is a linear operation.
}
Since matrix multiplication is a linear transformation let's look at some of the common
matrix transformations. Matrix transformations commonly used in computer graphics are
{\it dilation}, {\it shear}, and {\it rotation}. Notice that the common geometric transformation of
{\it translation} is not a linear transformation since if we translate then the origin does not
stay fixed.
\begin{problem}
Consider the square defined by the set of points $S =
\{(0,0)\,,\,(1,0)\,,\,(1,1)\,,\,(0,1)\}$. Let $T(\bx)$ be a linear transformation
defined as $T(\bx) = A\bx$ where $A$ is a matrix and $\bx \in S$. Applying the
transformation $T$ to the points in $S$ gives a new geometric shape. Describe the
geometric action of each of the following transformations by applying them to the
points in $S$.
\begin{enumerate}
\item[(a)] $T(\bx) = A\bx$ where
\[ A = \begin{pmatrix} 1 & 3 \\ 0 & 1 \end{pmatrix} \]
\item[(b)] $T(\bx) = A\bx$ where
\[ A = \begin{pmatrix} 1 & 0 \\ 3 & 1 \end{pmatrix} \]
\item[(c)] $T(\bx) = A\bx$ where
\[ A = \begin{pmatrix} 5 & 0 \\ 0 & 5 \end{pmatrix} \]