aboutsummaryrefslogtreecommitdiff
path: root/src/Lecture7/slides/X2-StudentsRequests.tex
blob: 787e7fb977336ff85947228b96eb491b40916a99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
\documentclass[11pt]{beamer}
\usetheme{Madrid}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\usepackage{svg}
\usepackage{color}
\usepackage{listings}
\usepackage{mathtools}
\usepackage{tikz-cd}
\usepackage{adjustbox}

\definecolor{myblue}{rgb}{0,0,0.5}
\lstset{
	language=Python,
	tabsize=4,
	basicstyle=\footnotesize,
	keywordstyle=\bf\color{myblue},
	commentstyle=\it\color{gray},
	numbers=left,
	numbersep=3pt,
	numberstyle=\tiny\color{gray},
}

\author[\texttt{sebastiano.tronto@uni.lu}]{Sebastiano Tronto}
\title[Students requests]%
{Students requests}
\logo{\includegraphics[scale=0.1]{img/unilu.jpg}} 
%\institute{University of Luxembourg} 

\date{2021-05-21} 

\begin{document}

\begin{frame}
  \titlepage
\end{frame}

\begin{frame}[plain]
	\begin{center} {\Huge More cryptography} \end{center}
\end{frame}

\begin{frame}{Cryptography}
	What we have seen:

	\vspace{0.3cm}
	\begin{itemize}
		\item \textbf{RSA:}
			sending messages using a private key / public key pair
		\item \textbf{Flip-a-coin:}
			cryptographic ``proof'' that the opponent is not cheating
	\end{itemize}
\end{frame}

