Полигон YMLSYMLS PolygonТашкент · 2026Tashkent · 2026
до попыткиuntil the attempt —
Лекция 1 · 13 октября 2026Lecture 1 · October 13, 2026m01АнализCalculusМатрицыMatricesМатричное дифференцированиеMatrix calculusCM.1CM.2CM.3CM.4CM.5CM.6CM.7CM.8

Производная как матрица: от Тейлора до наименьших квадратовThe derivative as a matrix: from Taylor to least squares

Одна мысль — «изменение = линейная часть + пренебрежимо малое» — проходит путь от числа $f'(x_0)$ до матрицы $Df(x_0)$ и градиента функции потерьOne idea — “change = linear part + something negligible” — travels from the number $f'(x_0)$ to the matrix $Df(x_0)$ and the gradient of a loss function

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

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

К концу урока ты оцениваешь ошибку многочлена Тейлора остаточным членом Лагранжа, выписываешь производную $f:\R^N\to\R^D$ как матрицу $D\times N$, перемножаешь матрицы производных по цепному правилу, выводишь градиент функции потерь наименьших квадратов и производную по матрице через след. Проверка — четыре финальные задачи ниже; m0119 идёт мини-тестом.

EN

By the end of the lesson, you bound the error of a Taylor polynomial with the Lagrange remainder, write the derivative of $f:\R^N\to\R^D$ as a $D\times N$ matrix, multiply derivative matrices by the chain rule, derive the gradient of the least-squares loss, and find the derivative with respect to a matrix through the trace. Check yourself with the four final problems below; m0119 is the mini-test.

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

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

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

Частные производные и правила работы с матрицами — размеры произведения, транспонирование, след — собраны в уроке f01. Если там что-то держится некрепко, начни с него: сегодня всё это используется без остановок.

Производная функции одной переменной и пределы — из дней Полигона 5 и 6; скалярное произведение и длина — из дня 9, матрицы — из дня 10. В Полигоне транспонирование обозначалось заглавной буквой T, а векторы часто писались строками. В школе, вслед за лектором, пишем $x^t$, и вектор — всегда столбец.

EN

Partial derivatives and the rules for matrices — sizes of a product, transpose, trace — are collected in lesson f01. If any of that feels shaky, start there: today all of it is used without pauses.

The derivative of a function of one variable and limits come from Poligon days 5 and 6; the dot product and length come from day 9, matrices from day 10. In Poligon the transpose was written with a capital T, and vectors were often written as rows. In the school, following the lecturer, we write $x^t$, and a vector is always a column.

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

  1. Производная: $f'(x_0)=\lim_{h\to0}\frac{f(x_0+h)-f(x_0)}{h}$Derivative: $f'(x_0)=\lim_{h\to0}\frac{f(x_0+h)-f(x_0)}{h}$
  2. Правило произведения $(uv)'=u'v+uv'$ и цепное правило $\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}$Product rule $(uv)'=u'v+uv'$ and chain rule $\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}$
  3. $k!=1\cdot2\cdots k$, $0!=1$; $(e^x)'=e^x$, $e^0=1$$k!=1\cdot2\cdots k$, $0!=1$; $(e^x)'=e^x$, $e^0=1$
  4. Частная производная $\partial f/\partial x^i$: дифференцируешь по $x^i$, остальные координаты — числаPartial derivative $\partial f/\partial x^i$: differentiate in $x^i$ and treat the other coordinates as numbers
  5. Произведение $M_{D\times N}\cdot M_{N\times K}$ даёт матрицу из $M_{D\times K}$; внутренние размеры обязаны совпастьThe product $M_{D\times N}\cdot M_{N\times K}$ gives a matrix in $M_{D\times K}$; the inner sizes must match
  6. $(AB)^t=B^tA^t$, $(A+B)^t=A^t+B^t$, $(A^t)^t=A$$(AB)^t=B^tA^t$, $(A+B)^t=A^t+B^t$, $(A^t)^t=A$
  7. След квадратной матрицы $\tr C$ — сумма диагональных элементов; $\tr(C+E)=\tr C+\tr E$, $\tr(cC)=c\,\tr C$The trace $\tr C$ of a square matrix is the sum of its diagonal entries; $\tr(C+E)=\tr C+\tr E$, $\tr(cC)=c\,\tr C$
  8. Скалярное произведение столбцов $x^ty=\sum_i x^iy^i$ и длина $\lVert x\rVert=\sqrt{x^tx}$Dot product of columns $x^ty=\sum_i x^iy^i$ and length $\lVert x\rVert=\sqrt{x^tx}$
  9. Неравенство Коши — Буняковского: $\lvert x^ty\rvert\le\lVert x\rVert\,\lVert y\rVert$Cauchy–Schwarz inequality: $\lvert x^ty\rvert\le\lVert x\rVert\,\lVert y\rVert$
зачем это в MLwhy this matters for ML
RU

Обучить модель — значит уменьшить функцию потерь (loss), которая зависит от тысяч или миллионов параметров. Для этого нужно знать, как изменится потеря при малом сдвиге параметров, а это и есть производная функции многих переменных. Лекция строит её как матрицу: для $f:\R^N\to\R^D$ это матрица $D\times N$, и дальше вся техника сводится к умножению матриц.

Три конкретные связи. Шаг градиентного спуска $x\leftarrow x-\eta\nabla f(x)$ использует градиент, то есть транспонированную матрицу производной. Обратное распространение ошибки (backpropagation) — это цепное правило $D(F\circ G)=DF\cdot DG$, применённое слой за слоем. Формула $\nabla\lVert b-Ax\rVert^2=2A^t(Ax-b)$ — это градиент линейной регрессии, первой модели любого курса ML. Производная по матрице $X$ нужна потому, что веса слоя нейросети — матрица.

Формула Тейлора отвечает на вопрос, насколько можно доверять приближению: остаточный член Лагранжа даёт гарантированную оценку ошибки. На такой оценке держится объяснение, почему маленький шаг обучения уменьшает потерю, а слишком большой может её увеличить.

EN

Training a model means decreasing a loss function that depends on thousands or millions of parameters. For that you need to know how the loss changes when the parameters move a little, and that is exactly the derivative of a multivariable function. The lecture builds it as a matrix: for $f:\R^N\to\R^D$ it is a $D\times N$ matrix, and from then on the whole technique is matrix multiplication.

Three concrete links. A gradient descent step $x\leftarrow x-\eta\nabla f(x)$ uses the gradient, that is, the transposed derivative matrix. Backpropagation is the chain rule $D(F\circ G)=DF\cdot DG$ applied layer by layer. The formula $\nabla\lVert b-Ax\rVert^2=2A^t(Ax-b)$ is the gradient of linear regression, the first model of every ML course. The derivative with respect to a matrix $X$ is needed because the weights of a neural-network layer form a matrix.

Taylor’s theorem answers how far an approximation can be trusted: the Lagrange remainder gives a guaranteed error bound. Such a bound is behind the explanation of why a small learning step decreases the loss while a step that is too large can increase it.

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

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

  1. 1О-малое и линейное приближениеLittle-o and linear approximationЗаписываешь $f(x_0+h)-f(x_0)=f'(x_0)h+o(h)$, считаешь приближённое значение и проверяешь, что остаток мал по сравнению с $h$You write $f(x_0+h)-f(x_0)=f'(x_0)h+o(h)$, compute an approximate value, and check that the remainder is small compared with $h$m0101m0106
  2. 2Формула Тейлора и остаток ЛагранжаTaylor’s theorem and the Lagrange remainderНаходишь точку $\xi$ из теоремы о среднем, выписываешь многочлен Тейлора, сворачиваешь телескопическую сумму и оцениваешь остаточный членYou find the point $\xi$ from the mean value theorem, write a Taylor polynomial, collapse a telescoping sum, and bound the remainderm0102m0103m0107m0108m0113m0117
  3. 3Норма и скалярное произведение матрицNorm and inner product of matricesСчитаешь $\lVert A\rVert=\sqrt{\tr(A^tA)}$ и след произведения неквадратных матриц в обоих порядкахYou compute $\lVert A\rVert=\sqrt{\tr(A^tA)}$ and the trace of a product of non-square matrices in both ordersm0104m0109
  4. 4Матрица производной и производная по направлениюDerivative matrix and directional derivativeВыписываешь $Df(x_0)$ размера $D\times N$ из частных производных и умножаешь её на направление $u$ справаYou write the $D\times N$ matrix $Df(x_0)$ from partial derivatives and multiply it by a direction $u$ on the rightm0105m0110
  5. 5Цепное правило как произведение матрицChain rule as a matrix productПеремножаешь $DF$ и $DG$ в нужном порядке, сверяя размеры, и получаешь производную композицииYou multiply $DF$ and $DG$ in the right order, checking the sizes, and get the derivative of the compositionm0111m0114m0118
  6. 6Градиент через предел и транспонированиеGradient through the limit and the transposeПодставляешь $x_0+hu$, раскрываешь скобки, сводишь одинаковые числа транспонированием и читаешь $Df(x_0)$ и $\nabla f(x_0)$You substitute $x_0+hu$, expand, merge equal numbers by transposing, and read off $Df(x_0)$ and $\nabla f(x_0)$m0112m0115m0119
  7. 7Производная по матрице через следDerivative with respect to a matrix through the traceЗаписываешь число как след, переставляешь множители по цикличности и читаешь матрицу $Df(X_0)$ размера $n\times m$You write a number as a trace, reorder the factors by the cyclic property, and read off the $n\times m$ matrix $Df(X_0)$m0109m0116m0120

УрокLesson

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

Вход: насколько изменится потеря

Пусть потеря модели $f(x)=\lVert b-Ax\rVert^2$ зависит от вектора весов $x\in\R^N$. Сдвинем веса на маленький вектор $u$. Насколько изменится потеря? Ответ урока: приблизительно на $Df(x)\,u$, где $Df(x)=-2(b-Ax)^tA$ — одна строка из $N$ чисел. Чтобы получить эту строку честно, лектор начинает с функции одной переменной и шаг за шагом заменяет число матрицей.

Производная через о-малое

Если сильно увеличить график гладкой функции около точки $x_0$, он почти не отличается от прямой. Наклон этой прямой и есть производная: изменение функции равно «наклон × сдвиг» плюс что-то, что намного меньше сдвига.

О-малое

Пишут $g(h)=o(h)$ при $h\to0$, если $\lim_{h\to0}\frac{g(h)}{h}=0$: $g$ стремится к нулю быстрее, чем $h$.

Производная как лучшее линейное приближение

Число $f'(x_0)$ — производная $f$ в точке $x_0$, если

$$f(x_0+h)-f(x_0)=f'(x_0)\,h+o(h),\qquad h\to0.$$

Это то же, что обычное определение: раздели обе части на $h$ и устреми $h\to0$.

Пример. $f(x)=x^2$, $x_0=3$: $f(3+h)-f(3)=9+6h+h^2-9=6h+h^2$. Слагаемое $h^2$ — это $o(h)$, потому что $h^2/h=h\to0$. Значит $f'(3)=6$. При $h=0.01$ изменение равно $0.06+0.0001$: линейная часть даёт почти всё.

Цепное правило лектор пишет в обозначениях Лейбница, $\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}$, — это его любимая запись. Ниже произведение чисел в этой формуле станет произведением матриц.

Зачем это в ML

Шаг обучения меняет веса на маленький вектор, и потеря меняется почти ровно на линейную часть. Поэтому производная указывает, куда шагать: при малом шаге остаток $o(\cdot)$ пренебрежимо мал.

Теорема Лагранжа о среднем

Если за два часа машина проехала 120 км, то в какой-то момент спидометр показывал ровно 60 км/ч. На графике: хорда между концами отрезка параллельна касательной в некоторой внутренней точке.

Теорема Лагранжа о среднем

Если $f$ непрерывна на $[a,b]$ и $f'$ существует на $(a,b)$, то найдётся $\xi\in(a,b)$, для которого

$$f(b)-f(a)=f'(\xi)(b-a).$$

Сравни с формулой через о-малое. Там производная взята в известной точке, но есть ошибка $o(h)$. Здесь равенство точное, но точка $\xi$ неизвестна. Известно только, что $\xi$ лежит строго внутри $(a,b)$, — и в доказательстве формулы Тейлора это окажется важным.

Пример. $f(x)=x^2$ на $[1,3]$: $f(3)-f(1)=8$ и $f'(\xi)(3-1)=4\xi$, поэтому $\xi=2$ — внутри отрезка.

Зачем это в ML

Если $\lvert f'\rvert\le L$ на всём отрезке, теорема даёт $\lvert f(b)-f(a)\rvert\le L\lvert b-a\rvert$: функция не может измениться сильнее. Такие константы (константы Липшица) ограничивают безопасный шаг обучения.

Формула Тейлора с остаточным членом Лагранжа

Линейное приближение использует одну производную. Если добавить вторую, третью и так далее, многочлен повторяет ещё и изгиб графика. Цена — ошибка, и у неё оказывается точная форма, как в теореме о среднем.

Формула Тейлора с остаточным членом в форме Лагранжа

Если $f,f',\dots,f^{(N)}$ непрерывны на $[a,b]$, а $f^{(N+1)}$ существует на $(a,b)$, то для некоторого $\xi\in(a,b)$

$$f(b)-f(a)=\sum_{k=1}^{N}\frac{f^{(k)}(a)}{k!}(b-a)^k+\frac{f^{(N+1)}(\xi)}{(N+1)!}(b-a)^{N+1}.$$

Последнее слагаемое — остаточный член. При $N=0$ сумма пуста, и получается теорема о среднем. Если $b<a$, формула верна с $\xi$ строго между $b$ и $a$.

Пример. $f(x)=e^x$, $a=0$, $b=0.1$, $N=2$. Все производные равны $e^x$, в нуле они равны 1, поэтому $e^{0.1}=1+0.1+\frac{0.01}{2}+\frac{e^{\xi}}{6}\cdot0.001=1.105+\frac{e^{\xi}}{6000}$ при $\xi\in(0,0.1)$. Так как $e^{\xi}<e^{0.1}<2$, ошибка многочлена меньше $\frac{2}{6000}\approx0.0003$. Точное значение $e^{0.1}\approx1.10517$: ошибка $0.00017$, оценка выполнена.

Лектор доказал формулу из теоремы о среднем и объяснил зачем: математика — не набор фактов, а теоремы, связанные логикой.

Доказательство в четыре шага

Идея. Заменить $a$ на переменную $x$, построить две вспомогательные функции, которые обращаются в ноль в точке $b$, и применить теорему о среднем к их комбинации.

Шаг 1. Две вспомогательные функции.

$$\varphi(x)=f(b)-\Big\{f(x)+\sum_{k=1}^{N}\frac{f^{(k)}(x)}{k!}(b-x)^k\Big\},\qquad \psi(x)=(b-x)^{N+1}.$$

При $x=b$ все степени $(b-x)^k$ равны нулю, поэтому $\varphi(b)=f(b)-f(b)=0$ и $\psi(b)=0$. При $x=a$ получаем $\psi(a)=(b-a)^{N+1}$, а $\varphi(a)$ — это $f(b)$ минус многочлен Тейлора, то есть ровно остаточный член, который нужно найти.

Шаг 2. Производные. $\psi'(x)=-(N+1)(b-x)^N$ по цепному правилу. Для $\varphi$ каждое слагаемое суммы дифференцируется по правилу произведения, и сумма становится телескопической: она имеет вид $(a_N-a_{N-1})+\dots+(a_1-a_0)$, и от неё остаётся только $a_N-a_0$. Итог:

$$\varphi'(x)=-\frac{f^{(N+1)}(x)}{N!}(b-x)^N.$$

Промежуточное вычисление — пункт 1 домашнего задания: лектор просил проделать его самостоятельно.

Шаг 3. Вспомогательная функция в духе Коши.

$$F(x)=[\varphi(x)-\varphi(a)][\psi(b)-\psi(a)]-[\varphi(b)-\varphi(a)][\psi(x)-\psi(a)].$$

При $x=a$ обе квадратные скобки с $x$ равны нулю, поэтому $F(a)=0$. При $x=b$ два произведения совпадают, поэтому $F(b)=0$. По теореме о среднем $0=F(b)-F(a)=F'(\xi)(b-a)$ для некоторого $\xi\in(a,b)$, то есть

$$\varphi'(\xi)[\psi(b)-\psi(a)]-\psi'(\xi)[\varphi(b)-\varphi(a)]=0.$$

Подставим $\psi(b)-\psi(a)=-(b-a)^{N+1}$, $\varphi(b)-\varphi(a)=-\varphi(a)$ и производные из шага 2:

$$\frac{f^{(N+1)}(\xi)}{N!}(b-\xi)^N(b-a)^{N+1}-(N+1)(b-\xi)^N\varphi(a)=0.$$

Шаг 4. Сократить на $(b-\xi)^N$. Это законно только потому, что $\xi$ лежит строго внутри $(a,b)$, так что $b-\xi\ne0$. Лектор подчеркнул: даже такая скромная информация о точке полезна. Делим на $(N+1)(b-\xi)^N$:

$$\varphi(a)=\frac{f^{(N+1)}(\xi)}{N!\,(N+1)}(b-a)^{N+1}=\frac{f^{(N+1)}(\xi)}{(N+1)!}(b-a)^{N+1}.\ ∎$$

Ряд Тейлора для $e^x$

При $a=0$ все производные $e^x$ в нуле равны 1, поэтому для любого $b$

$$e^b=\sum_{k=0}^{N}\frac{b^k}{k!}+\frac{e^{\theta}}{(N+1)!}b^{N+1},\qquad \theta\ \text{между}\ 0\ \text{и}\ b.$$

Ряд получится, если остаток стремится к нулю при $N\to\infty$. Множитель $e^{\theta}$ не больше $e^{\lvert b\rvert}$ и от $N$ не зависит. Осталось понять, почему $\lvert b\rvert^n/n!\to0$. Довод студента на лекции: запиши $\frac{b^n}{n!}=\frac b1\cdot\frac b2\cdots\frac bn$. Например, при $b=3$ первые три множителя дают $4.5$, а каждый следующий не больше $\frac34$, поэтому $\frac{3^n}{n!}\le4.5\cdot\left(\frac34\right)^{n-3}\to0$. Отсюда $e^x=\sum_{k\ge0}\frac{x^k}{k!}$ для всех $x$: ряд сходится к $e^x$, потому что ошибка конечного многочлена под контролем.

Зачем это в ML

Методы второго порядка (метод Ньютона) приближают потерю многочленом Тейлора степени 2. Квадратичное слагаемое объясняет, почему слишком большой шаг обучения расходится: при большом сдвиге оно перевешивает линейную часть.

Векторы, ковекторы и матрицы

Обозначения лектора, которыми дальше пишется всё:

  • $\R^N$ — столбцы высоты $N$; координаты пишутся с верхним индексом: $x=(x^1,\dots,x^N)^t$.
  • $M_{m\times n}$ — вещественные матрицы с $m$ строками и $n$ столбцами; элемент $a_{ij}$ стоит в строке $i$, столбце $j$.
  • $(\R^N)^*$ — строки, ковекторы: строка $a^t$ берёт столбец $x$ и возвращает число $a^tx$.
  • Столбец и строка — просто матрицы с одним столбцом или одной строкой. Число — матрица $1\times1$.

