Skip to content

Assignment 1 and 2 solutions added to the book #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2be6a98
analytical ridge regression removed some redundand material from prio…
clippert May 5, 2025
4a278d3
analytical ridge regression renamed chapter
clippert May 5, 2025
586b682
quadratic optimization
clippert May 5, 2025
fb7579f
renamed section of ridge to quadratic optimization
clippert May 5, 2025
634b4ed
renamed section of ridge to quadratic optimization
clippert May 5, 2025
7cfbd66
changed toc for remaining content
clippert May 5, 2025
7de6a28
added taylors theorem
clippert May 6, 2025
adc9903
added taylors theorem
clippert May 6, 2025
c941752
Taylors theorem
clippert May 7, 2025
8839607
Taylors theorem
clippert May 7, 2025
ba51855
se ction on analytic functions in taylor
clippert May 7, 2025
ee71947
fix typo in Clairuts theorem
clippert May 7, 2025
d7208b8
increased degree of taylor approximation and moved approximation poin…
clippert May 7, 2025
11ad6e9
increased degree of taylor approximation and moved approximation poin…
clippert May 7, 2025
cb1b6fb
increased degree of taylor approximation and moved approximation poin…
clippert May 8, 2025
5978199
created stubs for next chapter decompositions
clippert May 8, 2025
1595f12
monday lecture done. PLU section slightly messy still
clippert May 12, 2025
3525164
week 5 up to quadratic forms
clippert May 13, 2025
b13e574
merged w05
clippert May 13, 2025
9399e32
material w06
clippert May 14, 2025
9f36e59
week 1 and 2 sheet solutions added to the book
Arman-Beykmohammadi May 15, 2025
ebe39a5
draft material w05
clippert May 15, 2025
4fa9a00
added PCA section
clippert May 16, 2025
6aadc18
fixed bugs
clippert May 19, 2025
53e548f
added back fixed version of Rayleih quotients no warnings compilation
clippert May 20, 2025
85f8c34
added stubs of matrix_norms and pseudoinverse
clippert May 20, 2025
fd4934d
stubs for convexity and mercers theorem
clippert May 20, 2025
e255adb
stubs for representer theorem
clippert May 20, 2025
5d16a17
week 3 solutions added to the book
Arman-Beykmohammadi May 21, 2025
a1a9e78
Merge branch 'HealthML:main' into w12_solutions
Arman-Beykmohammadi May 21, 2025
cc9cfcb
separated convex sets and functions into files
clippert May 22, 2025
31a921a
separated convex sets and functions into files
clippert May 22, 2025
ae56088
fixed propostion label
clippert May 23, 2025
dad61a0
fixed propostion label
clippert May 23, 2025
d69dfe2
created figures for convexity and removed all errors and warnings
clippert May 23, 2025
902b859
changed format of proof in svd
clippert May 25, 2025
fef720f
material for w06
clippert May 25, 2025
366b36a
added collaborative filtering example
clippert May 25, 2025
35f51f4
bugfix yAy
clippert May 26, 2025
26454d3
material wednesday
clippert May 27, 2025
413fd33
bugfix
clippert May 28, 2025
cd702a3
mm
clippert May 30, 2025
161f1a7
fixed small bug in svd (unkown target name 5)
clippert May 30, 2025
79b3197
Exercise 4 solutions added to the book
Arman-Beykmohammadi May 30, 2025
bc0648f
Merge branch 'HealthML:main' into w12_solutions
Arman-Beykmohammadi May 30, 2025
931620a
Merge branch 'w12_solutions' of github.com:Arman-Beykmohammadi/Math4M…
Arman-Beykmohammadi May 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 48 additions & 18 deletions book/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ parts:
chapters:
# week 1
- file: chapter_ml_basics/intro
title: Machine Learning Basics
title: Machine Learning Problems
sections:
- file: chapter_ml_basics/classification
title: Classification
Expand Down Expand Up @@ -66,25 +66,45 @@ parts:
- file: chapter_calculus/minima_first_order_condition
title: First Order Condition
- file: chapter_calculus/analytical_solution_ridge
title: Ridge Regression
title: Quadratic Optimization
- file: chapter_calculus/line_search
title: Line Search
- file: chapter_calculus/hessian
title: Hessian
- file: chapter_calculus/taylors_theorem
# - file: chapter_calculus/irls
# title: Iteratively Re-Weighted Least Squares
# study the properties of matrices
# - file: chapter_decompositions/overview_decompositions # chapter_linear_algebra/linear_algebra
# sections:
# - file: chapter_decompositions/eigenvectors
# - file: chapter_decompositions/trace_determinant
# - file: chapter_decompositions/orthogonal_matrices
# - file: chapter_decompositions/symmetric_matrices
# - file: chapter_decompositions/psd_matrices
# - file: chapter_decompositions/svd
# - file: chapter_decompositions/big_picture
# - file: chapter_decompositions/pseudoinverse
# - file: chapter_decompositions/low_rank_approximation
# - file: chapter_decompositions/matrix_norms
- file: chapter_decompositions/overview_decompositions
title: Matrix Analysis
sections:
- file: chapter_decompositions/matrix_rank
- file: chapter_decompositions/determinant
- file: chapter_decompositions/row_equivalence
- file: chapter_decompositions/square_matrices
- file: chapter_decompositions/trace
- file: chapter_decompositions/eigenvectors # end week 05
- file: chapter_decompositions/orthogonal_matrices
- file: chapter_decompositions/symmetric_matrices
- file: chapter_decompositions/Rayleigh_quotients
- file: chapter_decompositions/matrix_norms
- file: chapter_decompositions/psd_matrices
- file: chapter_decompositions/pca # PCA as example for the eigenvalue decomposition of a psd matrix
title: Principal Components Analysis
- file: chapter_decompositions/svd #
# - file: chapter_decompositions/RBF_kernel_Positive_Definite
- file: chapter_decompositions/pseudoinverse
- file: chapter_decompositions/orthogonal_projections
- file: chapter_decompositions/big_picture
title: Fundamental Subspaces
# - file: chapter_decompositions/representer_theorem
# - file: chapter_convexity/overview_convexity
# title: Convexity
# sections:
# - file: chapter_convexity/convex_sets
# - file: chapter_convexity/convex_functions
# continue with second order optimization
# title: Second-Order Optimization
# - file: chapter_calculus/newtons_method
# title: Newton's Method
# - file: chapter_taylor/minima_second_order_condition
Expand All @@ -93,16 +113,13 @@ parts:
# - file: chapter_calculus/orthogonal_projections
# - file: chapter_taylor/overview_taylor
# sections:
# - file: chapter_convexity/overview_convexity
# sections:
# - file: chapter_convexity/convexity
# - file: chapter_optimization/overview_optimization
# sections:
# - file: chapter_optimization/optimization
# - file: chapter_optimization/optimization_second_order
# - file: chapter_optimization/bfgs
# - file: chapter_optimization/orthogonal_projection
# - file: chapter_probability/overview_probability
# title: Probability and Random Variables
# sections:
# - file: chapter_probability/probability_basics
# - file: chapter_probability/random_variables
Expand Down Expand Up @@ -149,8 +166,21 @@ parts:
title: First Fundamental Theorem of Calculus
- file: appendix/second_fundamental_theorem_calculus
title: Second Fundamental Theorem of Calculus
- file: appendix/Clairauts_theorem
title: Clairaut's Theorem
- file: appendix/differentiation_rules
title: Differentiation Rules
- file: appendix/Exercise Sheet Solutions.md
title: Exercise Sheet Solutions
sections:
- file: appendix/Exercise Sheet 1 Solutions.md
title: Exercise Sheet 1 Solutions
- file: appendix/Exercise Sheet 2 Solutions.md
title: Exercise Sheet 2 Solutions
- file: appendix/Exercise Sheet 3 Solutions.md
title: Exercise Sheet 3 Solutions
- file: appendix/Exercise Sheet 4 Solutions.md
title: Exercise Sheet 4 Solutions
# sections:
# - file: appendix/proof_vector_spaces
# title: Vector Spaces
77 changes: 77 additions & 0 deletions book/appendix/Clairauts_theorem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Symmetry of Mixed Partial Derivatives (Clairaut’s Theorem)