\begin{frame}{Cryptography}
	\begin{itemize}
		\item Rely on integer factorization being hard

			\vspace{0.3cm}
			\textbf{Example:} the best-known factorization algorithm
			(\href{https://en.wikipedia.org/wiki/General\_number\_field\_sieve}%
			{\emph{General number field sieve}}) has complexity
			\begin{align*}
				\sim O\left(
					e^{\sqrt[3]{\frac{64}{9}\log_2n\cdot(\log_2\log_2n)^2}}
				\right)
			\end{align*}

			Factoring a number with $300$ digits:
			\begin{itemize}
				\item Your laptop: $10^{13}$ billion years
				\item Best supercomputer: $13$ billion years
					(age of the universe)
			\end{itemize}
	\end{itemize}
\end{frame}

\begin{frame}{Symmetric and asymmetric cryptography}
	\begin{itemize}
		\item Our examples are \emph{asymmetric}: different public/private keys
		\item Safe against eavesdroppers
		\item Symmetric protocols can be faster and simpler, but you need
			a secure way to exchange a key
	\end{itemize}
\end{frame}

\begin{frame}{Diffie-Hellman key exchange}
	\begin{itemize}
		\item Generate a ``password'' without communicating it directly
		\item It can then be used for symmetric cryptography
		\item Based on a different hard problem:
			\href{https://en.wikipedia.org/wiki/Discrete\_logarithm}%
			{\emph{discrete logarithm}}
	\end{itemize}
\end{frame}

\begin{frame}{Diffie-Hellman key exchange}
	\begin{itemize}
		\item Alice and Bob agree on a prime number $p$ and an integer $g$
		\item Alice picks an integer $a$ and sends $(g^a\bmod p)$ to Bob
		\item Bob picks an integer $b$ and sends $(g^b\bmod p)$ to Alice
		\item Alice can compute $(g^b)^a\bmod p$ and Bob can compute
			$(g^a)^b\bmod p$. This is their shared secret (key).
	\end{itemize}
\end{frame}

\begin{frame}{Diffie-Hellman with colors (from Wikipedia)}
	\begin{center}\includesvg[scale=0.45]{img/DH}\end{center}
\end{frame}

\begin{frame}{Diffie-Hellman key exchange}
	\begin{itemize}
		\item Knowing $h$ and $a$, it is hard to find $g$ such that
			$g^a \bmod p =h$ (discrete logarithm problem)
		\item Very simple, many variants
		\item Any group can be used, e.g. Elliptic Curves (see
\href{https://en.wikipedia.org/wiki/Elliptic-curve_Diffie\%E2\%80\%93Hellman}%
			{Wikipedia: elliptic-curve Diffie-Hellman})
	\end{itemize}
\end{frame}


\begin{frame}[plain]
	\begin{center} {\Huge Numerical methods for PDEs} \end{center}
\end{frame}

\begin{frame}{Solving partial differential equations}
	\begin{itemize}
		\item Very, very hard
		\item Very important in practical applications (physics and such)
		\item Approximations are necessary, might as well use numerical methods
	\end{itemize}
\end{frame}

\begin{frame}{Numerical methods for ODEs}
	\begin{block}{Problem}
		Given $f(x,y)$, $x_0$ and $y_0$, find an approximation
		for $y(x)$ such that
		\begin{align*}
			\begin{cases}
				y'(x) = f(x, y(x))\\
				y(x_0) =y_0
			\end{cases}
		\end{align*}
	\end{block}

	\begin{block}{Approximation}
		We can describe $y(x)$ in an interval $[x_0,x_1]$ by giving the
		(approximate) values $y(s_0)$, \dots, $y(s_n)$ for many
		values of $s_i\in [x_0, x_1]$.
	\end{block}
\end{frame}

\begin{frame}{Euler's method}
	\begin{block}{Idea}
		For $h$ small
		\begin{align*}
			y'(x)\approx\frac{y(x+h)-y(x)}{h}
		\end{align*}
		which implies
		\begin{align*}
			y(x+h) \approx y(x) + h\cdot f(x, y(x))
		\end{align*}
	\end{block}
\end{frame}

\begin{frame}{Euler's method}
	\begin{block}{Algorithm}
		\textbf{Input:} the data $f(x,y)$, $x_0$, $y_0$ and $x_1$ describing
			the problem and the desired range for the solution.

		\vspace{0.3cm}
		\textbf{Output:} $x_0=s_0 < s_1 < \dots < s_n=x_1$ and
			$y_0, \dots, y_n$ such that $y_i\approx y(s_i)$.

		\vspace{0.3cm}
		\begin{enumerate}
			\item Choose a value $n$ and let
				$h=\frac{x_1-x_0}{n}$ and $s_i=x_0+ih$
			\item For $i=0,\dots, n-1$ compute
				$y_{i+1}=y_i+h\cdot f(s_i, y_i)$
			\item Return $s_0, \dots, s_n$ and $y_0, \dots, y_n$
		\end{enumerate}
	\end{block}
\end{frame}

\begin{frame}{Euler's method}
	\begin{itemize}
		\item Very simple and fast
		\item Generalization for higher-order equations: Runge-Kutta methods
		\item A similar idea works for some PDEs
	\end{itemize}
\end{frame}

\begin{frame}{The heat equation (PDE)}
	\begin{align*}
		\frac{\partial u}{\partial t} = \frac{\partial^2 u}{\partial x_1^2} +
		\frac{\partial^2 u}{\partial x_2^2} + \cdots +
		\frac{\partial^2 u}{\partial x_n^2}
	\end{align*}
	
	Where
	\[u(x_1,x_2,\dots,x_n,t): \mathbb R^n\times \mathbb R_+\to \mathbb R\]
	describes the quantity of heat at the point $(x_1,\dots x_n)$ at time $t$.

	\vspace{0.3cm} It appears also outside thermodynamics: mathematical finance
	(\href{https://en.wikipedia.org/wiki/Black\%E2\%80\%93Scholes\_equation}%
	{Black-Scholes equation}), quantum mechanics
	(\href{https://en.wikipedia.org/wiki/Schr\%C3\%B6dinger\_equation}%
	{Schrödinger equation}), image analysis\dots
\end{frame}

\begin{frame}{A simple case ($n=1$, in $[0,1]^2$)}
	\begin{block}{Problem}
		Given $u_0(t)$, $u_1(t)$ and $u^0(x)$, find an approximation
		for $u(x,t)$ such that
		\begin{align*}
			\begin{cases}
				\frac{\partial u}{\partial t} =
					\frac{\partial^2 u}{\partial x^2} \\
				u(0,t) = u_{(0)}(t) \quad \text{(boundary condition)}\\
				u(1,t) = u_{(1)}(t) \quad \text{(boundary condition)}\\
				u(x,0) = u^0(x) \quad \text{(initial condition)}
			\end{cases}
		\end{align*}
	\end{block}

	\begin{block}{Approximation}
		Values $u_i^j\approx u(s_i, r^j)$ for
		$(s_i,r^j)\in [0,1]\times [0,1]$
	\end{block}
\end{frame}

\begin{frame}{Idea}
	For $k$ small:
	\begin{align*}
		\frac{\partial u(x,t)}{\partial t} \approx \frac{u(x,t+k)-u(x,t)}{k}\\
	\end{align*}
	For $h$ small (left limit + right limit):
	\begin{align*}
		\frac{\partial^2 u(x,t)}{\partial x^2} &\approx
			\frac{\partial}{\partial x}\left(
				\frac{u(x,t) - u(x-h,t)}{h}
			\right)\\
		&\approx \frac1h\left(
			\frac{\partial u(x,t)}{\partial x} -
			\frac{\partial u(x-h,t)}{\partial x}
		\right)\\
		&\approx \frac1h\left(
			\frac{u(x+h,t) - u(x,t)}{h} - \frac{u(x,t)-u(x-h,t)}{h}
		\right)\\
		&\approx \frac{u(x+h,t)-2u(x,t)+u(x-h,t)}{h^2}
	\end{align*}
\end{frame}

\begin{frame}{Idea}
	From the equation
	\begin{align*}
		\frac{u_i^{j+1}-u_i^j}{k}= \frac{u_{i+1}^j-2u_{i}^j+u_{i-1}^j}{h^2}
	\end{align*}
	we find the formula
	\begin{align*}
		u_i^{j+1} = \frac{k}{h^2}\left(u_{i+1}^j - 2u_i^j + u_{i-1}^j\right)
			 + u_i^j
	\end{align*}
\end{frame}

\begin{frame}{Finite difference method for the heat equation}
	\begin{block}{Algorithm}
		\textbf{Input:} $u_{(0)}^j$, $u_{(1)}^j$ (boundary)
			and $u_i^0$ (initial).

		\vspace{0.3cm}
		\textbf{Output:} values $u_i^j$ approximating a solution.

		\vspace{0.3cm}
		\begin{enumerate}
			\item Let  $m=\operatorname{len}(u_0)-1$,
				$n=\operatorname{len}(u^0)-1$ and $k=1/m$, $h=1/n$
				%\begin{align*}
				%	\begin{array}{cccc}
				%		k=\frac{t_1-t_0}{m}, & h=\frac{x_1-x_0}{n}, &
				%		r^j = t_0 +jk, & s_i = x_0+ih
				%	\end{array}
				%\end{align*}
			\item For $j=0,\dots, m-1$ do the following:
				\begin{itemize}
					\item For $i=1,\dots, n-1$ compute
						\begin{align*}
							u_i^{j+1} = \frac{k}{h^2}\left(u_{i+1}^j - 
							             2u_i^j + u_{i-1}^j\right) + u_i^j
						\end{align*}
				\end{itemize}
			\item Return the $u_i^j$
		\end{enumerate}
	\end{block}
\end{frame}

\begin{frame}{Other PDEs}
	\begin{itemize}
		\item In general, there is no generic method
		\item You might need to write specific code for your equation
		\item Some packages exists
			(e.g. \href{https://wiki.octave.org/Fem-fenics}{fem-fenics} for
			\href{https://www.gnu.org/software/octave/index}{Gnu Octave})
	\end{itemize}
\end{frame}

\end{document}

Generated with cgit - Back to sebastiano.tronto.net