На доске лектор ставит над векторами стрелки ($\vec x$); здесь стрелки опущены, вектор — всегда столбец.

Пример. $a=(1,2)^t$, тогда $a^t$ — ковектор, и $a^tx=x^1+2x^2$ для $x\in\R^2$. Матрица $1\times1$ при транспонировании не меняется: $(a^tx)^t=x^ta=a^tx$. Этот факт решит главную трудность раздела про наименьшие квадраты.

Длина и скалярное произведение матриц

Матрицу $m\times n$ можно читать как длинный вектор из $mn$ чисел. Тогда её длина — корень из суммы квадратов всех элементов, а скалярное произведение — сумма произведений соответствующих элементов.

Длины и скалярное произведение$$\lVert x\rVert=\sqrt{x^tx},\qquad \lVert A\rVert=\sqrt{\tr(A^tA)},\qquad \tr(A^tA)=\sum_{i,j}a_{ij}^2.$$

Для $A,B\in M_{m\times n}$ скалярное произведение $\langle A,B\rangle=\tr(A^tB)$. Длина матрицы называется нормой Фробениуса.

Транспонирование здесь нужно: $A^tB$ — квадратная матрица $n\times n$, у неё есть след, и $\langle A,A\rangle\ge0$. Для столбцов формула превращается в привычную $x^ty$, потому что след матрицы $1\times1$ равен ей самой.

Пример. $A=\begin{pmatrix}1&2\\0&3\end{pmatrix}$: $A^tA=\begin{pmatrix}1&0\\2&3\end{pmatrix}\begin{pmatrix}1&2\\0&3\end{pmatrix}=\begin{pmatrix}1&2\\2&13\end{pmatrix}$, след $1+13=14$, и сумма квадратов элементов $1+4+0+9=14$. Значит $\lVert A\rVert=\sqrt{14}$.

Длина даёт расстояние, а расстояние — пределы: «$u\to0$» значит $\lVert u\rVert\to0$.

Цикличность следа

Если $A\in M_{n\times m}$ и $B\in M_{m\times n}$, то $\tr(AB)=\tr(BA)$. Матрицы не обязаны быть квадратными: $AB$ имеет размер $n\times n$, $BA$ — размер $m\times m$, а следы равны.

Пример. $A=(1\ \ 2)$, $B=(3,4)^t$: $AB=(11)$, след 11; $BA=\begin{pmatrix}3&6\\4&8\end{pmatrix}$, след $3+8=11$.

На доске остались ещё неравенства: $\lVert x+y\rVert\le\lVert x\rVert+\lVert y\rVert$, $\lVert Ax\rVert\le\lVert A\rVert\,\lVert x\rVert$, $\lVert A+B\rVert\le\lVert A\rVert+\lVert B\rVert$, $\lVert AB\rVert\le\lVert A\rVert\,\lVert B\rVert$. Их доказательства и доказательство цикличности — домашнее задание.

Зачем это в ML

Регуляризация весов (weight decay) добавляет к потере $\lambda\lVert W\rVert^2$ — квадрат нормы Фробениуса матрицы весов. Неравенство $\lVert Wx\rVert\le\lVert W\rVert\,\lVert x\rVert$ ограничивает, во сколько раз слой может усилить свой вход.

Производная отображения $\R^N\to\R^D$ — матрица $D\times N$

Та же фраза, что для числа: изменение равно линейной части плюс пренебрежимо малое. Только сдвиг теперь — вектор $u\in\R^N$, изменение — вектор из $\R^D$, а «умножить на число» превращается в «умножить на матрицу».

Производная (матрица Якоби)

Пусть $f:\R^N\to\R^D$, $y=f(x)$. Производная $f$ в точке $x_0$ — матрица $A\in M_{D\times N}$, для которой

$$f(x_0+u)-f(x_0)=Au+o(\lVert u\rVert),\quad\text{то есть}\quad \lim_{\lVert u\rVert\to0}\frac{f(x_0+u)-f(x_0)-Au}{\lVert u\rVert}=0.$$

Обозначение: $Df(x_0)$. Элемент в строке $i$, столбце $j$ равен $\partial f^i/\partial x^j$: строка отвечает компоненте $f^i$, столбец — переменной $x^j$. Обычная производная — матрица $1\times1$, которая оказалась числом.

Пример. $f:\R^3\to\R^2$, $f(x)=\big(x^1x^2,\ x^2+(x^3)^2\big)^t$, $x_0=(1,2,1)^t$. Частные производные:

$$Df(x)=\begin{pmatrix}x^2&x^1&0\\0&1&2x^3\end{pmatrix},\qquad Df(x_0)=\begin{pmatrix}2&1&0\\0&1&2\end{pmatrix}.$$

Размер $2\times3$: две компоненты, три переменные.

Два значения слова «якобиан»

Иногда «якобианом» называют определитель матрицы Якоби (когда $N=D$). Он нужен для замены переменных в интегралах, а в этом курсе интегралы не рассматриваются. У нас матрица Якоби — это $Df(x_0)$.

Частных производных мало

Лектор подчеркнул: существование матрицы $Df(x_0)$ сильнее, чем существование всех частных производных. Пример не из лекции: $f(x^1,x^2)=\frac{x^1x^2}{(x^1)^2+(x^2)^2}$, $f(0,0)=0$ имеет обе частные производные в нуле (они равны 0), но вдоль прямой $x^1=x^2$ равна $\frac12$ и даже не непрерывна в нуле.

Зачем это в ML

Каждый слой нейросети — отображение $\R^N\to\R^D$. Его матрица Якоби и есть то, что перемножает обратное распространение ошибки.

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

Когда $D=1$, матрица $Df(x_0)$ — строка $1\times N$. Градиент — её транспонирование, столбец: $\nabla f(x_0)=Df(x_0)^t$. Лектор настаивал: градиент — вектор, а не ковектор.

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

Если $Df(x_0)$ существует, то для любого $u\in\R^N$

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

При $D=1$ это число $\langle\nabla f(x_0),u\rangle$.

Доказательство. При $u=0$ обе части равны нулю. Пусть $u\ne0$. По определению с вектором $hu$ вместо $u$: $f(x_0+hu)-f(x_0)=Df(x_0)(hu)+o(\lVert hu\rVert)$. Делим на $h$:

$$\frac{f(x_0+hu)-f(x_0)}{h}=Df(x_0)u+\frac{o(\lVert hu\rVert)}{\lVert hu\rVert}\cdot\frac{\lVert hu\rVert}{h}.$$

Первая дробь стремится к нулю, а модуль второй равен $\lVert u\rVert$ и от $h$ не зависит. Произведение стремится к нулю. ∎

Это главный вычислительный инструмент урока: чтобы найти матрицу $Df(x_0)$, посчитай этот предел для произвольного $u$ и прочитай, что стоит перед $u$.

Пример. $f(x)=(x^1)^2x^2$, $x_0=(1,2)^t$, $u=(1,1)^t$. Частные производные дают $Df(x_0)=(2x^1x^2,\ (x^1)^2)=(4,\ 1)$, и $Df(x_0)u=4+1=5$. Проверка пределом: $f(1+h,2+h)=(1+2h+h^2)(2+h)=2+5h+4h^2+h^3$, значит $\frac{f(x_0+hu)-f(x_0)}{h}=5+4h+h^2\to5$.

Зачем это в ML

Среди единичных направлений $u$ число $\langle\nabla f,u\rangle$ меньше всего при $u=-\nabla f/\lVert\nabla f\rVert$ (это Коши — Буняковский). Поэтому градиентный спуск идёт против градиента: это направление быстрейшего убывания.

Цепное правило как произведение матриц

Главный частный случай. Пусть $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)$ существуют, то

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

Правой части на фото доски нет; это стандартная формула, которая следует из общего вида ниже. Условие — существование всей матрицы $Df(u_0)$, а не только частных производных.

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

Пусть $G:\R^M\to\R^N$ и $F:\R^N\to\R^D$. Тогда

$$D(F\circ G)(x_0)=DF(G(x_0))\cdot DG(x_0),$$

произведение матриц размеров $D\times N$ и $N\times M$, результат — $D\times M$. В координатах: $\frac{\partial y^j}{\partial x^i}=\sum_{k=1}^{N}\frac{\partial y^j}{\partial u^k}\frac{\partial u^k}{\partial x^i}$.

Доказательство лектор дал на следующей лекции (урок m02).

Пример. $G(x)=(x^1+x^2,\ x^1-x^2)^t$, $F(u)=u^1u^2$, $x_0=(2,1)^t$. Тогда $u_0=G(x_0)=(3,1)^t$, $DF(u_0)=(u^2,\ u^1)=(1,\ 3)$, $DG=\begin{pmatrix}1&1\\1&-1\end{pmatrix}$, и

$$D(F\circ G)(x_0)=(1,\ 3)\begin{pmatrix}1&1\\1&-1\end{pmatrix}=(4,\ -2).$$

Проверка: $F(G(x))=(x^1)^2-(x^2)^2$, частные производные $2x^1=4$ и $-2x^2=-2$.

Зачем это в ML

Нейросеть — композиция слоёв. Обратное распространение ошибки перемножает их матрицы Якоби от последнего слоя к первому. В записи $D(F\circ G)=DF\cdot DG$ это слева направо: первой стоит строка производной потери, и после каждого умножения снова получается строка, а не большая матрица.

Пример лектора: наименьшие квадраты

$f(x)=\lVert b-Ax\rVert^2$, $x\in\R^N$, $A\in M_{D\times N}$, $b\in\R^D$ — функция потерь линейной регрессии. Лектор вывел её производную по схеме, которая полностью разобрана в эталонной задаче ниже. Два правила из этого вывода:

  • Никогда не дифференцируй длину — дифференцируй квадрат длины. Длина ведёт себя как $\lvert x\rvert$, у которого нет производной в нуле, а квадрат длины — произведение $(b-Ax)^t(b-Ax)$.
  • Число равно своему транспонированию. Два средних слагаемых разложения совпадают: $(Au)^t(b-Ax_0)=\big((Au)^t(b-Ax_0)\big)^t=(b-Ax_0)^tAu$.

Результат, обведённый на доске:

$$Df(x_0)=-2(b-Ax_0)^tA,\qquad \nabla f(x_0)=2A^t(Ax_0-b).$$
Дополнение

На этой лекции не прозвучало: приравняв градиент нулю, получаем нормальные уравнения $A^tAx=A^tb$. Это тема урока m02; здесь — чтобы было видно, куда ведёт формула.

Производная по матрице: след и цикличность

Пусть $X\in M_{m\times n}$ — переменная, $a\in\R^m$ и $b\in\R^n$ фиксированы, $f(X)=a^tXb$ — число.

Соглашение лектора

Производная $Df(X_0)$ — матрица размера $n\times m$, которая действует на сдвиг $U\in M_{m\times n}$ так:

$$Df(X_0)\cdot U=\tr\big(Df(X_0)\,U\big).$$

Размер $n\times m$ выбран, чтобы произведение $Df(X_0)\,U$ было квадратным $n\times n$ и имело след.

Предел считается в одну строку, потому что $f$ линейна: $\frac{a^t(X_0+hU)b-a^tX_0b}{h}=a^tUb$. Трудность в другом: $U$ застряла в середине, а умножение матриц некоммутативно, её нельзя просто вынести вправо. Приём лектора — два факта: число равно своему следу, и след цикличен:

$$a^tUb=\tr(a^tUb)=\tr\big((a^tU)\,b\big)=\tr\big(b\,(a^tU)\big)=\tr\big((ba^t)\,U\big).$$

Значит $Df(X_0)=ba^t$ — матрица $n\times m$. Её транспонирование $ab^t$ имеет ту же форму, что и $X$; эту форму называют градиентом в библиотеках ML.

Пример. $m=2$, $n=3$, $a=(1,2)^t$, $b=(1,0,1)^t$: $Df(X_0)=ba^t=\begin{pmatrix}1&2\\0&0\\1&2\end{pmatrix}$, размер $3\times2$. Проверка одним элементом: сдвиг $U$ с единицей в строке 1, столбце 1 и нулями в остальных местах даёт $a^tUb=a^1b^1=1$, и $\tr(Df(X_0)\,U)$ равен элементу $Df(X_0)$ в строке 1, столбце 1, то есть тоже 1.

Зачем это в ML

Веса слоя — матрица $W$. Чтобы сделать шаг градиентного спуска $W\leftarrow W-\eta G$, нужна матрица $G$ той же формы, что $W$: это транспонированная $Df(W)$. Её библиотеки и хранят рядом с весами.

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

  1. Производная — лучшее линейное приближение: изменение $=$ линейная часть $+\,o(\cdot)$.
  2. Теорема о среднем — точное равенство в неизвестной точке $\xi$ строго внутри отрезка.
  3. Остаточный член Лагранжа $\frac{f^{(N+1)}(\xi)}{(N+1)!}(b-a)^{N+1}$ даёт гарантированную оценку ошибки многочлена Тейлора.
  4. Для $f:\R^N\to\R^D$ производная — матрица $D\times N$ частных производных, а градиент $\nabla f=(Df)^t$ — столбец.
  5. Матрицу $Df(x_0)$ находят через предел $\frac{f(x_0+hu)-f(x_0)}{h}$ и читают коэффициент при $u$.
  6. Цепное правило: $D(F\circ G)=DF\cdot DG$, размеры $D\times N$ и $N\times M$.
  7. Длину не дифференцируют — дифференцируют квадрат длины; число равно своему транспонированию.
  8. Для функции от матрицы: число $=$ его след, цикличность ставит $U$ вправо, $Df(X_0)\in M_{n\times m}$.
EN

Entry: how much does the loss change

Let the loss of a model, $f(x)=\lVert b-Ax\rVert^2$, depend on a weight vector $x\in\R^N$. Move the weights by a small vector $u$. How much does the loss change? The answer of this lesson: approximately by $Df(x)\,u$, where $Df(x)=-2(b-Ax)^tA$ is a single row of $N$ numbers. To get this row honestly, the lecturer starts from a function of one variable and replaces the number by a matrix step by step.

The derivative through little-o

Zoom far into the graph of a smooth function near a point $x_0$, and it is almost indistinguishable from a straight line. The slope of that line is the derivative: the change of the function equals “slope × shift” plus something much smaller than the shift.

Little-o

We write $g(h)=o(h)$ as $h\to0$ if $\lim_{h\to0}\frac{g(h)}{h}=0$: $g$ goes to zero faster than $h$.

The derivative as the best linear approximation

The number $f'(x_0)$ is the derivative of $f$ at $x_0$ if

$$f(x_0+h)-f(x_0)=f'(x_0)\,h+o(h),\qquad h\to0.$$

This is the usual definition: divide both sides by $h$ and let $h\to0$.

Example. $f(x)=x^2$, $x_0=3$: $f(3+h)-f(3)=9+6h+h^2-9=6h+h^2$. The term $h^2$ is $o(h)$ because $h^2/h=h\to0$. So $f'(3)=6$. For $h=0.01$ the change is $0.06+0.0001$: the linear part gives almost everything.

The lecturer writes the chain rule in Leibniz notation, $\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}$ — the lecturer’s favorite notation. Below, the product of numbers in this formula becomes a product of matrices.

Why this matters for ML

A training step moves the weights by a small vector, and the loss changes almost exactly by the linear part. That is why the derivative tells you where to step: for a small step the remainder $o(\cdot)$ is negligible.

The mean value theorem

If a car covered 120 km in two hours, then at some moment its speedometer showed exactly 60 km/h. On the graph: the chord between the endpoints is parallel to the tangent line at some interior point.

Mean value theorem

If $f$ is continuous on $[a,b]$ and $f'$ exists on $(a,b)$, then there is $\xi\in(a,b)$ such that

$$f(b)-f(a)=f'(\xi)(b-a).$$

Compare with the little-o formula. There the derivative is taken at a known point, but there is an error $o(h)$. Here the equality is exact, but the point $\xi$ is unknown. All we know is that $\xi$ lies strictly inside $(a,b)$ — and in the proof of Taylor’s theorem this turns out to matter.

Example. $f(x)=x^2$ on $[1,3]$: $f(3)-f(1)=8$ and $f'(\xi)(3-1)=4\xi$, so $\xi=2$ — inside the interval.

Why this matters for ML

If $\lvert f'\rvert\le L$ on the whole interval, the theorem gives $\lvert f(b)-f(a)\rvert\le L\lvert b-a\rvert$: the function cannot change more than that. Such constants (Lipschitz constants) bound a safe learning step.

Taylor’s theorem with the Lagrange remainder

The linear approximation uses one derivative. Add the second, the third, and so on, and the polynomial also follows the bending of the graph. The price is an error, and it turns out to have an exact form, as in the mean value theorem.

Taylor’s theorem with the Lagrange remainder

If $f,f',\dots,f^{(N)}$ are continuous on $[a,b]$ and $f^{(N+1)}$ exists on $(a,b)$, then for some $\xi\in(a,b)$

$$f(b)-f(a)=\sum_{k=1}^{N}\frac{f^{(k)}(a)}{k!}(b-a)^k+\frac{f^{(N+1)}(\xi)}{(N+1)!}(b-a)^{N+1}.$$

The last term is the remainder. For $N=0$ the sum is empty, and we get the mean value theorem. If $b<a$, the formula holds with $\xi$ strictly between $b$ and $a$.

Example. $f(x)=e^x$, $a=0$, $b=0.1$, $N=2$. All derivatives equal $e^x$, and at zero they equal 1, so $e^{0.1}=1+0.1+\frac{0.01}{2}+\frac{e^{\xi}}{6}\cdot0.001=1.105+\frac{e^{\xi}}{6000}$ with $\xi\in(0,0.1)$. Since $e^{\xi}<e^{0.1}<2$, the error of the polynomial is less than $\frac{2}{6000}\approx0.0003$. The exact value is $e^{0.1}\approx1.10517$: the error is $0.00017$, and the bound holds.

The lecturer proved the theorem from the mean value theorem and explained why: mathematics is not a collection of facts but theorems linked by logic.

The proof in four steps

Idea. Replace $a$ by a variable $x$, build two helper functions that vanish at $b$, and apply the mean value theorem to a combination of them.

Step 1. Two helper functions.

$$\varphi(x)=f(b)-\Big\{f(x)+\sum_{k=1}^{N}\frac{f^{(k)}(x)}{k!}(b-x)^k\Big\},\qquad \psi(x)=(b-x)^{N+1}.$$

At $x=b$ all powers $(b-x)^k$ vanish, so $\varphi(b)=f(b)-f(b)=0$ and $\psi(b)=0$. At $x=a$ we get $\psi(a)=(b-a)^{N+1}$, while $\varphi(a)$ is $f(b)$ minus the Taylor polynomial, that is, exactly the remainder we want to find.

