Полигон YMLSYMLS PolygonТашкент · 2026Tashkent · 2026
до попыткиuntil the attempt —
Подтягиваем базуCatch-upf01АнализCalculusМатрицыMatricesПодтягиваем базуCatch-upF3.2F3.7F4.2F4.4CM.4CM.7CM.11

Частные производные и матричная арифметикаPartial derivatives and matrix arithmetic

Четыре опоры, на которых стоят лекции math-01 и math-02: размеры при умножении, транспонирование произведения, след и частные производные вплоть до вторыхThe four supports under lectures math-01 and math-02: sizes in a product, the transpose of a product, the trace, and partial derivatives up to second order

решено 13 из 2013 of 20 solved

цель урокаlesson goal
RU

К концу урока ты подписываешь размеры под каждым множителем и не путаешь $(AB)^t$ с $A^tB^t$, сводишь след произведения с вектором на конце к одному числу, считаешь частные производные первого и второго порядка, в том числе после замены переменных, и делаешь шаг градиентного спуска для квадратичной функции потерь. Проверка — три финальные задачи ниже; f0119 идёт мини-тестом.

EN

By the end of the lesson you write the sizes under every factor and never confuse $(AB)^t$ with $A^tB^t$, reduce the trace of a product that ends in a vector to a single number, compute first- and second-order partial derivatives, including after a change of variables, and take one gradient descent step for a quadratic loss. The check is the three final problems below; f0119 is the mini-test.

Самостоятельные задачиIndependent problems

К концу урока эти задачи нужно решать без подсказок.By the end of the lesson, solve these problems without hints.

Мост · что нужно вспомнитьBridge · what to recall

Вспомни вслух, до открытия конспектовRecall aloud before opening your notes

  1. Производные: $(x^n)' = nx^{n-1}$, $(e^x)' = e^x$, $(\ln x)' = 1/x$, $(\sin x)' = \cos x$, $(\cos x)' = -\sin x$, $(\sqrt x)' = \frac{1}{2\sqrt x}$Derivatives: $(x^n)' = nx^{n-1}$, $(e^x)' = e^x$, $(\ln x)' = 1/x$, $(\sin x)' = \cos x$, $(\cos x)' = -\sin x$, $(\sqrt x)' = \frac{1}{2\sqrt x}$
  2. Правило произведения: $(pq)' = p'q + pq'$; производная постоянной равна нулюProduct rule: $(pq)' = p'q + pq'$; the derivative of a constant is zero
  3. Матрица $A\in M_{m\times n}$ — таблица из $m$ строк и $n$ столбцов; $a_{ij}$ стоит в строке $i$, столбце $j$A matrix $A\in M_{m\times n}$ is a table with $m$ rows and $n$ columns; $a_{ij}$ sits in row $i$, column $j$
  4. Скалярное произведение $x^ty = x^1y^1 + \dots + x^Ny^N$ для столбцов $x,y\in\R^N$, и $x^tx = \lVert x\rVert^2$The dot product $x^ty = x^1y^1 + \dots + x^Ny^N$ for columns $x,y\in\R^N$, and $x^tx = \lVert x\rVert^2$
  5. Вектор — это столбец, то есть матрица $N\times1$; строка — матрица $1\times N$A vector is a column, that is, an $N\times1$ matrix; a row is a $1\times N$ matrix
  6. Определение производной через о-малое: $f(x_0+h) - f(x_0) = f'(x_0)\,h + o(h)$ при $h\to0$The derivative via little-o: $f(x_0+h) - f(x_0) = f'(x_0)\,h + o(h)$ as $h\to0$
  7. Шаг градиентного спуска: $w \leftarrow w - \eta\nabla L(w)$, где $\eta > 0$ — величина шагаA gradient descent step: $w \leftarrow w - \eta\nabla L(w)$, where $\eta > 0$ is the step size
зачем это в MLwhy this matters for ML
RU

На лекциях math-01 и math-02 эти четыре вещи используются в каждой строке, а объясняются мимоходом или не объясняются вовсе: лектор считает их известными. Вывод $\nabla\lVert b-Ax\rVert^2 = 2A^t(Ax-b)$ (функция потерь линейной регрессии) держится на правиле $(AB)^t = B^tA^t$ и на том, что число равно своему транспонированию. Ответ $Df(X_0) = ba^t$ для $f(X) = a^tXb$ — производная по матрице весов — получен одним приёмом: число равно своему следу, а след цикличен. Домашнее задание HW-M02 с лапласианом в полярных и сферических координатах — это сплошь вторые частные производные сложных функций.

В ML то же самое встречается без лекций: каждый слой нейросети — умножение $Wx$ с проверкой размеров, обратное распространение ошибки — цепное правило, применённое слой за слоем, а шаг обучения — вычитание градиента. Если одна из этих опор шатается, на лекции перестаёт быть видно идею: всё внимание уходит на то, чтобы понять, откуда взялась строчка.

EN

Lectures math-01 and math-02 use these four things in every line and explain them only in passing or not at all: the lecturer assumes them. The derivation of $\nabla\lVert b-Ax\rVert^2 = 2A^t(Ax-b)$ (the linear regression loss) rests on the rule $(AB)^t = B^tA^t$ and on the fact that a number equals its own transpose. The answer $Df(X_0) = ba^t$ for $f(X) = a^tXb$ — a derivative with respect to a weight matrix — comes from one trick: a number equals its own trace, and the trace is cyclic. Homework HW-M02, with the Laplacian in polar and spherical coordinates, is second partial derivatives of composite functions from start to finish.

In ML the same things appear without any lecture: every network layer is a product $Wx$ with a size check, backpropagation is the chain rule applied layer by layer, and a training step subtracts a gradient. If one of these supports is shaky, the idea of the lecture stops being visible: all attention goes into working out where a line came from.

Навыки по порядкуSkills in order

Тема разбита на микронавыки от простого к сложному. У каждого — тренировочные задачи.The topic is split into micro-skills from simple to complex, each with its practice problems.

  1. 1Размеры и элемент произведенияSizes and an entry of a productПодписываешь размеры $(m\times n)(n\times k)$, находишь любой элемент $(AB)_{ij}$ как строку на столбец и знаешь, когда произведение не определеноYou write the sizes $(m\times n)(n\times k)$, find any entry $(AB)_{ij}$ as a row times a column, and know when a product is undefinedf0101 ✓f0108 ✓
  2. 2Транспонирование произведенияTranspose of a productРазворачиваешь порядок в $(AB)^t = B^tA^t$ и превращаешь число $x^tAu$ в $u^tA^tx$, не теряя транспонированияYou reverse the order in $(AB)^t = B^tA^t$ and turn the number $x^tAu$ into $u^tA^tx$ without losing the transposef0102 ✓f0114f0118
  3. 3След и цикличностьTrace and the cyclic propertyСчитаешь след по диагонали и сводишь $\tr$ произведения с вектором на конце к одному скалярному произведениюYou compute a trace from the diagonal and reduce the $\tr$ of a product that ends in a vector to a single dot productf0103 ✓f0109 ✓f0115f0118
  4. 4Цепное правило для одной переменнойOne-variable chain ruleРазбираешь сложную функцию на слои и перемножаешь производные слоёв, каждую в своей точкеYou split a composite function into layers and multiply the derivatives of the layers, each at its own pointf0104 ✓f0110 ✓
  5. 5Частные производные и градиентPartial derivatives and the gradientЗамораживаешь все переменные, кроме одной, собираешь градиент и проверяешь формулу $\nabla(x^tAx) = (A+A^t)x$ покоординатноYou freeze all variables but one, assemble the gradient, and check the formula $\nabla(x^tAx) = (A+A^t)x$ coordinate by coordinatef0105 ✓f0111 ✓f0116f0119
  6. 6Вторые и смешанные производныеSecond and mixed derivativesДифференцируешь частную производную ещё раз, соблюдая порядок переменных и правило произведенияYou differentiate a partial derivative once more, keeping the order of the variables and the product rulef0106 ✓f0112 ✓f0120
  7. 7Цепное правило при замене переменныхChain rule for a change of variablesСчитаешь первые и вторые производные функции $f(x(u,v),y(u,v))$, применяя цепное правило заново к каждой частной производной $f$You compute the first and second derivatives of $f(x(u,v),y(u,v))$, applying the chain rule again to each partial derivative of $f$f0107 ✓f0113 ✓f0117f0120

УрокLesson

разбираем с нуляfrom first principles
RU

Вход: одна функция, два способа

Возьми матрицу $A = \begin{pmatrix}1&3\\1&2\end{pmatrix}$ и функцию двух переменных $f(x) = x^tAx$, где $x = (x^1,x^2)^t$. Раскроем произведение: $Ax = (x^1+3x^2,\ x^1+2x^2)^t$, и

$$f(x) = x^1(x^1+3x^2) + x^2(x^1+2x^2) = (x^1)^2 + 4x^1x^2 + 2(x^2)^2.$$

Вопрос урока: как быстро меняется $f$ в точке $x_0 = (1,1)^t$, если двигать только $x^1$? А если только $x^2$? Ответ — два числа, $6$ и $8$. К концу урока ты получишь их двумя независимыми путями: частными производными по формуле и одним матричным умножением $(A+A^t)x_0$. По дороге понадобятся размеры при умножении, правило транспонирования, след и частные производные — ровно то, на чём стоят лекции math-01 и math-02.

Обозначения

Как у лектора: транспонирование $A^t$; $M_{m\times n}$ — матрицы из $m$ строк и $n$ столбцов; векторы — столбцы; координаты с верхним индексом, $x^1$ — это первая координата, а не степень. Степень координаты пишется со скобками: $(x^1)^2$. В днях Полигона (день 10, день 18) транспонирование записано заглавной буквой T, а векторы — строками; в ML-школе так не пишем.

Размеры и произведение матриц

Картинка: элемент произведения $AB$ в строке $i$, столбце $j$ — это скалярное произведение строки $i$ матрицы $A$ на столбец $j$ матрицы $B$. Чтобы оно существовало, длина строки $A$ должна совпасть с высотой столбца $B$.

Произведение матриц

Пусть $A\in M_{m\times n}$, $B\in M_{n\times k}$. Тогда $AB\in M_{m\times k}$ и

$$(AB)_{ij} = \sum_{s=1}^{n} a_{is}b_{sj},\qquad i = 1,\dots,m,\quad j = 1,\dots,k.$$

Правило размеров: $(m\times n)(n\times k) = m\times k$ — внутренние размеры совпадают и исчезают, внешние остаются.

Пример. $A = \begin{pmatrix}1&2\\0&-1\\3&1\end{pmatrix}\in M_{3\times2}$ и $x = (2,1)^t\in M_{2\times1}$. Размеры: $(3\times2)(2\times1) = 3\times1$, значит, ответ — столбец из трёх чисел:

$$Ax = \begin{pmatrix}1\cdot2+2\cdot1\\0\cdot2+(-1)\cdot1\\3\cdot2+1\cdot1\end{pmatrix} = \begin{pmatrix}4\\-1\\7\end{pmatrix}.$$

Произведение $xA$ не определено: в $(2\times1)(3\times2)$ внутренние размеры $1$ и $3$ не совпадают.

Порядок множителей

Даже когда существуют оба произведения $AB$ и $BA$, они обычно различны и могут иметь разные размеры: для $A\in M_{2\times3}$, $B\in M_{3\times2}$ матрица $AB$ имеет размер $2\times2$, а $BA$ — размер $3\times3$. Перед каждым умножением подписывай размеры под множителями. Эта проверка занимает пять секунд.

Строка — это матрица $1\times N$, столбец — матрица $N\times1$. Поэтому для $x,y\in\R^N$ произведение $x^ty$ имеет размер $(1\times N)(N\times1) = 1\times1$ — это одно число $x^1y^1+\dots+x^Ny^N$, а $xy^t$ имеет размер $(N\times1)(1\times N) = N\times N$ — это целая матрица, внешнее произведение.

Зачем это в ML

Линейный слой нейросети — это $y = Wx$ с $W\in M_{D\times N}$: на входе $N$ признаков, на выходе $D$ чисел. Значительная часть ошибок в коде моделей — несовпавшие размеры, и ловятся они ровно правилом $(m\times n)(n\times k)$.

Транспонирование произведения

Транспонирование отражает таблицу относительно главной диагонали: $(A^t)_{ij} = a_{ji}$, строки становятся столбцами. Если $A\in M_{m\times n}$, то $A^t\in M_{n\times m}$.

Почему у произведения меняется порядок? Размеры подсказывают ответ раньше формулы. Пусть $A\in M_{m\times n}$, $B\in M_{n\times k}$; тогда $(AB)^t\in M_{k\times m}$. Из $A^t\in M_{n\times m}$ и $B^t\in M_{k\times n}$ матрицу размера $k\times m$ можно получить только как $B^tA^t$; произведение $A^tB^t$ при $m\ne k$ даже не определено.

Правила транспонирования$$(A^t)^t = A,\qquad (A+B)^t = A^t+B^t,\qquad (\lambda A)^t = \lambda A^t,\qquad (AB)^t = B^tA^t.$$

Для трёх множителей порядок разворачивается целиком: $(ABC)^t = C^tB^tA^t$.

Почему $(AB)^t = B^tA^t$. Сравним элементы в строке $i$, столбце $j$:

$$\big((AB)^t\big)_{ij} = (AB)_{ji} = \sum_{s} a_{js}b_{si} = \sum_{s} b_{si}a_{js} = \sum_{s} (B^t)_{is}(A^t)_{sj} = (B^tA^t)_{ij}.$$

Третье равенство — перестановка двух чисел в каждом слагаемом, четвёртое — запись $b_{si} = (B^t)_{is}$ и $a_{js} = (A^t)_{sj}$.

Число равно своему транспонированию. Матрица $1\times1$ при транспонировании не меняется. Лектор пользуется этим постоянно: для $A\in M_{D\times N}$, $u\in\R^N$, $v\in\R^D$

$$v^tAu = (v^tAu)^t = u^tA^t(v^t)^t = u^tA^tv.$$

Пример. $u = (1,2)^t$, $v = (1,0,1)^t$, а $A\in M_{3\times2}$ — та же, что в примере выше. Тогда $Au = (1+4,\ 0-2,\ 3+2)^t = (5,-2,5)^t$, и $v^tAu = 5+0+5 = 10$. С другой стороны, $A^tv = (1+3,\ 2+1)^t = (4,3)^t$, и $u^tA^tv = 4+6 = 10$ ✓.

Где теряют транспонирование

В числе $x^tAu$ нельзя просто поменять местами $x$ и $u$: $x^tAu = u^tA^tx$, а не $u^tAx$. Эти два числа совпадают, только если $A = A^t$. В задаче f0114 именно это отличает верный ответ от неверного.

Зачем это в ML

В выводе градиента функции потерь линейной регрессии (лекция math-01) два средних слагаемых $(Au)^t(b-Ax_0)$ и $(b-Ax_0)^tAu$ сводятся в одно ровно этим приёмом. Отсюда множитель $2$ в $\nabla f = 2A^t(Ax_0-b)$.

След и цикличность

Картинка: у квадратной матрицы есть диагональ из левого верхнего угла в правый нижний. След — сумма чисел на ней. Неожиданное свойство следа в том, что ему безразличен порядок двух множителей, хотя самим произведениям — нет.

След и цикличность

Для квадратной $C\in M_{n\times n}$ след — сумма диагональных элементов: $\tr C = c_{11}+c_{22}+\dots+c_{nn}$. Для $A\in M_{m\times n}$ и $B\in M_{n\times m}$ обе матрицы $AB\in M_{m\times m}$ и $BA\in M_{n\times n}$ квадратные, и

$$\tr(AB) = \tr(BA).$$

Сами $A$ и $B$ не обязаны быть квадратными; размеры $AB$ и $BA$ при этом разные, а следы равны.

Свойство цикличности сформулировано на лекции math-01 (доска 15). Его доказательство — пункт 4 домашнего задания HW-M01, поэтому здесь доказательства нет: урок учит пользоваться свойством и проверять его на числах.

Пример. $A = \begin{pmatrix}1&2&0\\0&1&1\end{pmatrix}\in M_{2\times3}$, $B = \begin{pmatrix}1&0\\2&1\\0&3\end{pmatrix}\in M_{3\times2}$. Для следа нужны только диагональные элементы. У $AB$ ($2\times2$): $(AB)_{11} = 1\cdot1+2\cdot2+0\cdot0 = 5$, $(AB)_{22} = 0\cdot0+1\cdot1+1\cdot3 = 4$, так что $\tr(AB) = 9$. У $BA$ ($3\times3$): $(BA)_{11} = 1\cdot1+0\cdot0 = 1$, $(BA)_{22} = 2\cdot2+1\cdot1 = 5$, $(BA)_{33} = 0\cdot0+3\cdot1 = 3$, так что $\tr(BA) = 9$ ✓.

Три следствия, которыми пользуются чаще самого свойства.

  1. Число равно своему следу: для матрицы $1\times1$ выполнено $\tr c = c$.
  2. Множители можно прокручивать по кругу: $\tr(ABC) = \tr(CAB) = \tr(BCA)$. Первое равенство — это $\tr(XY) = \tr(YX)$ при $X = AB$, $Y = C$; второе — то же при $X = CA$, $Y = B$: $\tr\big((CA)B\big) = \tr\big(B(CA)\big)$. Переставлять множители произвольно нельзя: $\tr(ABC)$ и $\tr(ACB)$ в общем случае различны.
  3. Вектор на конце можно перенести в начало: для $u,v\in\R^N$ выполнено $\tr(uv^t) = \tr(v^tu) = v^tu$. Слева след матрицы $N\times N$, справа одно скалярное произведение.

На лекции math-01 так получен ответ для $f(X) = a^tXb$: матрица $U$ «зажата» посередине, и её выводят в конец:

$$a^tUb = \tr(a^tUb) = \tr\big((a^tU)\,b\big) = \tr\big(b\,(a^tU)\big) = \tr\big((ba^t)\,U\big).$$
Зачем это в ML

Веса нейросети — матрицы, и производная функции потерь по матрице весов вычисляется именно так: число записывают как след и прокручивают множители, пока изменение $U$ не окажется справа. Отсюда $Df(X_0) = ba^t$.

Производная сложной функции одной переменной

Картинка: $y$ зависит от $u$, а $u$ зависит от $x$. Сдвинь $x$ на малое $h$: $u$ сдвинется примерно на $g'(x_0)\,h$, а $y$ — примерно на $f'(u_0)\cdot g'(x_0)\,h$. Скорости перемножаются.

Цепное правило

Пусть $u = g(x)$ дифференцируема в точке $x_0$, а $y = f(u)$ дифференцируема в точке $u_0 = g(x_0)$. Тогда $y = f(g(x))$ дифференцируема в $x_0$ и

$$\frac{dy}{dx}\Big|_{x_0} = f'(u_0)\,g'(x_0),\qquad\text{в обозначениях Лейбница}\qquad \frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}.$$

