05 Calculus: Extrema, Convexity, and Taylor Series

image.png լուսանկարի հղումը, Գյումրի, Ֆրունզիկ, Հեղինակ՝ Robert Levonyan

📚 Նյութը ToDo

🏡 Տնային

Note
  1. ❗❗❗ DON’T CHECK THE SOLUTIONS BEFORE TRYING TO DO THE HOMEWORK BY YOURSELF❗❗❗
  2. Please don’t hesitate to ask questions, never forget about the 🍊karalyok🍊 principle!
  3. The harder the problem is, the more 🧀cheeses🧀 it has.
  4. Problems with 🎁 are just extra bonuses. It would be good to try to solve them, but also it’s not the highest priority task.
  5. If the problem involve many boring calculations, feel free to skip them - important part is understanding the concepts.
  6. Submit your solutions here (even if it’s unfinished)

Extrema

01 Box Problem

image.png

Video Solution in Armenian

02 Finding Local Extrema

Let \(f : [-1,2] \to \mathbb{R}, x \mapsto \exp(x^3 - 2x^2)\).

  1. Compute \(f'(x)\).

  2. Plot \(f\) and \(f'\) (you can use any graphing tool or software).

  3. Find all possible candidates \(x^*\) for maxima and minima.

    Hint: \(\exp\) is a strictly monotone function.

  4. Compute \(f''(x)\).

  5. Determine if the candidates are local maxima, minima or neither.

  6. Find the global maximum and global minimum of \(f\) on \([-1,2]\).

Convexity

03 Convex Function Properties

Consider two convex functions \(f,g : \mathbb{R} \to \mathbb{R}\).

  1. Show that \(f + g\) is convex.

  2. Now, assume that \(g\) is additionally non-decreasing, i.e., \(g(y) \geq g(x)\) for all \(x \in \mathbb{R}\), for all \(y \in \mathbb{R}\) with \(y > x\). Show that \(g \circ f\) is convex.

04 Testing Convexity in ML Functions

Determine whether the following ML-related functions are convex, concave, or neither on the given intervals:

  1. Mean Squared Error: \(L(w) = \frac{1}{2}(w - 3)^2\) on \(\mathbb{R}\)
  2. ReLU Activation: \(\text{ReLU}(x) = \max(0, x)\) on \(\mathbb{R}\)
  3. Sigmoid Function: \(\sigma(x) = \frac{1}{1 + e^{-x}}\) on \(\mathbb{R}\)

05 L2-Regularized Linear Regression

Consider the L2-regularized mean squared error loss function: \[R_\lambda(w) = \frac{1}{n}\sum_{i=1}^{n}(wx_i - y_i)^2 + \lambda w^2\]

where \(\{(x_i, y_i)\}_{i=1}^n\) are training data points, \(w\) is the model parameter, and \(\lambda > 0\) is the regularization parameter.

  1. Find the optimum \(w^*\) and determine if it’s a minimum or maximum.
  2. Is the function \(R_\lambda(w)\) convex? Justify your answer.
  3. Is the minimizer unique? Explain why this is important for machine learning.

06 Logistic Loss and Its Properties

The logistic loss is the foundation of logistic regression, one of the most important algorithms in machine learning for binary classification. Understanding its derivative is crucial for gradient-based optimization.

Consider the logistic loss function: \[\ell(z;y) = -y\log\sigma(z) - (1-y)\log(1-\sigma(z))\]

where \(\sigma(z) = \frac{1}{1+e^{-z}}\) is the sigmoid function, \(z\) is the logit (linear combination of features), and \(y \in \{0,1\}\) is the true binary label.

  1. Task: Show that \(\frac{d}{dz}\ell(z;y) = \sigma(z) - y\).

  2. Bonus: Check if the function \(g(z) = (y - \sigma(z))^2\) is convex with respect to \(z\).

07 Lipschitz Continuity & Gradient Clipping

A function \(f: \mathbb{R} \to \mathbb{R}\) is called L-Lipschitz continuous if there exists a constant \(L \geq 0\) such that: \[|f(x) - f(y)| \leq L|x - y|\] for all \(x, y\) in the domain. The smallest such constant \(L\) is called the Lipschitz constant.

This property is crucial in deep learning for gradient clipping, ensuring gradients don’t explode during training.

Consider the sigmoid function \(\sigma(z) = \frac{1}{1+e^{-z}}\).

Task: Prove that \(\sigma(z)\) is L-Lipschitz continuous and find the optimal (smallest possible) Lipschitz constant \(L\).

Taylor Series

08 Taylor Series Expansions

Find the Taylor series expansion around the given point for each function:

  1. \(f(x) = e^x\) around \(x = 0\) (Maclaurin series)
  2. \(g(x) = \ln(x)\) around \(x = 1\)
  3. \(h(x) = \cos(x)\) around \(x = 0\) (first 4 non-zero terms)

🛠️ Գործնական ToDo

🎲 41 (05)

Flag Counter