Step 2. Derivatives. $\psi'(x)=-(N+1)(b-x)^N$ by the chain rule. For $\varphi$, each term of the sum is differentiated by the product rule, and the sum becomes telescoping: it has the form $(a_N-a_{N-1})+\dots+(a_1-a_0)$, and only $a_N-a_0$ survives. The result:

$$\varphi'(x)=-\frac{f^{(N+1)}(x)}{N!}(b-x)^N.$$

The intermediate computation is homework item 1: the lecturer asked you to redo it on your own.

Step 3. A Cauchy-style helper.

$$F(x)=[\varphi(x)-\varphi(a)][\psi(b)-\psi(a)]-[\varphi(b)-\varphi(a)][\psi(x)-\psi(a)].$$

At $x=a$ both brackets containing $x$ vanish, so $F(a)=0$. At $x=b$ the two products coincide, so $F(b)=0$. By the mean value theorem $0=F(b)-F(a)=F'(\xi)(b-a)$ for some $\xi\in(a,b)$, that is,

$$\varphi'(\xi)[\psi(b)-\psi(a)]-\psi'(\xi)[\varphi(b)-\varphi(a)]=0.$$

Substitute $\psi(b)-\psi(a)=-(b-a)^{N+1}$, $\varphi(b)-\varphi(a)=-\varphi(a)$, and the derivatives from step 2:

$$\frac{f^{(N+1)}(\xi)}{N!}(b-\xi)^N(b-a)^{N+1}-(N+1)(b-\xi)^N\varphi(a)=0.$$

Step 4. Cancel $(b-\xi)^N$. This is legal only because $\xi$ lies strictly inside $(a,b)$, so $b-\xi\ne0$. The lecturer stressed it: even this slight information about the point is useful. Divide by $(N+1)(b-\xi)^N$:

$$\varphi(a)=\frac{f^{(N+1)}(\xi)}{N!\,(N+1)}(b-a)^{N+1}=\frac{f^{(N+1)}(\xi)}{(N+1)!}(b-a)^{N+1}.\ ∎$$

The Taylor series of $e^x$

With $a=0$, every derivative of $e^x$ equals 1 at zero, so for any $b$

$$e^b=\sum_{k=0}^{N}\frac{b^k}{k!}+\frac{e^{\theta}}{(N+1)!}b^{N+1},\qquad \theta\ \text{between}\ 0\ \text{and}\ b.$$

We get a series if the remainder goes to zero as $N\to\infty$. The factor $e^{\theta}$ is at most $e^{\lvert b\rvert}$ and does not depend on $N$. It remains to see why $\lvert b\rvert^n/n!\to0$. A student’s argument in class: write $\frac{b^n}{n!}=\frac b1\cdot\frac b2\cdots\frac bn$. For example, with $b=3$ the first three factors give $4.5$, and every later factor is at most $\frac34$, so $\frac{3^n}{n!}\le4.5\cdot\left(\frac34\right)^{n-3}\to0$. Hence $e^x=\sum_{k\ge0}\frac{x^k}{k!}$ for all $x$: the series converges to $e^x$ because the error of the finite polynomial is under control.

Why this matters for ML

Second-order methods (Newton’s method) approximate the loss by a Taylor polynomial of degree 2. The quadratic term explains why a learning rate that is too large diverges: for a large shift it outweighs the linear part.

Vectors, covectors, and matrices

The lecturer’s notation, used for everything below:

  • $\R^N$ — columns of height $N$; coordinates carry upper indices: $x=(x^1,\dots,x^N)^t$.
  • $M_{m\times n}$ — real matrices with $m$ rows and $n$ columns; the entry $a_{ij}$ sits in row $i$, column $j$.
  • $(\R^N)^*$ — rows, covectors: a row $a^t$ takes a column $x$ and returns the number $a^tx$.
  • A column and a row are just matrices with one column or one row. A number is a $1\times1$ matrix.

On the board the lecturer puts arrows over vectors ($\vec x$); here the arrows are omitted, and a vector is always a column.

Example. $a=(1,2)^t$; then $a^t$ is a covector, and $a^tx=x^1+2x^2$ for $x\in\R^2$. A $1\times1$ matrix does not change under transposition: $(a^tx)^t=x^ta=a^tx$. This fact resolves the main difficulty of the section on least squares.

Length and inner product of matrices

An $m\times n$ matrix can be read as a long vector of $mn$ numbers. Then its length is the square root of the sum of squares of all entries, and the inner product is the sum of products of corresponding entries.

Lengths and inner product$$\lVert x\rVert=\sqrt{x^tx},\qquad \lVert A\rVert=\sqrt{\tr(A^tA)},\qquad \tr(A^tA)=\sum_{i,j}a_{ij}^2.$$

For $A,B\in M_{m\times n}$ the inner product is $\langle A,B\rangle=\tr(A^tB)$. The length of a matrix is called the Frobenius norm.

The transpose is needed here: $A^tB$ is a square $n\times n$ matrix, it has a trace, and $\langle A,A\rangle\ge0$. For columns the formula becomes the familiar $x^ty$, because the trace of a $1\times1$ matrix is that matrix itself.

Example. $A=\begin{pmatrix}1&2\\0&3\end{pmatrix}$: $A^tA=\begin{pmatrix}1&0\\2&3\end{pmatrix}\begin{pmatrix}1&2\\0&3\end{pmatrix}=\begin{pmatrix}1&2\\2&13\end{pmatrix}$, the trace is $1+13=14$, and the sum of squares of the entries is $1+4+0+9=14$. So $\lVert A\rVert=\sqrt{14}$.

Length gives distance, and distance gives limits: “$u\to0$” means $\lVert u\rVert\to0$.

Cyclic property of the trace

If $A\in M_{n\times m}$ and $B\in M_{m\times n}$, then $\tr(AB)=\tr(BA)$. The matrices do not have to be square: $AB$ has size $n\times n$, $BA$ has size $m\times m$, and the traces are equal.

Example. $A=(1\ \ 2)$, $B=(3,4)^t$: $AB=(11)$, trace 11; $BA=\begin{pmatrix}3&6\\4&8\end{pmatrix}$, trace $3+8=11$.

The board also listed inequalities: $\lVert x+y\rVert\le\lVert x\rVert+\lVert y\rVert$, $\lVert Ax\rVert\le\lVert A\rVert\,\lVert x\rVert$, $\lVert A+B\rVert\le\lVert A\rVert+\lVert B\rVert$, $\lVert AB\rVert\le\lVert A\rVert\,\lVert B\rVert$. Their proofs and the proof of the cyclic property are homework.

Why this matters for ML

Weight decay adds $\lambda\lVert W\rVert^2$ to the loss — the squared Frobenius norm of the weight matrix. The inequality $\lVert Wx\rVert\le\lVert W\rVert\,\lVert x\rVert$ bounds how much a layer can amplify its input.

The derivative of a map $\R^N\to\R^D$ is a $D\times N$ matrix

The same sentence as for numbers: the change equals the linear part plus something negligible. Only now the shift is a vector $u\in\R^N$, the change is a vector in $\R^D$, and “multiply by a number” becomes “multiply by a matrix”.

Derivative (Jacobian matrix)

Let $f:\R^N\to\R^D$, $y=f(x)$. The derivative of $f$ at $x_0$ is a matrix $A\in M_{D\times N}$ such that

$$f(x_0+u)-f(x_0)=Au+o(\lVert u\rVert),\quad\text{that is,}\quad \lim_{\lVert u\rVert\to0}\frac{f(x_0+u)-f(x_0)-Au}{\lVert u\rVert}=0.$$

Notation: $Df(x_0)$. The entry in row $i$, column $j$ is $\partial f^i/\partial x^j$: the row belongs to the component $f^i$, the column to the variable $x^j$. An ordinary derivative is a $1\times1$ matrix that happens to be a number.

Example. $f:\R^3\to\R^2$, $f(x)=\big(x^1x^2,\ x^2+(x^3)^2\big)^t$, $x_0=(1,2,1)^t$. Partial derivatives:

$$Df(x)=\begin{pmatrix}x^2&x^1&0\\0&1&2x^3\end{pmatrix},\qquad Df(x_0)=\begin{pmatrix}2&1&0\\0&1&2\end{pmatrix}.$$

Size $2\times3$: two components, three variables.

Two meanings of “Jacobian”

Sometimes “the Jacobian” means the determinant of the Jacobian matrix (when $N=D$). It is used for changes of variables in integrals, and this course does not cover integrals. For us the Jacobian matrix is $Df(x_0)$.

Partial derivatives are not enough

The lecturer stressed: the existence of the matrix $Df(x_0)$ is stronger than the existence of all partial derivatives. An example not from the lecture: $f(x^1,x^2)=\frac{x^1x^2}{(x^1)^2+(x^2)^2}$, $f(0,0)=0$ has both partial derivatives at zero (both equal 0), but along the line $x^1=x^2$ it equals $\frac12$ and is not even continuous at zero.

Why this matters for ML

Each layer of a neural network is a map $\R^N\to\R^D$. Its Jacobian matrix is exactly what backpropagation multiplies.

Gradient and directional derivative

When $D=1$, the matrix $Df(x_0)$ is a $1\times N$ row. The gradient is its transpose, a column: $\nabla f(x_0)=Df(x_0)^t$. The lecturer insisted: the gradient is a vector, not a covector.

Directional derivative

If $Df(x_0)$ exists, then for every $u\in\R^N$

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

For $D=1$ this is the number $\langle\nabla f(x_0),u\rangle$.

Proof. For $u=0$ both sides are zero. Let $u\ne0$. By the definition with the vector $hu$ in place of $u$: $f(x_0+hu)-f(x_0)=Df(x_0)(hu)+o(\lVert hu\rVert)$. Divide by $h$:

$$\frac{f(x_0+hu)-f(x_0)}{h}=Df(x_0)u+\frac{o(\lVert hu\rVert)}{\lVert hu\rVert}\cdot\frac{\lVert hu\rVert}{h}.$$

The first fraction goes to zero, and the absolute value of the second equals $\lVert u\rVert$ and does not depend on $h$. The product goes to zero. ∎

This is the main computing tool of the lesson: to find the matrix $Df(x_0)$, compute this limit for an arbitrary $u$ and read off what multiplies $u$.

Example. $f(x)=(x^1)^2x^2$, $x_0=(1,2)^t$, $u=(1,1)^t$. Partial derivatives give $Df(x_0)=(2x^1x^2,\ (x^1)^2)=(4,\ 1)$, and $Df(x_0)u=4+1=5$. Check by the limit: $f(1+h,2+h)=(1+2h+h^2)(2+h)=2+5h+4h^2+h^3$, so $\frac{f(x_0+hu)-f(x_0)}{h}=5+4h+h^2\to5$.

Why this matters for ML

Among unit directions $u$, the number $\langle\nabla f,u\rangle$ is smallest at $u=-\nabla f/\lVert\nabla f\rVert$ (this is Cauchy–Schwarz). That is why gradient descent moves against the gradient: it is the direction of fastest decrease.

The chain rule as a matrix product

The essential special case. Let $y=f(u^1,\dots,u^N)$ and $u^j=g^j(t)$, $u_0^j=g^j(t_0)$. If $Df(u_0)$ exists and all $(g^j)'(t_0)$ exist, then

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

The right-hand side is not on the board photo; it is the standard formula, and it follows from the general form below. The condition is the existence of the whole matrix $Df(u_0)$, not only of the partial derivatives.

Chain rule

Let $G:\R^M\to\R^N$ and $F:\R^N\to\R^D$. Then

$$D(F\circ G)(x_0)=DF(G(x_0))\cdot DG(x_0),$$

a product of matrices of sizes $D\times N$ and $N\times M$; the result is $D\times M$. In coordinates: $\frac{\partial y^j}{\partial x^i}=\sum_{k=1}^{N}\frac{\partial y^j}{\partial u^k}\frac{\partial u^k}{\partial x^i}$.

The lecturer gave the proof in the next lecture (lesson m02).

Example. $G(x)=(x^1+x^2,\ x^1-x^2)^t$, $F(u)=u^1u^2$, $x_0=(2,1)^t$. Then $u_0=G(x_0)=(3,1)^t$, $DF(u_0)=(u^2,\ u^1)=(1,\ 3)$, $DG=\begin{pmatrix}1&1\\1&-1\end{pmatrix}$, and

$$D(F\circ G)(x_0)=(1,\ 3)\begin{pmatrix}1&1\\1&-1\end{pmatrix}=(4,\ -2).$$

Check: $F(G(x))=(x^1)^2-(x^2)^2$, with partial derivatives $2x^1=4$ and $-2x^2=-2$.

Why this matters for ML

A neural network is a composition of layers. Backpropagation multiplies their Jacobian matrices from the last layer to the first. In the notation $D(F\circ G)=DF\cdot DG$ this is left to right: the row of the loss derivative comes first, and after each multiplication you again get a row rather than a large matrix.

The lecturer’s example: least squares

$f(x)=\lVert b-Ax\rVert^2$, $x\in\R^N$, $A\in M_{D\times N}$, $b\in\R^D$ — the loss of linear regression. The lecturer derived its derivative by the scheme that is worked out in full in the model problem below. Two rules from that derivation:

  • Never differentiate a length; differentiate the squared length. A length behaves like $\lvert x\rvert$, which has no derivative at zero, while the squared length is a product $(b-Ax)^t(b-Ax)$.
  • A number equals its own transpose. The two middle terms of the expansion coincide: $(Au)^t(b-Ax_0)=\big((Au)^t(b-Ax_0)\big)^t=(b-Ax_0)^tAu$.

The result, boxed on the board:

$$Df(x_0)=-2(b-Ax_0)^tA,\qquad \nabla f(x_0)=2A^t(Ax_0-b).$$
Not from the lecture

Not said in this lecture: setting the gradient to zero gives the normal equations $A^tAx=A^tb$. That is the topic of lesson m02; it is mentioned here to show where the formula leads.

Derivative with respect to a matrix: trace and cyclic property

Let $X\in M_{m\times n}$ be the variable, $a\in\R^m$ and $b\in\R^n$ fixed, and $f(X)=a^tXb$ a number.

The lecturer’s convention

The derivative $Df(X_0)$ is an $n\times m$ matrix that acts on a shift $U\in M_{m\times n}$ as follows:

$$Df(X_0)\cdot U=\tr\big(Df(X_0)\,U\big).$$

The size $n\times m$ is chosen so that the product $Df(X_0)\,U$ is a square $n\times n$ matrix and has a trace.

The limit takes one line because $f$ is linear: $\frac{a^t(X_0+hU)b-a^tX_0b}{h}=a^tUb$. The difficulty is elsewhere: $U$ is trapped in the middle, and matrix multiplication is not commutative, so you cannot simply move it to the right. The lecturer’s trick uses two facts: a number equals its own trace, and the trace is cyclic:

$$a^tUb=\tr(a^tUb)=\tr\big((a^tU)\,b\big)=\tr\big(b\,(a^tU)\big)=\tr\big((ba^t)\,U\big).$$

So $Df(X_0)=ba^t$, an $n\times m$ matrix. Its transpose $ab^t$ has the same shape as $X$; ML libraries call this shape-matched form the gradient.

Example. $m=2$, $n=3$, $a=(1,2)^t$, $b=(1,0,1)^t$: $Df(X_0)=ba^t=\begin{pmatrix}1&2\\0&0\\1&2\end{pmatrix}$, size $3\times2$. Check one entry: the shift $U$ with a one in row 1, column 1 and zeros elsewhere gives $a^tUb=a^1b^1=1$, and $\tr(Df(X_0)\,U)$ equals the entry of $Df(X_0)$ in row 1, column 1, which is also 1.

Why this matters for ML

The weights of a layer form a matrix $W$. To take a gradient descent step $W\leftarrow W-\eta G$, you need a matrix $G$ of the same shape as $W$: it is the transposed $Df(W)$. That is what libraries store next to the weights.

What should stay with you

  1. The derivative is the best linear approximation: change $=$ linear part $+\,o(\cdot)$.
  2. The mean value theorem is an exact equality at an unknown point $\xi$ strictly inside the interval.
  3. The Lagrange remainder $\frac{f^{(N+1)}(\xi)}{(N+1)!}(b-a)^{N+1}$ gives a guaranteed error bound for a Taylor polynomial.
  4. For $f:\R^N\to\R^D$ the derivative is the $D\times N$ matrix of partial derivatives, and the gradient $\nabla f=(Df)^t$ is a column.
  5. The matrix $Df(x_0)$ is found through the limit $\frac{f(x_0+hu)-f(x_0)}{h}$ by reading off the coefficient of $u$.
  6. Chain rule: $D(F\circ G)=DF\cdot DG$, with sizes $D\times N$ and $N\times M$.
  7. Do not differentiate a length — differentiate the squared length; a number equals its own transpose.
  8. For a function of a matrix: a number $=$ its trace, the cyclic property moves $U$ to the right, $Df(X_0)\in M_{n\times m}$.

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

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

Что видноWhat you seeПервый ходFirst move
Спрашивают, насколько изменится функция при малом сдвигеYou are asked how much a function changes under a small shiftВыпиши линейную часть: $f'(x_0)h$ для числа, $Df(x_0)u$ для вектораWrite the linear part: $f'(x_0)h$ for a number, $Df(x_0)u$ for a vector
Нужно оценить ошибку многочлена ТейлораYou need to bound the error of a Taylor polynomialЗапиши остаточный член Лагранжа и оцени $f^{(N+1)}(\xi)$ сверху на всём отрезкеWrite the Lagrange remainder and bound $f^{(N+1)}(\xi)$ from above over the whole interval
Функция задана через длину $\lVert\cdot\rVert$The function is given through a length $\lVert\cdot\rVert$Дифференцируй квадрат длины: перепиши его как $v^tv$Differentiate the squared length: rewrite it as $v^tv$
В выкладке два числа вида $(Au)^tv$ и $v^tAu$A computation contains two numbers of the form $(Au)^tv$ and $v^tAu$Это одно и то же число: число равно своему транспонированиюThey are the same number: a number equals its own transpose
Функция — композиция отображенийThe function is a composition of mapsПеремножь матрицы производных: $D(F\circ G)=DF\cdot DG$, внешнюю бери в точке $G(x_0)$ и сверь размерыMultiply the derivative matrices: $D(F\circ G)=DF\cdot DG$, take the outer one at $G(x_0)$, and check the sizes
Переменная — матрица $X$, а $U$ застряла в середине произведенияThe variable is a matrix $X$, and $U$ is trapped in the middle of a productЗапиши число как след и переставь множители по цикличности, чтобы $U$ встала справаWrite the number as a trace and reorder the factors by the cyclic property so that $U$ stands on the right
Нужно найти градиентYou need the gradientСначала найди строку $Df(x_0)$, потом транспонируй её в столбецFirst find the row $Df(x_0)$, then transpose it into a column
эталонная задачаmodel problem

Градиент функции потерь линейной регрессии с L2-штрафомGradient of the linear-regression loss with an L2 penalty

RU

Условие. $f(x)=\lVert b-Ax\rVert^2+\lambda\lVert x\rVert^2$, где $A\in M_{D\times N}$, $b\in\R^D$, $x\in\R^N$, $\lambda>0$ — число. Найти $Df(x_0)$ и $\nabla f(x_0)$.