Пример. $y = (1+\sin x)^3$ в точке $x = 0$. Слои: $y = u^3$, $u = 1+\sin x$. Значение внутреннего слоя: $u_0 = 1+\sin0 = 1$. Производные: $\frac{dy}{du} = 3u^2 = 3$ при $u_0 = 1$ и $\frac{du}{dx} = \cos x = 1$ при $x = 0$. Итог: $\frac{dy}{dx} = 3\cdot1 = 3$. Если слоёв три, множителей тоже три, и каждая производная берётся в значении своего внутреннего слоя.

Две ошибки цепного правила

Первая — забыть внутреннюю производную: $\big(\sin(x^2)\big)' = \cos(x^2)\cdot2x$, а не $\cos(x^2)$. Вторая — взять производную внешнего слоя не в той точке: $f'$ считается в $u_0 = g(x_0)$, а не в $x_0$. Проверка: перед дифференцированием выпиши значения всех слоёв в точке.

Зачем это в ML

Даже один нейрон $y = \sigma(wx+b)$ — сложная функция: $\frac{\partial y}{\partial w} = \sigma'(wx+b)\cdot x$. Обратное распространение ошибки — это то же цепное правило, применённое слой за слоем справа налево.

Частные производные и градиент

Картинка: график $z = f(x^1,x^2)$ — поверхность над плоскостью. Разрежь её вертикальной плоскостью $x^2 = \text{const}$: получится кривая, и наклон этой кривой — частная производная по $x^1$. Двигаешь одну координату, остальные стоят на месте.

Частная производная

Для $f:\R^N\to\R$ и точки $x_0$ частная производная по $x^i$ —

$$\frac{\partial f}{\partial x^i}(x_0) = \lim_{h\to0}\frac{f(x_0+he_i)-f(x_0)}{h},$$

где $e_i$ — столбец с единицей на месте $i$ и нулями на остальных местах. Считается она как обычная производная по $x^i$, когда все остальные координаты считаются числами.

Пример из входа. $f = (x^1)^2 + 4x^1x^2 + 2(x^2)^2$. По $x^1$, считая $x^2$ числом: $\frac{\partial f}{\partial x^1} = 2x^1 + 4x^2$, в точке $(1,1)^t$ это $6$. По $x^2$, считая $x^1$ числом: $\frac{\partial f}{\partial x^2} = 4x^1 + 4x^2$, в точке это $8$.

Пример со сложной функцией. $f(x^1,x^2) = \ln\big(1+(x^1)^2x^2\big)$. По $x^1$ — цепное правило одной переменной, $x^2$ стоит как число: $\frac{\partial f}{\partial x^1} = \frac{2x^1x^2}{1+(x^1)^2x^2}$; в точке $(1,1)^t$ это $\frac{2}{2} = 1$.

Градиент

Строка частных производных — это матрица производной $Df(x_0) = \Big(\frac{\partial f}{\partial x^1}(x_0),\ \dots,\ \frac{\partial f}{\partial x^N}(x_0)\Big)$ размера $1\times N$. Градиент — её транспонирование, столбец: $\nabla f(x_0) = Df(x_0)^t$.

Лектор подчеркнул на math-01: если $Df(x_0)$ существует, то её элементы — частные производные, но одно существование всех частных производных слабее существования $Df(x_0)$.

Дополнение

Не из лекции, но снимает этот вопрос для всех задач урока: если частные производные непрерывны в окрестности точки, то $Df$ в этой точке существует. У многочленов, $\sin$, $\cos$, $e^x$ и $\ln$ в области определения частные производные непрерывны.

Градиент квадратичной формы. Почему в примере входа получилось $(A+A^t)x_0$? Раскроем $f(x_0+hu) = (x_0+hu)^tA(x_0+hu)$, пользуясь $(x_0+hu)^t = x_0^t + hu^t$:

$$f(x_0+hu) = x_0^tAx_0 + h\,x_0^tAu + h\,u^tAx_0 + h^2\,u^tAu.$$

Число $x_0^tAu$ равно своему транспонированию $u^tA^tx_0$, поэтому коэффициент при $h$ равен $u^tA^tx_0 + u^tAx_0 = u^t(A+A^t)x_0$. По предложению лекции math-01 о производной по направлению предел $\frac{f(x_0+hu)-f(x_0)}{h}$ при $h\to0$ равен $Df(x_0)\,u$, значит, $Df(x_0)\,u = \big((A+A^t)x_0\big)^tu$ для любого $u$, и

$$\nabla(x^tAx) = (A+A^t)x.$$

Проверка на входе: $A + A^t = \begin{pmatrix}2&4\\4&4\end{pmatrix}$, и $(A+A^t)(1,1)^t = (6,8)^t$ — те же $6$ и $8$ ✓.

Зачем это в ML

Квадратичная функция потерь — простейшая модель того, что происходит около минимума любой гладкой функции потерь. Шаг градиентного спуска $w\leftarrow w - \eta\nabla L(w)$ требует ровно этого: столбца частных производных в текущей точке. Задача f0119 делает такой шаг целиком.

Вторые и смешанные производные

Частная производная $\partial f/\partial x^i$ — снова функция тех же переменных, и её можно дифференцировать ещё раз.

Вторые производные$$\frac{\partial^2 f}{\partial x^j\,\partial x^i} = \frac{\partial}{\partial x^j}\Big(\frac{\partial f}{\partial x^i}\Big),\qquad \frac{\partial^2 f}{\partial (x^i)^2} = \frac{\partial}{\partial x^i}\Big(\frac{\partial f}{\partial x^i}\Big).$$

Читается справа налево: сначала по $x^i$ (переменная, стоящая ближе к $f$), потом результат по $x^j$. Так же записаны производные $g''(t)$ на доске лекции math-02.

Пример. $f(x,y) = x^2y^3$. Первые производные: $\frac{\partial f}{\partial x} = 2xy^3$, $\frac{\partial f}{\partial y} = 3x^2y^2$. Вторые: $\frac{\partial^2 f}{\partial x^2} = 2y^3$, $\frac{\partial^2 f}{\partial y^2} = 6x^2y$, $\frac{\partial^2 f}{\partial x\,\partial y} = \frac{\partial}{\partial x}(3x^2y^2) = 6xy^2$ и $\frac{\partial^2 f}{\partial y\,\partial x} = \frac{\partial}{\partial y}(2xy^3) = 6xy^2$. Смешанные совпали.

Дополнение: теорема Шварца

Не из лекции; нужна для гессиана и лапласиана. Если все вторые частные производные $f$ непрерывны в окрестности точки, то в этой точке $\frac{\partial^2 f}{\partial x\,\partial y} = \frac{\partial^2 f}{\partial y\,\partial x}$. Порядок дифференцирования тогда не важен, но писать его всё равно нужно аккуратно: это проверка, что ничего не пропущено.

Две конструкции из вторых производных встретятся в курсе сразу. Гессиан — матрица $H$ с элементами $H_{ij} = \frac{\partial^2 f}{\partial x^i\,\partial x^j}$. Для функции из входа $\frac{\partial^2 f}{\partial (x^1)^2} = 2$, $\frac{\partial^2 f}{\partial x^1\,\partial x^2} = 4$, $\frac{\partial^2 f}{\partial (x^2)^2} = 4$, то есть $H = \begin{pmatrix}2&4\\4&4\end{pmatrix} = A + A^t$. Лапласиан функции двух переменных — $\Delta f = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2}$, сумма диагонали гессиана. Например, $\Delta(x^2-y^2) = 2-2 = 0$, а $\Delta(x^2+y^2) = 2+2 = 4$.

Правило произведения во второй производной

Если первая производная — произведение, например $\frac{\partial}{\partial y}\sin(xy) = x\cos(xy)$, то при дифференцировании по $x$ оба множителя зависят от $x$. Нужно правило произведения: два слагаемых, а не одно.

Зачем это в ML

Гессиан описывает кривизну функции потерь. Слишком большой шаг градиентного спуска для данной кривизны перепрыгивает минимум, а методы второго порядка (метод Ньютона) используют гессиан напрямую.

Цепное правило для нескольких переменных и замена переменных

Картинка: $t$ сдвигается на $\Delta t$, каждая $u^j$ сдвигается примерно на $g_j'(t_0)\,\Delta t$, и каждый такой сдвиг меняет $f$ примерно на $\frac{\partial f}{\partial u^j}\,g_j'(t_0)\,\Delta t$. Вклады складываются.

Цепное правило (лекция math-01)

Пусть $y = f(u^1,\dots,u^N)$, $u^j = g_j(t)$, $u_0^j = g_j(t_0)$, матрица $Df(u_0)$ существует и все $g_j'(t_0)$ существуют. Тогда

$$\frac{dy}{dt}\Big|_{t_0} = \sum_{j=1}^{N}\frac{\partial f}{\partial u^j}(u_0)\,g_j'(t_0).$$

В общем виде $D(F\circ G) = DF\cdot DG$ — произведение матриц.

Правая часть этой формулы на фото доски не попала; в конспекте она восстановлена как стандартная, и в таком же виде её доказывали на лекции math-02.

Пример. $y = (u^1)^2u^2$, $u^1 = \cos t$, $u^2 = \sin t$, точка $t = 0$. Значения: $u_0 = (1,0)^t$. Частные производные в $u_0$: $\frac{\partial f}{\partial u^1} = 2u^1u^2 = 0$, $\frac{\partial f}{\partial u^2} = (u^1)^2 = 1$. Производные слоёв: $g_1'(0) = -\sin0 = 0$, $g_2'(0) = \cos0 = 1$. Итог: $\frac{dy}{dt} = 0\cdot0 + 1\cdot1 = 1$. Проверка подстановкой: $y = \cos^2t\sin t$, $y' = -2\cos t\sin^2t + \cos^3t$, при $t = 0$ это $1$ ✓.

Замена переменных. Если $x = x(u,v)$, $y = y(u,v)$ и $g(u,v) = f\big(x(u,v),y(u,v)\big)$, то частная производная по $u$ — то же цепное правило, только $v$ заморожена:

$$\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\frac{\partial x}{\partial u} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial u}.$$

Для полярных координат $x = r\cos\theta$, $y = r\sin\theta$ это формулы с доски лекции math-02 (там, как у лектора, одной буквой $f$ обозначена и функция от $x,y$, и она же как функция от $r,\theta$):

$$\frac{\partial f}{\partial r} = \frac{\partial f}{\partial x}\cos\theta + \frac{\partial f}{\partial y}\sin\theta,\qquad \frac{\partial f}{\partial\theta} = \frac{\partial f}{\partial x}(-r\sin\theta) + \frac{\partial f}{\partial y}\,r\cos\theta.$$

Вторые производные после замены — главное место урока. В формуле для $\frac{\partial g}{\partial u}$ стоят $\frac{\partial f}{\partial x}$ и $\frac{\partial f}{\partial y}$, взятые в точке $\big(x(u,v),y(u,v)\big)$. Это снова сложные функции от $u$ и $v$. Поэтому при втором дифференцировании по $u$ работают два правила сразу:

  1. Цепное правило заново для каждой частной производной $f$: $\frac{\partial}{\partial u}\Big(\frac{\partial f}{\partial x}\Big) = \frac{\partial^2 f}{\partial x^2}\frac{\partial x}{\partial u} + \frac{\partial^2 f}{\partial y\,\partial x}\frac{\partial y}{\partial u}$.
  2. Правило произведения, если коэффициенты $\frac{\partial x}{\partial u}$, $\frac{\partial y}{\partial u}$ сами зависят от $u$: тогда появляется ещё слагаемое $\frac{\partial f}{\partial x}\frac{\partial^2 x}{\partial u^2}$ (и такое же для $y$).

Как это выглядит на конкретной функции, показывает эталонная задача ниже.

Что теряют во второй производной

Чаще всего теряют одно из двух: что $\frac{\partial f}{\partial x}$ зависит от $u$ через $x$ и $y$ (тогда пропадают вторые производные $f$), или что коэффициент вроде $\cos\theta$ или $r$ тоже надо дифференцировать (тогда пропадают первые производные $f$). Проверка: подставь конкретную функцию, например $f = x^2y$, и сравни с прямым счётом.

Зачем это в ML

Нормировка признака $x = (x'-\mu)/\sigma$ — это замена переменной, и по цепному правилу $\frac{\partial L}{\partial x'} = \frac{\partial L}{\partial x}\cdot\frac{1}{\sigma}$: масштаб признака напрямую меняет масштаб градиента. Та же схема в новом базисе — это полярные и сферические координаты из HW-M02.

Что должно остаться в голове

  1. $(m\times n)(n\times k) = m\times k$: подписывай размеры под каждым множителем.
  2. $(AB)^t = B^tA^t$; число равно своему транспонированию, поэтому $x^tAu = u^tA^tx$.
  3. $\tr(AB) = \tr(BA)$ и для неквадратных $A$, $B$; число равно своему следу; $\tr(uv^t) = v^tu$.
  4. Цепное правило: производная внешнего слоя в значении внутреннего, умноженная на производную внутреннего.
  5. Частная производная: заморозь остальные переменные; градиент — столбец; $\nabla(x^tAx) = (A+A^t)x$.
  6. $\frac{\partial^2 f}{\partial x^j\,\partial x^i}$ — сначала по $x^i$, потом по $x^j$; при непрерывных вторых производных порядок не важен.
  7. После замены переменных частная производная $f$ — снова сложная функция: второе дифференцирование — цепное правило заново плюс правило произведения.
EN

Entry: one function, two routes

Take the matrix $A = \begin{pmatrix}1&3\\1&2\end{pmatrix}$ and the function of two variables $f(x) = x^tAx$, where $x = (x^1,x^2)^t$. Expand the product: $Ax = (x^1+3x^2,\ x^1+2x^2)^t$, and

$$f(x) = x^1(x^1+3x^2) + x^2(x^1+2x^2) = (x^1)^2 + 4x^1x^2 + 2(x^2)^2.$$

The question of the lesson: how fast does $f$ change at the point $x_0 = (1,1)^t$ if only $x^1$ moves? And if only $x^2$ moves? The answer is two numbers, $6$ and $8$. By the end of the lesson you get them by two independent routes: partial derivatives of the formula, and a single matrix product $(A+A^t)x_0$. On the way you need sizes in a product, the transpose rule, the trace, and partial derivatives — exactly what lectures math-01 and math-02 stand on.

Notation

As the lecturer writes it: the transpose is $A^t$; $M_{m\times n}$ is the set of matrices with $m$ rows and $n$ columns; vectors are columns; components carry upper indices, so $x^1$ is the first component, not a power. A power of a component is written with parentheses: $(x^1)^2$. In the Poligon days (day 10, day 18) the transpose is written with a capital T and vectors as rows; the ML School does not write them that way.

Sizes and the matrix product

The picture: the entry of $AB$ in row $i$, column $j$ is the dot product of row $i$ of $A$ with column $j$ of $B$. For it to exist, the length of a row of $A$ must equal the height of a column of $B$.

Matrix product

Let $A\in M_{m\times n}$, $B\in M_{n\times k}$. Then $AB\in M_{m\times k}$ and

$$(AB)_{ij} = \sum_{s=1}^{n} a_{is}b_{sj},\qquad i = 1,\dots,m,\quad j = 1,\dots,k.$$

The size rule: $(m\times n)(n\times k) = m\times k$ — the inner sizes match and disappear, the outer ones remain.

Example. $A = \begin{pmatrix}1&2\\0&-1\\3&1\end{pmatrix}\in M_{3\times2}$ and $x = (2,1)^t\in M_{2\times1}$. Sizes: $(3\times2)(2\times1) = 3\times1$, so the answer is a column of three numbers:

$$Ax = \begin{pmatrix}1\cdot2+2\cdot1\\0\cdot2+(-1)\cdot1\\3\cdot2+1\cdot1\end{pmatrix} = \begin{pmatrix}4\\-1\\7\end{pmatrix}.$$

The product $xA$ is undefined: in $(2\times1)(3\times2)$ the inner sizes $1$ and $3$ do not match.

Order of the factors

Even when both products $AB$ and $BA$ exist, they are usually different and can have different sizes: for $A\in M_{2\times3}$, $B\in M_{3\times2}$ the matrix $AB$ has size $2\times2$, and $BA$ has size $3\times3$. Before every product, write the sizes under the factors. This check takes five seconds.

A row is a $1\times N$ matrix, a column is an $N\times1$ matrix. So for $x,y\in\R^N$ the product $x^ty$ has size $(1\times N)(N\times1) = 1\times1$ — it is one number $x^1y^1+\dots+x^Ny^N$, while $xy^t$ has size $(N\times1)(1\times N) = N\times N$ — it is a whole matrix, the outer product.

Why this matters for ML

A linear layer of a neural network is $y = Wx$ with $W\in M_{D\times N}$: $N$ features in, $D$ numbers out. A large share of bugs in model code are mismatched sizes, and they are caught by exactly the rule $(m\times n)(n\times k)$.

Transpose of a product

The transpose reflects the table across the main diagonal: $(A^t)_{ij} = a_{ji}$, rows become columns. If $A\in M_{m\times n}$, then $A^t\in M_{n\times m}$.

Why does the order change for a product? The sizes give the answer before the formula does. Let $A\in M_{m\times n}$, $B\in M_{n\times k}$; then $(AB)^t\in M_{k\times m}$. From $A^t\in M_{n\times m}$ and $B^t\in M_{k\times n}$ a matrix of size $k\times m$ can only be obtained as $B^tA^t$; the product $A^tB^t$ is not even defined when $m\ne k$.

Transpose rules$$(A^t)^t = A,\qquad (A+B)^t = A^t+B^t,\qquad (\lambda A)^t = \lambda A^t,\qquad (AB)^t = B^tA^t.$$

For three factors the order reverses completely: $(ABC)^t = C^tB^tA^t$.

Why $(AB)^t = B^tA^t$. Compare the entries in row $i$, column $j$:

$$\big((AB)^t\big)_{ij} = (AB)_{ji} = \sum_{s} a_{js}b_{si} = \sum_{s} b_{si}a_{js} = \sum_{s} (B^t)_{is}(A^t)_{sj} = (B^tA^t)_{ij}.$$

The third equality swaps two numbers in each term; the fourth writes $b_{si} = (B^t)_{is}$ and $a_{js} = (A^t)_{sj}$.

A number equals its own transpose. A $1\times1$ matrix does not change under transposition. The lecturer uses this all the time: for $A\in M_{D\times N}$, $u\in\R^N$, $v\in\R^D$

$$v^tAu = (v^tAu)^t = u^tA^t(v^t)^t = u^tA^tv.$$

Example. $u = (1,2)^t$, $v = (1,0,1)^t$, and $A\in M_{3\times2}$ is the same as in the example above. Then $Au = (1+4,\ 0-2,\ 3+2)^t = (5,-2,5)^t$, and $v^tAu = 5+0+5 = 10$. On the other side, $A^tv = (1+3,\ 2+1)^t = (4,3)^t$, and $u^tA^tv = 4+6 = 10$ ✓.

Where the transpose gets lost

