diff --git a/Task 3/Assignment_3_eng.pdf b/Task 3/Assignment_3_eng.pdf index ed98b52..9d7df3a 100644 Binary files a/Task 3/Assignment_3_eng.pdf and b/Task 3/Assignment_3_eng.pdf differ diff --git a/Task 3/Assignment_3_ru.pdf b/Task 3/Assignment_3_ru.pdf index 8c1d35f..78c310a 100644 Binary files a/Task 3/Assignment_3_ru.pdf and b/Task 3/Assignment_3_ru.pdf differ diff --git a/Task 3/tex/Assignment_3_eng.tex b/Task 3/tex/Assignment_3_eng.tex index 745fef0..be5775a 100644 --- a/Task 3/tex/Assignment_3_eng.tex +++ b/Task 3/tex/Assignment_3_eng.tex @@ -55,7 +55,7 @@ $$ \end{itemize} \item (5) -Consider a particle of unit mass, which is prepared at $t=0$ at $x=0$ at rest $v=0$. The particle is exposed to piece--wise constant external force $f_i$ at $i-1< t \le i$, with $i=1,2,...,10$. Let $a=(x(t=10),v(t=10))$ be a vector composed of coordinate and velocity of a particle at $t=10$. Derive the matrix $A$ such that $a=Af$ (note that $A$ is of a shape $2\times 10$). Using (a numerical) SVD decomposition, evaluate $f$ of minimal norm such that $a=(1,0)$. +Consider a particle of unit mass, which is prepared at $t=0$ at $x=0$ at rest $v=0$. The particle is exposed to piece--wise constant external force $f_i$ at $i-1< t \le i$, with $i=1,2,...,10$. Let $a=(x(t=10),v(t=10))$ be a vector composed of coordinate and velocity of a particle at $t=10$. Derive the matrix $A$ such that $a=Af$ (note that $A$ is of a shape $2\times 10$). Using (a numerical) SVD decomposition, evaluate $f$ of minimal Euclidean norm such that $a=(1,0)$. \item (5) Consider the function $f(x) = 10 \sin(x)$. Generate a dataset $D$ that will consist of $n = 7$ points drawn as follows. For each point randomly draw $x_i$ uniformly in $[0,6]$ and define $y_i = f(x_i) + \epsilon_i$, @@ -104,8 +104,10 @@ where $\epsilon$ is a vector of iid Gaussian random numbers. Your task will be t \end{itemize} \item (7) Consider the problem $$ -\mathrm{minimize\quad}\Vert Ax-b \Vert_2 \mathrm{\quad subject\;to\quad}Cx=0\mathrm{\quad with\;respect\;to\quad}x. +\mathrm{minimize\quad}\Vert Ax-b \Vert_2 \mathrm{\quad subject\;to\quad}Cx=0\mathrm{\quad with\;respect\;to\quad}x, $$ +where $A$ and $C$ are matrices and $x$ and $b$ are vectors. + Using the method of Lagrange multipliers, and assuming $A^TA$ to be invertible, derive explicit expression for optimal $x$. \item (20) Here we will consider the problem of localization of points in a 2D plane. Consider $n$ points, for which we have the \emph{approximate} locations $r_i=\left(x_i, y_i\right)$. We measure $k$ angles between certain points: $\theta_{ijk}=\angle(r_k-r_i, r_j-r_i)$. Our goal is to use the results of the measurements to improve the estimation of the locations $r_i$. @@ -114,7 +116,7 @@ To be specific, consider $n=3$ points, for which we have approximate locations $ $$ (\bar{r}_3-\bar{r}_1)\cdot(\bar{r}_3-\bar{r}_1) = |\bar{r}_3-\bar{r}_1||\bar{r}_3-\bar{r}_1|\cos\theta_{123}, $$ -which can be linearized in $dr_i$, assuming this correction will end up small. In this approach, one constructs a single (in general, $k$) equation for six (in general, $2n$) variables, so the system will typically by overdetermined. We can consider this system in the least squares sense, which amounts to determining the smallest correction to all $r_i$ which makes the updated locations consistent with observations. In the particular numerical example above, one may find $dr_1=(-h, 0),\;dr_2=(h, -h),\; dr_3=(0, h)$ where $h=\pi/80\approx 0.04$. +which can be linearized in $dr_i$, assuming this correction will end up small. In this approach, one constructs a single (in general, $k$) equation for six (in general, $2n$) variables, so the system will typically by underdetermined. We can consider this system in the least squares sense, which amounts to determining the smallest correction to all $r_i$ which makes the updated locations consistent with observations. In the particular numerical example above, one may find $dr_1=(-h, 0),\;dr_2=(h, -h),\; dr_3=(0, h)$ where $h=\pi/80\approx 0.04$. Your task is to write the code, which will accept the current estimate of the positions $r_i$ ($n\times 2$, float) and measurement results $\theta_{ijk}$, which are specified by i) indices of points ($k\times 3$, int) and ii) angles ($k$, float); and will output the derived correction to the point positions $dr_i$ ($n\times 2$, float). You can use the numerical example in this exercise to test your code. diff --git a/Task 3/tex/Assignment_3_ru.tex b/Task 3/tex/Assignment_3_ru.tex index 832aa5d..2902bd7 100644 --- a/Task 3/tex/Assignment_3_ru.tex +++ b/Task 3/tex/Assignment_3_ru.tex @@ -77,7 +77,7 @@ $$ \item (5) Частица единичной массы в начальный момент времени покоится в точке $x = 0$. Затем она подвергается воздействию кусочно-постоянной внешней силы $f_i \;\; (i = 1 \ldots 10)$. -Пусть $a = \eval{(x,\: v)}_{t=10}$ --- вектор, состоящий из координаты и скорости частицы в конечный момент времени. Найдите матрицу $A$ такую, что $a = Af$. Заметьте, что она будет иметь размер $2\times 10$. С помощью SVD-разложения численно найдите вектор $f$ наименьшей нормы, при котором $a = (1,\, 0)$. +Пусть $a = \eval{(x,\: v)}_{t=10}$ --- вектор, состоящий из координаты и скорости частицы в конечный момент времени. Найдите матрицу $A$ такую, что $a = Af$. Заметьте, что она будет иметь размер $2\times 10$. С помощью SVD-разложения численно найдите вектор $f$ наименьшей евклидовой нормы, при котором $a = (1,\, 0)$. \item (5) Создайте датасет следующим образом: выберите $n = 7$ точек $x_i$ из равномерного распределения на отрезке $[0,\,6]$. Затем вычислите $y_i = f(x_i) + \epsilon_i$, где $f(x) = 10 \sin(x)$, а $\epsilon_i$~---~независимые стандартные нормальные случайные величины. Изобразите на одном графике точки датасета и функцию $f$. @@ -130,7 +130,7 @@ $$ % \item (7) Рассмотрим задачу оптимизации $$ -\min_x\, \norm!{Ax - b} \quad\text{при условии}\quad Cx = 0 +\min_x\, \norm!{Ax - b}_2 \quad\text{при условии}\quad Cx = \vv 0 $$ Предполагая, что матрица $A^T A$ обратима, воспользуйтесь методом множителей Лагранжа и получите выражение для точки минимума $x$. @@ -146,7 +146,7 @@ $$ \abs{A_1 A_2} \cdot \abs{A_3 A_2} \cdot \cos(\theta_{123}) $$ Это условие может быть линеаризовано в предположении, что поправки окажутся малыми. -При таком подходе мы конструируем $m = 1$ уравнений для $2n = 6$ переменных. В общем случае число измеренных углов $m$ может быть большим, и система окажется переопределённой. Но мы можем рассматривать её в смысле метода наименьших квадратов, т.е. пытаться определить наименьшие поправки к координатам, которые делали бы их согласованными с измерениями. В рассмотренном примере можно найти решение +При таком подходе мы конструируем $m = 1$ уравнений для $2n = 6$ переменных. Система обычно оказывается недоопределённой. Но мы можем рассматривать её в смысле метода наименьших квадратов, т.е. пытаться определить наименьшие поправки к координатам, которые делали бы их согласованными с измерениями. В рассмотренном примере можно найти решение $$ dr_1 = (dx_1,\, dy_1) = (0, h), \quad dr_2=(-h,\, 0), \quad