Это функция потерь линейной регрессии со штрафом на веса (weight decay). Лектор разобрал случай $\lambda=0$; штраф добавляет одно слагаемое и показывает, что схема не ломается. Смотри на порядок решений: та же схема закрывает m0112, m0115 и финал m0119, а для функции от матрицы — m0116 и финал m0120.

Шаг 1. Решить, что дифференцировать. Длина ведёт себя как модуль $\lvert x\rvert$ и в нуле не имеет производной. Квадрат длины — произведение, а произведение дифференцируется по известным правилам:

$$f(x)=(b-Ax)^t(b-Ax)+\lambda\,x^tx.$$

Шаг 2. Решить, какого размера ответ. $f:\R^N\to\R$, значит $Df(x_0)$ — строка $1\times N$, а $\nabla f(x_0)=Df(x_0)^t$ — столбец высоты $N$. Этот размер — проверка в конце.

Шаг 3. Подставить $x_0+hu$ и раскрыть скобки. Обозначим $r=b-Ax_0$, столбец высоты $D$. Тогда $b-A(x_0+hu)=r-hAu$, а $(r-hAu)^t=r^t-h(Au)^t$ по правилу транспонирования суммы. Раскрываем:

$$f(x_0+hu)=r^tr-h(Au)^tr-h\,r^tAu+h^2(Au)^tAu+\lambda\big(x_0^tx_0+h\,u^tx_0+h\,x_0^tu+h^2u^tu\big).$$

Шаг 4. Разделить на $h$ и устремить $h\to0$. Слагаемые без $h$ сокращаются с $f(x_0)=r^tr+\lambda x_0^tx_0$, слагаемые с $h^2$ после деления на $h$ стремятся к нулю:

$$\lim_{h\to0}\frac{f(x_0+hu)-f(x_0)}{h}=-(Au)^tr-r^tAu+\lambda\big(u^tx_0+x_0^tu\big).$$

Шаг 5. Свести одинаковые числа и прочитать матрицу при $u$. Каждое слагаемое — матрица $1\times1$, то есть число, а число равно своему транспонированию: $(Au)^tr=\big((Au)^tr\big)^t=r^tAu$ и $u^tx_0=x_0^tu$. Предел равен

$$-2r^tAu+2\lambda x_0^tu=\big(-2(b-Ax_0)^tA+2\lambda x_0^t\big)u.$$

Функция — многочлен от координат $x$, поэтому её производная существует, и по предложению о производной по направлению этот предел равен $Df(x_0)u$ для любого $u$. Значит

$$Df(x_0)=-2(b-Ax_0)^tA+2\lambda x_0^t.$$

Шаг 6. Транспонировать и проверить.

$$\nabla f(x_0)=Df(x_0)^t=-2A^t(b-Ax_0)+2\lambda x_0=2A^t(Ax_0-b)+2\lambda x_0.$$

Размеры: $A^t$ — $N\times D$, $Ax_0-b$ — высоты $D$, их произведение — высоты $N$, как и $x_0$. Частный случай $N=D=1$: $f(x)=(b-ax)^2+\lambda x^2$, и обычная производная $f'(x)=-2a(b-ax)+2\lambda x=2a(ax-b)+2\lambda x$ совпадает с формулой. При $\lambda=0$ получается результат лектора $Df(x_0)=-2(b-Ax_0)^tA$.

Алгоритм
  1. Перепиши каждый квадрат длины как $v^tv$.
  2. Назови размер ответа: $Df(x_0)$ — строка $1\times N$, $\nabla f(x_0)$ — столбец.
  3. Подставь $x_0+hu$ и раскрой скобки, транспонируя суммы по слагаемым.
  4. Раздели на $h$ и устреми $h\to0$: остаются только слагаемые первой степени по $h$.
  5. Сведи одинаковые числа транспонированием (для функции от матрицы — следом и цикличностью) и прочитай матрицу при $u$.
  6. Транспонируй в градиент и проверь размеры и частный случай $N=1$.
EN

Problem. $f(x)=\lVert b-Ax\rVert^2+\lambda\lVert x\rVert^2$, where $A\in M_{D\times N}$, $b\in\R^D$, $x\in\R^N$, and $\lambda>0$ is a number. Find $Df(x_0)$ and $\nabla f(x_0)$.

This is the loss of linear regression with a penalty on the weights (weight decay). The lecturer worked out the case $\lambda=0$; the penalty adds one term and shows that the scheme does not break. Watch the order of decisions: the same scheme solves m0112, m0115, and the final m0119, and for a function of a matrix, m0116 and the final m0120.

Step 1. Decide what to differentiate. A length behaves like the absolute value $\lvert x\rvert$ and has no derivative at zero. The squared length is a product, and a product is differentiated by the familiar rules:

$$f(x)=(b-Ax)^t(b-Ax)+\lambda\,x^tx.$$

Step 2. Decide the size of the answer. $f:\R^N\to\R$, so $Df(x_0)$ is a $1\times N$ row, and $\nabla f(x_0)=Df(x_0)^t$ is a column of height $N$. This size is the check at the end.

Step 3. Substitute $x_0+hu$ and expand. Write $r=b-Ax_0$, a column of height $D$. Then $b-A(x_0+hu)=r-hAu$, and $(r-hAu)^t=r^t-h(Au)^t$ by the rule for the transpose of a sum. Expand:

$$f(x_0+hu)=r^tr-h(Au)^tr-h\,r^tAu+h^2(Au)^tAu+\lambda\big(x_0^tx_0+h\,u^tx_0+h\,x_0^tu+h^2u^tu\big).$$

Step 4. Divide by $h$ and let $h\to0$. The terms without $h$ cancel against $f(x_0)=r^tr+\lambda x_0^tx_0$, and the terms with $h^2$ go to zero after division by $h$:

$$\lim_{h\to0}\frac{f(x_0+hu)-f(x_0)}{h}=-(Au)^tr-r^tAu+\lambda\big(u^tx_0+x_0^tu\big).$$

Step 5. Merge equal numbers and read off the matrix in front of $u$. Each term is a $1\times1$ matrix, that is, a number, and a number equals its own transpose: $(Au)^tr=\big((Au)^tr\big)^t=r^tAu$ and $u^tx_0=x_0^tu$. The limit is

$$-2r^tAu+2\lambda x_0^tu=\big(-2(b-Ax_0)^tA+2\lambda x_0^t\big)u.$$

The function is a polynomial in the coordinates of $x$, so its derivative exists, and by the proposition on the directional derivative this limit equals $Df(x_0)u$ for every $u$. Hence

$$Df(x_0)=-2(b-Ax_0)^tA+2\lambda x_0^t.$$

Step 6. Transpose and check.

$$\nabla f(x_0)=Df(x_0)^t=-2A^t(b-Ax_0)+2\lambda x_0=2A^t(Ax_0-b)+2\lambda x_0.$$

Sizes: $A^t$ is $N\times D$, $Ax_0-b$ has height $D$, their product has height $N$, as does $x_0$. Special case $N=D=1$: $f(x)=(b-ax)^2+\lambda x^2$, and the ordinary derivative $f'(x)=-2a(b-ax)+2\lambda x=2a(ax-b)+2\lambda x$ agrees with the formula. With $\lambda=0$ we recover the lecturer’s result $Df(x_0)=-2(b-Ax_0)^tA$.

Algorithm
  1. Rewrite every squared length as $v^tv$.
  2. Name the size of the answer: $Df(x_0)$ is a $1\times N$ row, $\nabla f(x_0)$ is a column.
  3. Substitute $x_0+hu$ and expand, transposing sums term by term.
  4. Divide by $h$ and let $h\to0$: only the terms of first degree in $h$ remain.
  5. Merge equal numbers by transposing (for a function of a matrix, by the trace and its cyclic property) and read off the matrix in front of $u$.
  6. Transpose into the gradient and check the sizes and the special case $N=1$.

Что подчеркнул лекторWhat the lecturer stressed

Время записано как часть:минуты:секунды; «—» — без точной метки.Time is recording part:minutes:seconds; “—” means no exact timestamp.

ВремяTimeЧто подчеркнулWhat was stressed
1:04:19О-малое — точный символ: $g(h)=o(h)$ значит, что $g(h)/h\to0$, то есть $g$ стремится к нулю быстрее, чем $h$Little-o is a precise symbol: $g(h)=o(h)$ means that $g(h)/h\to0$, that is, $g$ goes to zero faster than $h$
1:17:48Математика — не набор фактов, а теоремы, связанные логикой; поэтому формулу Тейлора выводят из теоремы о среднемMathematics is not a collection of facts but theorems linked by logic; that is why Taylor’s theorem is derived from the mean value theorem
1:26:01Проверь телескопическое вычисление $\varphi'$ самостоятельно: глядя, как считает лектор, этому не научитьсяCheck the telescoping computation of $\varphi'$ yourself: you do not learn it just by watching the lecturer calculate
1:32:25Сокращать на $(b-\xi)^N$ можно только потому, что $\xi$ лежит строго внутри отрезка: даже такая скромная информация о точке полезнаYou may cancel $(b-\xi)^N$ only because $\xi$ lies strictly inside the interval: even this slight information about the point is useful
1:45:39Тем же способом получи ряд Тейлора для $\sin x$ — это домашнее заданиеUse the same method to get the Taylor series of $\sin x$ — this is your homework
2:17:56В скалярном произведении матриц транспонирование нужно, чтобы скалярный квадрат был неотрицательнымThe inner product of matrices needs the transpose so that the inner product of a matrix with itself is nonnegative
2:37:16Матрица производной — это матрица частных производных, она называется матрицей ЯкобиThe derivative matrix is the matrix of partial derivatives; it is called the Jacobian matrix
2:38:07Осторожно: «якобианом» иногда называют определитель матрицы ЯкобиBe careful: “the Jacobian” sometimes refers to the determinant of the Jacobian matrix
2:42:13Градиент — вектор, а не ковектор: строку производной транспонируют в столбецThe gradient is a vector, not a covector: the row of the derivative is transposed into a column
3:06:33Существование производной — больше, чем существование всех частных производныхThe existence of the derivative is more than the existence of all partial derivatives
3:22:11Видишь длину — бери квадрат длины: длину дифференцировать плохо, квадрат длины — хорошоWhenever you see a length, take the square of the length: the length is bad to differentiate, its square is good
3:27:43Число — матрица $1\times1$, и при транспонировании оно не меняетсяA number is a $1\times1$ matrix, and transposing it gives itself
3:40:06$U$ застряла в середине произведения, а умножение матриц некоммутативно — вынести её просто так нельзя$U$ is trapped in the middle of the product, and matrix multiplication is not commutative — you cannot just move it out
3:42:17Для цикличности следа матрицы не обязаны быть одного размераThe cyclic property of the trace does not need the matrices to be of the same size

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

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

видеоvideo3Blue1Brown · Taylor series3Blue1Brown · Taylor series EN
Картинка к многочленам Тейлора: каждое новое слагаемое подгоняет ещё одну производнуюA picture for Taylor polynomials: each new term matches one more derivative
текстtextTerence Parr, Jeremy Howard · The Matrix Calculus You Need For Deep LearningTerence Parr, Jeremy Howard · The Matrix Calculus You Need For Deep Learning EN
Матрица Якоби, цепное правило и градиенты слоёв нейросети; транспонирование там обозначено буквой TThe Jacobian matrix, the chain rule, and gradients of neural-network layers; the transpose there is written with the letter T
справочникreferenceThe Matrix CookbookThe Matrix Cookbook EN
Таблицы производных по векторам и матрицам для самопроверки; соглашение о форме производной там своё, сверяй с урокомTables of derivatives with respect to vectors and matrices for self-checking; its convention for the shape of the derivative differs, so compare with the lesson
как работать с задачамиhow to work with the problems
RU

Полный объём — 20 задач. Иди по ступеням 1 → 4, не перепрыгивая. Перед каждой подсказкой отметь уверенность: это нужно тьютору, чтобы отличить хрупкое знание от ошибки в понимании. Доказательства m0113 и m0115 пиши на бумаге целиком, потом сверяй с решением построчно.

Минимум — 12 задач. Все задачи с отметками «минимум» и «обязательная»: m0104, m0107, m0108, m0110, m0112, m0114, m0115, m0116 и все четыре финала m0117–m0120.

Обязательные — 4 задачи. Это мосты к финалам: m0108 ведёт к m0117 (остаток Лагранжа), m0114 — к m0118 (произведение матриц производных), m0115 — к мини-тесту m0119 (градиент через предел), m0116 — к m0120 (след и цикличность). Если времени мало, делай эти четыре и мини-тест.

Формат ответа

Нецелые ответы вводятся с четырьмя знаками после запятой, разделитель — точка (запятая тоже принимается). Если спрашивают элемент матрицы, сначала выпиши размер матрицы: половина ошибок урока — в размерах.

EN

Full workload — 20 problems. Go through ladder steps 1 → 4 without skipping. Before opening each hint, mark your confidence: the tutor needs it to tell fragile knowledge from a misunderstanding. Write the proofs m0113 and m0115 on paper in full, then compare with the solution line by line.

Minimum — 12 problems. All problems marked “minimum” and “required”: m0104, m0107, m0108, m0110, m0112, m0114, m0115, m0116, and all four finals m0117–m0120.

Required — 4 problems. These are the bridges to the finals: m0108 leads to m0117 (Lagrange remainder), m0114 to m0118 (product of derivative matrices), m0115 to the mini-test m0119 (gradient through the limit), m0116 to m0120 (trace and cyclic property). If time is short, do these four and the mini-test.

Answer format

Enter non-integer answers with four decimal places, using a point as the separator (a comma is also accepted). If you are asked for an entry of a matrix, write down the size of the matrix first: half of the mistakes in this lesson are size mistakes.

20
полный объёмfull workload
12
минимумminimum
4
обязательные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

решено 0 из 50 of 5 solved

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

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

Пусть $f(x)=\sqrt x$. По формуле $f(x_0+h)\approx f(x_0)+f'(x_0)\,h$ с $x_0=4$ и $h=0.1$ найдите приближённое значение $\sqrt{4.1}$. Ответ округлите до четырёх знаков после запятой.

EN

Let $f(x)=\sqrt x$. Using the formula $f(x_0+h)\approx f(x_0)+f'(x_0)\,h$ with $x_0=4$ and $h=0.1$, find an approximate value of $\sqrt{4.1}$. Round your answer to four decimal places.

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

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

Нужна производная $f'(x)=\frac{1}{2\sqrt x}$ в точке $x_0=4$; корень из 4 известен точно, поэтому всё считается без калькулятора.

EN

You need the derivative $f'(x)=\frac{1}{2\sqrt x}$ at $x_0=4$; the square root of 4 is known exactly, so everything is computed without a calculator.

РешениеSolution
RU

Значения в точке. $f(4)=\sqrt4=2$ и $f'(4)=\frac{1}{2\sqrt4}=\frac14$.

Линейная часть. $f'(4)\,h=\frac14\cdot0.1=0.025$, поэтому

$$\sqrt{4.1}\approx2+0.025=2.025=2.0250.$$

Проверка. $2.025^2=4.100625$, это чуть больше $4.1$: приближение завышено, и точное значение $\sqrt{4.1}\approx2.0248$. Ошибка около $0.0002$ — она намного меньше сдвига $h=0.1$, как и обещает слагаемое $o(h)$.

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

Та же формула для векторов: $f(x_0+u)\approx f(x_0)+Df(x_0)\,u$. В m0110 вместо числа $f'(x_0)$ стоит строка $Df(x_0)$.

EN

Values at the point. $f(4)=\sqrt4=2$ and $f'(4)=\frac{1}{2\sqrt4}=\frac14$.

Linear part. $f'(4)\,h=\frac14\cdot0.1=0.025$, so

$$\sqrt{4.1}\approx2+0.025=2.025=2.0250.$$

Check. $2.025^2=4.100625$, slightly more than $4.1$: the approximation is a little too high, and the exact value is $\sqrt{4.1}\approx2.0248$. The error is about $0.0002$ — much smaller than the shift $h=0.1$, as the term $o(h)$ promises.

Where this leads

The same formula for vectors: $f(x_0+u)\approx f(x_0)+Df(x_0)\,u$. In m0110 the number $f'(x_0)$ is replaced by the row $Df(x_0)$.

m0102ступень 1step 1CM.2доска, фото 01board, photo 01
RU

Для $f(x)=x^3$ на отрезке $[0,3]$ найдите точку $\xi\in(0,3)$ из теоремы Лагранжа о среднем, то есть такую, что $f(3)-f(0)=f'(\xi)\,(3-0)$. Ответ округлите до четырёх знаков после запятой.

EN

For $f(x)=x^3$ on the interval $[0,3]$, find the point $\xi\in(0,3)$ from the mean value theorem, that is, the point with $f(3)-f(0)=f'(\xi)\,(3-0)$. Round your answer to four decimal places.

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

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

Посчитай левую часть числом, а справа подставь $f'(\xi)=3\xi^2$. Получится уравнение на $\xi$; из двух корней нужен тот, что лежит в $(0,3)$.

EN

Compute the left-hand side as a number, and on the right substitute $f'(\xi)=3\xi^2$. You get an equation for $\xi$; of the two roots, you need the one in $(0,3)$.

РешениеSolution
RU

Левая часть. $f(3)-f(0)=27-0=27$.

Правая часть. $f'(x)=3x^2$, поэтому $f'(\xi)\cdot3=9\xi^2$.

Уравнение. $9\xi^2=27$, значит $\xi^2=3$ и $\xi=\pm\sqrt3$. Внутри $(0,3)$ лежит только $\xi=\sqrt3\approx1.7321$.

Проверка. $f'(\sqrt3)=3\cdot3=9$, и это ровно средний наклон хорды: $\frac{27}{3}=9$. Точка лежит строго внутри отрезка, как требует теорема.

EN

Left-hand side. $f(3)-f(0)=27-0=27$.

Right-hand side. $f'(x)=3x^2$, so $f'(\xi)\cdot3=9\xi^2$.

Equation. $9\xi^2=27$, so $\xi^2=3$ and $\xi=\pm\sqrt3$. Only $\xi=\sqrt3\approx1.7321$ lies inside $(0,3)$.

Check. $f'(\sqrt3)=3\cdot3=9$, which is exactly the average slope of the chord: $\frac{27}{3}=9$. The point lies strictly inside the interval, as the theorem requires.

m0103ступень 1step 1CM.2авторскаяoriginal
RU

Вычислите сумму

$$\sum_{k=1}^{5}\left(\frac{2^k}{k!}-\frac{2^{k-1}}{(k-1)!}\right).$$

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

EN

Compute the sum

$$\sum_{k=1}^{5}\left(\frac{2^k}{k!}-\frac{2^{k-1}}{(k-1)!}\right).$$

Round your answer to four decimal places.

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

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

Обозначь $a_k=\frac{2^k}{k!}$. Тогда слагаемое с номером $k$ — это $a_k-a_{k-1}$.

EN

Write $a_k=\frac{2^k}{k!}$. Then the term with index $k$ is $a_k-a_{k-1}$.

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