In the number $x^tAu$ you cannot simply swap $x$ and $u$: $x^tAu = u^tA^tx$, not $u^tAx$. These two numbers coincide only if $A = A^t$. In problem f0114 this is exactly what separates the right answer from a wrong one.

Why this matters for ML

In the derivation of the gradient of the linear regression loss (lecture math-01) the two middle terms $(Au)^t(b-Ax_0)$ and $(b-Ax_0)^tAu$ merge into one by exactly this trick. That is where the factor $2$ in $\nabla f = 2A^t(Ax_0-b)$ comes from.

Trace and the cyclic property

The picture: a square matrix has a diagonal from the top-left corner to the bottom-right one. The trace is the sum of the numbers on it. The unexpected property of the trace is that it does not care about the order of two factors, even though the products themselves do.

Trace and the cyclic property

For a square $C\in M_{n\times n}$ the trace is the sum of the diagonal entries: $\tr C = c_{11}+c_{22}+\dots+c_{nn}$. For $A\in M_{m\times n}$ and $B\in M_{n\times m}$ both matrices $AB\in M_{m\times m}$ and $BA\in M_{n\times n}$ are square, and

$$\tr(AB) = \tr(BA).$$

$A$ and $B$ themselves need not be square; $AB$ and $BA$ then have different sizes, but equal traces.

The cyclic property was stated in lecture math-01 (board 15). Its proof is item 4 of homework HW-M01, so there is no proof here: the lesson teaches you to use the property and to check it on numbers.

Example. $A = \begin{pmatrix}1&2&0\\0&1&1\end{pmatrix}\in M_{2\times3}$, $B = \begin{pmatrix}1&0\\2&1\\0&3\end{pmatrix}\in M_{3\times2}$. The trace needs only the diagonal entries. For $AB$ ($2\times2$): $(AB)_{11} = 1\cdot1+2\cdot2+0\cdot0 = 5$, $(AB)_{22} = 0\cdot0+1\cdot1+1\cdot3 = 4$, so $\tr(AB) = 9$. For $BA$ ($3\times3$): $(BA)_{11} = 1\cdot1+0\cdot0 = 1$, $(BA)_{22} = 2\cdot2+1\cdot1 = 5$, $(BA)_{33} = 0\cdot0+3\cdot1 = 3$, so $\tr(BA) = 9$ ✓.

Three consequences that are used more often than the property itself.

  1. A number equals its own trace: for a $1\times1$ matrix, $\tr c = c$.
  2. Factors can be rotated around the cycle: $\tr(ABC) = \tr(CAB) = \tr(BCA)$. The first equality is $\tr(XY) = \tr(YX)$ with $X = AB$, $Y = C$; the second is the same with $X = CA$, $Y = B$: $\tr\big((CA)B\big) = \tr\big(B(CA)\big)$. Factors cannot be permuted arbitrarily: $\tr(ABC)$ and $\tr(ACB)$ are different in general.
  3. A vector at the end can be moved to the front: for $u,v\in\R^N$, $\tr(uv^t) = \tr(v^tu) = v^tu$. On the left is the trace of an $N\times N$ matrix, on the right a single dot product.

This is how lecture math-01 got the answer for $f(X) = a^tXb$: the matrix $U$ is “trapped” in the middle, and it is moved to the end:

$$a^tUb = \tr(a^tUb) = \tr\big((a^tU)\,b\big) = \tr\big(b\,(a^tU)\big) = \tr\big((ba^t)\,U\big).$$
Why this matters for ML

The weights of a neural network are matrices, and the derivative of a loss with respect to a weight matrix is computed exactly like this: write the number as a trace and rotate the factors until the change $U$ stands on the right. Hence $Df(X_0) = ba^t$.

Derivative of a composite function of one variable

The picture: $y$ depends on $u$, and $u$ depends on $x$. Move $x$ by a small $h$: $u$ moves by about $g'(x_0)\,h$, and $y$ by about $f'(u_0)\cdot g'(x_0)\,h$. The rates multiply.

Chain rule

Let $u = g(x)$ be differentiable at the point $x_0$, and $y = f(u)$ be differentiable at the point $u_0 = g(x_0)$. Then $y = f(g(x))$ is differentiable at $x_0$ and

$$\frac{dy}{dx}\Big|_{x_0} = f'(u_0)\,g'(x_0),\qquad\text{in Leibniz notation}\qquad \frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}.$$

Example. $y = (1+\sin x)^3$ at the point $x = 0$. Layers: $y = u^3$, $u = 1+\sin x$. The value of the inner layer: $u_0 = 1+\sin0 = 1$. Derivatives: $\frac{dy}{du} = 3u^2 = 3$ at $u_0 = 1$ and $\frac{du}{dx} = \cos x = 1$ at $x = 0$. Result: $\frac{dy}{dx} = 3\cdot1 = 3$. With three layers there are three factors, and each derivative is taken at the value of its own inner layer.

Two chain rule mistakes

The first is forgetting the inner derivative: $\big(\sin(x^2)\big)' = \cos(x^2)\cdot2x$, not $\cos(x^2)$. The second is taking the derivative of the outer layer at the wrong point: $f'$ is evaluated at $u_0 = g(x_0)$, not at $x_0$. The check: before differentiating, write down the values of all layers at the point.

Why this matters for ML

Even a single neuron $y = \sigma(wx+b)$ is a composite function: $\frac{\partial y}{\partial w} = \sigma'(wx+b)\cdot x$. Backpropagation is the same chain rule applied layer by layer, from right to left.

Partial derivatives and the gradient

The picture: the graph $z = f(x^1,x^2)$ is a surface over the plane. Cut it with the vertical plane $x^2 = \text{const}$: you get a curve, and the slope of that curve is the partial derivative with respect to $x^1$. One coordinate moves, the others stay put.

Partial derivative

For $f:\R^N\to\R$ and a point $x_0$, the partial derivative with respect to $x^i$ is

$$\frac{\partial f}{\partial x^i}(x_0) = \lim_{h\to0}\frac{f(x_0+he_i)-f(x_0)}{h},$$

where $e_i$ is the column with a one in place $i$ and zeros elsewhere. It is computed as an ordinary derivative in $x^i$, with all other components treated as numbers.

Example from the entry. $f = (x^1)^2 + 4x^1x^2 + 2(x^2)^2$. In $x^1$, treating $x^2$ as a number: $\frac{\partial f}{\partial x^1} = 2x^1 + 4x^2$, which is $6$ at $(1,1)^t$. In $x^2$, treating $x^1$ as a number: $\frac{\partial f}{\partial x^2} = 4x^1 + 4x^2$, which is $8$ at the point.

Example with a composite function. $f(x^1,x^2) = \ln\big(1+(x^1)^2x^2\big)$. In $x^1$ this is the one-variable chain rule, with $x^2$ standing as a number: $\frac{\partial f}{\partial x^1} = \frac{2x^1x^2}{1+(x^1)^2x^2}$; at $(1,1)^t$ this is $\frac{2}{2} = 1$.

Gradient

The row of partial derivatives is the derivative matrix $Df(x_0) = \Big(\frac{\partial f}{\partial x^1}(x_0),\ \dots,\ \frac{\partial f}{\partial x^N}(x_0)\Big)$ of size $1\times N$. The gradient is its transpose, a column: $\nabla f(x_0) = Df(x_0)^t$.

The lecturer stressed in math-01: if $Df(x_0)$ exists, its entries are the partial derivatives, but the mere existence of all partial derivatives is weaker than the existence of $Df(x_0)$.

Not from the lecture

Added because it settles this question for every problem of the lesson: if the partial derivatives are continuous near the point, then $Df$ exists at that point. Polynomials, $\sin$, $\cos$, $e^x$, and $\ln$ have continuous partial derivatives on their domains.

Gradient of a quadratic form. Why did the entry example give $(A+A^t)x_0$? Expand $f(x_0+hu) = (x_0+hu)^tA(x_0+hu)$, using $(x_0+hu)^t = x_0^t + hu^t$:

$$f(x_0+hu) = x_0^tAx_0 + h\,x_0^tAu + h\,u^tAx_0 + h^2\,u^tAu.$$

The number $x_0^tAu$ equals its own transpose $u^tA^tx_0$, so the coefficient of $h$ is $u^tA^tx_0 + u^tAx_0 = u^t(A+A^t)x_0$. By the proposition on directional derivatives from lecture math-01, the limit of $\frac{f(x_0+hu)-f(x_0)}{h}$ as $h\to0$ equals $Df(x_0)\,u$, so $Df(x_0)\,u = \big((A+A^t)x_0\big)^tu$ for every $u$, and

$$\nabla(x^tAx) = (A+A^t)x.$$

Check on the entry: $A + A^t = \begin{pmatrix}2&4\\4&4\end{pmatrix}$, and $(A+A^t)(1,1)^t = (6,8)^t$ — the same $6$ and $8$ ✓.

Why this matters for ML

A quadratic loss is the simplest model of what happens near the minimum of any smooth loss. A gradient descent step $w\leftarrow w - \eta\nabla L(w)$ needs exactly this: the column of partial derivatives at the current point. Problem f0119 takes such a step from start to finish.

Second and mixed derivatives

The partial derivative $\partial f/\partial x^i$ is again a function of the same variables, and it can be differentiated once more.

Second derivatives$$\frac{\partial^2 f}{\partial x^j\,\partial x^i} = \frac{\partial}{\partial x^j}\Big(\frac{\partial f}{\partial x^i}\Big),\qquad \frac{\partial^2 f}{\partial (x^i)^2} = \frac{\partial}{\partial x^i}\Big(\frac{\partial f}{\partial x^i}\Big).$$

Read it from right to left: first in $x^i$ (the variable closer to $f$), then the result in $x^j$. The derivatives $g''(t)$ on the board of lecture math-02 are written the same way.

Example. $f(x,y) = x^2y^3$. First derivatives: $\frac{\partial f}{\partial x} = 2xy^3$, $\frac{\partial f}{\partial y} = 3x^2y^2$. Second: $\frac{\partial^2 f}{\partial x^2} = 2y^3$, $\frac{\partial^2 f}{\partial y^2} = 6x^2y$, $\frac{\partial^2 f}{\partial x\,\partial y} = \frac{\partial}{\partial x}(3x^2y^2) = 6xy^2$ and $\frac{\partial^2 f}{\partial y\,\partial x} = \frac{\partial}{\partial y}(2xy^3) = 6xy^2$. The mixed derivatives coincide.

Not from the lecture: Schwarz’s theorem

Added because the Hessian and the Laplacian need it. If all second partial derivatives of $f$ are continuous near a point, then at that point $\frac{\partial^2 f}{\partial x\,\partial y} = \frac{\partial^2 f}{\partial y\,\partial x}$. The order of differentiation then does not matter, but still write it carefully: it is a check that nothing was skipped.

Two constructions made of second derivatives appear in the course right away. The Hessian is the matrix $H$ with entries $H_{ij} = \frac{\partial^2 f}{\partial x^i\,\partial x^j}$. For the entry function $\frac{\partial^2 f}{\partial (x^1)^2} = 2$, $\frac{\partial^2 f}{\partial x^1\,\partial x^2} = 4$, $\frac{\partial^2 f}{\partial (x^2)^2} = 4$, that is, $H = \begin{pmatrix}2&4\\4&4\end{pmatrix} = A + A^t$. The Laplacian of a function of two variables is $\Delta f = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2}$, the sum of the diagonal of the Hessian. For example, $\Delta(x^2-y^2) = 2-2 = 0$, and $\Delta(x^2+y^2) = 2+2 = 4$.

The product rule in a second derivative

If the first derivative is a product, for example $\frac{\partial}{\partial y}\sin(xy) = x\cos(xy)$, then both factors depend on $x$ when you differentiate in $x$. You need the product rule: two terms, not one.

Why this matters for ML

The Hessian describes the curvature of the loss. A gradient descent step that is too large for that curvature jumps over the minimum, and second-order methods (Newton’s method) use the Hessian directly.

Multivariable chain rule and change of variables

The picture: $t$ moves by $\Delta t$, each $u^j$ moves by about $g_j'(t_0)\,\Delta t$, and each such move changes $f$ by about $\frac{\partial f}{\partial u^j}\,g_j'(t_0)\,\Delta t$. The contributions add up.

Chain rule (lecture math-01)

Let $y = f(u^1,\dots,u^N)$, $u^j = g_j(t)$, $u_0^j = g_j(t_0)$, let the matrix $Df(u_0)$ exist, and let all $g_j'(t_0)$ exist. Then

$$\frac{dy}{dt}\Big|_{t_0} = \sum_{j=1}^{N}\frac{\partial f}{\partial u^j}(u_0)\,g_j'(t_0).$$

In general form, $D(F\circ G) = DF\cdot DG$ — a product of matrices.

The right-hand side of this formula is not on the board photo; the lesson notes reconstruct it as the standard formula, and lecture math-02 proved it in this same form.

Example. $y = (u^1)^2u^2$, $u^1 = \cos t$, $u^2 = \sin t$, the point $t = 0$. Values: $u_0 = (1,0)^t$. Partial derivatives at $u_0$: $\frac{\partial f}{\partial u^1} = 2u^1u^2 = 0$, $\frac{\partial f}{\partial u^2} = (u^1)^2 = 1$. Derivatives of the layers: $g_1'(0) = -\sin0 = 0$, $g_2'(0) = \cos0 = 1$. Result: $\frac{dy}{dt} = 0\cdot0 + 1\cdot1 = 1$. Check by substitution: $y = \cos^2t\sin t$, $y' = -2\cos t\sin^2t + \cos^3t$, which is $1$ at $t = 0$ ✓.

Change of variables. If $x = x(u,v)$, $y = y(u,v)$, and $g(u,v) = f\big(x(u,v),y(u,v)\big)$, then the partial derivative in $u$ is the same chain rule with $v$ frozen:

$$\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\frac{\partial x}{\partial u} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial u}.$$

For polar coordinates $x = r\cos\theta$, $y = r\sin\theta$ these are the formulas from the board of lecture math-02 (there, as the lecturer does, one letter $f$ denotes both the function of $x,y$ and the same function of $r,\theta$):

$$\frac{\partial f}{\partial r} = \frac{\partial f}{\partial x}\cos\theta + \frac{\partial f}{\partial y}\sin\theta,\qquad \frac{\partial f}{\partial\theta} = \frac{\partial f}{\partial x}(-r\sin\theta) + \frac{\partial f}{\partial y}\,r\cos\theta.$$

Second derivatives after a change of variables — the central point of the lesson. The formula for $\frac{\partial g}{\partial u}$ contains $\frac{\partial f}{\partial x}$ and $\frac{\partial f}{\partial y}$ evaluated at the point $\big(x(u,v),y(u,v)\big)$. These are again composite functions of $u$ and $v$. So when you differentiate in $u$ a second time, two rules work at once:

  1. The chain rule again for each partial derivative of $f$: $\frac{\partial}{\partial u}\Big(\frac{\partial f}{\partial x}\Big) = \frac{\partial^2 f}{\partial x^2}\frac{\partial x}{\partial u} + \frac{\partial^2 f}{\partial y\,\partial x}\frac{\partial y}{\partial u}$.
  2. The product rule, if the coefficients $\frac{\partial x}{\partial u}$, $\frac{\partial y}{\partial u}$ themselves depend on $u$: then one more term appears, $\frac{\partial f}{\partial x}\frac{\partial^2 x}{\partial u^2}$ (and the same one for $y$).

The model problem below shows how this looks on a concrete function.

What gets lost in a second derivative

Most often one of two things is lost: that $\frac{\partial f}{\partial x}$ depends on $u$ through $x$ and $y$ (then the second derivatives of $f$ disappear), or that a coefficient such as $\cos\theta$ or $r$ also has to be differentiated (then the first derivatives of $f$ disappear). The check: substitute a concrete function, for example $f = x^2y$, and compare with direct computation.

Why this matters for ML

Normalizing a feature, $x = (x'-\mu)/\sigma$, is a change of variables, and by the chain rule $\frac{\partial L}{\partial x'} = \frac{\partial L}{\partial x}\cdot\frac{1}{\sigma}$: the scale of a feature directly changes the scale of the gradient. The same scheme in a new basis is the polar and spherical coordinates of HW-M02.

What should stay with you

  1. $(m\times n)(n\times k) = m\times k$: write the sizes under every factor.
  2. $(AB)^t = B^tA^t$; a number equals its own transpose, so $x^tAu = u^tA^tx$.
  3. $\tr(AB) = \tr(BA)$ also for non-square $A$, $B$; a number equals its own trace; $\tr(uv^t) = v^tu$.
  4. Chain rule: the derivative of the outer layer at the value of the inner one, times the derivative of the inner one.
  5. Partial derivative: freeze the other variables; the gradient is a column; $\nabla(x^tAx) = (A+A^t)x$.
  6. $\frac{\partial^2 f}{\partial x^j\,\partial x^i}$ means first in $x^i$, then in $x^j$; with continuous second derivatives the order does not matter.
  7. After a change of variables a partial derivative of $f$ is again a composite function: the second differentiation is the chain rule again plus the product rule.

Признаки и действияTriggers and actions

Слева — что видно в условии. Справа — что сделать первым.Left: what you see in the statement. Right: the first move.

Что видноWhat you seeПервый ходFirst move
Произведение матриц разных размеровA product of matrices of different sizesПодпиши размеры под множителями: внутренние должны совпасть, внешние дают размер ответаWrite the sizes under the factors: the inner ones must match, the outer ones give the size of the answer
Нужен один элемент произведения, $(AB)_{ij}$ или элемент $(AB)^t$One entry of a product is needed, $(AB)_{ij}$ or an entry of $(AB)^t$Не считай всю матрицу: строка $i$ на столбец $j$, а для $(AB)^t$ сначала поменяй индексы местамиDo not compute the whole matrix: row $i$ times column $j$, and for $(AB)^t$ swap the indices first
Транспонирование произведения $(AB)^t$ или $(ABC)^t$The transpose of a product, $(AB)^t$ or $(ABC)^t$Разверни порядок: $B^tA^t$, $C^tB^tA^t$Reverse the order: $B^tA^t$, $C^tB^tA^t$
В выкладке стоит число вида $x^tAu$ или $(Au)^tv$A derivation contains a number such as $x^tAu$ or $(Au)^tv$Это матрица $1\times1$: она равна своему транспонированию и своему следуIt is a $1\times1$ matrix: it equals its own transpose and its own trace
След произведения, на конце которого вектор, например $\tr(Mab^t)$The trace of a product that ends in a vector, for example $\tr(Mab^t)$Перенеси строку $b^t$ в начало по цикличности: получится одно число $b^tMa$Move the row $b^t$ to the front by the cyclic property: you get the single number $b^tMa$
Сложная функция одной переменнойA composite function of one variableВыпиши слои и их значения в точке, затем перемножь производные слоёвWrite down the layers and their values at the point, then multiply the derivatives of the layers
Функция вида $x^tAx$ или $w^tAw - 2b^tw$A function such as $x^tAx$ or $w^tAw - 2b^tw$Градиент $(A+A^t)x$ (минус $2b$); проверь одну координату частной производнойThe gradient is $(A+A^t)x$ (minus $2b$); check one component with a partial derivative
Вторая производная функции $f(x(u,v),y(u,v))$A second derivative of $f(x(u,v),y(u,v))$Частные производные $f$ снова зависят от $u,v$: цепное правило к каждой заново, правило произведения для коэффициентовThe partial derivatives of $f$ again depend on $u,v$: apply the chain rule to each of them again, and the product rule to the coefficients
эталонная задачаmodel problem

