Initial commit
This commit is contained in:
commit
98b7349508
4 changed files with 263 additions and 0 deletions
150
.gitignore
vendored
Executable file
150
.gitignore
vendored
Executable file
|
@ -0,0 +1,150 @@
|
|||
*.ijvm
|
||||
*.mic1
|
||||
|
||||
# ---> TeX
|
||||
## Core latex/pdflatex auxiliary files:
|
||||
*.aux
|
||||
*.lof
|
||||
*.log
|
||||
*.lot
|
||||
*.fls
|
||||
*.out
|
||||
*.toc
|
||||
|
||||
## Intermediate documents:
|
||||
*.dvi
|
||||
*-converted-to.*
|
||||
# these rules might exclude image files for figures etc.
|
||||
# *.ps
|
||||
# *.eps
|
||||
# *.pdf
|
||||
|
||||
## Bibliography auxiliary files (bibtex/biblatex/biber):
|
||||
*.bbl
|
||||
*.bcf
|
||||
*.blg
|
||||
*-blx.aux
|
||||
*-blx.bib
|
||||
*.brf
|
||||
*.run.xml
|
||||
|
||||
## Build tool auxiliary files:
|
||||
*.fdb_latexmk
|
||||
*.synctex
|
||||
*.synctex.gz
|
||||
*.synctex.gz(busy)
|
||||
*.pdfsync
|
||||
|
||||
## Auxiliary and intermediate files from other packages:
|
||||
|
||||
|
||||
# algorithms
|
||||
*.alg
|
||||
*.loa
|
||||
|
||||
# achemso
|
||||
acs-*.bib
|
||||
|
||||
# amsthm
|
||||
*.thm
|
||||
|
||||
# beamer
|
||||
*.nav
|
||||
*.snm
|
||||
*.vrb
|
||||
|
||||
#(e)ledmac/(e)ledpar
|
||||
*.end
|
||||
*.[1-9]
|
||||
*.[1-9][0-9]
|
||||
*.[1-9][0-9][0-9]
|
||||
*.[1-9]R
|
||||
*.[1-9][0-9]R
|
||||
*.[1-9][0-9][0-9]R
|
||||
*.eledsec[1-9]
|
||||
*.eledsec[1-9]R
|
||||
*.eledsec[1-9][0-9]
|
||||
*.eledsec[1-9][0-9]R
|
||||
*.eledsec[1-9][0-9][0-9]
|
||||
*.eledsec[1-9][0-9][0-9]R
|
||||
|
||||
# glossaries
|
||||
*.acn
|
||||
*.acr
|
||||
*.glg
|
||||
*.glo
|
||||
*.gls
|
||||
|
||||
# gnuplottex
|
||||
*-gnuplottex-*
|
||||
|
||||
# hyperref
|
||||
*.brf
|
||||
|
||||
# knitr
|
||||
*-concordance.tex
|
||||
*.tikz
|
||||
*-tikzDictionary
|
||||
|
||||
# listings
|
||||
*.lol
|
||||
|
||||
# makeidx
|
||||
*.idx
|
||||
*.ilg
|
||||
*.ind
|
||||
*.ist
|
||||
|
||||
# minitoc
|
||||
*.maf
|
||||
*.mtc
|
||||
*.mtc[0-9]
|
||||
*.mtc[1-9][0-9]
|
||||
|
||||
# minted
|
||||
_minted*
|
||||
*.pyg
|
||||
|
||||
# morewrites
|
||||
*.mw
|
||||
|
||||
# mylatexformat
|
||||
*.fmt
|
||||
|
||||
# nomencl
|
||||
*.nlo
|
||||
|
||||
# sagetex
|
||||
*.sagetex.sage
|
||||
*.sagetex.py
|
||||
*.sagetex.scmd
|
||||
|
||||
# sympy
|
||||
*.sout
|
||||
*.sympy
|
||||
sympy-plots-for-*.tex/
|
||||
|
||||
# TikZ & PGF
|
||||
*.dpth
|
||||
*.md5
|
||||
*.auxlock
|
||||
|
||||
# todonotes
|
||||
*.tdo
|
||||
|
||||
# xindy
|
||||
*.xdy
|
||||
|
||||
# WinEdt
|
||||
*.bak
|
||||
*.sav
|
||||
|
||||
# Mac stupid tmp files
|
||||
.DS_Store
|
||||
|
||||
!*.pdf
|
||||
*.zip
|
||||
|
||||
**/*-figure*.pdf
|
||||
|
||||
*~
|
43
hw1/ex3.m
Normal file
43
hw1/ex3.m
Normal file
|
@ -0,0 +1,43 @@
|
|||
%% Exercise 3.1
|
||||
|
||||
% f(x1, x2) = x1^2 + u * x2^2;
|
||||
|
||||
% [x1 x2] [1 0] [x1] + [0][x1]
|
||||
% [0 u] [x2] + [0][x2]
|
||||
|
||||
% A = [1 0; 0 u]; b = [0; 0]
|
||||
|
||||
%% Exercise 3.2
|
||||
|
||||
|
||||
for u = 1:10
|
||||
A = [1 0; 0 u];
|
||||
|
||||
xs = -10:1:10;
|
||||
ys = xs;
|
||||
|
||||
Z = zeros(size(xs, 2), size(ys, 2));
|
||||
|
||||
for i = 1:size(xs, 2)
|
||||
for j = 1:size(ys, 2)
|
||||
vec = [xs(i); ys(j)];
|
||||
Z(i, j) = vec' * A * vec;
|
||||
end
|
||||
end
|
||||
|
||||
if u <= 5
|
||||
fig = u;
|
||||
con = 5 + u;
|
||||
else
|
||||
fig = 10 + u - 5;
|
||||
con = 15 + u - 5;
|
||||
end
|
||||
|
||||
subplot(4, 5, fig);
|
||||
h = surf(xs, ys, Z);
|
||||
set(h,'LineStyle','none');
|
||||
title(sprintf("Surf for u=%d", u));
|
||||
subplot(4, 5, con);
|
||||
contour(xs, ys, Z, 20);
|
||||
title(sprintf("Contour for u=%d", u));
|
||||
end
|
BIN
hw1/main.pdf
Normal file
BIN
hw1/main.pdf
Normal file
Binary file not shown.
70
hw1/main.tex
Normal file
70
hw1/main.tex
Normal file
|
@ -0,0 +1,70 @@
|
|||
\documentclass{scrartcl}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{amsmath}
|
||||
|
||||
\setlength{\parindent}{0cm}
|
||||
\setlength{\parskip}{0.5\baselineskip}
|
||||
|
||||
\title{Optimisation methods -- Homework 1}
|
||||
\author{Claudio Maggioni}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
\section{Exercise 1}
|
||||
|
||||
\subsection{Gradient and Hessian}
|
||||
|
||||
The gradient and the Hessian for $f$ are the following:
|
||||
|
||||
\[\nabla f = \begin{bmatrix}2x_1 + x_2 \cdot \cos(x_1) \\ 9x^2_2 + \sin(x_1)\end{bmatrix} \]
|
||||
|
||||
\[H_f = \begin{bmatrix}2 - x_2 \cdot \sin(x_1) & \cos(x_1)\\\cos(x_1) & 18x_2\end{bmatrix} \]
|
||||
|
||||
\subsection{Taylor expansion}
|
||||
|
||||
\[f(h) = 0 + \langle\begin{bmatrix}0 + 0 \\ 0 + 0\end{bmatrix},\begin{bmatrix}h_1\\h_2\end{bmatrix}\rangle + \frac12 \langle\begin{bmatrix}2 - 0 & 1\\1 & 0\end{bmatrix} \begin{bmatrix}h_1 \\ h_2\end{bmatrix}, \begin{bmatrix}h_1 \\ h_2\end{bmatrix}\rangle + O(\|h\|^3)\]
|
||||
\[f(h) = \frac12 \langle\begin{bmatrix}2h_1 + h_2 \\ h_1\end{bmatrix}, \begin{bmatrix}h_1 \\ h_2\end{bmatrix}\rangle + O(\|h\|^3)\]
|
||||
\[f(h) = \frac12 \left(2h^2_1 + 2 h_1h_2\right) + O(\|h\|^3)\]
|
||||
\[f(h) = h^2_1 + h_1h_2 + O(\|h\|^3)\]
|
||||
|
||||
\section{Exercise 2}
|
||||
|
||||
\subsection{Gradient and Hessian}
|
||||
|
||||
For $A$ symmetric, we have:
|
||||
|
||||
\[\frac{d}{dx}\langle b, x\rangle = \langle b,\cdot \rangle = b\]
|
||||
\[\frac{d}{dx}\langle Ax, x\rangle = 2\langle Ax,\cdot \rangle = 2Ax\]
|
||||
|
||||
Then:
|
||||
|
||||
\[\nabla J = Ax - b\]
|
||||
\[H_J = \frac{d}{dx} \nabla J = A\]
|
||||
|
||||
\subsection{First order necessary condition}
|
||||
|
||||
It is a necessary condition for a minimizer $x^*$ of $J$ that:
|
||||
|
||||
\[\nabla J (x^*) = 0 \Leftrightarrow Ax^* = b\]
|
||||
|
||||
\subsection{Second order necessary condition}
|
||||
|
||||
It is a necessary condition for a minimizer $x^*$ of $J$ that:
|
||||
|
||||
\[\nabla^2 J(x^*) \geq 0 \Leftrightarrow A \text{ is positive semi-definite}\]
|
||||
|
||||
\subsection{Sufficient conditions}
|
||||
|
||||
It is a sufficient condition for $x^*$ to be a minimizer of $J$ that the first necessary condition is true and that:
|
||||
|
||||
\[\nabla^2 J(x^*) > 0 \Leftrightarrow A \text{ is positive definite}\]
|
||||
|
||||
\subsection{Does $\min_{x \in R^n} J(x)$ have a unique solution?}
|
||||
|
||||
Not in general. If for example we consider A and b to be only zeros, then $J(x) = 0$ for all $x \in \!R^n$ and thus $J$ would have an infinite number of minimizers.
|
||||
|
||||
However, for if $A$ would be guaranteed to have full rank, the minimizer would be unique because the first order necessary condition would hold only for one value $x^*$. This is because the linear system $Ax^* = b$ would have one and only one solution (due to $A$ being full rank).
|
||||
|
||||
\end{document}
|
Reference in a new issue