Выпиши первые два и последнее слагаемые в виде разностей $a_k-a_{k-1}$: что с чем сокращается?

EN

Write the first two terms and the last one as differences $a_k-a_{k-1}$: what cancels with what?

РешениеSolution
RU

Узнать структуру. При $a_k=\frac{2^k}{k!}$ слагаемое равно $a_k-a_{k-1}$, и сумма записывается так:

$$(a_1-a_0)+(a_2-a_1)+(a_3-a_2)+(a_4-a_3)+(a_5-a_4).$$

Каждое $a_1,\dots,a_4$ входит один раз с плюсом и один раз с минусом. Остаётся $a_5-a_0$.

Посчитать. $a_5=\frac{32}{120}=\frac{4}{15}$, $a_0=\frac{2^0}{0!}=1$. Сумма равна

$$\frac{4}{15}-1=-\frac{11}{15}\approx-0.7333.$$

Проверка прямым счётом. $a_0=1$, $a_1=2$, $a_2=2$, $a_3=\frac43$, $a_4=\frac23$, $a_5=\frac{4}{15}$. Слагаемые: $1,\ 0,\ -\frac23,\ -\frac23,\ -\frac25$. Их сумма $1-\frac43-\frac25=\frac{15-20-6}{15}=-\frac{11}{15}$.

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

Такая же телескопическая сумма возникает в шаге 2 доказательства формулы Тейлора, только $a_k$ там — функции от $x$.

EN

Recognize the structure. With $a_k=\frac{2^k}{k!}$, the term equals $a_k-a_{k-1}$, and the sum reads

$$(a_1-a_0)+(a_2-a_1)+(a_3-a_2)+(a_4-a_3)+(a_5-a_4).$$

Each of $a_1,\dots,a_4$ appears once with a plus and once with a minus. What remains is $a_5-a_0$.

Compute. $a_5=\frac{32}{120}=\frac{4}{15}$, $a_0=\frac{2^0}{0!}=1$. The sum equals

$$\frac{4}{15}-1=-\frac{11}{15}\approx-0.7333.$$

Check by direct computation. $a_0=1$, $a_1=2$, $a_2=2$, $a_3=\frac43$, $a_4=\frac23$, $a_5=\frac{4}{15}$. The terms are $1,\ 0,\ -\frac23,\ -\frac23,\ -\frac25$. Their sum is $1-\frac43-\frac25=\frac{15-20-6}{15}=-\frac{11}{15}$.

Where this leads

The same kind of telescoping sum appears in step 2 of the proof of Taylor’s theorem, only there the $a_k$ are functions of $x$.

m0104ступень 1step 1минимумminimumCM.5CM.4доска, фото 04board, photo 04
RU

Пусть $A=\begin{pmatrix}1&2&2\\0&4&0\end{pmatrix}\in M_{2\times3}$. Найдите норму $\lVert A\rVert=\sqrt{\tr(A^tA)}$.

EN

Let $A=\begin{pmatrix}1&2&2\\0&4&0\end{pmatrix}\in M_{2\times3}$. Find the norm $\lVert A\rVert=\sqrt{\tr(A^tA)}$.

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

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

$A^tA$ — матрица $3\times3$; для следа нужны только её диагональные элементы. Элемент $(A^tA)_{jj}$ — произведение столбца $j$ матрицы $A$ на самого себя.

EN

$A^tA$ is a $3\times3$ matrix; the trace needs only its diagonal entries. The entry $(A^tA)_{jj}$ is column $j$ of $A$ multiplied by itself.

РешениеSolution
RU

Произведение. $A^t=\begin{pmatrix}1&0\\2&4\\2&0\end{pmatrix}\in M_{3\times2}$, и $A^tA\in M_{3\times3}$:

$$A^tA=\begin{pmatrix}1\cdot1+0\cdot0&1\cdot2+0\cdot4&1\cdot2+0\cdot0\\2\cdot1+4\cdot0&2\cdot2+4\cdot4&2\cdot2+4\cdot0\\2\cdot1+0\cdot0&2\cdot2+0\cdot4&2\cdot2+0\cdot0\end{pmatrix}=\begin{pmatrix}1&2&2\\2&20&4\\2&4&4\end{pmatrix}.$$

След и норма. $\tr(A^tA)=1+20+4=25$, поэтому $\lVert A\rVert=\sqrt{25}=5$.

Проверка. Сумма квадратов всех элементов: $1+4+4+0+16+0=25$. Совпадает со следом.

EN

Product. $A^t=\begin{pmatrix}1&0\\2&4\\2&0\end{pmatrix}\in M_{3\times2}$, and $A^tA\in M_{3\times3}$:

$$A^tA=\begin{pmatrix}1\cdot1+0\cdot0&1\cdot2+0\cdot4&1\cdot2+0\cdot0\\2\cdot1+4\cdot0&2\cdot2+4\cdot4&2\cdot2+4\cdot0\\2\cdot1+0\cdot0&2\cdot2+0\cdot4&2\cdot2+0\cdot0\end{pmatrix}=\begin{pmatrix}1&2&2\\2&20&4\\2&4&4\end{pmatrix}.$$

Trace and norm. $\tr(A^tA)=1+20+4=25$, so $\lVert A\rVert=\sqrt{25}=5$.

Check. The sum of squares of all entries: $1+4+4+0+16+0=25$. It agrees with the trace.

m0105ступень 1step 1CM.6CM.4доска, фото 07board, photo 07
RU

Пусть $f:\R^2\to\R^3$, $f(x)=\big((x^1)^2x^2,\ x^1+x^2,\ (x^2)^2\big)^t$. Найдите сумму всех элементов матрицы $Df(x_0)$ в точке $x_0=(1,2)^t$.

EN

Let $f:\R^2\to\R^3$, $f(x)=\big((x^1)^2x^2,\ x^1+x^2,\ (x^2)^2\big)^t$. Find the sum of all entries of the matrix $Df(x_0)$ at the point $x_0=(1,2)^t$.

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

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

$Df(x_0)$ имеет размер $3\times2$: строка $i$ — частные производные компоненты $f^i$ по $x^1$ и $x^2$.

EN

$Df(x_0)$ has size $3\times2$: row $i$ holds the partial derivatives of the component $f^i$ with respect to $x^1$ and $x^2$.

РешениеSolution
RU

Матрица производной. Строки — компоненты, столбцы — переменные:

$$Df(x)=\begin{pmatrix}2x^1x^2&(x^1)^2\\1&1\\0&2x^2\end{pmatrix},\qquad Df(1,2)=\begin{pmatrix}4&1\\1&1\\0&4\end{pmatrix}.$$

Сумма элементов. $4+1+1+1+0+4=11$.

Проверка пределом. Сумма элементов равна сумме координат вектора $Df(x_0)\,(1,1)^t$, а это производная по направлению $u=(1,1)^t$. Считаем её по определению: $f(1+h,2+h)=\big((1+h)^2(2+h),\ 3+2h,\ (2+h)^2\big)^t$. Коэффициенты при $h$: в первой компоненте $(1+2h+h^2)(2+h)=2+5h+\dots$ даёт 5, во второй 2, в третьей $4+4h+h^2$ даёт 4. Сумма $5+2+4=11$.

EN

Derivative matrix. Rows are components, columns are variables:

$$Df(x)=\begin{pmatrix}2x^1x^2&(x^1)^2\\1&1\\0&2x^2\end{pmatrix},\qquad Df(1,2)=\begin{pmatrix}4&1\\1&1\\0&4\end{pmatrix}.$$

Sum of entries. $4+1+1+1+0+4=11$.

Check by the limit. The sum of the entries equals the sum of the coordinates of the vector $Df(x_0)\,(1,1)^t$, which is the directional derivative along $u=(1,1)^t$. Compute it from the definition: $f(1+h,2+h)=\big((1+h)^2(2+h),\ 3+2h,\ (2+h)^2\big)^t$. Coefficients of $h$: in the first component $(1+2h+h^2)(2+h)=2+5h+\dots$ gives 5, in the second 2, in the third $4+4h+h^2$ gives 4. The sum is $5+2+4=11$.

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

решено 0 из 70 of 7 solved

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

m0106ступень 2step 2CM.1лекция, 1:04:19lecture, 1:04:19
RU

Пусть $f(x)=x^3$, $x_0=2$ и $r(h)=f(x_0+h)-f(x_0)-f'(x_0)\,h$. Найдите $\lim_{h\to0}\frac{r(h)}{h^2}$.

EN

Let $f(x)=x^3$, $x_0=2$, and $r(h)=f(x_0+h)-f(x_0)-f'(x_0)\,h$. Find $\lim_{h\to0}\frac{r(h)}{h^2}$.

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

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

Раскрой $(2+h)^3$ по формуле куба суммы и вычти $f(2)$ и $f'(2)\,h$.

EN

Expand $(2+h)^3$ by the cube-of-a-sum formula and subtract $f(2)$ and $f'(2)\,h$.

РешениеSolution
RU

Раскрыть. $(2+h)^3=8+3\cdot4h+3\cdot2h^2+h^3=8+12h+6h^2+h^3$.

Остаток. $f(2)=8$ и $f'(x)=3x^2$, поэтому $f'(2)=12$ и

$$r(h)=8+12h+6h^2+h^3-8-12h=6h^2+h^3.$$

Предел. $\frac{r(h)}{h^2}=6+h\to6$.

Заодно $\frac{r(h)}{h}=6h+h^2\to0$, то есть $r(h)=o(h)$: так и должно быть по определению производной.

Проверка. По формуле Тейлора $r(h)\approx\frac{f''(2)}{2}h^2$, а $f''(x)=6x$, $\frac{f''(2)}{2}=\frac{12}{2}=6$.

EN

Expand. $(2+h)^3=8+3\cdot4h+3\cdot2h^2+h^3=8+12h+6h^2+h^3$.

Remainder. $f(2)=8$ and $f'(x)=3x^2$, so $f'(2)=12$ and

$$r(h)=8+12h+6h^2+h^3-8-12h=6h^2+h^3.$$

Limit. $\frac{r(h)}{h^2}=6+h\to6$.

Also $\frac{r(h)}{h}=6h+h^2\to0$, that is, $r(h)=o(h)$: this is what the definition of the derivative requires.

Check. By Taylor’s theorem $r(h)\approx\frac{f''(2)}{2}h^2$, and $f''(x)=6x$, $\frac{f''(2)}{2}=\frac{12}{2}=6$.

m0107ступень 2step 2минимумminimumCM.2лекция, 1:35:28lecture, 1:35:28
RU

Для $f(x)=e^{2x}$ выпишите многочлен Тейлора степени 3 в точке $a=0$, $P_3(b)=\sum_{k=0}^{3}\frac{f^{(k)}(0)}{k!}b^k$, и найдите $P_3(0.5)$. Ответ округлите до четырёх знаков после запятой.

EN

For $f(x)=e^{2x}$, write the Taylor polynomial of degree 3 at $a=0$, $P_3(b)=\sum_{k=0}^{3}\frac{f^{(k)}(0)}{k!}b^k$, and find $P_3(0.5)$. Round your answer to four decimal places.

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

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

Каждое дифференцирование $e^{2x}$ добавляет множитель 2: найди $f^{(k)}(x)$ и $f^{(k)}(0)$.

EN

Each differentiation of $e^{2x}$ adds a factor of 2: find $f^{(k)}(x)$ and $f^{(k)}(0)$.

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

$f^{(k)}(0)=2^k$, поэтому $P_3(b)=\sum_{k=0}^{3}\frac{(2b)^k}{k!}$. При $b=0.5$ получается $2b=1$.

EN

$f^{(k)}(0)=2^k$, so $P_3(b)=\sum_{k=0}^{3}\frac{(2b)^k}{k!}$. For $b=0.5$ you get $2b=1$.

РешениеSolution
RU

Производные. $f'(x)=2e^{2x}$, $f''(x)=4e^{2x}$, $f'''(x)=8e^{2x}$, в общем виде $f^{(k)}(x)=2^ke^{2x}$ и $f^{(k)}(0)=2^k$.

Многочлен. $P_3(b)=1+2b+\frac{4b^2}{2}+\frac{8b^3}{6}=\sum_{k=0}^{3}\frac{(2b)^k}{k!}$.

Значение. При $b=0.5$: $P_3(0.5)=1+1+\frac12+\frac16=\frac{8}{3}\approx2.6667$.

Проверка остатком. Точное значение $f(0.5)=e\approx2.7183$, ошибка $\approx0.0516$. По Лагранжу ошибка равна $\frac{f^{(4)}(\xi)}{4!}(0.5)^4=\frac{16e^{2\xi}}{24}\cdot\frac{1}{16}=\frac{e^{2\xi}}{24}$ при $\xi\in(0,0.5)$, то есть лежит между $\frac{1}{24}\approx0.0417$ и $\frac{e}{24}\approx0.1133$. Число $0.0516$ в этом промежутке.

EN

Derivatives. $f'(x)=2e^{2x}$, $f''(x)=4e^{2x}$, $f'''(x)=8e^{2x}$; in general $f^{(k)}(x)=2^ke^{2x}$ and $f^{(k)}(0)=2^k$.

Polynomial. $P_3(b)=1+2b+\frac{4b^2}{2}+\frac{8b^3}{6}=\sum_{k=0}^{3}\frac{(2b)^k}{k!}$.

Value. For $b=0.5$: $P_3(0.5)=1+1+\frac12+\frac16=\frac{8}{3}\approx2.6667$.

Check with the remainder. The exact value is $f(0.5)=e\approx2.7183$, the error is $\approx0.0516$. By Lagrange the error equals $\frac{f^{(4)}(\xi)}{4!}(0.5)^4=\frac{16e^{2\xi}}{24}\cdot\frac{1}{16}=\frac{e^{2\xi}}{24}$ with $\xi\in(0,0.5)$, so it lies between $\frac{1}{24}\approx0.0417$ and $\frac{e}{24}\approx0.1133$. The number $0.0516$ is in this range.

m0108ступень 2step 2обязательнаяrequiredCM.2доска, фото 01board, photo 01
RU

Для $f(x)=e^x$, $a=0$, $b=1$, $N=4$ формула Тейлора с остаточным членом Лагранжа утверждает, что $e-P_4(1)=\frac{e^{\theta}}{5!}$ для некоторого $\theta\in(0,1)$, где $P_4(1)=\sum_{k=0}^{4}\frac{1}{k!}$. Найдите $\theta$, используя $e\approx2.718281828$. Ответ округлите до четырёх знаков после запятой.

EN

For $f(x)=e^x$, $a=0$, $b=1$, $N=4$, Taylor’s theorem with the Lagrange remainder states that $e-P_4(1)=\frac{e^{\theta}}{5!}$ for some $\theta\in(0,1)$, where $P_4(1)=\sum_{k=0}^{4}\frac{1}{k!}$. Find $\theta$ using $e\approx2.718281828$. Round your answer to four decimal places.

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

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

Сначала посчитай $P_4(1)$ точной дробью, затем разность $e-P_4(1)$.

EN

First compute $P_4(1)$ as an exact fraction, then the difference $e-P_4(1)$.

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

Получится уравнение $e^{\theta}=120\,\big(e-P_4(1)\big)$; осталось взять натуральный логарифм.

EN

You get the equation $e^{\theta}=120\,\big(e-P_4(1)\big)$; it remains to take the natural logarithm.

РешениеSolution
RU

Многочлен. $P_4(1)=1+1+\frac12+\frac16+\frac1{24}=\frac{24+24+12+4+1}{24}=\frac{65}{24}\approx2.708333$.

Остаток. $e-P_4(1)\approx2.718282-2.708333=0.0099485$.

Уравнение на $\theta$. $\frac{e^{\theta}}{120}=0.0099485$, значит $e^{\theta}=120\cdot0.0099485\approx1.19382$ и

$$\theta=\ln1.19382\approx0.1772.$$

Проверка. $\theta$ лежит в $(0,1)$, как обещает теорема. Ещё одна проверка: при $\theta\in(0,1)$ остаток обязан лежать между $\frac{1}{120}\approx0.00833$ и $\frac{e}{120}\approx0.02265$, и $0.0099485$ туда попадает.

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

В финале m0117 точку $\theta$ никто не знает, и остаток оценивают сверху через $e^{\theta}<3$.

EN

Polynomial. $P_4(1)=1+1+\frac12+\frac16+\frac1{24}=\frac{24+24+12+4+1}{24}=\frac{65}{24}\approx2.708333$.

Remainder. $e-P_4(1)\approx2.718282-2.708333=0.0099485$.

Equation for $\theta$. $\frac{e^{\theta}}{120}=0.0099485$, so $e^{\theta}=120\cdot0.0099485\approx1.19382$ and

$$\theta=\ln1.19382\approx0.1772.$$

Check. $\theta$ lies in $(0,1)$, as the theorem promises. One more check: for $\theta\in(0,1)$ the remainder must lie between $\frac{1}{120}\approx0.00833$ and $\frac{e}{120}\approx0.02265$, and $0.0099485$ is in this range.

Where this leads

In the final m0117 nobody knows the point $\theta$, and the remainder is bounded from above through $e^{\theta}<3$.

m0109ступень 2step 2CM.5CM.4доска, фото 15board, photo 15
RU

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

EN

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

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

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

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

EN

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

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

Для проверки посчитай $\tr(AB)$ — след матрицы $2\times2$ — и сравни.

EN

To check, compute $\tr(AB)$ — the trace of a $2\times2$ matrix — and compare.

РешениеSolution
RU

Диагональ $BA$. $(BA)_{11}=1\cdot1+2\cdot0=1$, $(BA)_{22}=0\cdot0+1\cdot1=1$, $(BA)_{33}=3\cdot2+0\cdot1=6$.

След. $\tr(BA)=1+1+6=8$.

Проверка цикличностью. $AB\in M_{2\times2}$:

$$AB=\begin{pmatrix}1\cdot1+0\cdot0+2\cdot3&1\cdot2+0\cdot1+2\cdot0\\0\cdot1+1\cdot0+1\cdot3&0\cdot2+1\cdot1+1\cdot0\end{pmatrix}=\begin{pmatrix}7&2\\3&1\end{pmatrix},$$

$\tr(AB)=7+1=8$. Матрицы $AB$ и $BA$ разного размера, а следы совпали.

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

Перестановку $\tr(XY)=\tr(YX)$ для неквадратных множителей ты применишь в m0116 и m0120, чтобы вынести сдвиг $U$ вправо.

EN

Diagonal of $BA$. $(BA)_{11}=1\cdot1+2\cdot0=1$, $(BA)_{22}=0\cdot0+1\cdot1=1$, $(BA)_{33}=3\cdot2+0\cdot1=6$.

Trace. $\tr(BA)=1+1+6=8$.

Check by the cyclic property. $AB\in M_{2\times2}$:

$$AB=\begin{pmatrix}1\cdot1+0\cdot0+2\cdot3&1\cdot2+0\cdot1+2\cdot0\\0\cdot1+1\cdot0+1\cdot3&0\cdot2+1\cdot1+1\cdot0\end{pmatrix}=\begin{pmatrix}7&2\\3&1\end{pmatrix},$$