Вторая производная после нелинейной замены переменныхSecond derivative after a nonlinear change of variables

RU

Условие. $f(x,y) = xy$, $x = u^2 - v^2$, $y = 2uv$, $g(u,v) = f\big(x(u,v),y(u,v)\big)$. Найти $\frac{\partial^2 g}{\partial u^2}$ в точке $(u,v) = (1,1)$.

Смотреть надо на порядок ходов, а не на числа: та же схема закрывает f0113, мост f0117 и финал f0120.

Шаг 1. Решить, от чего что зависит. $g$ зависит от $u$ через обе переменные $x$ и $y$. Значит, в $\frac{\partial g}{\partial u}$ будет два слагаемых. Сразу выписываем значения в точке: $x = 1-1 = 0$, $y = 2\cdot1\cdot1 = 2$.

Шаг 2. Собрать все производные замены, которые понадобятся. $\frac{\partial x}{\partial u} = 2u$, $\frac{\partial y}{\partial u} = 2v$, $\frac{\partial^2 x}{\partial u^2} = 2$, $\frac{\partial^2 y}{\partial u^2} = 0$. В точке: $2$, $2$, $2$, $0$. Коэффициенты зависят от $u$ — значит, на втором шаге понадобится правило произведения.

Шаг 3. Первая производная — цепное правило.

$$\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\cdot2u + \frac{\partial f}{\partial y}\cdot2v.$$

Шаг 4. Вторая производная — правило произведения и цепное правило заново. Каждое слагаемое — произведение двух функций от $u,v$: первое — $\frac{\partial f}{\partial x}(x(u,v),y(u,v))$ на $2u$, второе — $\frac{\partial f}{\partial y}(x(u,v),y(u,v))$ на $2v$. Правило произведения:

$$\frac{\partial}{\partial u}\Big(\frac{\partial f}{\partial x}\cdot2u\Big) = \Big(\frac{\partial^2 f}{\partial x^2}\cdot2u + \frac{\partial^2 f}{\partial y\,\partial x}\cdot2v\Big)\cdot2u + \frac{\partial f}{\partial x}\cdot2,$$$$\frac{\partial}{\partial u}\Big(\frac{\partial f}{\partial y}\cdot2v\Big) = \Big(\frac{\partial^2 f}{\partial x\,\partial y}\cdot2u + \frac{\partial^2 f}{\partial y^2}\cdot2v\Big)\cdot2v + \frac{\partial f}{\partial y}\cdot0.$$

Скобки — это цепное правило, применённое к $\frac{\partial f}{\partial x}$ и $\frac{\partial f}{\partial y}$; последние слагаемые — правило произведения.

Шаг 5. Подставить производные $f$ в точке. Для $f = xy$: $\frac{\partial f}{\partial x} = y = 2$, $\frac{\partial f}{\partial y} = x = 0$, $\frac{\partial^2 f}{\partial x^2} = 0$, $\frac{\partial^2 f}{\partial y^2} = 0$, смешанные равны $1$. При $u = v = 1$:

$$\frac{\partial^2 g}{\partial u^2} = (0\cdot2 + 1\cdot2)\cdot2 + 2\cdot2 + (1\cdot2 + 0\cdot2)\cdot2 + 0 = 4 + 4 + 4 = 12.$$

Шаг 6. Проверить прямой подстановкой. $g = (u^2-v^2)\cdot2uv = 2u^3v - 2uv^3$. Тогда $\frac{\partial g}{\partial u} = 6u^2v - 2v^3$ и $\frac{\partial^2 g}{\partial u^2} = 12uv = 12$ ✓. Если бы на шаге 4 пропало слагаемое $\frac{\partial f}{\partial x}\cdot2$, вышло бы $8$, и проверка это поймала бы.

Алгоритм
  1. Выпиши, через какие переменные $g$ зависит от $u$, и значения всех переменных в точке.
  2. Выпиши первые и вторые производные замены: $\frac{\partial x}{\partial u}$, $\frac{\partial^2 x}{\partial u^2}$ и такие же для $y$.
  3. Первая производная: сумма «частная производная $f$ × производная замены» по всем путям.
  4. Вторая производная: к каждой частной производной $f$ цепное правило заново, к коэффициентам — правило произведения.
  5. Подставь числа только в конце и проверь результат прямой подстановкой конкретной функции.
EN

Problem. $f(x,y) = xy$, $x = u^2 - v^2$, $y = 2uv$, $g(u,v) = f\big(x(u,v),y(u,v)\big)$. Find $\frac{\partial^2 g}{\partial u^2}$ at the point $(u,v) = (1,1)$.

Look at the order of the moves, not at the numbers: the same scheme closes f0113, the bridge f0117, and the final f0120.

Step 1. Decide what depends on what. $g$ depends on $u$ through both variables $x$ and $y$. So $\frac{\partial g}{\partial u}$ will have two terms. Write the values at the point right away: $x = 1-1 = 0$, $y = 2\cdot1\cdot1 = 2$.

Step 2. Collect every derivative of the change of variables you will need. $\frac{\partial x}{\partial u} = 2u$, $\frac{\partial y}{\partial u} = 2v$, $\frac{\partial^2 x}{\partial u^2} = 2$, $\frac{\partial^2 y}{\partial u^2} = 0$. At the point: $2$, $2$, $2$, $0$. The coefficients depend on $u$ — so the second differentiation will need the product rule.

Step 3. First derivative — the chain rule.

$$\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\cdot2u + \frac{\partial f}{\partial y}\cdot2v.$$

Step 4. Second derivative — the product rule and the chain rule again. Each term is the product of two functions of $u,v$: the first is $\frac{\partial f}{\partial x}(x(u,v),y(u,v))$ times $2u$, the second is $\frac{\partial f}{\partial y}(x(u,v),y(u,v))$ times $2v$. The product rule gives:

$$\frac{\partial}{\partial u}\Big(\frac{\partial f}{\partial x}\cdot2u\Big) = \Big(\frac{\partial^2 f}{\partial x^2}\cdot2u + \frac{\partial^2 f}{\partial y\,\partial x}\cdot2v\Big)\cdot2u + \frac{\partial f}{\partial x}\cdot2,$$$$\frac{\partial}{\partial u}\Big(\frac{\partial f}{\partial y}\cdot2v\Big) = \Big(\frac{\partial^2 f}{\partial x\,\partial y}\cdot2u + \frac{\partial^2 f}{\partial y^2}\cdot2v\Big)\cdot2v + \frac{\partial f}{\partial y}\cdot0.$$

The brackets are the chain rule applied to $\frac{\partial f}{\partial x}$ and $\frac{\partial f}{\partial y}$; the last terms come from the product rule.

Step 5. Substitute the derivatives of $f$ at the point. For $f = xy$: $\frac{\partial f}{\partial x} = y = 2$, $\frac{\partial f}{\partial y} = x = 0$, $\frac{\partial^2 f}{\partial x^2} = 0$, $\frac{\partial^2 f}{\partial y^2} = 0$, and the mixed ones equal $1$. At $u = v = 1$:

$$\frac{\partial^2 g}{\partial u^2} = (0\cdot2 + 1\cdot2)\cdot2 + 2\cdot2 + (1\cdot2 + 0\cdot2)\cdot2 + 0 = 4 + 4 + 4 = 12.$$

Step 6. Check by direct substitution. $g = (u^2-v^2)\cdot2uv = 2u^3v - 2uv^3$. Then $\frac{\partial g}{\partial u} = 6u^2v - 2v^3$ and $\frac{\partial^2 g}{\partial u^2} = 12uv = 12$ ✓. Had the term $\frac{\partial f}{\partial x}\cdot2$ been lost in step 4, the result would be $8$, and the check would catch it.

Algorithm
  1. Write down through which variables $g$ depends on $u$, and the values of all variables at the point.
  2. Write down the first and second derivatives of the change of variables: $\frac{\partial x}{\partial u}$, $\frac{\partial^2 x}{\partial u^2}$, and the same for $y$.
  3. First derivative: the sum of “partial derivative of $f$ × derivative of the change” over all paths.
  4. Second derivative: the chain rule again for each partial derivative of $f$, the product rule for the coefficients.
  5. Substitute numbers only at the end, and check the result by direct substitution of a concrete function.

Дополнительные материалыAdditional materials

Другие объяснения той же темы. Открывай их, если урока не хватило.Other explanations of the same topic. Open them if the lesson was not enough.

интерактивinteractivematrixmultiplication.xyzmatrixmultiplication.xyz EN
Анимация умножения матриц: видно, откуда берётся каждое число произведенияAn animation of matrix multiplication: you see where each number of the product comes from
видеоvideo3Blue1Brown · Matrix multiplication as composition3Blue1Brown · Matrix multiplication as composition EN
Произведение матриц как композиция преобразований: откуда берётся формула и почему порядок важенThe matrix product as a composition of transformations: where the formula comes from and why the order matters
текстtextMIT 18.02SC Multivariable CalculusMIT 18.02SC Multivariable Calculus EN
Частные производные, цепное правило и замена переменных с разобранными задачамиPartial derivatives, the chain rule, and change of variables with worked problems
как работать с задачамиhow to work with the problems
RU

Задачи урока выстроены в лестницу из четырёх ступеней. Две линии идут параллельно: матричная (размеры, транспонирование, след) и аналитическая (цепное правило, частные и вторые производные, замена переменных). На ступени 3 они сходятся. Иди по ступеням по порядку; у каждой задачи сначала отметь уверенность, потом открывай подсказку.

Полный объём — 20 задач. Всё, что есть на странице.

Минимум — 12 задач. f0102, f0103, f0104, f0105, f0106, f0113, f0116 и все обязательные. Это базовые техники обеих линий и мосты к финалам.

Обязательные — 5 задач. f0114 — мост к финалу f0119: раскрытие $x^tAx$ и транспонирование числа. f0117 — мост к финалу f0120: вторая производная после линейной замены. И сами финалы f0118, f0119, f0120. Финал f0119 идёт мини-тестом: 20 минут, без подсказок.

Ответы вводятся числом; десятичная дробь пишется через точку, запятая тоже принимается. Самопроверка на бумаге: в каждой задаче со сложной функцией выпиши значения слоёв в точке до дифференцирования, в каждой матричной — размеры под множителями.

EN

The lesson problems form a ladder of four steps. Two lines run in parallel: the matrix line (sizes, transpose, trace) and the calculus line (chain rule, partial and second derivatives, change of variables). They meet at ladder step 3. Go through the steps in order; for each problem mark your confidence first, then open a hint.

Full workload — 20 problems. Everything on the page.

Minimum — 12 problems. f0102, f0103, f0104, f0105, f0106, f0113, f0116, and all required ones. That is the basic techniques of both lines plus the bridges to the finals.

Required — 5 problems. f0114 is the bridge to the final f0119: expanding $x^tAx$ and transposing a number. f0117 is the bridge to the final f0120: a second derivative after a linear change of variables. Then the finals themselves: f0118, f0119, f0120. The final f0119 is the mini-test: 20 minutes, no hints.

Answers are entered as numbers; write decimals with a point, a comma is accepted too. A self-check on paper: in every problem with a composite function, write down the values of the layers at the point before differentiating; in every matrix problem, write the sizes under the factors.

20
полный объёмfull workload
12
минимумminimum
5
обязательныеrequired

Полный объём — все задачи ниже. Минимум — если времени мало. Обязательные — мосты к финалам, их не пропускают.Full workload: every problem below. Minimum: when time is short. Required: the bridges to the finals; never skip them.

Ступень 1 · Базовая техникаStep 1 · Basic technique

решено 7 из 77 of 7 solved

Один ход и маленькие числа: проверка, что определение понято. 1–3 минуты на задачу.One move and small numbers: a check that the definition is understood. 1–3 minutes per problem.

f0101ступень 1step 1F4.2✓авторскаяoriginal
RU

Пусть $A = \begin{pmatrix}1&2&0\\-1&3&1\end{pmatrix}\in M_{2\times3}$ и $B = \begin{pmatrix}2&1\\0&-1\\4&2\end{pmatrix}\in M_{3\times2}$. Найдите элемент матрицы $AB$ в строке 2, столбце 1.

EN

Let $A = \begin{pmatrix}1&2&0\\-1&3&1\end{pmatrix}\in M_{2\times3}$ and $B = \begin{pmatrix}2&1\\0&-1\\4&2\end{pmatrix}\in M_{3\times2}$. Find the entry of $AB$ in row 2, column 1.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

Элемент $(AB)_{21}$ — скалярное произведение второй строки $A$ на первый столбец $B$.

EN

The entry $(AB)_{21}$ is the dot product of the second row of $A$ with the first column of $B$.

РешениеSolution
RU

Размеры. $(2\times3)(3\times2) = 2\times2$: внутренние размеры совпали, произведение определено, и элемент в строке 2, столбце 1 существует.

Строка на столбец. Вторая строка $A$ — $(-1,\ 3,\ 1)$, первый столбец $B$ — $(2,0,4)^t$:

$$(AB)_{21} = (-1)\cdot2 + 3\cdot0 + 1\cdot4 = -2 + 0 + 4 = 2.$$

Проверка всей матрицей. Первая строка $AB$: $(1\cdot2+2\cdot0+0\cdot4,\ 1\cdot1+2\cdot(-1)+0\cdot2) = (2,\ -1)$; вторая: $\big(2,\ (-1)\cdot1+3\cdot(-1)+1\cdot2\big) = (2,\ -2)$. Значит,

$$AB = \begin{pmatrix}2&-1\\2&-2\end{pmatrix},$$

и в строке 2, столбце 1 стоит $2$ ✓.

Куда это ведёт

В f0108 те же матрицы умножаются в другом порядке, и размер ответа становится другим.

EN

Sizes. $(2\times3)(3\times2) = 2\times2$: the inner sizes match, the product is defined, and the entry in row 2, column 1 exists.

Row times column. The second row of $A$ is $(-1,\ 3,\ 1)$, the first column of $B$ is $(2,0,4)^t$:

$$(AB)_{21} = (-1)\cdot2 + 3\cdot0 + 1\cdot4 = -2 + 0 + 4 = 2.$$

Check with the whole matrix. The first row of $AB$: $(1\cdot2+2\cdot0+0\cdot4,\ 1\cdot1+2\cdot(-1)+0\cdot2) = (2,\ -1)$; the second: $\big(2,\ (-1)\cdot1+3\cdot(-1)+1\cdot2\big) = (2,\ -2)$. So

$$AB = \begin{pmatrix}2&-1\\2&-2\end{pmatrix},$$

and row 2, column 1 holds $2$ ✓.

Where this leads

In f0108 the same matrices are multiplied in the other order, and the size of the answer changes.

f0102ступень 1step 1минимумminimumCM.4F4.2✓авторскаяoriginal
RU

Пусть $A = \begin{pmatrix}1&2\\3&4\end{pmatrix}$ и $B = \begin{pmatrix}0&1\\-1&2\end{pmatrix}$. Найдите элемент матрицы $(AB)^t$ в строке 1, столбце 2.

EN

Let $A = \begin{pmatrix}1&2\\3&4\end{pmatrix}$ and $B = \begin{pmatrix}0&1\\-1&2\end{pmatrix}$. Find the entry of $(AB)^t$ in row 1, column 2.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

Транспонирование меняет местами номер строки и номер столбца: $\big((AB)^t\big)_{12} = (AB)_{21}$.

EN

The transpose swaps the row number and the column number: $\big((AB)^t\big)_{12} = (AB)_{21}$.

РешениеSolution
RU

Переход к элементу $AB$. По определению транспонирования $\big((AB)^t\big)_{12} = (AB)_{21}$.

Строка на столбец. Вторая строка $A$ — $(3,\ 4)$, первый столбец $B$ — $(0,-1)^t$:

$$(AB)_{21} = 3\cdot0 + 4\cdot(-1) = -4.$$

Проверка через $B^tA^t$. $B^t = \begin{pmatrix}0&-1\\1&2\end{pmatrix}$, $A^t = \begin{pmatrix}1&3\\2&4\end{pmatrix}$. Элемент $(B^tA^t)_{12}$ — первая строка $B^t$ на второй столбец $A^t$: $0\cdot3 + (-1)\cdot4 = -4$ ✓.

Неверный порядок даёт другое число

$(A^tB^t)_{12}$ — первая строка $A^t$, то есть $(1,\ 3)$, на второй столбец $B^t$, то есть $(-1,2)^t$: $-1 + 6 = 5$. Порядок в $(AB)^t = B^tA^t$ разворачивается.

EN

Back to an entry of $AB$. By the definition of the transpose, $\big((AB)^t\big)_{12} = (AB)_{21}$.

Row times column. The second row of $A$ is $(3,\ 4)$, the first column of $B$ is $(0,-1)^t$:

$$(AB)_{21} = 3\cdot0 + 4\cdot(-1) = -4.$$

Check with $B^tA^t$. $B^t = \begin{pmatrix}0&-1\\1&2\end{pmatrix}$, $A^t = \begin{pmatrix}1&3\\2&4\end{pmatrix}$. The entry $(B^tA^t)_{12}$ is the first row of $B^t$ times the second column of $A^t$: $0\cdot3 + (-1)\cdot4 = -4$ ✓.

The wrong order gives another number

$(A^tB^t)_{12}$ is the first row of $A^t$, that is $(1,\ 3)$, times the second column of $B^t$, that is $(-1,2)^t$: $-1 + 6 = 5$. In $(AB)^t = B^tA^t$ the order reverses.

f0103ступень 1step 1минимумminimumF4.4F4.2✓авторскаяoriginal
RU

Пусть $A = \begin{pmatrix}1&0&2\\-1&1&0\end{pmatrix}\in M_{2\times3}$ и $B = \begin{pmatrix}3&1\\0&2\\1&-1\end{pmatrix}\in M_{3\times2}$. Найдите $\tr(BA)$.

EN

Let $A = \begin{pmatrix}1&0&2\\-1&1&0\end{pmatrix}\in M_{2\times3}$ and $B = \begin{pmatrix}3&1\\0&2\\1&-1\end{pmatrix}\in M_{3\times2}$. Find $\tr(BA)$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

$BA$ — матрица $3\times3$, но для следа нужны только три диагональных элемента: $(BA)_{ii}$ — строка $i$ матрицы $B$ на столбец $i$ матрицы $A$.

EN

$BA$ is a $3\times3$ matrix, but the trace needs only the three diagonal entries: $(BA)_{ii}$ is row $i$ of $B$ times column $i$ of $A$.

РешениеSolution
RU

Размер. $(3\times2)(2\times3) = 3\times3$, след — сумма трёх диагональных элементов.