:::{prf:theorem} Clairaut Schwarz
:label: thm-Clairaut-appendix
:nonumber:

Let $f: \mathbb{R}^2 \to \mathbb{R}$ be a function such that both mixed partial derivatives $\frac{\partial^2 f}{\partial x \partial y}$ and $\frac{\partial^2 f}{\partial y \partial x}$ exist and are **continuous** on an open set containing a point $(x_0, y_0)$

Then:

$$
\boxed{
\frac{\partial^2 f}{\partial x \partial y}(x_0, y_0) = \frac{\partial^2 f}{\partial y \partial x}(x_0, y_0)
}
$$

That is, **the order of differentiation can be interchanged**.
:::

## Intuition

If a function is smooth enough (specifically, if the second-order partial derivatives exist and are continuous), then the "curvature" in the $x$ direction after differentiating in the $y$ direction is the same as the curvature in the $y$ direction after differentiating in the $x$ direction.

---

## Proof Sketch

We will sketch a proof using the **mean value theorem** and the definition of partial derivatives. Let’s assume that $f$ has continuous second partial derivatives in an open rectangle around the point $(x_0, y_0)$.

Define:

$$
F(h,k) = \frac{f(x_0 + h, y_0 + k) - f(x_0 + h, y_0) - f(x_0, y_0 + k) + f(x_0, y_0)}{hk}
$$