$\tr(AB)=7+1=8$. The matrices $AB$ and $BA$ have different sizes, yet the traces agree.

Where this leads

You will use the swap $\tr(XY)=\tr(YX)$ for non-square factors in m0116 and m0120 to move the shift $U$ to the right.

m0110ступень 2step 2минимумminimumCM.6доска, фото 08board, photo 08
RU

Пусть $f:\R^3\to\R$, $f(x)=x^1x^2+(x^3)^2$, $x_0=(1,2,1)^t$, $u=(1,-1,2)^t$. Найдите производную по направлению $Df(x_0)\,u$.

EN

Let $f:\R^3\to\R$, $f(x)=x^1x^2+(x^3)^2$, $x_0=(1,2,1)^t$, $u=(1,-1,2)^t$. Find the directional derivative $Df(x_0)\,u$.

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

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

$Df(x_0)$ — строка $1\times3$ из частных производных в точке $x_0$; умножь её на столбец $u$ справа.

EN

$Df(x_0)$ is a $1\times3$ row of partial derivatives at $x_0$; multiply it by the column $u$ on the right.

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

$Df(x)=(x^2,\ x^1,\ 2x^3)$.

EN

$Df(x)=(x^2,\ x^1,\ 2x^3)$.

РешениеSolution
RU

Матрица производной. $\frac{\partial f}{\partial x^1}=x^2$, $\frac{\partial f}{\partial x^2}=x^1$, $\frac{\partial f}{\partial x^3}=2x^3$, поэтому $Df(x_0)=(2,\ 1,\ 2)$ и $\nabla f(x_0)=(2,1,2)^t$.

Умножение на направление.

$$Df(x_0)\,u=(2,\ 1,\ 2)\begin{pmatrix}1\\-1\\2\end{pmatrix}=2-1+4=5.$$

Проверка пределом. $x_0+hu=(1+h,\ 2-h,\ 1+2h)^t$, и $f(x_0+hu)=(1+h)(2-h)+(1+2h)^2=(2+h-h^2)+(1+4h+4h^2)=3+5h+3h^2$. Так как $f(x_0)=3$, $\frac{f(x_0+hu)-f(x_0)}{h}=5+3h\to5$.

EN

Derivative matrix. $\frac{\partial f}{\partial x^1}=x^2$, $\frac{\partial f}{\partial x^2}=x^1$, $\frac{\partial f}{\partial x^3}=2x^3$, so $Df(x_0)=(2,\ 1,\ 2)$ and $\nabla f(x_0)=(2,1,2)^t$.

Multiply by the direction.

$$Df(x_0)\,u=(2,\ 1,\ 2)\begin{pmatrix}1\\-1\\2\end{pmatrix}=2-1+4=5.$$

Check by the limit. $x_0+hu=(1+h,\ 2-h,\ 1+2h)^t$, and $f(x_0+hu)=(1+h)(2-h)+(1+2h)^2=(2+h-h^2)+(1+4h+4h^2)=3+5h+3h^2$. Since $f(x_0)=3$, $\frac{f(x_0+hu)-f(x_0)}{h}=5+3h\to5$.

m0111ступень 2step 2CM.7доска, фото 10board, photo 10
RU

Пусть $y=f(u^1,u^2)=(u^1)^2u^2$, где $u^1=t^2$ и $u^2=3t-1$. По цепному правилу $\frac{dy}{dt}=\frac{\partial f}{\partial u^1}\frac{du^1}{dt}+\frac{\partial f}{\partial u^2}\frac{du^2}{dt}$ найдите $\frac{dy}{dt}$ при $t_0=1$.

EN

Let $y=f(u^1,u^2)=(u^1)^2u^2$, where $u^1=t^2$ and $u^2=3t-1$. Using the chain rule $\frac{dy}{dt}=\frac{\partial f}{\partial u^1}\frac{du^1}{dt}+\frac{\partial f}{\partial u^2}\frac{du^2}{dt}$, find $\frac{dy}{dt}$ at $t_0=1$.

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

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

Частные производные $f$ бери в точке $u_0=(u^1(1),u^2(1))=(1,2)$, а производные $u^j$ — в точке $t_0=1$.

EN

Take the partial derivatives of $f$ at the point $u_0=(u^1(1),u^2(1))=(1,2)$, and the derivatives of $u^j$ at $t_0=1$.

РешениеSolution
RU

Точка. $u_0=(1^2,\ 3\cdot1-1)=(1,2)$.

Множители. $\frac{\partial f}{\partial u^1}=2u^1u^2=4$, $\frac{\partial f}{\partial u^2}=(u^1)^2=1$ в точке $u_0$; $\frac{du^1}{dt}=2t=2$, $\frac{du^2}{dt}=3$ при $t_0=1$.

Сборка. $\frac{dy}{dt}=4\cdot2+1\cdot3=11$. В матричной записи это произведение строки $Df(u_0)=(4,\ 1)$ на столбец $(2,3)^t$.

Проверка. Подставим сразу: $y=t^4(3t-1)=3t^5-t^4$, $\frac{dy}{dt}=15t^4-4t^3$, при $t=1$ получаем $15-4=11$.

EN

Point. $u_0=(1^2,\ 3\cdot1-1)=(1,2)$.

Factors. $\frac{\partial f}{\partial u^1}=2u^1u^2=4$, $\frac{\partial f}{\partial u^2}=(u^1)^2=1$ at $u_0$; $\frac{du^1}{dt}=2t=2$, $\frac{du^2}{dt}=3$ at $t_0=1$.

Assemble. $\frac{dy}{dt}=4\cdot2+1\cdot3=11$. In matrix form this is the row $Df(u_0)=(4,\ 1)$ times the column $(2,3)^t$.

Check. Substitute directly: $y=t^4(3t-1)=3t^5-t^4$, $\frac{dy}{dt}=15t^4-4t^3$, and at $t=1$ we get $15-4=11$.

m0112ступень 2step 2минимумminimumCM.8доска, фото 13board, photo 13
RU

Пусть $A=\begin{pmatrix}1&1\\1&2\\1&3\end{pmatrix}\in M_{3\times2}$, $b=(1,2,2)^t$, $f(x)=\lVert b-Ax\rVert^2$ для $x\in\R^2$. Найдите вторую координату градиента $\nabla f(x_0)$ в точке $x_0=(0,1)^t$.

EN

Let $A=\begin{pmatrix}1&1\\1&2\\1&3\end{pmatrix}\in M_{3\times2}$, $b=(1,2,2)^t$, and $f(x)=\lVert b-Ax\rVert^2$ for $x\in\R^2$. Find the second coordinate of the gradient $\nabla f(x_0)$ at the point $x_0=(0,1)^t$.

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

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

Формула лектора: $\nabla f(x_0)=2A^t(Ax_0-b)$. Начни с остатка $Ax_0-b$ — столбца высоты 3.

EN

The lecturer’s formula: $\nabla f(x_0)=2A^t(Ax_0-b)$. Start with the residual $Ax_0-b$, a column of height 3.

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

$Ax_0-b=(0,0,1)^t$. Осталось умножить $A^t$ (размер $2\times3$) на этот столбец.

EN

$Ax_0-b=(0,0,1)^t$. It remains to multiply $A^t$ (size $2\times3$) by this column.

РешениеSolution
RU

Остаток. $Ax_0=(1\cdot0+1\cdot1,\ 1\cdot0+2\cdot1,\ 1\cdot0+3\cdot1)^t=(1,2,3)^t$, и $Ax_0-b=(0,0,1)^t$.

Градиент. $A^t=\begin{pmatrix}1&1&1\\1&2&3\end{pmatrix}$, поэтому

$$\nabla f(x_0)=2A^t\begin{pmatrix}0\\0\\1\end{pmatrix}=2\begin{pmatrix}1\\3\end{pmatrix}=\begin{pmatrix}2\\6\end{pmatrix}.$$

Вторая координата равна 6.

Проверка пределом. Вторая координата градиента — производная по направлению $e_2=(0,1)^t$. Имеем $b-A(x_0+he_2)=(1,2,2)^t-(1,2,3)^t-h(1,2,3)^t=(-h,\ -2h,\ -1-3h)^t$, поэтому $f(x_0+he_2)=h^2+4h^2+(1+3h)^2=1+6h+14h^2$ и $\frac{f(x_0+he_2)-f(x_0)}{h}=6+14h\to6$.

EN

Residual. $Ax_0=(1\cdot0+1\cdot1,\ 1\cdot0+2\cdot1,\ 1\cdot0+3\cdot1)^t=(1,2,3)^t$, and $Ax_0-b=(0,0,1)^t$.

Gradient. $A^t=\begin{pmatrix}1&1&1\\1&2&3\end{pmatrix}$, so

$$\nabla f(x_0)=2A^t\begin{pmatrix}0\\0\\1\end{pmatrix}=2\begin{pmatrix}1\\3\end{pmatrix}=\begin{pmatrix}2\\6\end{pmatrix}.$$

The second coordinate is 6.

Check by the limit. The second coordinate of the gradient is the directional derivative along $e_2=(0,1)^t$. We have $b-A(x_0+he_2)=(1,2,2)^t-(1,2,3)^t-h(1,2,3)^t=(-h,\ -2h,\ -1-3h)^t$, so $f(x_0+he_2)=h^2+4h^2+(1+3h)^2=1+6h+14h^2$ and $\frac{f(x_0+he_2)-f(x_0)}{h}=6+14h\to6$.

Ступень 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.

m0113ступень 3step 3CM.3CM.2по мотивам ДЗ HW-M01, п. 2based on homework HW-M01, item 2
RU

Докажите, что для любого $x\in\R$

$$e^{-x}=\sum_{k=0}^{\infty}\frac{(-1)^kx^k}{k!},$$

то есть что остаточный член формулы Тейлора функции $f(x)=e^{-x}$ в точке $a=0$ стремится к нулю при $N\to\infty$.

EN

Prove that for every $x\in\R$

$$e^{-x}=\sum_{k=0}^{\infty}\frac{(-1)^kx^k}{k!},$$

that is, that the remainder of Taylor’s formula for $f(x)=e^{-x}$ at $a=0$ goes to zero as $N\to\infty$.

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

Найди $f^{(k)}(x)$ и $f^{(k)}(0)$ и запиши формулу Тейлора с остаточным членом Лагранжа при $a=0$, $b=x$.

EN

Find $f^{(k)}(x)$ and $f^{(k)}(0)$ and write Taylor’s formula with the Lagrange remainder for $a=0$, $b=x$.

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

Оцени $\lvert f^{(N+1)}(\theta)\rvert=e^{-\theta}$ сверху числом, не зависящим от $N$, при $\theta$ между 0 и $x$. Затем покажи, что $\frac{c^n}{n!}\to0$ для $c=\lvert x\rvert$: сравни соседние члены.

EN

Bound $\lvert f^{(N+1)}(\theta)\rvert=e^{-\theta}$ from above by a number that does not depend on $N$, for $\theta$ between 0 and $x$. Then show that $\frac{c^n}{n!}\to0$ for $c=\lvert x\rvert$: compare neighboring terms.

РешениеSolution
RU

Производные. $f'(x)=-e^{-x}$, $f''(x)=e^{-x}$, и в общем виде $f^{(k)}(x)=(-1)^ke^{-x}$; значит $f^{(k)}(0)=(-1)^k$.

Формула Тейлора. При $x=0$ утверждение верно: обе части равны 1. Пусть $x\ne0$. По формуле с $a=0$, $b=x$ (при $x<0$ точка $\theta$ лежит между $x$ и 0) для каждого $N$ найдётся $\theta$ строго между 0 и $x$, такое что

$$e^{-x}=\sum_{k=0}^{N}\frac{(-1)^kx^k}{k!}+R_N,\qquad R_N=\frac{(-1)^{N+1}e^{-\theta}}{(N+1)!}x^{N+1}.$$

Оценка множителя. Так как $\lvert\theta\rvert<\lvert x\rvert$, имеем $-\theta<\lvert x\rvert$ и $e^{-\theta}<e^{\lvert x\rvert}$. Поэтому, обозначив $c=\lvert x\rvert$,

$$\lvert R_N\rvert\le e^{c}\,\frac{c^{N+1}}{(N+1)!}.$$

Множитель $e^c$ не зависит от $N$.

Почему $\frac{c^n}{n!}\to0$. Выберем целое $n_0\ge2c$. При $n\ge n_0$

$$\frac{c^{n+1}}{(n+1)!}=\frac{c^n}{n!}\cdot\frac{c}{n+1}\le\frac{c^n}{n!}\cdot\frac{c}{2c}=\frac12\cdot\frac{c^n}{n!},$$

потому что $n+1>n_0\ge2c$. Применяя это неравенство $n-n_0$ раз, получаем $\frac{c^n}{n!}\le\frac{c^{n_0}}{n_0!}\left(\frac12\right)^{n-n_0}\to0$ при $n\to\infty$.

Вывод. $\lvert R_N\rvert\le e^c\frac{c^{N+1}}{(N+1)!}\to0$, поэтому частичные суммы стремятся к $e^{-x}$, и ряд сходится к $e^{-x}$ при любом $x$. ∎

Проверка. При $x=1$, $N=3$: $1-1+\frac12-\frac16\approx0.3333$, а $e^{-1}\approx0.3679$; ошибка $0.0346$ не больше оценки $e\cdot\frac{1}{24}\approx0.1133$.

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

Та же схема — производные, остаток Лагранжа, оценка $f^{(N+1)}$ числом, $\frac{c^n}{n!}\to0$ — нужна в пункте 2 домашнего задания для $\sin x$ и $\cos x$.

EN

Derivatives. $f'(x)=-e^{-x}$, $f''(x)=e^{-x}$, and in general $f^{(k)}(x)=(-1)^ke^{-x}$; hence $f^{(k)}(0)=(-1)^k$.

Taylor’s formula. For $x=0$ the statement holds: both sides equal 1. Let $x\ne0$. By the formula with $a=0$, $b=x$ (for $x<0$ the point $\theta$ lies between $x$ and 0), for each $N$ there is $\theta$ strictly between 0 and $x$ such that

$$e^{-x}=\sum_{k=0}^{N}\frac{(-1)^kx^k}{k!}+R_N,\qquad R_N=\frac{(-1)^{N+1}e^{-\theta}}{(N+1)!}x^{N+1}.$$

Bound the factor. Since $\lvert\theta\rvert<\lvert x\rvert$, we have $-\theta<\lvert x\rvert$ and $e^{-\theta}<e^{\lvert x\rvert}$. So, writing $c=\lvert x\rvert$,

$$\lvert R_N\rvert\le e^{c}\,\frac{c^{N+1}}{(N+1)!}.$$

The factor $e^c$ does not depend on $N$.

Why $\frac{c^n}{n!}\to0$. Choose an integer $n_0\ge2c$. For $n\ge n_0$

$$\frac{c^{n+1}}{(n+1)!}=\frac{c^n}{n!}\cdot\frac{c}{n+1}\le\frac{c^n}{n!}\cdot\frac{c}{2c}=\frac12\cdot\frac{c^n}{n!},$$

because $n+1>n_0\ge2c$. Applying this inequality $n-n_0$ times, we get $\frac{c^n}{n!}\le\frac{c^{n_0}}{n_0!}\left(\frac12\right)^{n-n_0}\to0$ as $n\to\infty$.

Conclusion. $\lvert R_N\rvert\le e^c\frac{c^{N+1}}{(N+1)!}\to0$, so the partial sums tend to $e^{-x}$, and the series converges to $e^{-x}$ for every $x$. ∎

Check. For $x=1$, $N=3$: $1-1+\frac12-\frac16\approx0.3333$, while $e^{-1}\approx0.3679$; the error $0.0346$ is not larger than the bound $e\cdot\frac{1}{24}\approx0.1133$.

Where this leads

The same scheme — derivatives, the Lagrange remainder, a bound on $f^{(N+1)}$ by a number, $\frac{c^n}{n!}\to0$ — is needed in item 2 of the homework for $\sin x$ and $\cos x$.

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

m0114ступень 3step 3обязательнаяrequiredCM.7CM.6доска, фото 11board, photo 11
RU

Пусть $G:\R^2\to\R^2$, $G(x)=(x^1x^2,\ x^1+x^2)^t$, и $F:\R^2\to\R$, $F(u)=(u^1)^2+3u^2$. Найдите вторую координату градиента $\nabla(F\circ G)$ в точке $x_0=(1,2)^t$, вычислив $D(F\circ G)(x_0)=DF(G(x_0))\cdot DG(x_0)$.

EN

Let $G:\R^2\to\R^2$, $G(x)=(x^1x^2,\ x^1+x^2)^t$, and $F:\R^2\to\R$, $F(u)=(u^1)^2+3u^2$. Find the second coordinate of the gradient $\nabla(F\circ G)$ at the point $x_0=(1,2)^t$ by computing $D(F\circ G)(x_0)=DF(G(x_0))\cdot DG(x_0)$.

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

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

Размеры: $DF$ — строка $1\times2$, $DG$ — матрица $2\times2$. Внешнюю производную $DF$ бери в точке $u_0=G(x_0)$, а не в $x_0$.

EN

Sizes: $DF$ is a $1\times2$ row, $DG$ is a $2\times2$ matrix. Take the outer derivative $DF$ at the point $u_0=G(x_0)$, not at $x_0$.

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

$u_0=(2,3)^t$, $DF(u_0)=(4,\ 3)$, $DG(x_0)=\begin{pmatrix}2&1\\1&1\end{pmatrix}$.

EN

$u_0=(2,3)^t$, $DF(u_0)=(4,\ 3)$, $DG(x_0)=\begin{pmatrix}2&1\\1&1\end{pmatrix}$.

РешениеSolution
RU

Внутренняя функция. $u_0=G(1,2)=(1\cdot2,\ 1+2)^t=(2,3)^t$ и

$$DG(x)=\begin{pmatrix}x^2&x^1\\1&1\end{pmatrix},\qquad DG(x_0)=\begin{pmatrix}2&1\\1&1\end{pmatrix}.$$

Внешняя функция. $DF(u)=(2u^1,\ 3)$, поэтому $DF(u_0)=(4,\ 3)$.

Произведение. Размеры $1\times2$ и $2\times2$, результат $1\times2$:

$$D(F\circ G)(x_0)=(4,\ 3)\begin{pmatrix}2&1\\1&1\end{pmatrix}=(4\cdot2+3\cdot1,\ 4\cdot1+3\cdot1)=(11,\ 7).$$

Градиент — столбец $(11,7)^t$, вторая координата равна 7.

Проверка подстановкой. $F(G(x))=(x^1x^2)^2+3(x^1+x^2)$, и $\frac{\partial}{\partial x^2}=2(x^1)^2x^2+3=2\cdot1\cdot2+3=7$.

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

В финале m0118 то же произведение, только внутреннее отображение — слой $\R^2\to\R^3$, а внешнее даёт два числа.

EN

Inner function. $u_0=G(1,2)=(1\cdot2,\ 1+2)^t=(2,3)^t$ and