Диагональ.

$$(BA)_{11} = 3\cdot1 + 1\cdot(-1) = 2,\qquad (BA)_{22} = 0\cdot0 + 2\cdot1 = 2,\qquad (BA)_{33} = 1\cdot2 + (-1)\cdot0 = 2.$$

Значит, $\tr(BA) = 2+2+2 = 6$.

Проверка цикличностью. $AB$ — матрица $2\times2$. Её диагональ: $(AB)_{11} = 1\cdot3+0\cdot0+2\cdot1 = 5$, $(AB)_{22} = (-1)\cdot1+1\cdot2+0\cdot(-1) = 1$. Значит, $\tr(AB) = 6 = \tr(BA)$ ✓, хотя размеры $AB$ и $BA$ разные.

EN

Size. $(3\times2)(2\times3) = 3\times3$; the trace is the sum of three diagonal entries.

Diagonal.

$$(BA)_{11} = 3\cdot1 + 1\cdot(-1) = 2,\qquad (BA)_{22} = 0\cdot0 + 2\cdot1 = 2,\qquad (BA)_{33} = 1\cdot2 + (-1)\cdot0 = 2.$$

So $\tr(BA) = 2+2+2 = 6$.

Check with the cyclic property. $AB$ is a $2\times2$ matrix. Its diagonal: $(AB)_{11} = 1\cdot3+0\cdot0+2\cdot1 = 5$, $(AB)_{22} = (-1)\cdot1+1\cdot2+0\cdot(-1) = 1$. So $\tr(AB) = 6 = \tr(BA)$ ✓, even though $AB$ and $BA$ have different sizes.

f0104ступень 1step 1минимумminimumF3.2✓авторскаяoriginal
RU

Найдите производную функции $y = (3x^2-1)^4$ в точке $x = 1$.

EN

Find the derivative of $y = (3x^2-1)^4$ at the point $x = 1$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

Внешний слой $y = u^4$, внутренний $u = 3x^2-1$. Производная внешнего слоя берётся в значении $u_0 = u(1)$.

EN

The outer layer is $y = u^4$, the inner one is $u = 3x^2-1$. The derivative of the outer layer is taken at the value $u_0 = u(1)$.

РешениеSolution
RU

Слои и значения. $u = 3x^2-1$, $y = u^4$. При $x = 1$: $u_0 = 3-1 = 2$.

Производные слоёв. $\frac{dy}{du} = 4u^3$, при $u_0 = 2$ это $4\cdot8 = 32$. $\frac{du}{dx} = 6x$, при $x = 1$ это $6$.

Цепное правило.

$$\frac{dy}{dx}\Big|_{x=1} = 32\cdot6 = 192.$$

Проверка линейным приближением. При малом $h$: $u(1+h) = 3(1+h)^2-1 = 2 + 6h + 3h^2$, а $(2+6h+3h^2)^4 = 16 + 4\cdot2^3\cdot6h + o(h) = 16 + 192h + o(h)$. Коэффициент при $h$ равен $192$ ✓.

EN

Layers and values. $u = 3x^2-1$, $y = u^4$. At $x = 1$: $u_0 = 3-1 = 2$.

Derivatives of the layers. $\frac{dy}{du} = 4u^3$, which is $4\cdot8 = 32$ at $u_0 = 2$. $\frac{du}{dx} = 6x$, which is $6$ at $x = 1$.

Chain rule.

$$\frac{dy}{dx}\Big|_{x=1} = 32\cdot6 = 192.$$

Check with the linear approximation. For small $h$: $u(1+h) = 3(1+h)^2-1 = 2 + 6h + 3h^2$, and $(2+6h+3h^2)^4 = 16 + 4\cdot2^3\cdot6h + o(h) = 16 + 192h + o(h)$. The coefficient of $h$ is $192$ ✓.

f0105ступень 1step 1минимумminimumF3.7✓авторскаяoriginal
RU

Пусть $f(x^1,x^2) = (x^1)^3x^2 - 2x^1(x^2)^2$. Найдите $\dfrac{\partial f}{\partial x^2}$ в точке $(1,2)^t$.

EN

Let $f(x^1,x^2) = (x^1)^3x^2 - 2x^1(x^2)^2$. Find $\dfrac{\partial f}{\partial x^2}$ at the point $(1,2)^t$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

Считай $x^1$ числом и дифференцируй по $x^2$. Точку подставляй только после дифференцирования.

EN

Treat $x^1$ as a number and differentiate in $x^2$. Substitute the point only after differentiating.

РешениеSolution
RU

Дифференцирование по $x^2$. В первом слагаемом $(x^1)^3$ — числовой множитель при $x^2$, его производная по $x^2$ равна $(x^1)^3$. Во втором $-2x^1$ — числовой множитель при $(x^2)^2$: производная $-2x^1\cdot2x^2 = -4x^1x^2$.

$$\frac{\partial f}{\partial x^2} = (x^1)^3 - 4x^1x^2.$$

Точка. $x^1 = 1$, $x^2 = 2$: $1 - 4\cdot1\cdot2 = 1 - 8 = -7$.

Проверка определением. $f(1,\ 2+h) = (2+h) - 2(2+h)^2 = 2 + h - 8 - 8h - 2h^2 = -6 - 7h - 2h^2$, $f(1,2) = -6$, поэтому $\frac{f(1,2+h)-f(1,2)}{h} = -7 - 2h \to -7$ ✓.

EN

Differentiating in $x^2$. In the first term $(x^1)^3$ is a numerical factor of $x^2$, so its derivative in $x^2$ is $(x^1)^3$. In the second, $-2x^1$ is a numerical factor of $(x^2)^2$: the derivative is $-2x^1\cdot2x^2 = -4x^1x^2$.

$$\frac{\partial f}{\partial x^2} = (x^1)^3 - 4x^1x^2.$$

The point. $x^1 = 1$, $x^2 = 2$: $1 - 4\cdot1\cdot2 = 1 - 8 = -7$.

Check with the definition. $f(1,\ 2+h) = (2+h) - 2(2+h)^2 = 2 + h - 8 - 8h - 2h^2 = -6 - 7h - 2h^2$, $f(1,2) = -6$, so $\frac{f(1,2+h)-f(1,2)}{h} = -7 - 2h \to -7$ ✓.

f0106ступень 1step 1минимумminimumF3.7✓авторскаяoriginal
RU

Пусть $f(x,y) = x^3y^2$. Найдите $\dfrac{\partial^2 f}{\partial x\,\partial y}$ в точке $(1,2)^t$.

EN

Let $f(x,y) = x^3y^2$. Find $\dfrac{\partial^2 f}{\partial x\,\partial y}$ at the point $(1,2)^t$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

По определению это $\dfrac{\partial}{\partial x}\Big(\dfrac{\partial f}{\partial y}\Big)$: сначала по $y$, потом результат по $x$.

EN

By definition this is $\dfrac{\partial}{\partial x}\Big(\dfrac{\partial f}{\partial y}\Big)$: first in $y$, then the result in $x$.

РешениеSolution
RU

Сначала по $y$. $x$ — число: $\frac{\partial f}{\partial y} = x^3\cdot2y = 2x^3y$.

Потом по $x$. $y$ — число: $\frac{\partial}{\partial x}(2x^3y) = 6x^2y$.

Точка. $6\cdot1^2\cdot2 = 12$.

Проверка другим порядком. $\frac{\partial f}{\partial x} = 3x^2y^2$, $\frac{\partial}{\partial y}(3x^2y^2) = 6x^2y$ — то же выражение, как и обещает теорема Шварца для многочлена ✓.

EN

First in $y$. $x$ is a number: $\frac{\partial f}{\partial y} = x^3\cdot2y = 2x^3y$.

Then in $x$. $y$ is a number: $\frac{\partial}{\partial x}(2x^3y) = 6x^2y$.

The point. $6\cdot1^2\cdot2 = 12$.

Check with the other order. $\frac{\partial f}{\partial x} = 3x^2y^2$, $\frac{\partial}{\partial y}(3x^2y^2) = 6x^2y$ — the same expression, as Schwarz’s theorem promises for a polynomial ✓.

f0107ступень 1step 1CM.7✓авторскаяoriginal
RU

Пусть $y = f(u^1,u^2) = u^1u^2 + (u^2)^2$, где $u^1 = t^2$, $u^2 = 3t-1$. Найдите $\dfrac{dy}{dt}$ при $t = 1$.

EN

Let $y = f(u^1,u^2) = u^1u^2 + (u^2)^2$, where $u^1 = t^2$, $u^2 = 3t-1$. Find $\dfrac{dy}{dt}$ at $t = 1$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

Цепное правило лекции: $\dfrac{dy}{dt} = \dfrac{\partial f}{\partial u^1}\dfrac{du^1}{dt} + \dfrac{\partial f}{\partial u^2}\dfrac{du^2}{dt}$, частные производные — в точке $u_0 = \big(u^1(1),u^2(1)\big)^t$.

EN

The chain rule from the lecture: $\dfrac{dy}{dt} = \dfrac{\partial f}{\partial u^1}\dfrac{du^1}{dt} + \dfrac{\partial f}{\partial u^2}\dfrac{du^2}{dt}$, with the partial derivatives at the point $u_0 = \big(u^1(1),u^2(1)\big)^t$.

РешениеSolution
RU

Значения. При $t = 1$: $u^1 = 1$, $u^2 = 3-1 = 2$, то есть $u_0 = (1,2)^t$.

Частные производные $f$ в $u_0$. $\frac{\partial f}{\partial u^1} = u^2 = 2$; $\frac{\partial f}{\partial u^2} = u^1 + 2u^2 = 1 + 4 = 5$.

Производные замены при $t = 1$. $\frac{du^1}{dt} = 2t = 2$; $\frac{du^2}{dt} = 3$.

Цепное правило.

$$\frac{dy}{dt}\Big|_{t=1} = 2\cdot2 + 5\cdot3 = 4 + 15 = 19.$$

Проверка подстановкой. $y(t) = t^2(3t-1) + (3t-1)^2 = 3t^3 - t^2 + 9t^2 - 6t + 1 = 3t^3 + 8t^2 - 6t + 1$, и $y'(t) = 9t^2 + 16t - 6$, при $t = 1$ это $9 + 16 - 6 = 19$ ✓.

EN

Values. At $t = 1$: $u^1 = 1$, $u^2 = 3-1 = 2$, that is, $u_0 = (1,2)^t$.

Partial derivatives of $f$ at $u_0$. $\frac{\partial f}{\partial u^1} = u^2 = 2$; $\frac{\partial f}{\partial u^2} = u^1 + 2u^2 = 1 + 4 = 5$.

Derivatives of the substitution at $t = 1$. $\frac{du^1}{dt} = 2t = 2$; $\frac{du^2}{dt} = 3$.

Chain rule.

$$\frac{dy}{dt}\Big|_{t=1} = 2\cdot2 + 5\cdot3 = 4 + 15 = 19.$$

Check by substitution. $y(t) = t^2(3t-1) + (3t-1)^2 = 3t^3 - t^2 + 9t^2 - 6t + 1 = 3t^3 + 8t^2 - 6t + 1$, and $y'(t) = 9t^2 + 16t - 6$, which is $9 + 16 - 6 = 19$ at $t = 1$ ✓.

Ступень 2 · Техника с усложнениемStep 2 · Technique with one complication

решено 6 из 66 of 6 solved

Тот же ход и ровно одно усложнение: больше размер, знак или композиция.The same move plus exactly one complication: a larger size, a sign, or a composition.

f0108ступень 2step 2F4.2✓авторскаяoriginal
RU

Пусть $A = \begin{pmatrix}1&2&0\\-1&3&1\end{pmatrix}\in M_{2\times3}$ и $B = \begin{pmatrix}2&1\\0&-1\\4&2\end{pmatrix}\in M_{3\times2}$ (те же, что в f0101). Найдите сумму всех элементов матрицы $BA$.

EN

Let $A = \begin{pmatrix}1&2&0\\-1&3&1\end{pmatrix}\in M_{2\times3}$ and $B = \begin{pmatrix}2&1\\0&-1\\4&2\end{pmatrix}\in M_{3\times2}$ (the same as in f0101). Find the sum of all entries of $BA$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Сначала размер: $(3\times2)(2\times3)$. Матрица $BA$ не той же формы, что $AB$.

EN

Start with the size: $(3\times2)(2\times3)$. The matrix $BA$ does not have the shape of $AB$.

Подсказка 2 из 2Hint 2 of 2
RU

Строка $i$ матрицы $BA$ равна $b_{i1}\cdot(\text{строка 1 матрицы } A) + b_{i2}\cdot(\text{строка 2 матрицы } A)$.

EN

Row $i$ of $BA$ equals $b_{i1}\cdot(\text{row 1 of } A) + b_{i2}\cdot(\text{row 2 of } A)$.

РешениеSolution
RU

Размер. $(3\times2)(2\times3) = 3\times3$: девять элементов, а у $AB$ из f0101 их четыре.

Строки $BA$. Строка $i$ — комбинация строк $A$ с коэффициентами из строки $i$ матрицы $B$:

$$\text{строка 1: } 2\cdot(1,2,0) + 1\cdot(-1,3,1) = (2-1,\ 4+3,\ 0+1) = (1,\ 7,\ 1),$$$$\text{строка 2: } 0\cdot(1,2,0) + (-1)\cdot(-1,3,1) = (1,\ -3,\ -1),$$$$\text{строка 3: } 4\cdot(1,2,0) + 2\cdot(-1,3,1) = (4-2,\ 8+6,\ 0+2) = (2,\ 14,\ 2).$$

Сумма. $(1+7+1) + (1-3-1) + (2+14+2) = 9 - 3 + 18 = 24$.

Проверка другим путём. Сумма всех элементов матрицы $C$ — это $\mathbf 1^tC\mathbf 1$, где $\mathbf 1$ — столбец из единиц нужной длины. Тогда сумма элементов $BA$ равна $(\mathbf 1^tB)(A\mathbf 1)$. Строка $\mathbf 1^tB$ — суммы столбцов $B$: $(2+0+4,\ 1-1+2) = (6,\ 2)$. Столбец $A\mathbf 1$ — суммы строк $A$: $(3,3)^t$. Произведение: $6\cdot3 + 2\cdot3 = 24$ ✓.

EN

Size. $(3\times2)(2\times3) = 3\times3$: nine entries, while $AB$ from f0101 has four.

Rows of $BA$. Row $i$ is a combination of the rows of $A$ with coefficients from row $i$ of $B$:

$$\text{row 1: } 2\cdot(1,2,0) + 1\cdot(-1,3,1) = (2-1,\ 4+3,\ 0+1) = (1,\ 7,\ 1),$$$$\text{row 2: } 0\cdot(1,2,0) + (-1)\cdot(-1,3,1) = (1,\ -3,\ -1),$$$$\text{row 3: } 4\cdot(1,2,0) + 2\cdot(-1,3,1) = (4-2,\ 8+6,\ 0+2) = (2,\ 14,\ 2).$$

Sum. $(1+7+1) + (1-3-1) + (2+14+2) = 9 - 3 + 18 = 24$.

Check by another route. The sum of all entries of a matrix $C$ is $\mathbf 1^tC\mathbf 1$, where $\mathbf 1$ is a column of ones of the right length. So the sum of the entries of $BA$ is $(\mathbf 1^tB)(A\mathbf 1)$. The row $\mathbf 1^tB$ holds the column sums of $B$: $(2+0+4,\ 1-1+2) = (6,\ 2)$. The column $A\mathbf 1$ holds the row sums of $A$: $(3,3)^t$. The product: $6\cdot3 + 2\cdot3 = 24$ ✓.

f0109ступень 2step 2F4.4CM.4✓авторскаяoriginal
RU

Пусть $u = (1,-2,3)^t$ и $v = (2,1,1)^t$. Найдите $\tr(uv^t)$.

EN

Let $u = (1,-2,3)^t$ and $v = (2,1,1)^t$. Find $\tr(uv^t)$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

$uv^t$ — матрица $3\times3$. Можно взять её диагональ, а можно применить цикличность: $\tr(uv^t) = \tr(v^tu)$. Какого размера $v^tu$?

EN

$uv^t$ is a $3\times3$ matrix. You can take its diagonal, or use the cyclic property: $\tr(uv^t) = \tr(v^tu)$. What is the size of $v^tu$?

РешениеSolution
RU

Путь 1: диагональ. $(uv^t)_{ii} = u^iv^i$, поэтому

$$\tr(uv^t) = 1\cdot2 + (-2)\cdot1 + 3\cdot1 = 2 - 2 + 3 = 3.$$

Путь 2: цикличность. $\tr(uv^t) = \tr(v^tu)$, а $v^tu$ — матрица $(1\times3)(3\times1) = 1\times1$, то есть число $2\cdot1 + 1\cdot(-2) + 1\cdot3 = 3$. След числа равен самому числу ✓.

Куда это ведёт

След матрицы $3\times3$ оказался одним скалярным произведением. В f0115 и f0118 перед вектором стоят ещё матрицы, но приём тот же.

EN

Route 1: the diagonal. $(uv^t)_{ii} = u^iv^i$, so

$$\tr(uv^t) = 1\cdot2 + (-2)\cdot1 + 3\cdot1 = 2 - 2 + 3 = 3.$$

Route 2: the cyclic property. $\tr(uv^t) = \tr(v^tu)$, and $v^tu$ is a $(1\times3)(3\times1) = 1\times1$ matrix, that is, the number $2\cdot1 + 1\cdot(-2) + 1\cdot3 = 3$. The trace of a number is the number itself ✓.

Where this leads

The trace of a $3\times3$ matrix turned out to be a single dot product. In f0115 and f0118 more matrices stand in front of the vector, but the trick is the same.

f0110ступень 2step 2F3.2✓авторскаяoriginal
RU

Найдите производную функции $y = \sqrt{1+(x^2+1)^3}$ в точке $x = 1$.

EN

Find the derivative of $y = \sqrt{1+(x^2+1)^3}$ at the point $x = 1$.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Три слоя: $y = \sqrt w$, $w = 1+v^3$, $v = x^2+1$. Сначала посчитай значения всех слоёв при $x = 1$.

EN

Three layers: $y = \sqrt w$, $w = 1+v^3$, $v = x^2+1$. First compute the values of all layers at $x = 1$.

Подсказка 2 из 2Hint 2 of 2
RU

$\dfrac{dy}{dx} = \dfrac{dy}{dw}\cdot\dfrac{dw}{dv}\cdot\dfrac{dv}{dx}$, и каждая производная берётся в значении своего внутреннего слоя.

EN

$\dfrac{dy}{dx} = \dfrac{dy}{dw}\cdot\dfrac{dw}{dv}\cdot\dfrac{dv}{dx}$, and each derivative is taken at the value of its own inner layer.

РешениеSolution
RU

Значения слоёв. При $x = 1$: $v_0 = 2$, $w_0 = 1 + 8 = 9$, $y_0 = 3$.