Then, as $h, k \to 0$, $F(h,k) \to \frac{\partial^2 f}{\partial y \partial x}(x_0, y_0)$ and also $F(h,k) \to \frac{\partial^2 f}{\partial x \partial y}(x_0, y_0)$, provided the second partial derivatives are continuous.

### Step-by-step:

1. By the **Mean Value Theorem**, the numerator of $F(h,k)$ can be interpreted as a finite difference approximation to a mixed partial derivative.
2. Using Taylor’s Theorem with remainder, or via integral representations of derivatives, one can show that:

$$
\lim_{(h,k) \to (0,0)} F(h,k) = \frac{\partial^2 f}{\partial x \partial y}(x_0, y_0)
$$

and also

$$
\lim_{(h,k) \to (0,0)} F(h,k) = \frac{\partial^2 f}{\partial y \partial x}(x_0, y_0)
$$

due to continuity of the second derivatives.
3. Hence, the limits agree and the mixed partials are equal.

Therefore:

$$
\frac{\partial^2 f}{\partial x \partial y}(x_0, y_0) = \frac{\partial^2 f}{\partial y \partial x}(x_0, y_0)
$$

---

## When Clairaut's Theorem **Does Not Apply**

If the second-order mixed partial derivatives exist but are **not continuous**, the symmetry may fail. A classic counterexample is:

$$
f(x, y) =
\begin{cases}
\frac{xy(x^2 - y^2)}{x^2 + y^2}, & \text{if } (x, y) \neq (0, 0) \\
0, & \text{if } (x, y) = (0, 0)
\end{cases}
$$

This function has both mixed partial derivatives at the origin, but they are not equal because they are not continuous there.

60 changes: 60 additions & 0 deletions book/appendix/Exercise Sheet 1 Solutions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Exercise Sheet 1 Solutions


### 1.
#### (a)
Take any \(v_1=(a,b)\) and \(v_2=(c,d)\) in \(V\); then \(b=3a+1\) and \(d=3c+1\).
Their sum is
\[
v_1+v_2=(a+c,\;b+d)=(a+c,\;3a+1+3c+1)=\bigl(a+c,\;3(a+c)+2\bigr),
\]
which **does not** satisfy \(b+d=3(a+c)+1\). Hence \(V\) is *not* closed under addition ⇒ **not a vector space**.
(Equivalently, the additive identity \((0,0)\notin V\), violating axiom V1.)

#### (b)
All axioms except **distributivity over scalar addition** fail:

Take \(v=(a,b)\) and scalars \(\alpha,\beta\in\mathbb R\).
\[
(\alpha+\beta)\,v=((\alpha+\beta)a,\;b),
\quad
\alpha v+\beta v=(\alpha a,\;b)+(\beta a,\;b)=((\alpha+\beta)a,\;2b).
\]
Unless \(b=0\), the second component differs, so
\((\alpha+\beta)v\neq\alpha v+\beta v\).
Therefore \(V\) is **not** a vector space.


### 2.
#### (a)
*Zero vector:* \((0,0)\) satisfies \(0=2\cdot0\).
*Closure (addition):* if \(y_1=2x_1\) and \(y_2=2x_2\), then
\[
y_1+y_2 = 2(x_1+x_2).
\]
*Closure (scalar mult.):* for \(\alpha\in\mathbb R\),
\[
\alpha(x,y)=(\alpha x,\;2\alpha x).
\]
All three conditions hold ⇒ \(W\) **is a subspace**.

#### (b)
Pick \((x,y)\in W\) with \(x>0\) and any negative scalar \(\alpha<0\).
Then
\[
\alpha(x,y)=(\alpha x,\;\alpha y),
\]
and \(\alpha x<0\). Thus \(\alpha(x,y)\notin W\).
Not closed under scalar multiplication ⇒ **not a subspace**.


### 3.
For \(x=(a,b)\), \(y=(c,d)\) and scalars \(\alpha,\beta\):
\[
T(\alpha x+\beta y)=\bigl((\alpha a+\beta c)^{2},\;\alpha b+\beta d\bigr),
\]
\[
\alpha T(x)+\beta T(y)=\bigl(\alpha^{2}a^{2}+\beta^{2}c^{2},\;\alpha b+\beta d\bigr).
\]
The first components differ unless \(a c=0\) or \(\alpha\beta=0\).
Hence \(T\) **violates additivity/homogeneity ⇒ not linear**.
Loading