$$DG(x)=\begin{pmatrix}x^2&x^1\\1&1\end{pmatrix},\qquad DG(x_0)=\begin{pmatrix}2&1\\1&1\end{pmatrix}.$$

Outer function. $DF(u)=(2u^1,\ 3)$, so $DF(u_0)=(4,\ 3)$.

Product. Sizes $1\times2$ and $2\times2$, result $1\times2$:

$$D(F\circ G)(x_0)=(4,\ 3)\begin{pmatrix}2&1\\1&1\end{pmatrix}=(4\cdot2+3\cdot1,\ 4\cdot1+3\cdot1)=(11,\ 7).$$

The gradient is the column $(11,7)^t$; its second coordinate is 7.

Check by substitution. $F(G(x))=(x^1x^2)^2+3(x^1+x^2)$, and $\frac{\partial}{\partial x^2}=2(x^1)^2x^2+3=2\cdot1\cdot2+3=7$.

Where this leads

The final m0118 has the same product, only the inner map is a layer $\R^2\to\R^3$ and the outer one returns two numbers.

m0115ступень 3step 3обязательнаяrequiredCM.8CM.4доска, фото 12board, photo 12
RU

Пусть $S\in M_{N\times N}$ — произвольная (не обязательно симметричная) матрица и $f(x)=x^tSx$ для $x\in\R^N$. Докажите через предел $\lim_{h\to0}\frac{f(x_0+hu)-f(x_0)}{h}$, что $Df(x_0)=x_0^t(S+S^t)$ и $\nabla f(x_0)=(S+S^t)x_0$.

EN

Let $S\in M_{N\times N}$ be an arbitrary (not necessarily symmetric) matrix and $f(x)=x^tSx$ for $x\in\R^N$. Prove through the limit $\lim_{h\to0}\frac{f(x_0+hu)-f(x_0)}{h}$ that $Df(x_0)=x_0^t(S+S^t)$ and $\nabla f(x_0)=(S+S^t)x_0$.

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

Подставь $x_0+hu$ и раскрой $(x_0+hu)^tS(x_0+hu)$ на четыре слагаемых.

EN

Substitute $x_0+hu$ and expand $(x_0+hu)^tS(x_0+hu)$ into four terms.

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

Слагаемые $h\,u^tSx_0$ и $h\,x_0^tSu$ — числа. Транспонируй первое, чтобы $u$ встал справа.

EN

The terms $h\,u^tSx_0$ and $h\,x_0^tSu$ are numbers. Transpose the first one so that $u$ stands on the right.

РешениеSolution
RU

Раскрыть скобки. $(x_0+hu)^t=x_0^t+hu^t$, поэтому

$$f(x_0+hu)=(x_0^t+hu^t)S(x_0+hu)=x_0^tSx_0+h\,x_0^tSu+h\,u^tSx_0+h^2u^tSu.$$

Предел. $f(x_0)=x_0^tSx_0$ сокращается, деление на $h$ даёт

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

Свести числа. $u^tSx_0$ — матрица $1\times1$ (размеры $1\times N$, $N\times N$, $N\times1$), поэтому она равна своему транспонированию: $u^tSx_0=(u^tSx_0)^t=x_0^tS^t(u^t)^t=x_0^tS^tu$. Предел равен

$$x_0^tSu+x_0^tS^tu=x_0^t(S+S^t)\,u.$$

Прочитать матрицу. $f$ — многочлен от координат, поэтому $Df(x_0)$ существует, и по предложению о производной по направлению предел равен $Df(x_0)u$ для любого $u$. Значит $Df(x_0)=x_0^t(S+S^t)$ — строка $1\times N$, и

$$\nabla f(x_0)=Df(x_0)^t=(S+S^t)^tx_0=(S^t+S)x_0.\ ∎$$

Проверка. При $N=1$, $S=(s)$: $f(x)=sx^2$, $f'(x)=2sx=(s+s)x$. Для симметричной $S$ получается $2Sx_0$. И согласование с формулой лектора: $\lVert b-Ax\rVert^2=x^tA^tAx-2b^tAx+b^tb$, а для $S=A^tA$ имеем $S+S^t=2A^tA$, так что квадратичная часть даёт $2A^tAx_0$ — ровно первое слагаемое в $2A^t(Ax_0-b)$.

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

Это схема эталонной задачи на новой функции. В мини-тесте m0119 её результат $2A^t(Ax-b)$ используется для шага градиентного спуска.

EN

Expand. $(x_0+hu)^t=x_0^t+hu^t$, so

$$f(x_0+hu)=(x_0^t+hu^t)S(x_0+hu)=x_0^tSx_0+h\,x_0^tSu+h\,u^tSx_0+h^2u^tSu.$$

Limit. $f(x_0)=x_0^tSx_0$ cancels, and division by $h$ gives

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

Merge the numbers. $u^tSx_0$ is a $1\times1$ matrix (sizes $1\times N$, $N\times N$, $N\times1$), so it equals its own transpose: $u^tSx_0=(u^tSx_0)^t=x_0^tS^t(u^t)^t=x_0^tS^tu$. The limit equals

$$x_0^tSu+x_0^tS^tu=x_0^t(S+S^t)\,u.$$

Read off the matrix. $f$ is a polynomial in the coordinates, so $Df(x_0)$ exists, and by the proposition on the directional derivative the limit equals $Df(x_0)u$ for every $u$. Hence $Df(x_0)=x_0^t(S+S^t)$, a $1\times N$ row, and

$$\nabla f(x_0)=Df(x_0)^t=(S+S^t)^tx_0=(S^t+S)x_0.\ ∎$$

Check. For $N=1$, $S=(s)$: $f(x)=sx^2$, $f'(x)=2sx=(s+s)x$. For a symmetric $S$ we get $2Sx_0$. And agreement with the lecturer’s formula: $\lVert b-Ax\rVert^2=x^tA^tAx-2b^tAx+b^tb$, and for $S=A^tA$ we have $S+S^t=2A^tA$, so the quadratic part gives $2A^tAx_0$ — exactly the first term of $2A^t(Ax_0-b)$.

Where this leads

This is the model problem’s scheme on a new function. In the mini-test m0119 its result $2A^t(Ax-b)$ is used for a gradient descent step.

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

m0116ступень 3step 3обязательнаяrequiredCM.8CM.5доска, фото 15board, photo 15
RU

Пусть $X\in M_{2\times3}$, $a=(1,-1)^t\in\R^2$, $b=(2,0,1)^t\in\R^3$, $C=\begin{pmatrix}0&1\\2&0\\1&1\end{pmatrix}\in M_{3\times2}$ и $f(X)=a^tXb+\tr(CX)$. В соглашении лектора $Df(X_0)\in M_{3\times2}$ и $Df(X_0)\cdot U=\tr\big(Df(X_0)\,U\big)$ для $U\in M_{2\times3}$. Найдите элемент матрицы $Df(X_0)$ в строке 1, столбце 2 (он не зависит от $X_0$).

EN

Let $X\in M_{2\times3}$, $a=(1,-1)^t\in\R^2$, $b=(2,0,1)^t\in\R^3$, $C=\begin{pmatrix}0&1\\2&0\\1&1\end{pmatrix}\in M_{3\times2}$, and $f(X)=a^tXb+\tr(CX)$. In the lecturer’s convention $Df(X_0)\in M_{3\times2}$ and $Df(X_0)\cdot U=\tr\big(Df(X_0)\,U\big)$ for $U\in M_{2\times3}$. Find the entry of the matrix $Df(X_0)$ in row 1, column 2 (it does not depend on $X_0$).

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

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

Оба слагаемых линейны по $X$, поэтому предел $\frac{f(X_0+hU)-f(X_0)}{h}$ равен $a^tUb+\tr(CU)$.

EN

Both terms are linear in $X$, so the limit $\frac{f(X_0+hU)-f(X_0)}{h}$ equals $a^tUb+\tr(CU)$.

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

Запиши $a^tUb$ как $\tr(ba^tU)$ по цикличности следа. Тогда $Df(X_0)=ba^t+C$.

EN

Write $a^tUb$ as $\tr(ba^tU)$ by the cyclic property of the trace. Then $Df(X_0)=ba^t+C$.

РешениеSolution
RU

Предел. $f(X_0+hU)-f(X_0)=h\,a^tUb+h\,\tr(CU)$ по линейности умножения и следа, поэтому предел равен $a^tUb+\tr(CU)$.

Вынести $U$ вправо. $a^tUb$ — число, оно равно своему следу. По цикличности для множителей $a^tU$ (размер $1\times3$) и $b$ (размер $3\times1$): $a^tUb=\tr\big((a^tU)\,b\big)=\tr\big(b\,(a^tU)\big)=\tr\big((ba^t)\,U\big)$. Значит

$$a^tUb+\tr(CU)=\tr\big((ba^t+C)\,U\big),\qquad Df(X_0)=ba^t+C\in M_{3\times2}.$$

Посчитать.

$$ba^t=\begin{pmatrix}2\\0\\1\end{pmatrix}(1\ \ -1)=\begin{pmatrix}2&-2\\0&0\\1&-1\end{pmatrix},\qquad Df(X_0)=\begin{pmatrix}2&-1\\2&0\\2&0\end{pmatrix}.$$

Элемент в строке 1, столбце 2 равен $-2+1=-1$.

Проверка одним сдвигом. Пусть $U=E_{21}$ — матрица $2\times3$ с единицей в строке 2, столбце 1 и нулями в остальных местах. Тогда $a^tE_{21}b=a^2b^1=-1\cdot2=-2$. У матрицы $CE_{21}$ ненулевой только первый столбец, равный второму столбцу $C$, поэтому $\tr(CE_{21})=C_{12}=1$. Сумма $-2+1=-1$. С другой стороны, $\tr(Df(X_0)E_{21})$ равен элементу $Df(X_0)$ в строке 1, столбце 2. Сошлось.

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

В финале m0120 функция нелинейна, но после предела получается ровно такая же задача: число с $U$ в середине.

EN

Limit. $f(X_0+hU)-f(X_0)=h\,a^tUb+h\,\tr(CU)$ by linearity of multiplication and of the trace, so the limit equals $a^tUb+\tr(CU)$.

Move $U$ to the right. $a^tUb$ is a number, and it equals its own trace. By the cyclic property for the factors $a^tU$ (size $1\times3$) and $b$ (size $3\times1$): $a^tUb=\tr\big((a^tU)\,b\big)=\tr\big(b\,(a^tU)\big)=\tr\big((ba^t)\,U\big)$. Hence

$$a^tUb+\tr(CU)=\tr\big((ba^t+C)\,U\big),\qquad Df(X_0)=ba^t+C\in M_{3\times2}.$$

Compute.

$$ba^t=\begin{pmatrix}2\\0\\1\end{pmatrix}(1\ \ -1)=\begin{pmatrix}2&-2\\0&0\\1&-1\end{pmatrix},\qquad Df(X_0)=\begin{pmatrix}2&-1\\2&0\\2&0\end{pmatrix}.$$

The entry in row 1, column 2 equals $-2+1=-1$.

Check with one shift. Let $U=E_{21}$ be the $2\times3$ matrix with a one in row 2, column 1 and zeros elsewhere. Then $a^tE_{21}b=a^2b^1=-1\cdot2=-2$. In the matrix $CE_{21}$ only the first column is nonzero, and it equals the second column of $C$, so $\tr(CE_{21})=C_{12}=1$. The sum is $-2+1=-1$. On the other hand, $\tr(Df(X_0)E_{21})$ equals the entry of $Df(X_0)$ in row 1, column 2. They agree.

Where this leads

In the final m0120 the function is not linear, but after the limit you get exactly the same task: a number with $U$ in the middle.

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

решено 0 из 30 of 3 solved

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

m0117ступень 4step 4минимумminimumCM.2CM.3лекция, 1:39:20lecture, 1:39:20
RU

Число $e$ приближают многочленом Тейлора $P_N(1)=\sum_{k=0}^{N}\frac{1}{k!}$ функции $e^x$ в точке $a=0$. Остаточный член Лагранжа равен $\frac{e^{\theta}}{(N+1)!}$ при $\theta\in(0,1)$; используя $e^{\theta}<3$, получаем гарантированную оценку ошибки $\frac{3}{(N+1)!}$. Найдите наименьшее $N$, при котором эта оценка меньше $10^{-4}$.

EN

The number $e$ is approximated by the Taylor polynomial $P_N(1)=\sum_{k=0}^{N}\frac{1}{k!}$ of $e^x$ at $a=0$. The Lagrange remainder equals $\frac{e^{\theta}}{(N+1)!}$ with $\theta\in(0,1)$; using $e^{\theta}<3$, we get the guaranteed error bound $\frac{3}{(N+1)!}$. Find the smallest $N$ for which this bound is less than $10^{-4}$.

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

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

Условие $\frac{3}{(N+1)!}<10^{-4}$ равносильно $(N+1)!>30000$.

EN

The condition $\frac{3}{(N+1)!}<10^{-4}$ is equivalent to $(N+1)!>30000$.

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

Выпиши факториалы подряд: $5!=120$, $6!=720$, … и найди первый, превосходящий 30000.

EN

Write the factorials in a row: $5!=120$, $6!=720$, … and find the first one that exceeds 30000.

РешениеSolution
RU

Неравенство. $\frac{3}{(N+1)!}<10^{-4}$ равносильно $(N+1)!>3\cdot10^4=30000$.

Перебор факториалов. $6!=720$, $7!=5040$, $8!=40320$. Первый факториал больше 30000 — это $8!$, поэтому $N+1=8$ и $N=7$. При $N=6$ оценка $\frac{3}{5040}\approx0.000595$ ещё больше $10^{-4}$, при $N=7$ оценка $\frac{3}{40320}\approx0.0000744$ уже меньше.

Проверка фактической ошибкой. $P_7(1)=1+1+\frac12+\frac16+\frac1{24}+\frac1{120}+\frac1{720}+\frac1{5040}=\frac{13700}{5040}\approx2.7182540$, и $e-P_7(1)\approx0.0000279<10^{-4}$. Для $N=6$: $P_6(1)=\frac{1957}{720}\approx2.7180556$, ошибка $\approx0.000226$ — больше $10^{-4}$. Здесь оценка не завысила ответ: фактически тоже нужно $N=7$.

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

Так выбирают число слагаемых в любой вычислительной процедуре: по гарантированной оценке, а не по надежде.

EN

Inequality. $\frac{3}{(N+1)!}<10^{-4}$ is equivalent to $(N+1)!>3\cdot10^4=30000$.

Go through the factorials. $6!=720$, $7!=5040$, $8!=40320$. The first factorial above 30000 is $8!$, so $N+1=8$ and $N=7$. For $N=6$ the bound $\frac{3}{5040}\approx0.000595$ is still larger than $10^{-4}$; for $N=7$ the bound $\frac{3}{40320}\approx0.0000744$ is already smaller.

Check with the actual error. $P_7(1)=1+1+\frac12+\frac16+\frac1{24}+\frac1{120}+\frac1{720}+\frac1{5040}=\frac{13700}{5040}\approx2.7182540$, and $e-P_7(1)\approx0.0000279<10^{-4}$. For $N=6$: $P_6(1)=\frac{1957}{720}\approx2.7180556$, with error $\approx0.000226$ — larger than $10^{-4}$. Here the bound did not inflate the answer: in fact $N=7$ is needed as well.

Where this leads

This is how the number of terms is chosen in any numerical procedure: by a guaranteed bound, not by hope.

m0118ступень 4step 4минимумminimumCM.7CM.6доска, фото 11board, photo 11
RU

Крошечная сеть из двух слоёв: $z=G(x)=Wx$ с $W=\begin{pmatrix}1&0\\1&1\\0&2\end{pmatrix}\in M_{3\times2}$, затем $y=F(z)=\big((z^1)^2+z^2z^3,\ z^1-z^3\big)^t$, $F:\R^3\to\R^2$. Найдите элемент матрицы $D(F\circ G)(x_0)$ в строке 1, столбце 2 в точке $x_0=(1,1)^t$.

EN

A tiny two-layer network: $z=G(x)=Wx$ with $W=\begin{pmatrix}1&0\\1&1\\0&2\end{pmatrix}\in M_{3\times2}$, then $y=F(z)=\big((z^1)^2+z^2z^3,\ z^1-z^3\big)^t$, $F:\R^3\to\R^2$. Find the entry of the matrix $D(F\circ G)(x_0)$ in row 1, column 2 at the point $x_0=(1,1)^t$.

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

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

Производная линейного отображения $G(x)=Wx$ — сама матрица $W$. Размеры произведения $DF\cdot DG$: $2\times3$ на $3\times2$.

EN

The derivative of the linear map $G(x)=Wx$ is the matrix $W$ itself. Sizes of the product $DF\cdot DG$: $2\times3$ times $3\times2$.

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

$z_0=Wx_0=(1,2,2)^t$ и $DF(z)=\begin{pmatrix}2z^1&z^3&z^2\\1&0&-1\end{pmatrix}$.

EN

$z_0=Wx_0=(1,2,2)^t$ and $DF(z)=\begin{pmatrix}2z^1&z^3&z^2\\1&0&-1\end{pmatrix}$.

РешениеSolution
RU

Внутренний слой. $G(x_0+u)-G(x_0)=Wu$ точно, без остатка, поэтому $DG(x_0)=W$. Точка $z_0=Wx_0=(1\cdot1+0\cdot1,\ 1\cdot1+1\cdot1,\ 0\cdot1+2\cdot1)^t=(1,2,2)^t$.

Внешний слой. Строки — компоненты $F$, столбцы — переменные $z^1,z^2,z^3$:

$$DF(z)=\begin{pmatrix}2z^1&z^3&z^2\\1&0&-1\end{pmatrix},\qquad DF(z_0)=\begin{pmatrix}2&2&2\\1&0&-1\end{pmatrix}.$$

Произведение. $D(F\circ G)(x_0)=DF(z_0)\,W$, размеры $2\times3$ и $3\times2$, результат $2\times2$:

$$\begin{pmatrix}2&2&2\\1&0&-1\end{pmatrix}\begin{pmatrix}1&0\\1&1\\0&2\end{pmatrix}=\begin{pmatrix}2+2+0&0+2+4\\1+0+0&0+0-2\end{pmatrix}=\begin{pmatrix}4&6\\1&-2\end{pmatrix}.$$

Элемент в строке 1, столбце 2 равен 6.

Проверка подстановкой. $z=(x^1,\ x^1+x^2,\ 2x^2)^t$, поэтому $y^1=(x^1)^2+(x^1+x^2)\cdot2x^2=(x^1)^2+2x^1x^2+2(x^2)^2$ и $\frac{\partial y^1}{\partial x^2}=2x^1+4x^2=2+4=6$.

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

Обратное распространение ошибки делает ровно это для слоёв с миллионами весов: перемножает матрицы Якоби слоёв.

EN

Inner layer. $G(x_0+u)-G(x_0)=Wu$ exactly, with no remainder, so $DG(x_0)=W$. The point is $z_0=Wx_0=(1\cdot1+0\cdot1,\ 1\cdot1+1\cdot1,\ 0\cdot1+2\cdot1)^t=(1,2,2)^t$.