Производные слоёв. $\frac{dy}{dw} = \frac{1}{2\sqrt w} = \frac{1}{6}$ при $w_0 = 9$; $\frac{dw}{dv} = 3v^2 = 12$ при $v_0 = 2$; $\frac{dv}{dx} = 2x = 2$ при $x = 1$.

Цепное правило.

$$\frac{dy}{dx}\Big|_{x=1} = \frac{1}{6}\cdot12\cdot2 = 4.$$

Проверка другим путём. $y^2 = 1 + (x^2+1)^3$. Продифференцируем обе части по $x$: $2y\,y' = 3(x^2+1)^2\cdot2x$. При $x = 1$, $y = 3$: $6y' = 3\cdot4\cdot2 = 24$, откуда $y' = 4$ ✓.

EN

Values of the layers. At $x = 1$: $v_0 = 2$, $w_0 = 1 + 8 = 9$, $y_0 = 3$.

Derivatives of the layers. $\frac{dy}{dw} = \frac{1}{2\sqrt w} = \frac{1}{6}$ at $w_0 = 9$; $\frac{dw}{dv} = 3v^2 = 12$ at $v_0 = 2$; $\frac{dv}{dx} = 2x = 2$ at $x = 1$.

Chain rule.

$$\frac{dy}{dx}\Big|_{x=1} = \frac{1}{6}\cdot12\cdot2 = 4.$$

Check by another route. $y^2 = 1 + (x^2+1)^3$. Differentiate both sides in $x$: $2y\,y' = 3(x^2+1)^2\cdot2x$. At $x = 1$, $y = 3$: $6y' = 3\cdot4\cdot2 = 24$, so $y' = 4$ ✓.

f0111ступень 2step 2F3.7F3.2✓авторскаяoriginal
RU

Пусть $f(x^1,x^2) = \ln\big((x^1)^2 + 3x^1x^2\big)$. Найдите $\dfrac{\partial f}{\partial x^1}$ в точке $(1,1)^t$. Ответ запишите точно, в виде десятичной дроби.

EN

Let $f(x^1,x^2) = \ln\big((x^1)^2 + 3x^1x^2\big)$. Find $\dfrac{\partial f}{\partial x^1}$ at the point $(1,1)^t$. Give the answer exactly, as a decimal.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 1Hint 1 of 1
RU

Внешний слой $\ln w$, внутренний $w = (x^1)^2 + 3x^1x^2$. Переменная $x^2$ — число.

EN

The outer layer is $\ln w$, the inner one is $w = (x^1)^2 + 3x^1x^2$. The variable $x^2$ is a number.

РешениеSolution
RU

Внутренний слой. $w = (x^1)^2 + 3x^1x^2$, в точке $w_0 = 1 + 3 = 4$. По $x^1$ при замороженном $x^2$: $\frac{\partial w}{\partial x^1} = 2x^1 + 3x^2$, в точке $2 + 3 = 5$.

Цепное правило. $\frac{\partial f}{\partial x^1} = \frac{1}{w}\cdot\frac{\partial w}{\partial x^1} = \frac{2x^1+3x^2}{(x^1)^2+3x^1x^2}$, в точке $\frac{5}{4} = 1.25$.

Проверка линейным приближением. $f(1+h,\ 1) = \ln\big((1+h)^2 + 3(1+h)\big) = \ln(4 + 5h + h^2) = \ln4 + \ln\big(1 + \tfrac{5h+h^2}{4}\big)$. Так как $\ln(1+s) = s + o(s)$, получаем $f(1+h,1) = \ln4 + \frac{5}{4}h + o(h)$, и коэффициент при $h$ равен $1.25$ ✓.

EN

Inner layer. $w = (x^1)^2 + 3x^1x^2$, at the point $w_0 = 1 + 3 = 4$. In $x^1$ with $x^2$ frozen: $\frac{\partial w}{\partial x^1} = 2x^1 + 3x^2$, at the point $2 + 3 = 5$.

Chain rule. $\frac{\partial f}{\partial x^1} = \frac{1}{w}\cdot\frac{\partial w}{\partial x^1} = \frac{2x^1+3x^2}{(x^1)^2+3x^1x^2}$, at the point $\frac{5}{4} = 1.25$.

Check with the linear approximation. $f(1+h,\ 1) = \ln\big((1+h)^2 + 3(1+h)\big) = \ln(4 + 5h + h^2) = \ln4 + \ln\big(1 + \tfrac{5h+h^2}{4}\big)$. Since $\ln(1+s) = s + o(s)$, we get $f(1+h,1) = \ln4 + \frac{5}{4}h + o(h)$, and the coefficient of $h$ is $1.25$ ✓.

f0112ступень 2step 2F3.7F3.2✓авторскаяoriginal
RU

Пусть $f(x,y) = \sin(xy)$. Найдите $\dfrac{\partial^2 f}{\partial x\,\partial y}$ в точке $(1,\pi/3)^t$. Ответ округлите до четырёх знаков после запятой.

EN

Let $f(x,y) = \sin(xy)$. Find $\dfrac{\partial^2 f}{\partial x\,\partial y}$ at the point $(1,\pi/3)^t$. Round your answer to four decimal places.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Сначала $\dfrac{\partial f}{\partial y}$ по цепному правилу: $x$ — число, внутренний слой $xy$.

EN

First find $\dfrac{\partial f}{\partial y}$ by the chain rule: $x$ is a number, the inner layer is $xy$.

Подсказка 2 из 2Hint 2 of 2
RU

$\dfrac{\partial f}{\partial y} = x\cos(xy)$ — произведение двух множителей, и оба зависят от $x$. Дифференцируй по $x$ по правилу произведения.

EN

$\dfrac{\partial f}{\partial y} = x\cos(xy)$ is a product of two factors, and both depend on $x$. Differentiate in $x$ by the product rule.

РешениеSolution
RU

Сначала по $y$. Внутренний слой $xy$, его производная по $y$ равна $x$: $\frac{\partial f}{\partial y} = \cos(xy)\cdot x = x\cos(xy)$.

Потом по $x$, правило произведения. Множитель $x$ даёт $1\cdot\cos(xy)$; множитель $\cos(xy)$ даёт $x\cdot\big(-\sin(xy)\big)\cdot y$ (цепное правило, производная $xy$ по $x$ равна $y$):

$$\frac{\partial^2 f}{\partial x\,\partial y} = \cos(xy) - xy\sin(xy).$$

Точка. $xy = \pi/3$, $\cos\frac{\pi}{3} = \frac12$, $\sin\frac{\pi}{3} = \frac{\sqrt3}{2}$:

$$\frac12 - \frac{\pi}{3}\cdot\frac{\sqrt3}{2} = \frac12 - \frac{\pi\sqrt3}{6} \approx 0.5 - 0.9069 = -0.4069.$$

Проверка другим порядком. $\frac{\partial f}{\partial x} = y\cos(xy)$, и по правилу произведения $\frac{\partial}{\partial y}\big(y\cos(xy)\big) = \cos(xy) - xy\sin(xy)$ — то же выражение ✓. Без правила произведения осталось бы только $-xy\sin(xy) \approx -0.9069$: потерянное слагаемое $\cos(xy) = \frac12$ и есть разница.

Куда это ведёт

В полярных координатах коэффициенты $r$, $\cos\theta$, $\sin\theta$ стоят множителями при частных производных, и при втором дифференцировании нужно ровно это правило произведения.

EN

First in $y$. The inner layer is $xy$, its derivative in $y$ is $x$: $\frac{\partial f}{\partial y} = \cos(xy)\cdot x = x\cos(xy)$.

Then in $x$, the product rule. The factor $x$ gives $1\cdot\cos(xy)$; the factor $\cos(xy)$ gives $x\cdot\big(-\sin(xy)\big)\cdot y$ (the chain rule; the derivative of $xy$ in $x$ is $y$):

$$\frac{\partial^2 f}{\partial x\,\partial y} = \cos(xy) - xy\sin(xy).$$

The point. $xy = \pi/3$, $\cos\frac{\pi}{3} = \frac12$, $\sin\frac{\pi}{3} = \frac{\sqrt3}{2}$:

$$\frac12 - \frac{\pi}{3}\cdot\frac{\sqrt3}{2} = \frac12 - \frac{\pi\sqrt3}{6} \approx 0.5 - 0.9069 = -0.4069.$$

Check with the other order. $\frac{\partial f}{\partial x} = y\cos(xy)$, and by the product rule $\frac{\partial}{\partial y}\big(y\cos(xy)\big) = \cos(xy) - xy\sin(xy)$ — the same expression ✓. Without the product rule only $-xy\sin(xy) \approx -0.9069$ would remain: the lost term $\cos(xy) = \frac12$ is exactly the difference.

Where this leads

In polar coordinates the coefficients $r$, $\cos\theta$, $\sin\theta$ stand as factors next to the partial derivatives, and the second differentiation needs exactly this product rule.

f0113ступень 2step 2минимумminimumCM.11F3.7✓по мотивам ДЗ HW-M02, п. 2based on homework HW-M02, item 2
RU

Пусть $f(x,y) = x^2y$, где $x = r\cos\theta$, $y = r\sin\theta$. Найдите $\dfrac{\partial f}{\partial\theta}$ при $r = 2$, $\theta = \pi/4$. Ответ округлите до четырёх знаков после запятой.

EN

Let $f(x,y) = x^2y$, where $x = r\cos\theta$, $y = r\sin\theta$. Find $\dfrac{\partial f}{\partial\theta}$ at $r = 2$, $\theta = \pi/4$. Round your answer to four decimal places.

верноcorrect

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Формула с доски лекции math-02: $\dfrac{\partial f}{\partial\theta} = \dfrac{\partial f}{\partial x}(-r\sin\theta) + \dfrac{\partial f}{\partial y}\,r\cos\theta$. Сначала найди $x$ и $y$ в этой точке.

EN

The formula from the board of lecture math-02: $\dfrac{\partial f}{\partial\theta} = \dfrac{\partial f}{\partial x}(-r\sin\theta) + \dfrac{\partial f}{\partial y}\,r\cos\theta$. First find $x$ and $y$ at this point.

Подсказка 2 из 2Hint 2 of 2
RU

$x = y = \sqrt2$; $\dfrac{\partial f}{\partial x} = 2xy$, $\dfrac{\partial f}{\partial y} = x^2$.

EN

$x = y = \sqrt2$; $\dfrac{\partial f}{\partial x} = 2xy$, $\dfrac{\partial f}{\partial y} = x^2$.

РешениеSolution
RU

Значения. $\cos\frac{\pi}{4} = \sin\frac{\pi}{4} = \frac{\sqrt2}{2}$, поэтому $x = y = 2\cdot\frac{\sqrt2}{2} = \sqrt2$.

Частные производные $f$ в точке. $\frac{\partial f}{\partial x} = 2xy = 2\cdot\sqrt2\cdot\sqrt2 = 4$, $\frac{\partial f}{\partial y} = x^2 = 2$.

Производные замены. $\frac{\partial x}{\partial\theta} = -r\sin\theta = -\sqrt2$, $\frac{\partial y}{\partial\theta} = r\cos\theta = \sqrt2$.

Цепное правило.

$$\frac{\partial f}{\partial\theta} = 4\cdot(-\sqrt2) + 2\cdot\sqrt2 = -2\sqrt2 \approx -2.8284.$$

Проверка прямой подстановкой. $f = r^2\cos^2\theta\cdot r\sin\theta = r^3\cos^2\theta\sin\theta$. По $\theta$ (правило произведения): $r^3\big(-2\cos\theta\sin^2\theta + \cos^3\theta\big)$. При $\theta = \pi/4$: $\cos\theta\sin^2\theta = \cos^3\theta = \big(\frac{\sqrt2}{2}\big)^3 = \frac{\sqrt2}{4}$, и $8\cdot\big(-2\cdot\frac{\sqrt2}{4} + \frac{\sqrt2}{4}\big) = 8\cdot\big(-\frac{\sqrt2}{4}\big) = -2\sqrt2$ ✓.

EN

Values. $\cos\frac{\pi}{4} = \sin\frac{\pi}{4} = \frac{\sqrt2}{2}$, so $x = y = 2\cdot\frac{\sqrt2}{2} = \sqrt2$.

Partial derivatives of $f$ at the point. $\frac{\partial f}{\partial x} = 2xy = 2\cdot\sqrt2\cdot\sqrt2 = 4$, $\frac{\partial f}{\partial y} = x^2 = 2$.

Derivatives of the change of variables. $\frac{\partial x}{\partial\theta} = -r\sin\theta = -\sqrt2$, $\frac{\partial y}{\partial\theta} = r\cos\theta = \sqrt2$.

Chain rule.

$$\frac{\partial f}{\partial\theta} = 4\cdot(-\sqrt2) + 2\cdot\sqrt2 = -2\sqrt2 \approx -2.8284.$$

Check by direct substitution. $f = r^2\cos^2\theta\cdot r\sin\theta = r^3\cos^2\theta\sin\theta$. In $\theta$ (the product rule): $r^3\big(-2\cos\theta\sin^2\theta + \cos^3\theta\big)$. At $\theta = \pi/4$: $\cos\theta\sin^2\theta = \cos^3\theta = \big(\frac{\sqrt2}{2}\big)^3 = \frac{\sqrt2}{4}$, and $8\cdot\big(-2\cdot\frac{\sqrt2}{4} + \frac{\sqrt2}{4}\big) = 8\cdot\big(-\frac{\sqrt2}{4}\big) = -2\sqrt2$ ✓.

Ступень 3 · Мост к финалуStep 3 · Bridge to the final

решено 0 из 40 of 4 solved

Два хода вместе, как в финале. Здесь работает схема эталонной задачи.Two moves combined the way the final combines them. The model problem’s scheme works here.

f0114ступень 3step 3обязательнаяrequiredCM.4F3.7авторскаяoriginal
RU

Пусть $A = \begin{pmatrix}1&2\\0&3\end{pmatrix}$, $f(x) = x^tAx$ для $x\in\R^2$, $x_0 = (1,-1)^t$, $u = (2,1)^t$. Найдите

$$\lim_{h\to0}\frac{f(x_0+hu)-f(x_0)}{h}.$$
EN

Let $A = \begin{pmatrix}1&2\\0&3\end{pmatrix}$, $f(x) = x^tAx$ for $x\in\R^2$, $x_0 = (1,-1)^t$, $u = (2,1)^t$. Find

$$\lim_{h\to0}\frac{f(x_0+hu)-f(x_0)}{h}.$$

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Раскрой $(x_0+hu)^tA(x_0+hu)$ как произведение сумм, пользуясь $(x_0+hu)^t = x_0^t + hu^t$. Получится четыре слагаемых: одно без $h$, два с $h$, одно с $h^2$.

EN

Expand $(x_0+hu)^tA(x_0+hu)$ as a product of sums, using $(x_0+hu)^t = x_0^t + hu^t$. You get four terms: one without $h$, two with $h$, one with $h^2$.

Подсказка 2 из 2Hint 2 of 2
RU

Коэффициент при $h$ равен $x_0^tAu + u^tAx_0$. Матрица $A$ несимметрична, поэтому эти два числа не обязаны совпадать: посчитай каждое.

EN

The coefficient of $h$ is $x_0^tAu + u^tAx_0$. The matrix $A$ is not symmetric, so these two numbers need not coincide: compute each of them.

РешениеSolution
RU

Раскрытие. $(x_0+hu)^t = x_0^t + hu^t$ (транспонирование суммы и числового множителя), поэтому

$$f(x_0+hu) = (x_0^t + hu^t)A(x_0+hu) = x_0^tAx_0 + h\,x_0^tAu + h\,u^tAx_0 + h^2\,u^tAu.$$

Предел. Вычитаем $f(x_0) = x_0^tAx_0$ и делим на $h$:

$$\frac{f(x_0+hu)-f(x_0)}{h} = x_0^tAu + u^tAx_0 + h\,u^tAu \to x_0^tAu + u^tAx_0.$$

Два числа. $Au = (1\cdot2+2\cdot1,\ 0\cdot2+3\cdot1)^t = (4,3)^t$, $x_0^tAu = 1\cdot4 + (-1)\cdot3 = 1$. $Ax_0 = (1-2,\ 0-3)^t = (-1,-3)^t$, $u^tAx_0 = 2\cdot(-1) + 1\cdot(-3) = -5$. Сумма: $1 + (-5) = -4$.

Проверка через транспонирование. $x_0^tAu$ — число, оно равно своему транспонированию $u^tA^tx_0$. Значит, предел равен $u^t(A+A^t)x_0$. $A + A^t = \begin{pmatrix}2&2\\2&6\end{pmatrix}$, $(A+A^t)x_0 = (0,-4)^t$, $u^t(0,-4)^t = -4$ ✓.

Проверка координатами. $f(x) = (x^1)^2 + 2x^1x^2 + 3(x^2)^2$, $x_0 + hu = (1+2h,\ -1+h)^t$: $(1+2h)^2 + 2(1+2h)(-1+h) + 3(-1+h)^2 = (1+4h+4h^2) + (-2-2h+4h^2) + (3-6h+3h^2) = 2 - 4h + 11h^2$. Коэффициент при $h$ равен $-4$ ✓.

Ловушка

Если считать два средних слагаемых равными, получится $2\cdot1 = 2$ или $2\cdot(-5) = -10$. Они равны только при $A = A^t$; в выводе лекции math-01 они совпали, потому что там это одно и то же число, записанное двумя способами.

EN

Expansion. $(x_0+hu)^t = x_0^t + hu^t$ (the transpose of a sum and of a numerical factor), so

$$f(x_0+hu) = (x_0^t + hu^t)A(x_0+hu) = x_0^tAx_0 + h\,x_0^tAu + h\,u^tAx_0 + h^2\,u^tAu.$$

Limit. Subtract $f(x_0) = x_0^tAx_0$ and divide by $h$:

$$\frac{f(x_0+hu)-f(x_0)}{h} = x_0^tAu + u^tAx_0 + h\,u^tAu \to x_0^tAu + u^tAx_0.$$

Two numbers. $Au = (1\cdot2+2\cdot1,\ 0\cdot2+3\cdot1)^t = (4,3)^t$, $x_0^tAu = 1\cdot4 + (-1)\cdot3 = 1$. $Ax_0 = (1-2,\ 0-3)^t = (-1,-3)^t$, $u^tAx_0 = 2\cdot(-1) + 1\cdot(-3) = -5$. The sum: $1 + (-5) = -4$.

Check with the transpose. $x_0^tAu$ is a number, so it equals its own transpose $u^tA^tx_0$. Hence the limit is $u^t(A+A^t)x_0$. $A + A^t = \begin{pmatrix}2&2\\2&6\end{pmatrix}$, $(A+A^t)x_0 = (0,-4)^t$, $u^t(0,-4)^t = -4$ ✓.

Check with coordinates. $f(x) = (x^1)^2 + 2x^1x^2 + 3(x^2)^2$, $x_0 + hu = (1+2h,\ -1+h)^t$: $(1+2h)^2 + 2(1+2h)(-1+h) + 3(-1+h)^2 = (1+4h+4h^2) + (-2-2h+4h^2) + (3-6h+3h^2) = 2 - 4h + 11h^2$. The coefficient of $h$ is $-4$ ✓.

