forked from vasishth/MScStatisticsNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraduateCertificateNotes.Rnw
4916 lines (3415 loc) · 142 KB
/
GraduateCertificateNotes.Rnw
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
\documentclass[12pt]{book}
\usepackage{Sweave}
%% added by SV:
\usepackage{hyperref}
\hypersetup{colorlinks=TRUE,linkcolor=blue,anchorcolor=blue,filecolor=blue,pagecolor=blue,urlcolor=blue,citecolor=blue,bookmarksnumbered=true}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{gauss}
\usepackage[latin1]{inputenc}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{courier}
%
\usepackage{type1cm}
\usepackage{makeidx} % allows index generation
\usepackage{graphicx} % standard LaTeX graphics tool
% when including figure files
\usepackage{multicol} % used for the two-column index
\usepackage[bottom]{footmisc}% places footnotes at page bottom
\usepackage{amsthm}
\usepackage{esint}
\usepackage{cancel}
\usepackage{comment}
\excludecomment{answer}
%\includecomment{answer}
\setcounter{secnumdepth}{5}
%\newcommand{\vect}[1]{\boldsymbol{#1}}
\newcommand{\vect}[1]{\vec{#1}}
\newtheorem{definition}{Definition}
\newtheorem{theorem}{Theorem}
\newtheorem{fact}{Fact}
\newtheorem{proposition}{Proposition}
\usepackage{mathtools}
\makeatletter
\newcommand{\explain}[2]{\underset{\mathclap{\overset{\uparrow}{#2}}}{#1}}
\newcommand{\explainup}[2]{\overset{\mathclap{\underset{\downarrow}{#2}}}{#1}}
\makeatother
%% taken from http://brunoj.wordpress.com/2009/10/08/latex-the-framed-minipage/
\newsavebox{\fmbox}
\newenvironment{fmpage}[1]
{\begin{lrbox}{\fmbox}\begin{minipage}{#1}}
{\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}}
\hyphenation{distribu-tion}
\newcommand{\BlackBox}{\rule{1.5ex}{1.5ex}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\SweaveOpts{prefix.string=figures/statsnotesfig}
%\SweaveOpts{cache=TRUE}
\title{Notes to self\\
\small
on mathematics, probability theory, and statistics}
\author{Compiled by Shravan Vasishth}
\date{version of \today}
\DefineVerbatimEnvironment{Sinput}{Verbatim} {xleftmargin=2em}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{xleftmargin=2em}
\DefineVerbatimEnvironment{Scode}{Verbatim}{xleftmargin=2em}
\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}
\SweaveOpts{keep.source=TRUE}
\begin{document}
\SweaveOpts{concordance=TRUE}
\maketitle
\tableofcontents
<<echo=FALSE>>=
## customize
options(prompt="> ", continue=" ",
show.signif.stars=FALSE)
options(width=50)
options(SweaveHooks=list(fig=function() par(bg="white", fg="black")))
@
\chapter*{Preface}
It is worth noting that there is \textbf{absolutely nothing original} in terms of content in this document. As the title suggests, these are just notes for myself, for reviewing material I learnt in the Graduate Certificate in Statistics at Sheffield University (2011-12), and in the MSc at Sheffield (2012-2015). I try to remember to cite sources at the beginning of a section, but I might not do that consistently (sometimes I'm short on time). The references at the end of the document are an incomplete listing of the sources I consulted.
\begin{answer}
foobar
\end{answer}
\chapter{Helpful advice on studying math etc.}
%\begin{enumerate}
% \item Terry Tao's advice: \href{http://terrytao.wordpress.com/career-advice/}{http://terrytao.wordpress.com/career-advice/}
%\end{enumerate}
\chapter{Mathematics}
Sources: heavily depended on \cite{salas2003calculus}, \cite{spivak}, \cite{gilbertjordan} (the official textbook in the course), \cite{foxprimer} and various summaries on the internet on trigonometric functions.
\section{Homework assignments}
These assignments cover pretty much all the course material, so they are worth reviewing.
\begin{itemize}
\item Ass 0:
\begin{itemize}
\item Sets
\item Functions
\item Inequalities
\end{itemize}
\item Ass 1:
\begin{itemize}
\item Series
\item Partial Fractions and telescoping series
\item \textbf{Taylor, Maclaurin series}
\end{itemize}
\item Ass 2:
\begin{itemize}
\item \textbf{Integration methods}
\item Riemann integrals
\end{itemize}
\item Ass 3:
\begin{itemize}
\item Change of variables ($\int_0^\infty x^2 e^{-x^5}\, dx$)
\item Gamma function
\item Partial differentiation (level curves, lagrangian multipliers)
\item Vectors
\end{itemize}
\item Ass 4:
\begin{itemize}
\item Double integrals
\item Gaussian elimination
\item Inverse
\item Determinants
\end{itemize}
\item Ass 5:
\begin{itemize}
\item Polar coordinates
\item Linear independence
\item Diagonalization
\item Quadratic forms
\end{itemize}
\end{itemize}
\section{Trigonometry}
\subsection{Basic definitions}
\begin{figure}[!htbp]
\centering
\includegraphics[width=6cm]{triangle}
\caption{Right triangle.}
\label{fig:tri}
\end{figure}
\begin{equation}
\sin A = \frac{opp}{hyp} = \frac{a}{c}
\end{equation}
Cosine is the complement of the sine:
\begin{equation}
\cos A = \sin (90-A) = \sin B
\end{equation}
\begin{equation}
\cos A = \frac{b}{c}
\end{equation}
\subsection{Pythagorean identity}
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\begin{equation}
\begin{split}
\frac{a^2}{c^2} + \frac{b^2}{c^2} & = 1\\
\sin^2 A + \cos^2 A & = 1
\end{split}
\end{equation}
\subsection{Relations between trig functions}
\begin{equation}
\tan A = \frac{\sin A}{\cos A} = \frac{a}{c}/\frac{b}{c}= \frac{a}{b} =
\frac{opp}{adj}
\end{equation}
\begin{equation}
\cot A = \frac{1}{\tan A}=\frac{\cos A}{\sin A}
\end{equation}
\begin{equation}
\sec A = \frac{1}{\cos A}
\end{equation}
\begin{equation}
\csc A = \frac{1}{\sin A}
\end{equation}
%\begin{figure}[!htbp]
\begin{center}
\begin{fmpage}{.6\linewidth}
\begin{tabular}{c|c}
sin A = a/c (opp/hyp) & csc A = c/a (hyp/opp)\\
cos A = b/c (adj/hyp) & sec A = c/b (hyp/adj)\\
tan A = a/b (opp/adj) & cot A = b/a (adj/opp)\\
\end{tabular}
\end{fmpage}
\end{center}
%\end{figure}
Note that cot A = tan B, and csc A = sec B.
\subsection{Identities expressing trig functions in terms of their complements}
\begin{center}
\begin{fmpage}{.5\linewidth}
\begin{tabular}{c|c}
cos t = sin($\pi$/2-t) & sin t = cos($\pi$/2-t)\\
cot t = tan($\pi$/2-t) & tan t = cot($\pi$/2-t)\\
csc t = sec($\pi$/2-t) & sec t = csc($\pi$/2-t)\\
\end{tabular}
\end{fmpage}
\end{center}
\subsection{Periodicity}
\begin{center}
\begin{fmpage}{.5\linewidth}
\begin{tabular}{c|c}
$\sin t + 2\pi = \sin t$ & $\sin t + \pi = -\sin t$\\
$\cos t + 2\pi = \cos t$ & $\cos t + \pi = -\cos t$\\
$\tan t + 2\pi = \tan t$ & $\tan t + \pi = \tan t$\\
\end{tabular}
\end{fmpage}
\end{center}
\begin{center}
\begin{fmpage}{.6\linewidth}
\begin{tabular}{ccc}
$\sin 0 = 0$ & $\cos 0 = 1$ & $\tan 0 = 0$ \\
$\sin \frac{\pi}{2} = 1$ & $\cos \frac{\pi}{2} = 0$ & $\tan \frac{\pi}{2}$ undefined \\
$\sin \pi = 0$ & $\cos \pi = -1$ & $\tan \pi = -1$ \\
\end{tabular}
\end{fmpage}
\end{center}
\subsection{Law of cosines}
Three ways of writing it:
\begin{equation}
c^2 = a^2 + b^2 - 2ab \cos C
\end{equation}
\begin{equation}
a^2 = b^2 + c^2 - 2bc \cos C
\end{equation}
\begin{equation}
b^2 = c^2 + a^2 - 2ca \cos C
\end{equation}
\subsection{Law of sines}
\begin{equation}
\frac{\sin A}{a}=\frac{\sin B}{b}=\frac{\sin C}{c}
\end{equation}
\subsection{Odd and even functions}
A function $f$ is said to be an odd function if for any number $x$, $f(-x) = -f(x)$ (e.g., $f(y)=x^5$). A function $f$ is said to be an even function if for any number $x$, $f(-x) = f(x)$ (e.g., $f(y)=x^4$).
Odd functions: sin, tan, cotan, csc.
Even functions: cos, sec.
%$\sin $ is odd ($\sin -t=-\sin t $), $\cos$ is even ($\cos -t=\cos t $).
\subsection{Sum formulas for sine and cosine}
\begin{equation}
\sin (s + t) = \sin s \cos t + \cos s \sin t
\end{equation}
\begin{equation}
\cos (s + t) = \cos s \cos t - \sin s \sin t
\end{equation}
\subsection{Double angle formulas for sine and cosine}
\begin{equation}
\sin 2t = 2 \sin t \cos t
\end{equation}
\begin{equation}
\cos 2t = \cos^2 t - \sin^2 t = 2 \cos^2 t - 1 = 1 - 2 \sin^2 t
\end{equation}
\subsection{Less important identities}
Pythagorean formula for tan and sec:
\begin{equation}
\sec^2 t = 1 + \tan^2 t
\end{equation}
Identities expressing trig functions in terms of their supplements
\begin{equation}
\sin(\pi - t) = \sin t
\end{equation}
\begin{equation}
\cos(\pi - t) = -\cos t
\end{equation}
\begin{equation}
\tan(\pi - t) = -\tan t
\end{equation}
Difference formulas for sine and cosine
\begin{equation}
\sin (s - t) = \sin s \cos t - \cos s \sin t
\end{equation}
\begin{equation}
\cos (s - t) = \cos s \cos t + \sin s \sin t
\end{equation}
\section{Basic differentiation}
\subsection{Diff.\ from first principles}
Given a function $f(x)$, the derivative from first principles is:
\begin{equation}
f^{(1)}(x)= \frac{f(x+\delta x) - f(x)}{\delta x}
\end{equation}
\subsection{Derivations of combinations of functions}
\begin{equation}
(uv)' = uv' + vu'
\end{equation}
\begin{equation}
(u/v)' = \frac{vu' - uv'}{v^2}
\end{equation}
derivations of trig functions
\subsection{Leibniz' rule}
This is about successive differentiation of products of functions $uv$:
\begin{equation}
uv^{(n)}=u^{(n)}v + {n \choose 1}u^{(n-1)}v^{(1)} + \dots + {n \choose r}u^{(n-r)}v^{(r)} + uv^{(n)}
\end{equation}
\section{Series}
\subsection{Arithmetic series}
General form:
\begin{equation}
a+(a+d)+(a+2d)+\dots
\end{equation}
$k$-th partial sum for \textbf{arithmetic series}:
\begin{equation}
S_k = \underset{n=1}{\overset{k}{\sum}} (a+(n-1)d)
\end{equation}
The sum can be found by:
\begin{equation}
S_k = \frac{k}{2} (2a+(k-1)d)
\end{equation}
\subsection{Geometric series}
General form:
\begin{equation}
a+ar+ar^2\dots
\end{equation}
In summation notation:
\begin{equation}
\underset{n=1}{\overset{\infty}{\sum}} ar^{n-1}
\end{equation}
$k$-th partial sum:
\begin{equation}
S_k=\frac{a-(1-r^k)}{1-r}
\end{equation}
$S_\infty$ exists just in case $\mid r \mid < 1$.
\begin{equation}
S_\infty = \frac{a}{1-r}
\end{equation}
\subsection{Clever trick for computing partial sums of geometric series}
to-do (see my P-Ass1 solution)
\subsection{Power series}
\begin{equation}
\underset{n=0}{\overset{\infty}{\sum}} a_n (x-a)^n
\end{equation}
\textbf{radius of convergence}: to-do
\subsection{Taylor's theorem (Taylor series)}
We can represent a function as a power series (SV: not sure if we can do this for any function):
\begin{equation}
f(x)= a_0 + a_1 (x-a) + a_2 (x-a)^2 + \dots + a_n (x-a)^n + R_n (x)
\end{equation}
\noindent
where $R_n (x)$ is the remainder term (a power series beginning with $a_{n+1} (x-a)^{n+1}$).
\textbf{Taylor's theorem}: Let $f$ be a function that is $n+1$ times differentiable on an open interval containing points a and x. Then
\begin{equation}
f(x)= f(a) + f^{(1)} \frac{(x-a)^1}{1!} + f^{(2)} \frac{(x-a)^2}{2!} + \dots + f^{(n)} \frac{(x-a)^n}{n!} + R_n (x)
\end{equation}
\noindent
where $R_n (x) = f^{(n+1)} (c) \frac{(x-a)^n+1}{n+1!}$, $c$ is some point between a and x.
\textbf{Taylor series}: If $R_n (x)$ tends to zero as $n\rightarrow \infty$, then the series in the above theorem converges and is called the Taylor series:
\begin{equation}
\underset{n=0}{\overset{\infty}{\sum}} f^{(n)} \frac{(x-a)^n}{n!}
\end{equation}
basic taylor series: p. 91
combination rules for power series: p. 75
\subsection{Maximizing and minimizing functions}
\subsection{Partial derivatives}
\subsubsection{Chain rule for partial derivatives}
\subsection{Maxima and minima in higher dimensions}
\subsection{Lagrangian multipliers}
\section{Integration}
\subsection{Riemann sums}
A simple example comes from M-Ass-2-problem-2:
Given $\phi (x)$, the probability density function of the standard normal distribution:
\begin{equation*}
\phi (x) = \frac{1}{\sqrt{2\pi}} e^{-x^{2}/2}
\end{equation*}
We have to find an approximate value of
\begin{equation*}
\int_0^1 \phi (x)\, dx
\end{equation*}
We divide the interval $[0,1]$ into $10$ intervals of width $1/10$, and approximate the area under the curve by taking the sum of the $10$ rectangles under the curve. The width of each rectangle will be $\delta x=1/10$, and each of the ten $x_i$ are $1/10,2/10,\dots,10/10$, i.e., $i/10$, where $i=1,\dots, 10$.
The area $A$ can be computed by summing up the areas of the ten rectanges. Each rectangle's area is length $\times$ width, which is $\phi(x_i) \times \delta x$. Hence,
\begin{equation*}
A= \underset{i=1}{\overset{10}{\sum}} \phi(x_i) \delta x = \underset{i=1}{\overset{10}{\sum}}
\frac{1}{\sqrt{2\pi}} e^{-x_i^{2}/2} \times \frac{1}{10}
\end{equation*}
The constant terms $\frac{1}{\sqrt{2\pi}}$ and $\frac{1}{10}$ can be pulled out of the summation:
\begin{equation*}
A= \frac{1}{\sqrt{2\pi}} \frac{1}{10}
\underset{i=1}{\overset{10}{\sum}}
e^{-x_i^{2}/2}
\end{equation*}
We use R for the above calculations. First, we define the function for $e^{-x_i^{2}/2}$:
<<>>=
my.fn<-function(x)
{exp(1)^(-(x^2/2))}
@
Then we define $x_i$ (I made the code very general so that the number of intervals $n$ can be increased arbitrarily) and plug this into the function:
<<>>=
n<-10
(x.i<-(1:n)/n)
A<- ((1/n) * (1/sqrt(2 * pi)) * sum(my.fn(x.i)))
(A<-round(A,digits=5))
@
Compare this to the exact value, computed using R:
<<>>=
fprob2<-function(x){
(1/sqrt(2 * pi))*exp(1)^(-(x^2/2))
}
integrate(fprob2,lower=0,upper=1)
@
\textbf{Answer}: The approximate area is: $\Sexpr{A}$. This is a bit lower than the value in Neave's tables or the value computed by R, but this is because the ten rectangles fall inside the curve.
<<>>=
## As an aside, note that one can get really close
## to Neave's value by increasing $n$,
## say to a high number like 2000:
n<-2000
## 2000 rectangles now:
x.i<-(1:n)/n
(A<- ((1/n) * (1/sqrt(2 * pi)) * sum(my.fn(x.i))))
@
With 2000 rectangles, we can get a better estimate of the area than with 10 rectangles: \Sexpr{A}.
\subsection{Some common integrals}
\begin{equation}
\int \frac{1}{x}\, dx = \log \mid x \mid + c
\end{equation}
\begin{equation}
\int \log x\, dx = \frac{1}{x} + c
\end{equation}
\subsection{The Fundamental Theorem of Calculus}
The Fundamental Theorem states the following:
Let $f$ be a continuous real-valued function defined on a closed interval $[a, b]$. Let $F$ be the function defined, for all $x$ in $[a, b]$, by
\begin{equation*}
F(x) = \int_a^x f(u)\, du
\end{equation*}
Then, $F$ is continuous on $[a, b]$, differentiable on the open interval $(a, b)$, and
\begin{equation*}
F'(x) = f(x)
\end{equation*}
for all $x $ in $(a, b)$.
\subsection{Rules of integration}
\subsection{Standard integrals}
\subsection{The u-substitution}
From \cite[306]{salas2003calculus}:
An integral of the form
\begin{equation}
\int f(g(x)) g'(x) \, dx
\end{equation}
can be written as
\begin{equation}
\int f(u) \, du
\end{equation}
by setting
\begin{equation}
u = g(x)
\end{equation}
and
\begin{equation}
du = g'(x) \, dx
\end{equation}
If F is an antiderivative for f, then
\begin{equation}
\frac{d}{dx} [F(g(x))] \explain{=}{\textrm{by the chain rule}} F'(g(x)) g'(x) \explain{=}{F'=f} f(g(x)) g'(x)
\end{equation}
We can obtain the same result by calculating:
\begin{equation}
\int f(u) \, du
\end{equation}
and then substituting g(x) back in for u:
\begin{equation}
\int f(u) \, du = F(u)+C = F(g(x)) + C
\end{equation}
\textbf{A frequently occurring type of integral} is
\begin{equation}
\int \frac{g'(x)}{g(x)} \, dx
\end{equation}
Let $u=g(x)$, giving $\frac{du}{dx}=g'(x)$, i.e., $du = g'(x)\,dx$, so that
\begin{equation}
\int \frac{g'(x)}{g(x)}\,dx=\int \frac{1}{u} du = ln \mid u \mid +C
\end{equation}
\begin{center}
\begin{fmpage}{.5\linewidth}
\textbf{Examples}:
\begin{equation*}
\int \tan x \, dx = \int \frac{1}{\cos x} \sin x \, dx
\end{equation*}
\begin{equation*}
\int \frac{2x + b}{x^2+bx + c} \, dx
\end{equation*}
\end{fmpage}
\end{center}
\textbf{Functions of linear functions}: E.g., $\int cos(2x-1)\,dx$. Here, the general form is $\int f(ax+b)\,dx$. We do $u=ax+b$, and then $du=a \,dx$
\begin{center}
\begin{fmpage}{.9\linewidth}
\textbf{Using integration by substitution to compute the expectation of a standard normal random variable}:
The expectation of the standard normal random variable:
\begin{equation*}
E[Z] = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^\infty x e^{-x^2/2} \, dx
\end{equation*}
Let $u = -x^2/2$.
Then, $du/dx = -2x/2=-x$. I.e., $du= -x \, dx$ or $-du=x \, dx$.
We can rewrite the integral as:
\begin{equation*}
E[Z] = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^\infty e^{u} x \, dx\\
\end{equation*}
Replacing $x\, dx$ with $-du$ we get:
\begin{equation*}
-\frac{1}{\sqrt{2\pi}} \int_{-\infty}^\infty e^{u} \, du
\end{equation*}
which yields:
\begin{equation*}
-\frac{1}{\sqrt{2\pi}} [ e^{u} ]_{-\infty}^{\infty}
\end{equation*}
Replacing $u$ with $-x^2/2$ we get:
\begin{equation*}
-\frac{1}{\sqrt{2\pi}} [ e^{-x^2/2} ]_{-\infty}^{\infty} = 0
\end{equation*}
\end{fmpage}
\end{center}
\begin{center}
\begin{fmpage}{.9\linewidth}
\textbf{Examples}:
\begin{itemize}
\item From M-Ass2-problem-4a:
Use a substitution to find:
\begin{equation*}
\int_1^4 x^2 e^{-x^3}\, dx
\end{equation*}
\item From M-Ass2-problem-4b:
Use a substitution to find
\begin{equation*}
\int_1^4 \frac{1+2 \log_e x}{x} \, dx
\end{equation*}
\item From M-Ass2-problem-5:
We have to use an appropriate substitution to find the indefinite integral:
\begin{equation*}
\int x e^{-x^2}\, dx
\end{equation*}
Then,
use the answer to the above to calculate:
\begin{equation*}
\int_0^\infty x e^{-x^2}\, dx
\end{equation*}
Then, we have to use integration by parts (using the first answer above) to find a reduction formula for:
\begin{equation}\label{eq5c}
I_n = \int_0^{\infty} x^n e^{-x^2}\, dx
\end{equation}
[Note: this last problem needs a certain amount of concentration, so make yourself comfortable before you start.]
\end{itemize}
\end{fmpage}
\end{center}
\subsection{Integration by parts}
\begin{equation}
\frac{d(uv)}{dx} = u\frac{dv}{dx} + \int v\frac{du}{dx}
\end{equation}
\begin{equation}
uv = \int u\frac{dv}{dx}\, dx + \int v\frac{du}{dx}\, dx
\end{equation}
\begin{equation}
\int u\frac{dv}{dx}\, dx = uv - \int v\frac{du}{dx}\, dx
\end{equation}
\begin{center}
\begin{fmpage}{.9\linewidth}
\textbf{Examples}:
From M-Ass2-problem-4c: Use integration by parts to find
\begin{equation*}
\int_0^{\pi/2} \sin (2x) e^{-x}\, dx
\end{equation*}
The trick here: get the same expression on the right-hand side (RHS) as you have on the LHS, and then solve for the LHS.
\end{fmpage}
\end{center}
\subsection{Change of variables (gamma functions)}
We can solve integrals like
\begin{equation}
\int_0^\infty x^2 e^{-x^5}\, dx
\end{equation}
by restating it as the gamma function:
\begin{equation}
\Gamma (z) = \int_0^\infty x^{z-1}e^{-x}\, dx
\end{equation}
This can be done by, e.g., letting $y=x^5$, so that $dy/dx= 5x^4$, and therefore $dx= dy/5x^4 = dy/5*y^{4/5}$. This lets us rewrite the above integral in terms of y:
\begin{equation}
\frac{y^{2/5}}{5y^{4/5}}e^y\, dy
\end{equation}
This has the form of the gamma function, allowing us to state the integral in terms of the gamma function.
Note that
\begin{equation}
\Gamma(z) = (z-1) \Gamma (z-1)
\end{equation}
\subsection{Double integrals}
\subsection{Change of variables in multiple integration}
\subsection{Vectors}
A vector is an ordered triple. It has a geometric interpretation only when the coordinates are established.
\begin{equation}
\vect{a} = (x_1,y_1,z_1)
\end{equation}
\textbf{Norm}
\begin{equation}
\lVert \vect{a} \rVert = \sqrt{x_1^2 + y_1^2 + z_1^2}
\end{equation}
Vectors of norm 1 are called unit vectors. For each non-zero vector there is a unit vector going in the same direction.
\begin{equation}
u_{\vect{a}} = \frac{1}{\lVert \vect{a} \rVert}
\end{equation}
Also, every vector can be expressed as a linear combination of these three unit vectors:
\begin{equation}
\vect{i} = (1,0,0) \quad \vect{j} = (0,1,0) \quad \vect{k} = (0,0,1)
\end{equation}
I.e., if
\begin{equation}
\vect{a} = (x_1,y_1,z_1)
\end{equation}
then
\begin{equation}
\vect{a} = x_1 \vect{i} + y_1 \vect{j} + z_1 \vect{k}
\end{equation}
Dot product:
\begin{equation}
\vect{a}\cdot \vect{b} = a_1 b_1 + a_2 b_2 + a_3 b_3
\end{equation}
Note that
\begin{equation}
\vect{a}\vect{a} = \mid\mid \vect{a} \mid \mid ^2
\end{equation}
and
\begin{equation}
\vect{a}\cdot \vect{b} = \mid\mid\vect{a} \vect{b}\mid\mid \cos \theta
\end{equation}
Also,
\begin{equation}
\cos \theta = u_{\vect{a}} \cdot u_{\vect{b}}
\end{equation}
\section{Linear Algebra}
This section depends heavily on \cite{evenslinalg}, and sometimes I quote exactly from this book.
\subsection{Gaussian elimination for solving systems of linear equations}
Elementary row operations (note that these are reversible, and the effect of any sequence of row operations on a system of equations is to produce an equivalent system of equations):
\begin{enumerate}
\item \textbf{Replacement}: Replace one equation by the sum of itself and a multiple of another equation
\item \textbf{Interchange}: Interchange two equations
\item \textbf{Scaling}: Multiply all the terms of an equation by a nonzero constant
\end{enumerate}
\begin{definition}\label{def:roweq}
\textbf{Row equivalent}: Two matrices are row equivalent if a sequence of elementary row operations can transform one matrix to the other.
\end{definition}
\begin{definition}\label{def:echelon}
\textbf{Echelon form}: example:
\begin{equation}
\begin{pmatrix}
\explain{3}{pivot position} & 1 & 1 \\
0 & 4 & -1 \\
\explain{0}{pivot column} & 0 & 7
\end{pmatrix}
\end{equation}
\end{definition}
\begin{definition}\label{def:redechelon}
\textbf{Reduced echelon form}: example:
\begin{equation}
\begin{pmatrix}
1 & 1 & 1 \\
0 & 1 & -1 \\
0 & 0 & 1
\end{pmatrix}
\end{equation}
\end{definition}
\begin{theorem}\label{thm:consistent}
\textbf{Consistency}:
A linear system is consistent iff the rightmost column of an augmented matrix is not a pivot column, i.e.,
$[0 \cdots 0 b]$ with $b$ nonzero.
\end{theorem}
[A leading non-zero entry of a row, when used in this way, is called a
{\it pivot}.
]
\textbf{Identity matrix}
Multiplying a matrix by its inverse (see below) gives an identity matrix (the R function solve computes the inverse of a matrix):
<<>>=
(m3<-matrix(c(2,3,4,5),2,2))
(round(solve(m3)%*%m3))
@
And multiplying an identity matrix with any (conformable) matrix gives that matrix:
<<>>=
(I<-matrix(c(1,0,0,1),2,2))
(m4<-matrix(c(6,7,8,9),2,2))