Outer layer. Rows are the components of $F$, columns are the variables $z^1,z^2,z^3$:

$$DF(z)=\begin{pmatrix}2z^1&z^3&z^2\\1&0&-1\end{pmatrix},\qquad DF(z_0)=\begin{pmatrix}2&2&2\\1&0&-1\end{pmatrix}.$$

Product. $D(F\circ G)(x_0)=DF(z_0)\,W$, sizes $2\times3$ and $3\times2$, result $2\times2$:

$$\begin{pmatrix}2&2&2\\1&0&-1\end{pmatrix}\begin{pmatrix}1&0\\1&1\\0&2\end{pmatrix}=\begin{pmatrix}2+2+0&0+2+4\\1+0+0&0+0-2\end{pmatrix}=\begin{pmatrix}4&6\\1&-2\end{pmatrix}.$$

The entry in row 1, column 2 is 6.

Check by substitution. $z=(x^1,\ x^1+x^2,\ 2x^2)^t$, so $y^1=(x^1)^2+(x^1+x^2)\cdot2x^2=(x^1)^2+2x^1x^2+2(x^2)^2$ and $\frac{\partial y^1}{\partial x^2}=2x^1+4x^2=2+4=6$.

Where this leads

Backpropagation does exactly this for layers with millions of weights: it multiplies the Jacobian matrices of the layers.

m0120ступень 4step 4минимумminimumCM.8CM.5доска, фото 14board, photo 14
RU

Пусть $X\in M_{2\times3}$, $a=(1,2,-1)^t\in\R^3$ и $f(X)=\lVert Xa\rVert^2$. В соглашении лектора $Df(X_0)\in M_{3\times2}$ и $Df(X_0)\cdot U=\tr\big(Df(X_0)\,U\big)$ для $U\in M_{2\times3}$. Для $X_0=\begin{pmatrix}1&0&2\\0&1&1\end{pmatrix}$ найдите элемент матрицы $Df(X_0)$ в строке 2, столбце 1.

EN

Let $X\in M_{2\times3}$, $a=(1,2,-1)^t\in\R^3$, and $f(X)=\lVert Xa\rVert^2$. In the lecturer’s convention $Df(X_0)\in M_{3\times2}$ and $Df(X_0)\cdot U=\tr\big(Df(X_0)\,U\big)$ for $U\in M_{2\times3}$. For $X_0=\begin{pmatrix}1&0&2\\0&1&1\end{pmatrix}$ find the entry of the matrix $Df(X_0)$ in row 2, column 1.

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

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

Перепиши квадрат длины как $(Xa)^t(Xa)$, подставь $X_0+hU$ и раскрой скобки, как в эталонной задаче.

EN

Rewrite the squared length as $(Xa)^t(Xa)$, substitute $X_0+hU$, and expand, as in the model problem.

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

После предела и сведения одинаковых чисел получится $2(X_0a)^tUa$. Запиши это число как след и переставь множители так, чтобы $U$ встала справа.

EN

After the limit and merging equal numbers you get $2(X_0a)^tUa$. Write this number as a trace and reorder the factors so that $U$ stands on the right.

РешениеSolution
RU

Раскрыть скобки. $(X_0+hU)a=X_0a+hUa$, поэтому

$$f(X_0+hU)=(X_0a)^t(X_0a)+h(Ua)^t(X_0a)+h(X_0a)^t(Ua)+h^2(Ua)^t(Ua).$$

Предел. $\frac{f(X_0+hU)-f(X_0)}{h}\to(Ua)^t(X_0a)+(X_0a)^t(Ua)$. Оба слагаемых — числа, и первое равно своему транспонированию $(X_0a)^tUa$. Предел равен $2(X_0a)^tUa$.

След и цикличность. Множители: $(X_0a)^tU$ размера $1\times3$ и $a$ размера $3\times1$. Поэтому

$$2(X_0a)^tUa=\tr\big(2(X_0a)^tU\,a\big)=\tr\big(2a\,(X_0a)^tU\big),\qquad Df(X_0)=2a\,(X_0a)^t\in M_{3\times2}.$$

Посчитать. $X_0a=(1\cdot1+0\cdot2+2\cdot(-1),\ 0\cdot1+1\cdot2+1\cdot(-1))^t=(-1,1)^t$, и

$$Df(X_0)=2\begin{pmatrix}1\\2\\-1\end{pmatrix}(-1\ \ 1)=\begin{pmatrix}-2&2\\-4&4\\2&-2\end{pmatrix}.$$

Элемент в строке 2, столбце 1 равен $-4$.

Проверка одним сдвигом. $U=E_{12}$ — матрица $2\times3$ с единицей в строке 1, столбце 2. Тогда $E_{12}a=(a^2,0)^t=(2,0)^t$ и $f(X_0+hE_{12})=\lVert(-1+2h,\ 1)^t\rVert^2=(-1+2h)^2+1$. Производная по $h$ в нуле: $2\cdot(-1)\cdot2=-4$. А $\tr(Df(X_0)E_{12})$ — это элемент $Df(X_0)$ в строке 2, столбце 1. Сошлось.

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

Градиент той же формы, что $X$, — транспонирование $2(X_0a)a^t$. Именно его хранит библиотека ML для матрицы весов слоя.

EN

Expand. $(X_0+hU)a=X_0a+hUa$, so

$$f(X_0+hU)=(X_0a)^t(X_0a)+h(Ua)^t(X_0a)+h(X_0a)^t(Ua)+h^2(Ua)^t(Ua).$$

Limit. $\frac{f(X_0+hU)-f(X_0)}{h}\to(Ua)^t(X_0a)+(X_0a)^t(Ua)$. Both terms are numbers, and the first equals its own transpose $(X_0a)^tUa$. The limit equals $2(X_0a)^tUa$.

Trace and cyclic property. The factors are $(X_0a)^tU$ of size $1\times3$ and $a$ of size $3\times1$. Hence

$$2(X_0a)^tUa=\tr\big(2(X_0a)^tU\,a\big)=\tr\big(2a\,(X_0a)^tU\big),\qquad Df(X_0)=2a\,(X_0a)^t\in M_{3\times2}.$$

Compute. $X_0a=(1\cdot1+0\cdot2+2\cdot(-1),\ 0\cdot1+1\cdot2+1\cdot(-1))^t=(-1,1)^t$, and

$$Df(X_0)=2\begin{pmatrix}1\\2\\-1\end{pmatrix}(-1\ \ 1)=\begin{pmatrix}-2&2\\-4&4\\2&-2\end{pmatrix}.$$

The entry in row 2, column 1 equals $-4$.

Check with one shift. $U=E_{12}$ is the $2\times3$ matrix with a one in row 1, column 2. Then $E_{12}a=(a^2,0)^t=(2,0)^t$ and $f(X_0+hE_{12})=\lVert(-1+2h,\ 1)^t\rVert^2=(-1+2h)^2+1$. The derivative in $h$ at zero is $2\cdot(-1)\cdot2=-4$. And $\tr(Df(X_0)E_{12})$ is the entry of $Df(X_0)$ in row 2, column 1. They agree.

Where this leads

The gradient of the same shape as $X$ is the transpose $2(X_0a)a^t$. This is what an ML library stores for a layer’s weight matrix.

Мини-тест под таймером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.

m0119ступень 4step 4минимумminimumCM.8CM.6авторскаяoriginal
RU

Линейная регрессия: функция потерь $L(w)=\lVert y-Aw\rVert^2$ с $A=\begin{pmatrix}1&0\\1&1\\1&2\end{pmatrix}\in M_{3\times2}$ и $y=(1,2,4)^t$. Из точки $w_0=(0,0)^t$ сделан один шаг градиентного спуска $w_1=w_0-\eta\nabla L(w_0)$ с $\eta=0.05$. Найдите $L(w_1)$. Ответ округлите до четырёх знаков после запятой.

EN

Linear regression: the loss $L(w)=\lVert y-Aw\rVert^2$ with $A=\begin{pmatrix}1&0\\1&1\\1&2\end{pmatrix}\in M_{3\times2}$ and $y=(1,2,4)^t$. From the point $w_0=(0,0)^t$ one gradient descent step $w_1=w_0-\eta\nabla L(w_0)$ is taken with $\eta=0.05$. Find $L(w_1)$. Round your answer to four decimal places.

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

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

Градиент потерь наименьших квадратов: $\nabla L(w)=2A^t(Aw-y)$.

EN

The gradient of the least-squares loss: $\nabla L(w)=2A^t(Aw-y)$.

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

При $w_0=0$ получается $\nabla L(w_0)=-2A^ty$. Посчитай столбец $A^ty$ высоты 2.

EN

At $w_0=0$ you get $\nabla L(w_0)=-2A^ty$. Compute the column $A^ty$ of height 2.

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

$A^ty=(7,10)^t$. Найди $w_1$, затем остаток $y-Aw_1$ и сумму квадратов его координат.

EN

$A^ty=(7,10)^t$. Find $w_1$, then the residual $y-Aw_1$ and the sum of squares of its coordinates.

РешениеSolution
RU

Градиент. $A^ty=(1+2+4,\ 0+2+8)^t=(7,10)^t$, поэтому $\nabla L(w_0)=2A^t(0-y)=-2(7,10)^t=(-14,-20)^t$.

Шаг. $w_1=(0,0)^t-0.05\cdot(-14,-20)^t=(0.7,\ 1.0)^t$.

Новая потеря. $Aw_1=(0.7,\ 0.7+1.0,\ 0.7+2.0)^t=(0.7,1.7,2.7)^t$, остаток $y-Aw_1=(0.3,0.3,1.3)^t$, и

$$L(w_1)=0.09+0.09+1.69=1.87=1.8700.$$

Потеря упала с $L(w_0)=1+4+16=21$.

Проверка разложением. $L$ — квадратичная функция, поэтому для сдвига $d=w_1-w_0$ равенство $L(w_0+d)=L(w_0)+\nabla L(w_0)^td+\lVert Ad\rVert^2$ точное. Здесь $\nabla L(w_0)^td=-14\cdot0.7-20\cdot1.0=-29.8$ и $\lVert Ad\rVert^2=0.49+2.89+7.29=10.67$, так что $L(w_1)=21-29.8+10.67=1.87$.

Что видно из проверки

Одна линейная часть предсказала бы $21-29.8=-8.8$ — отрицательную потерю, что невозможно. Квадратичное слагаемое $10.67$ здесь велико: шаг $\eta=0.05$ уже не «маленький». Тот же расчёт для любого шага даёт $L(w_0-\eta\nabla L(w_0))=21-596\eta+4268\eta^2$: линейная часть растёт как $\eta$, квадратичная — как $\eta^2$, и при $\eta>596/4268\approx0.14$ потеря после шага больше исходной $21$.

EN

Gradient. $A^ty=(1+2+4,\ 0+2+8)^t=(7,10)^t$, so $\nabla L(w_0)=2A^t(0-y)=-2(7,10)^t=(-14,-20)^t$.

Step. $w_1=(0,0)^t-0.05\cdot(-14,-20)^t=(0.7,\ 1.0)^t$.

New loss. $Aw_1=(0.7,\ 0.7+1.0,\ 0.7+2.0)^t=(0.7,1.7,2.7)^t$, the residual is $y-Aw_1=(0.3,0.3,1.3)^t$, and

$$L(w_1)=0.09+0.09+1.69=1.87=1.8700.$$

The loss dropped from $L(w_0)=1+4+16=21$.

Check by expansion. $L$ is a quadratic function, so for the shift $d=w_1-w_0$ the equality $L(w_0+d)=L(w_0)+\nabla L(w_0)^td+\lVert Ad\rVert^2$ is exact. Here $\nabla L(w_0)^td=-14\cdot0.7-20\cdot1.0=-29.8$ and $\lVert Ad\rVert^2=0.49+2.89+7.29=10.67$, so $L(w_1)=21-29.8+10.67=1.87$.

What the check shows

The linear part alone would predict $21-29.8=-8.8$ — a negative loss, which is impossible. The quadratic term $10.67$ is large here: the step $\eta=0.05$ is no longer “small”. The same computation for any step gives $L(w_0-\eta\nabla L(w_0))=21-596\eta+4268\eta^2$: the linear part grows like $\eta$, the quadratic part like $\eta^2$, and for $\eta>596/4268\approx0.14$ the loss after the step is larger than the initial $21$.

Домашнее задание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

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

Домашнее задание лекции. Решений здесь нет: его проверяет тьютор. Ниже — формулировки, задачи урока, которые готовят к каждому пункту, и подсказка к первому ходу.

  1. Телескопическая производная. Самостоятельно проделай вычисление $\varphi'(x)$ из шага 2 доказательства формулы Тейлора. Готовит m0103. Подсказка: продифференцируй одно слагаемое $\frac{f^{(k)}(x)}{k!}(b-x)^k$ по правилу произведения, выпиши сумму при $N=3$ полностью и только потом переходи к общему $N$.
  2. Ряды Тейлора для $\sin x$ и $\cos x$, с доказательством, что остаток стремится к нулю. Готовят m0107, m0113, m0117. Подсказка: выпиши производные $\sin x$ до четвёртой и найди, через сколько шагов они повторяются.
  3. Упражнения с доски 1–5: $\lVert x+y\rVert\le\lVert x\rVert+\lVert y\rVert$; $\lVert Ax\rVert\le\lVert A\rVert\,\lVert x\rVert$ для $A\in M_{N\times N}$; $\lVert A\rVert=\sqrt{\sum_{j}\lVert\alpha_j\rVert^2}$ для столбцов $\alpha_j$ матрицы $A$; $\lVert A+B\rVert\le\lVert A\rVert+\lVert B\rVert$ и $\lVert AB\rVert\le\lVert A\rVert\,\lVert B\rVert$; $\tr(A^tA)=\sum a_{ij}^2$. Готовит m0104. Подсказка: начни с упражнения 3, оно прямо следует из определения; для 2 каждая координата $Ax$ — строка $A$, умноженная на $x$, и к ней применяется Коши — Буняковский.
  4. Цикличность следа $\tr(AB)=\tr(BA)$ для $A\in M_{n\times m}$, $B\in M_{m\times n}$. Готовит m0109. Подсказка: запиши диагональный элемент $(AB)_{ii}$ как сумму по внутреннему индексу.
  5. Градиент наименьших квадратов по координатам: получи $\nabla\lVert b-Ax\rVert^2$ через частные производные и сверь с $2A^t(Ax-b)$. Готовят m0112, m0115. Подсказка: запиши $f(x)=\sum_{i=1}^{D}\big(b^i-\sum_{j=1}^{N}a_{ij}x^j\big)^2$.
EN

The lecture’s homework. There are no solutions here: the tutor checks it. Below are the statements, the lesson problems that prepare each item, and a hint for the first move.

  1. Telescoping derivative. Redo on your own the computation of $\varphi'(x)$ from step 2 of the proof of Taylor’s theorem. Prepared by m0103. Hint: differentiate one term $\frac{f^{(k)}(x)}{k!}(b-x)^k$ by the product rule, write out the sum for $N=3$ in full, and only then move to a general $N$.
  2. Taylor series of $\sin x$ and $\cos x$, with a proof that the remainder goes to zero. Prepared by m0107, m0113, m0117. Hint: write the derivatives of $\sin x$ up to the fourth and find after how many steps they repeat.
  3. Board exercises 1–5: $\lVert x+y\rVert\le\lVert x\rVert+\lVert y\rVert$; $\lVert Ax\rVert\le\lVert A\rVert\,\lVert x\rVert$ for $A\in M_{N\times N}$; $\lVert A\rVert=\sqrt{\sum_{j}\lVert\alpha_j\rVert^2}$ for the columns $\alpha_j$ of $A$; $\lVert A+B\rVert\le\lVert A\rVert+\lVert B\rVert$ and $\lVert AB\rVert\le\lVert A\rVert\,\lVert B\rVert$; $\tr(A^tA)=\sum a_{ij}^2$. Prepared by m0104. Hint: start with exercise 3, which follows directly from the definition; for 2, each coordinate of $Ax$ is a row of $A$ times $x$, and Cauchy–Schwarz applies to it.
  4. Cyclic property of the trace $\tr(AB)=\tr(BA)$ for $A\in M_{n\times m}$, $B\in M_{m\times n}$. Prepared by m0109. Hint: write the diagonal entry $(AB)_{ii}$ as a sum over the inner index.
  5. Least-squares gradient by components: get $\nabla\lVert b-Ax\rVert^2$ through partial derivatives and compare with $2A^t(Ax-b)$. Prepared by m0112, m0115. Hint: write $f(x)=\sum_{i=1}^{D}\big(b^i-\sum_{j=1}^{N}a_{ij}x^j\big)^2$.

ИтогWrap-up

урок закрыт, когдаthe lesson is complete when
Матрицу $Df(x_0)$ для $f:\R^N\to\R^D$ выписываешь за две минуты и до счёта называешь её размер $D\times N$: m0105, m0118You write the matrix $Df(x_0)$ for $f:\R^N\to\R^D$ within two minutes and name its size $D\times N$ before computing: m0105, m0118
Оценку остаточного члена Лагранжа записываешь без конспекта и выбираешь по ней число слагаемых: m0108, m0117You write the Lagrange remainder bound without notes and choose the number of terms from it: m0108, m0117
Градиент $\lVert b-Ax\rVert^2$ выводишь через предел без подсказки и объясняешь вслух, откуда множитель 2: m0115, m0119You derive the gradient of $\lVert b-Ax\rVert^2$ through the limit without hints and explain aloud where the factor 2 comes from: m0115, m0119
В каждом произведении матриц сверяешь размеры множителей до умножения — за урок ни одной ошибки размеровIn every matrix product you check the sizes of the factors before multiplying — not a single size mistake during the lesson
Производную функции от матрицы получаешь через след и цикличность и называешь, чем $Df(X_0)$ отличается от градиента той же формы, что $X$: m0116, m0120You get the derivative of a function of a matrix through the trace and the cyclic property and name how $Df(X_0)$ differs from the gradient of the same shape as $X$: m0116, m0120
Мини-тест m0119 решён за 20 минут с первого вводаThe mini-test m0119 is solved within 20 minutes on the first entry
аудит урокаlesson audit
RU

Запиши в журнал каждую ошибку отдельной строкой и пометь тип. Размер: матрицы перемножены не в том порядке, градиент вышел строкой, внешняя производная взята не в той точке. Знак: потерян минус в $b-Ax$ или в $\psi'$. Остаток: производная $f^{(N+1)}$ оценена в одной точке, а не на всём отрезке. Если ошибок размера больше двух, перед уроком m02 повтори урок f01: на следующей лекции размеры понадобятся в каждой строке.

EN

Write each mistake on its own line in the error log and mark its type. Size: matrices multiplied in the wrong order, the gradient came out as a row, the outer derivative taken at the wrong point. Sign: a minus lost in $b-Ax$ or in $\psi'$. Remainder: the derivative $f^{(N+1)}$ bounded at one point instead of over the whole interval. If there are more than two size mistakes, review lesson f01 before lesson m02: in the next lecture sizes are needed on every line.