The trap

If you treat the two middle terms as equal, you get $2\cdot1 = 2$ or $2\cdot(-5) = -10$. They are equal only when $A = A^t$; in the derivation of lecture math-01 they coincided because there it is one number written in two ways.

f0115ступень 3step 3F4.4CM.4авторскаяoriginal
RU

Пусть $A = \begin{pmatrix}1&0\\2&1\\-1&3\end{pmatrix}\in M_{3\times2}$, $u = (1,2)^t$, $v = (3,-1,2)^t$. Найдите $\tr(Auv^t)$.

EN

Let $A = \begin{pmatrix}1&0\\2&1\\-1&3\end{pmatrix}\in M_{3\times2}$, $u = (1,2)^t$, $v = (3,-1,2)^t$. Find $\tr(Auv^t)$.

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Размеры: $(3\times2)(2\times1)(1\times3) = 3\times3$. Всю матрицу считать не нужно: перенеси $v^t$ в начало по цикличности.

EN

Sizes: $(3\times2)(2\times1)(1\times3) = 3\times3$. You do not need the whole matrix: move $v^t$ to the front by the cyclic property.

Подсказка 2 из 2Hint 2 of 2
RU

$\tr(Auv^t) = \tr\big((Au)\,v^t\big) = \tr\big(v^t(Au)\big)$, и $v^tAu$ — матрица $1\times1$.

EN

$\tr(Auv^t) = \tr\big((Au)\,v^t\big) = \tr\big(v^t(Au)\big)$, and $v^tAu$ is a $1\times1$ matrix.

РешениеSolution
RU

Цикличность. Положим $X = Au\in M_{3\times1}$, $Y = v^t\in M_{1\times3}$. Тогда $\tr(XY) = \tr(YX)$, то есть $\tr(Auv^t) = \tr(v^tAu)$, а $v^tAu$ — число.

Счёт. $Au = (1\cdot1+0\cdot2,\ 2\cdot1+1\cdot2,\ -1\cdot1+3\cdot2)^t = (1,4,5)^t$, и

$$v^tAu = 3\cdot1 + (-1)\cdot4 + 2\cdot5 = 3 - 4 + 10 = 9.$$

Проверка диагональю. $(Au)v^t$ — матрица $3\times3$ с элементами $(Au)^iv^j$; на диагонали $1\cdot3$, $4\cdot(-1)$, $5\cdot2$, сумма $3 - 4 + 10 = 9$ ✓.

EN

Cyclic property. Set $X = Au\in M_{3\times1}$, $Y = v^t\in M_{1\times3}$. Then $\tr(XY) = \tr(YX)$, that is, $\tr(Auv^t) = \tr(v^tAu)$, and $v^tAu$ is a number.

Computation. $Au = (1\cdot1+0\cdot2,\ 2\cdot1+1\cdot2,\ -1\cdot1+3\cdot2)^t = (1,4,5)^t$, and

$$v^tAu = 3\cdot1 + (-1)\cdot4 + 2\cdot5 = 3 - 4 + 10 = 9.$$

Check with the diagonal. $(Au)v^t$ is a $3\times3$ matrix with entries $(Au)^iv^j$; on the diagonal $1\cdot3$, $4\cdot(-1)$, $5\cdot2$, the sum is $3 - 4 + 10 = 9$ ✓.

f0116ступень 3step 3минимумminimumF3.7CM.4по мотивам ДЗ HW-M01, п. 5based on homework HW-M01, item 5
RU

Пусть $A = \begin{pmatrix}1&2\\0&3\end{pmatrix}$ и $f(x) = x^tAx$, где $x = (x^1,x^2)^t$. Найдите $\dfrac{\partial f}{\partial x^2}$ в точке $(2,1)^t$.

EN

Let $A = \begin{pmatrix}1&2\\0&3\end{pmatrix}$ and $f(x) = x^tAx$, where $x = (x^1,x^2)^t$. Find $\dfrac{\partial f}{\partial x^2}$ at the point $(2,1)^t$.

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Запиши $f$ в координатах: сначала столбец $Ax$, потом произведение $x^t(Ax)$.

EN

Write $f$ in coordinates: first the column $Ax$, then the product $x^t(Ax)$.

Подсказка 2 из 2Hint 2 of 2
RU

$f(x) = (x^1)^2 + 2x^1x^2 + 3(x^2)^2$. Дальше — частная производная по $x^2$.

EN

$f(x) = (x^1)^2 + 2x^1x^2 + 3(x^2)^2$. What remains is the partial derivative in $x^2$.

РешениеSolution
RU

Координаты. $Ax = (x^1 + 2x^2,\ 3x^2)^t$, и

$$f(x) = x^1(x^1+2x^2) + x^2\cdot3x^2 = (x^1)^2 + 2x^1x^2 + 3(x^2)^2.$$

Частная производная. По $x^2$, $x^1$ — число: $\frac{\partial f}{\partial x^2} = 2x^1 + 6x^2$. В точке $(2,1)^t$: $4 + 6 = 10$.

Проверка матричной формулой. $\nabla(x^tAx) = (A+A^t)x$, $A + A^t = \begin{pmatrix}2&2\\2&6\end{pmatrix}$, $(A+A^t)(2,1)^t = (4+2,\ 4+6)^t = (6,10)^t$. Вторая координата $10$ ✓.

Куда это ведёт

В финале f0119 такой градиент — шаг градиентного спуска.

EN

Coordinates. $Ax = (x^1 + 2x^2,\ 3x^2)^t$, and

$$f(x) = x^1(x^1+2x^2) + x^2\cdot3x^2 = (x^1)^2 + 2x^1x^2 + 3(x^2)^2.$$

Partial derivative. In $x^2$, with $x^1$ a number: $\frac{\partial f}{\partial x^2} = 2x^1 + 6x^2$. At $(2,1)^t$: $4 + 6 = 10$.

Check with the matrix formula. $\nabla(x^tAx) = (A+A^t)x$, $A + A^t = \begin{pmatrix}2&2\\2&6\end{pmatrix}$, $(A+A^t)(2,1)^t = (4+2,\ 4+6)^t = (6,10)^t$. The second component is $10$ ✓.

Where this leads

In the final f0119 such a gradient becomes a gradient descent step.

f0117ступень 3step 3обязательнаяrequiredCM.11F3.7по мотивам ДЗ HW-M02, п. 2based on homework HW-M02, item 2
RU

Пусть $f(x,y) = x^2y$ и $g(u,v) = f(u+v,\ u-v)$. Найдите $\dfrac{\partial^2 g}{\partial v\,\partial u}$ в точке $(u,v) = (2,1)$.

EN

Let $f(x,y) = x^2y$ and $g(u,v) = f(u+v,\ u-v)$. Find $\dfrac{\partial^2 g}{\partial v\,\partial u}$ at the point $(u,v) = (2,1)$.

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Сначала $\dfrac{\partial g}{\partial u}$ по цепному правилу: $\dfrac{\partial x}{\partial u} = 1$, $\dfrac{\partial y}{\partial u} = 1$. Получится сумма частных производных $f$, взятых в точке $(u+v,\ u-v)$.

EN

First find $\dfrac{\partial g}{\partial u}$ by the chain rule: $\dfrac{\partial x}{\partial u} = 1$, $\dfrac{\partial y}{\partial u} = 1$. You get a sum of partial derivatives of $f$ evaluated at the point $(u+v,\ u-v)$.

Подсказка 2 из 2Hint 2 of 2
RU

Каждое из слагаемых $\dfrac{\partial f}{\partial x}$, $\dfrac{\partial f}{\partial y}$ снова зависит от $u,v$ через $x$ и $y$. Дифференцируй его по $v$ по цепному правилу, где $\dfrac{\partial x}{\partial v} = 1$, $\dfrac{\partial y}{\partial v} = -1$.

EN

Each of the terms $\dfrac{\partial f}{\partial x}$, $\dfrac{\partial f}{\partial y}$ again depends on $u,v$ through $x$ and $y$. Differentiate it in $v$ by the chain rule, where $\dfrac{\partial x}{\partial v} = 1$, $\dfrac{\partial y}{\partial v} = -1$.

РешениеSolution
RU

Первая производная. $\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\cdot1 + \frac{\partial f}{\partial y}\cdot1$, обе производные $f$ в точке $(u+v,\ u-v)$.

Вторая производная, цепное правило заново.

$$\frac{\partial}{\partial v}\Big(\frac{\partial f}{\partial x}\Big) = \frac{\partial^2 f}{\partial x^2}\cdot1 + \frac{\partial^2 f}{\partial y\,\partial x}\cdot(-1),\qquad \frac{\partial}{\partial v}\Big(\frac{\partial f}{\partial y}\Big) = \frac{\partial^2 f}{\partial x\,\partial y}\cdot1 + \frac{\partial^2 f}{\partial y^2}\cdot(-1).$$

Складываем: смешанные производные входят с разными знаками и по теореме Шварца сокращаются:

$$\frac{\partial^2 g}{\partial v\,\partial u} = \frac{\partial^2 f}{\partial x^2} - \frac{\partial^2 f}{\partial y^2}.$$

Числа. Для $f = x^2y$: $\frac{\partial^2 f}{\partial x^2} = 2y$, $\frac{\partial^2 f}{\partial y^2} = 0$. Точка $(u,v) = (2,1)$ даёт $x = 3$, $y = 1$, поэтому ответ $2\cdot1 - 0 = 2$.

Проверка прямой подстановкой. $g = (u+v)^2(u-v) = (u^2+2uv+v^2)(u-v) = u^3 + u^2v - uv^2 - v^3$. Тогда $\frac{\partial g}{\partial u} = 3u^2 + 2uv - v^2$ и $\frac{\partial}{\partial v}\big(3u^2 + 2uv - v^2\big) = 2u - 2v$, в точке $4 - 2 = 2$ ✓.

Куда это ведёт

В финале f0120 та же схема даёт тождество для суммы $\frac{\partial^2 g}{\partial u^2} + \frac{\partial^2 g}{\partial v^2}$.

EN

First derivative. $\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\cdot1 + \frac{\partial f}{\partial y}\cdot1$, both derivatives of $f$ at the point $(u+v,\ u-v)$.

Second derivative, the chain rule again.

$$\frac{\partial}{\partial v}\Big(\frac{\partial f}{\partial x}\Big) = \frac{\partial^2 f}{\partial x^2}\cdot1 + \frac{\partial^2 f}{\partial y\,\partial x}\cdot(-1),\qquad \frac{\partial}{\partial v}\Big(\frac{\partial f}{\partial y}\Big) = \frac{\partial^2 f}{\partial x\,\partial y}\cdot1 + \frac{\partial^2 f}{\partial y^2}\cdot(-1).$$

Add them: the mixed derivatives enter with opposite signs and cancel by Schwarz’s theorem:

$$\frac{\partial^2 g}{\partial v\,\partial u} = \frac{\partial^2 f}{\partial x^2} - \frac{\partial^2 f}{\partial y^2}.$$

Numbers. For $f = x^2y$: $\frac{\partial^2 f}{\partial x^2} = 2y$, $\frac{\partial^2 f}{\partial y^2} = 0$. The point $(u,v) = (2,1)$ gives $x = 3$, $y = 1$, so the answer is $2\cdot1 - 0 = 2$.

Check by direct substitution. $g = (u+v)^2(u-v) = (u^2+2uv+v^2)(u-v) = u^3 + u^2v - uv^2 - v^3$. Then $\frac{\partial g}{\partial u} = 3u^2 + 2uv - v^2$ and $\frac{\partial}{\partial v}\big(3u^2 + 2uv - v^2\big) = 2u - 2v$, which is $4 - 2 = 2$ at the point ✓.

Where this leads

In the final f0120 the same scheme gives an identity for the sum $\frac{\partial^2 g}{\partial u^2} + \frac{\partial^2 g}{\partial v^2}$.

Ступень 4 · ФиналStep 4 · Final

решено 0 из 20 of 2 solved

Уровень лекции и домашнего задания. Решай без подсказок.Lecture and homework level. Solve without hints.

f0118ступень 4step 4обязательнаяrequiredF4.4CM.4авторскаяoriginal
RU

Пусть $a = (1,2,-1)^t$, $b = (3,0,1)^t$ и $M = \begin{pmatrix}2&1&0\\0&1&3\\1&-1&2\end{pmatrix}$. Найдите $\tr\big((ab^t)^tM\big)$.

EN

Let $a = (1,2,-1)^t$, $b = (3,0,1)^t$, and $M = \begin{pmatrix}2&1&0\\0&1&3\\1&-1&2\end{pmatrix}$. Find $\tr\big((ab^t)^tM\big)$.

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 2Hint 1 of 2
RU

Сначала транспонирование произведения: $(ab^t)^t = (b^t)^ta^t$. Чему равно $(b^t)^t$?

EN

Start with the transpose of a product: $(ab^t)^t = (b^t)^ta^t$. What is $(b^t)^t$?

Подсказка 2 из 2Hint 2 of 2
RU

Получится $\tr(ba^tM)$. Перенеси столбец $b$ в конец по цикличности: $\tr\big(b\,(a^tM)\big) = \tr\big((a^tM)\,b\big)$ — какого размера эта матрица?

EN

You get $\tr(ba^tM)$. Move the column $b$ to the end by the cyclic property: $\tr\big(b\,(a^tM)\big) = \tr\big((a^tM)\,b\big)$ — what is the size of this matrix?

РешениеSolution
RU

Транспонирование. $(ab^t)^t = (b^t)^ta^t = ba^t$.

Цикличность. $\tr(ba^tM) = \tr\big(b\,(a^tM)\big) = \tr\big((a^tM)\,b\big) = a^tMb$ — матрица $(1\times3)(3\times3)(3\times1) = 1\times1$.

Счёт. $Mb = (2\cdot3+1\cdot0+0\cdot1,\ 0\cdot3+1\cdot0+3\cdot1,\ 1\cdot3+(-1)\cdot0+2\cdot1)^t = (6,3,5)^t$, и

$$a^tMb = 1\cdot6 + 2\cdot3 + (-1)\cdot5 = 6 + 6 - 5 = 7.$$

Проверка прямым счётом. $ba^t = \begin{pmatrix}3&6&-3\\0&0&0\\1&2&-1\end{pmatrix}$. Диагональ $ba^tM$: строка 1 на столбец 1 матрицы $M$: $3\cdot2 + 6\cdot0 + (-3)\cdot1 = 3$; строка 2 нулевая, даёт $0$; строка 3 на столбец 3: $1\cdot0 + 2\cdot3 + (-1)\cdot2 = 4$. След $3 + 0 + 4 = 7$ ✓.

Зачем это в ML

$\tr\big((ab^t)^tM\big)$ — это скалярное произведение матриц $\langle ab^t, M\rangle$ из лекции math-01. Равенство $a^tMb = \tr\big((ba^t)M\big)$ — то самое, из которого там получено $Df(X_0) = ba^t$ для $f(X) = a^tXb$.

EN

Transpose. $(ab^t)^t = (b^t)^ta^t = ba^t$.

Cyclic property. $\tr(ba^tM) = \tr\big(b\,(a^tM)\big) = \tr\big((a^tM)\,b\big) = a^tMb$ — a matrix of size $(1\times3)(3\times3)(3\times1) = 1\times1$.

Computation. $Mb = (2\cdot3+1\cdot0+0\cdot1,\ 0\cdot3+1\cdot0+3\cdot1,\ 1\cdot3+(-1)\cdot0+2\cdot1)^t = (6,3,5)^t$, and

$$a^tMb = 1\cdot6 + 2\cdot3 + (-1)\cdot5 = 6 + 6 - 5 = 7.$$

Check by direct computation. $ba^t = \begin{pmatrix}3&6&-3\\0&0&0\\1&2&-1\end{pmatrix}$. The diagonal of $ba^tM$: row 1 times column 1 of $M$: $3\cdot2 + 6\cdot0 + (-3)\cdot1 = 3$; row 2 is zero and gives $0$; row 3 times column 3: $1\cdot0 + 2\cdot3 + (-1)\cdot2 = 4$. The trace is $3 + 0 + 4 = 7$ ✓.

Why this matters for ML

$\tr\big((ab^t)^tM\big)$ is the inner product of matrices $\langle ab^t, M\rangle$ from lecture math-01. The equality $a^tMb = \tr\big((ba^t)M\big)$ is exactly the one that gave $Df(X_0) = ba^t$ for $f(X) = a^tXb$ there.

f0120ступень 4step 4обязательнаяrequiredCM.11F3.7по мотивам ДЗ HW-M02, п. 2based on homework HW-M02, item 2
RU

Пусть у функции $f(x,y)$ непрерывны все частные производные до второго порядка включительно, и $g(u,v) = f(u+v,\ u-v)$. Докажите, что

$$\frac{\partial^2 g}{\partial u^2} + \frac{\partial^2 g}{\partial v^2} = 2\Big(\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2}\Big),$$

где производные $f$ взяты в точке $(u+v,\ u-v)$.

EN

Let all partial derivatives of $f(x,y)$ up to and including second order be continuous, and let $g(u,v) = f(u+v,\ u-v)$. Prove that

$$\frac{\partial^2 g}{\partial u^2} + \frac{\partial^2 g}{\partial v^2} = 2\Big(\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2}\Big),$$

where the derivatives of $f$ are evaluated at the point $(u+v,\ u-v)$.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 3Hint 1 of 3
RU

Первые производные: $\dfrac{\partial g}{\partial u} = \dfrac{\partial f}{\partial x} + \dfrac{\partial f}{\partial y}$ и $\dfrac{\partial g}{\partial v} = \dfrac{\partial f}{\partial x} - \dfrac{\partial f}{\partial y}$.

EN

First derivatives: $\dfrac{\partial g}{\partial u} = \dfrac{\partial f}{\partial x} + \dfrac{\partial f}{\partial y}$ and $\dfrac{\partial g}{\partial v} = \dfrac{\partial f}{\partial x} - \dfrac{\partial f}{\partial y}$.

Подсказка 2 из 3Hint 2 of 3
RU

Каждая из $\dfrac{\partial f}{\partial x}$, $\dfrac{\partial f}{\partial y}$ — снова функция от $u,v$ через $x = u+v$, $y = u-v$. Например, $\dfrac{\partial}{\partial u}\Big(\dfrac{\partial f}{\partial x}\Big) = \dfrac{\partial^2 f}{\partial x^2} + \dfrac{\partial^2 f}{\partial y\,\partial x}$.

EN

Each of $\dfrac{\partial f}{\partial x}$, $\dfrac{\partial f}{\partial y}$ is again a function of $u,v$ through $x = u+v$, $y = u-v$. For example, $\dfrac{\partial}{\partial u}\Big(\dfrac{\partial f}{\partial x}\Big) = \dfrac{\partial^2 f}{\partial x^2} + \dfrac{\partial^2 f}{\partial y\,\partial x}$.

Подсказка 3 из 3Hint 3 of 3
RU

Выпиши четыре слагаемых для $\dfrac{\partial^2 g}{\partial u^2}$ и четыре для $\dfrac{\partial^2 g}{\partial v^2}$, затем сложи и посмотри, какие смешанные производные сокращаются.

EN

Write out four terms for $\dfrac{\partial^2 g}{\partial u^2}$ and four for $\dfrac{\partial^2 g}{\partial v^2}$, then add them and see which mixed derivatives cancel.

РешениеSolution
RU

Производные замены. $x = u+v$, $y = u-v$, поэтому $\frac{\partial x}{\partial u} = 1$, $\frac{\partial y}{\partial u} = 1$, $\frac{\partial x}{\partial v} = 1$, $\frac{\partial y}{\partial v} = -1$. Все они постоянны, так что правило произведения здесь лишних слагаемых не даёт.

Первые производные. По цепному правилу (производные $f$ в точке $(u+v,\ u-v)$):

$$\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\cdot1 + \frac{\partial f}{\partial y}\cdot1,\qquad \frac{\partial g}{\partial v} = \frac{\partial f}{\partial x}\cdot1 + \frac{\partial f}{\partial y}\cdot(-1).$$

Вторая по $u$. Функции $\frac{\partial f}{\partial x}$ и $\frac{\partial f}{\partial y}$ дифференцируемы (их частные производные непрерывны), и к каждой применяем цепное правило заново:

$$\frac{\partial^2 g}{\partial u^2} = \Big(\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y\,\partial x}\Big) + \Big(\frac{\partial^2 f}{\partial x\,\partial y} + \frac{\partial^2 f}{\partial y^2}\Big).$$

Вторая по $v$. Так же, но $\frac{\partial y}{\partial v} = -1$:

$$\frac{\partial^2 g}{\partial v^2} = \Big(\frac{\partial^2 f}{\partial x^2} - \frac{\partial^2 f}{\partial y\,\partial x}\Big) - \Big(\frac{\partial^2 f}{\partial x\,\partial y} - \frac{\partial^2 f}{\partial y^2}\Big) = \frac{\partial^2 f}{\partial x^2} - \frac{\partial^2 f}{\partial y\,\partial x} - \frac{\partial^2 f}{\partial x\,\partial y} + \frac{\partial^2 f}{\partial y^2}.$$

Сумма. Каждая смешанная производная входит один раз с плюсом и один раз с минусом:

$$\frac{\partial^2 g}{\partial u^2} + \frac{\partial^2 g}{\partial v^2} = 2\frac{\partial^2 f}{\partial x^2} + 2\frac{\partial^2 f}{\partial y^2} = 2\Big(\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2}\Big).\ ∎$$

Теорема Шварца здесь даже не понадобилась: $\frac{\partial^2 f}{\partial y\,\partial x}$ и $\frac{\partial^2 f}{\partial x\,\partial y}$ сократились каждая сама с собой.

Проверка на функции. $f = x^2y$: справа $2(2y + 0) = 4y = 4(u-v)$. Слева $g = u^3 + u^2v - uv^2 - v^3$ (раскрыто в f0117), $\frac{\partial^2 g}{\partial u^2} = 6u + 2v$, $\frac{\partial^2 g}{\partial v^2} = -2u - 6v$, сумма $4u - 4v$ ✓.

Куда это ведёт

Это лапласиан при линейной замене переменных. В полярных координатах схема та же, но коэффициенты замены зависят от $r$ и $\theta$, и правило произведения добавляет слагаемые с первыми производными $f$.

EN

Derivatives of the change of variables. $x = u+v$, $y = u-v$, so $\frac{\partial x}{\partial u} = 1$, $\frac{\partial y}{\partial u} = 1$, $\frac{\partial x}{\partial v} = 1$, $\frac{\partial y}{\partial v} = -1$. All of them are constant, so the product rule adds no extra terms here.

First derivatives. By the chain rule (derivatives of $f$ at the point $(u+v,\ u-v)$):

$$\frac{\partial g}{\partial u} = \frac{\partial f}{\partial x}\cdot1 + \frac{\partial f}{\partial y}\cdot1,\qquad \frac{\partial g}{\partial v} = \frac{\partial f}{\partial x}\cdot1 + \frac{\partial f}{\partial y}\cdot(-1).$$

Second derivative in $u$. The functions $\frac{\partial f}{\partial x}$ and $\frac{\partial f}{\partial y}$ are differentiable (their partial derivatives are continuous), and we apply the chain rule to each of them again:

$$\frac{\partial^2 g}{\partial u^2} = \Big(\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y\,\partial x}\Big) + \Big(\frac{\partial^2 f}{\partial x\,\partial y} + \frac{\partial^2 f}{\partial y^2}\Big).$$

Second derivative in $v$. The same, but with $\frac{\partial y}{\partial v} = -1$:

$$\frac{\partial^2 g}{\partial v^2} = \Big(\frac{\partial^2 f}{\partial x^2} - \frac{\partial^2 f}{\partial y\,\partial x}\Big) - \Big(\frac{\partial^2 f}{\partial x\,\partial y} - \frac{\partial^2 f}{\partial y^2}\Big) = \frac{\partial^2 f}{\partial x^2} - \frac{\partial^2 f}{\partial y\,\partial x} - \frac{\partial^2 f}{\partial x\,\partial y} + \frac{\partial^2 f}{\partial y^2}.$$

Sum. Each mixed derivative enters once with a plus and once with a minus:

$$\frac{\partial^2 g}{\partial u^2} + \frac{\partial^2 g}{\partial v^2} = 2\frac{\partial^2 f}{\partial x^2} + 2\frac{\partial^2 f}{\partial y^2} = 2\Big(\frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2}\Big).\ ∎$$

Schwarz’s theorem was not even needed here: $\frac{\partial^2 f}{\partial y\,\partial x}$ and $\frac{\partial^2 f}{\partial x\,\partial y}$ each canceled with itself.

Check on a function. $f = x^2y$: the right side is $2(2y + 0) = 4y = 4(u-v)$. On the left, $g = u^3 + u^2v - uv^2 - v^3$ (expanded in f0117), $\frac{\partial^2 g}{\partial u^2} = 6u + 2v$, $\frac{\partial^2 g}{\partial v^2} = -2u - 6v$, the sum is $4u - 4v$ ✓.

Where this leads

This is the Laplacian under a linear change of variables. In polar coordinates the scheme is the same, but the coefficients of the change depend on $r$ and $\theta$, and the product rule adds terms with first derivatives of $f$.

Сравни своё доказательство с решением строка за строкой и отметь результат честно.Compare your proof with the solution line by line and mark the result honestly.

Мини-тест под таймеромTimed mini-test

20 минут20 minutes

Одна задача и таймер. Подсказки и решение открывай только после того, как время выйдет: это тренировка поведения на экзамене.One problem and a timer. Open hints and the solution only after time is up: this trains exam behavior.

f0119ступень 4step 4обязательнаяrequiredF3.7CM.4авторскаяoriginal
RU

Функция потерь $L(w) = w^tAw - 2b^tw$, $w\in\R^2$, где $A = \begin{pmatrix}2&1\\3&4\end{pmatrix}$ и $b = (1,2)^t$. Сделайте один шаг градиентного спуска $w_1 = w_0 - \eta\nabla L(w_0)$ из точки $w_0 = (1,1)^t$ с шагом $\eta = 0.1$ и найдите $L(w_1)$. Ответ запишите точно.

EN

The loss is $L(w) = w^tAw - 2b^tw$, $w\in\R^2$, where $A = \begin{pmatrix}2&1\\3&4\end{pmatrix}$ and $b = (1,2)^t$. Take one gradient descent step $w_1 = w_0 - \eta\nabla L(w_0)$ from the point $w_0 = (1,1)^t$ with step size $\eta = 0.1$ and find $L(w_1)$. Give the answer exactly.

Дробную часть отделяй точкой или запятой.Use a decimal point or a comma.

УверенностьConfidence1 — наугад, 2 — есть сомнения, 3 — уверенно1 — guess, 2 — unsure, 3 — sure
Подсказка 1 из 3Hint 1 of 3
RU

$\nabla L$ — столбец частных производных. Запиши $L$ в координатах или воспользуйся $\nabla(w^tAw) = (A+A^t)w$ и проверь одно другим.

EN

$\nabla L$ is the column of partial derivatives. Write $L$ in coordinates, or use $\nabla(w^tAw) = (A+A^t)w$ and check one against the other.

Подсказка 2 из 3Hint 2 of 3
RU

$\nabla(b^tw) = b$, поэтому $\nabla L(w) = (A+A^t)w - 2b$, где $A + A^t = \begin{pmatrix}4&4\\4&8\end{pmatrix}$.

EN

$\nabla(b^tw) = b$, so $\nabla L(w) = (A+A^t)w - 2b$, where $A + A^t = \begin{pmatrix}4&4\\4&8\end{pmatrix}$.

Подсказка 3 из 3Hint 3 of 3
RU

$\nabla L(w_0) = (6,8)^t$. Осталось найти $w_1$ и подставить его в $L$.

EN

$\nabla L(w_0) = (6,8)^t$. What remains is to find $w_1$ and substitute it into $L$.

РешениеSolution
RU

Координаты. $w^tAw = 2(w^1)^2 + (1+3)w^1w^2 + 4(w^2)^2$, $2b^tw = 2w^1 + 4w^2$, поэтому

$$L(w) = 2(w^1)^2 + 4w^1w^2 + 4(w^2)^2 - 2w^1 - 4w^2.$$

Градиент. $\frac{\partial L}{\partial w^1} = 4w^1 + 4w^2 - 2$, $\frac{\partial L}{\partial w^2} = 4w^1 + 8w^2 - 4$. В $w_0 = (1,1)^t$: $\nabla L(w_0) = (4+4-2,\ 4+8-4)^t = (6,8)^t$.

Проверка градиента формулой. $(A+A^t)w_0 - 2b = (4+4,\ 4+8)^t - (2,4)^t = (6,8)^t$ ✓.

Шаг. $w_1 = (1,1)^t - 0.1\cdot(6,8)^t = (1-0.6,\ 1-0.8)^t = (0.4,\ 0.2)^t$.

Значение потерь.

$$L(w_1) = 2\cdot0.16 + 4\cdot0.4\cdot0.2 + 4\cdot0.04 - 2\cdot0.4 - 4\cdot0.2 = 0.32 + 0.32 + 0.16 - 0.8 - 0.8 = -0.8.$$

Проверка смыслом. $L(w_0) = 2 + 4 + 4 - 2 - 4 = 4$. Шаг против градиента уменьшил потери с $4$ до $-0.8$, как и должен при достаточно малом $\eta$.

Зачем это в ML

Ровно так обучается модель: посчитать градиент потерь в текущих весах и сдвинуть веса против него. Ловушка этой задачи — несимметричная $A$: градиент $2Aw - 2b$ вместо $(A+A^t)w - 2b$ дал бы другой шаг.

EN

Coordinates. $w^tAw = 2(w^1)^2 + (1+3)w^1w^2 + 4(w^2)^2$, $2b^tw = 2w^1 + 4w^2$, so

$$L(w) = 2(w^1)^2 + 4w^1w^2 + 4(w^2)^2 - 2w^1 - 4w^2.$$

Gradient. $\frac{\partial L}{\partial w^1} = 4w^1 + 4w^2 - 2$, $\frac{\partial L}{\partial w^2} = 4w^1 + 8w^2 - 4$. At $w_0 = (1,1)^t$: $\nabla L(w_0) = (4+4-2,\ 4+8-4)^t = (6,8)^t$.

Check of the gradient with the formula. $(A+A^t)w_0 - 2b = (4+4,\ 4+8)^t - (2,4)^t = (6,8)^t$ ✓.

Step. $w_1 = (1,1)^t - 0.1\cdot(6,8)^t = (1-0.6,\ 1-0.8)^t = (0.4,\ 0.2)^t$.

Value of the loss.

$$L(w_1) = 2\cdot0.16 + 4\cdot0.4\cdot0.2 + 4\cdot0.04 - 2\cdot0.4 - 4\cdot0.2 = 0.32 + 0.32 + 0.16 - 0.8 - 0.8 = -0.8.$$

Sanity check. $L(w_0) = 2 + 4 + 4 - 2 - 4 = 4$. The step against the gradient lowered the loss from $4$ to $-0.8$, as it should for a small enough $\eta$.

Why this matters for ML

This is exactly how a model trains: compute the gradient of the loss at the current weights and move the weights against it. The trap of this problem is the nonsymmetric $A$: the gradient $2Aw - 2b$ instead of $(A+A^t)w - 2b$ would give a different step.

Домашнее заданиеHomework

HW-M01

Заново провести телескопическое вычисление φ′ в доказательстве формулы Тейлора; ряды Тейлора для sin и cos; упражнения 1–5 с доски (‖x+y‖ ≤ ‖x‖+‖y‖, ‖Ax‖ ≤ ‖A‖‖x‖, ‖A‖² = Σ‖αⱼ‖², ‖A+B‖, ‖AB‖ ≤ ‖A‖‖B‖, tr(AᵗA) = Σaᵢⱼ²); цикличность следа для неквадратных матриц; градиент метода наименьших квадратов по координатамRedo Taylor telescoping φ′; Taylor series of sin/cos; board exercises 1–5 (‖x+y‖ ≤ ‖x‖+‖y‖, ‖Ax‖ ≤ ‖A‖‖x‖, ‖A‖² = Σ‖αⱼ‖², ‖A+B‖, ‖AB‖ ≤ ‖A‖‖B‖, tr(AᵗA) = Σaᵢⱼ²); cyclic trace for non-square; least-squares gradient by components

Срок:Due: 14 октября 2026October 14, 2026 · статус:status: не начатоto do просроченоoverdue

HW-M02

(1) Z = Df(X₀) для f(X) = aᵗX⁻¹b; (2) полярные координаты: f_x, f_y через f_r, f_θ, затем лапласиан на плоскости; (3) лапласиан в сферических координатах в ℝ³; (4) выписать формулу Тейлора для функции многих переменных через g⁽ᵏ⁾; (5) вывести ∇f = Σλᵢ∇gᵢ из геометрического условия; (6) по желанию: оптическое свойство эллипса(1) Z = Df(X₀) for f(X) = aᵗX⁻¹b; (2) polar: f_x, f_y via f_r, f_θ, then 2D Laplacian; (3) spherical 3D Laplacian; (4) write out multivariable Taylor from g⁽ᵏ⁾; (5) derive ∇f = Σλᵢ∇gᵢ from geometric condition; (6) optional: ellipse reflection property

Срок:Due: 16 октября 2026October 16, 2026 · статус:status: не начатоto do просроченоoverdue

как готовитьсяhow to prepare
RU

HW-M01. Пункт 4 (доказать цикличность следа для неквадратных матриц) готовят f0103, f0109, f0115 и f0118: в них свойство используется и проверяется на числах, но не доказывается. Пункт 5 (градиент наименьших квадратов покоординатно) готовят f0116 и f0119: там та же работа — функция, записанная матрицами, раскрывается в координатах и дифференцируется по одной координате, только функция другая.

HW-M02. Пункты 2 и 3 (полярный и сферический лапласиан) готовят f0112, f0113, f0117, f0120 и эталонная задача: прямое направление полярных формул, вторая производная со множителем-произведением и вторая производная после замены переменных. Следи за двумя вещами: частные производные $f$ после замены снова зависят от новых переменных, а коэффициенты вроде $r$ и $\cos\theta$ тоже нужно дифференцировать. Пункт 4 (формула Тейлора через $g^{(k)}$) опирается на смешанные производные из f0106 и f0112.

Решений самих заданий здесь нет: их проверяет тьютор.

EN

HW-M01. Item 4 (prove the cyclic property of the trace for non-square matrices) is prepared by f0103, f0109, f0115, and f0118: they use the property and check it on numbers, but do not prove it. Item 5 (the least-squares gradient by components) is prepared by f0116 and f0119: the work is the same — a function written with matrices is expanded in coordinates and differentiated in one coordinate — only the function is different.

HW-M02. Items 2 and 3 (the polar and spherical Laplacian) are prepared by f0112, f0113, f0117, f0120, and the model problem: the forward direction of the polar formulas, a second derivative with a product factor, and a second derivative after a change of variables. Watch two things: after the change of variables the partial derivatives of $f$ again depend on the new variables, and coefficients such as $r$ and $\cos\theta$ also have to be differentiated. Item 4 (Taylor’s formula via $g^{(k)}$) relies on the mixed derivatives of f0106 and f0112.

The solutions of the homework itself are not here: the tutor checks it.

ИтогWrap-up

урок закрыт, когдаthe lesson is complete when
Размер произведения трёх матриц называешь за 10 секунд, подписав размеры под множителями, и сразу говоришь, какие из произведений $AB$, $BA$, $A^tB$ определеныYou name the size of a product of three matrices within 10 seconds, after writing the sizes under the factors, and say at once which of the products $AB$, $BA$, $A^tB$ are defined
В f0114 и f0118 транспонирование произведения записано с развёрнутым порядком без подсказки, а число $x^tAu$ переписано как $u^tA^tx$, а не $u^tAx$In f0114 and f0118 the transpose of a product is written with the order reversed without a hint, and the number $x^tAu$ is rewritten as $u^tA^tx$, not $u^tAx$
Частную производную многочлена или сложной функции двух переменных в точке находишь за 2 минуты и проверяешь пределом по определению или второй формулойYou find a partial derivative of a polynomial or a composite function of two variables at a point within 2 minutes and check it with the limit definition or a second formula
Смешанную производную со множителем-произведением, как в f0112, считаешь с двумя слагаемыми правила произведения и проверяешь другим порядком дифференцированияYou compute a mixed derivative with a product factor, as in f0112, with both terms of the product rule, and check it with the other order of differentiation
В f0120 выписаны все восемь слагаемых вторых производных и проверка на функции $f = x^2y$ проходитIn f0120 all eight terms of second derivatives are written out and the check on the function $f = x^2y$ passes
Мини-тест f0119 решён за 20 минут без подсказок, а градиент проверен покоординатно и формулой $(A+A^t)w - 2b$The mini-test f0119 is solved within 20 minutes without hints, and the gradient is checked both coordinate by coordinate and with the formula $(A+A^t)w - 2b$
аудит урокаlesson audit
RU

Запиши в журнал отдельной строкой каждую ошибку одного из трёх типов: перепутан порядок множителей (в произведении или при транспонировании); потеряна внутренняя производная или производная взята не в той точке; потеряно слагаемое во второй производной после замены переменных. Для каждой ошибки укажи, какая проверка её поймала бы: размеры, значения слоёв в точке или прямая подстановка конкретной функции.

EN

Write each mistake of one of three types as a separate line in the error log: the order of factors was mixed up (in a product or in a transpose); an inner derivative was lost or a derivative was taken at the wrong point; a term was lost in a second derivative after a change of variables. For each mistake, note which check would have caught it: the sizes, the values of the layers at the point, or direct substitution of a concrete function.