|
| 1 | +\documentclass[11pt,a4]{article} |
| 2 | + |
| 3 | +\usepackage[margin=2cm]{geometry} |
| 4 | + |
| 5 | +\usepackage{multicol} |
| 6 | + |
| 7 | +\usepackage{amsmath} |
| 8 | +\usepackage{url} |
| 9 | + |
| 10 | +\usepackage{amssymb} |
| 11 | + |
| 12 | +\usepackage{amsmath} |
| 13 | +\usepackage{url} |
| 14 | + |
| 15 | +\usepackage[utf8]{inputenc} |
| 16 | + |
| 17 | +% Default fixed font does not support bold face |
| 18 | +\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{10} % for bold |
| 19 | +\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{10} % for normal |
| 20 | + |
| 21 | +% Custom colors |
| 22 | +\usepackage{color} |
| 23 | +\definecolor{deepblue}{rgb}{0,0,0.5} |
| 24 | +\definecolor{deepred}{rgb}{0.6,0,0} |
| 25 | +\definecolor{deepgreen}{rgb}{0,0.5,0} |
| 26 | + |
| 27 | +\usepackage{listings} |
| 28 | + |
| 29 | +% Python style for highlighting |
| 30 | +\newcommand\pythonstyle{\lstset{ |
| 31 | +language=Python, |
| 32 | +basicstyle=\ttm, |
| 33 | +otherkeywords={self}, % Add keywords here |
| 34 | +keywordstyle=\ttb\color{deepblue}, |
| 35 | +emph={MyClass,__init__}, % Custom highlighting |
| 36 | +emphstyle=\ttb\color{deepred}, % Custom highlighting style |
| 37 | +stringstyle=\color{deepgreen}, |
| 38 | +frame=tb, % Any extra options here |
| 39 | +showstringspaces=false % |
| 40 | +}} |
| 41 | + |
| 42 | + |
| 43 | +% Python environment |
| 44 | +\lstnewenvironment{python}[1][] |
| 45 | +{ |
| 46 | +\pythonstyle |
| 47 | +\lstset{#1} |
| 48 | +} |
| 49 | +{} |
| 50 | + |
| 51 | +% Python for external files |
| 52 | +\newcommand\pythonexternal[2][]{{ |
| 53 | +\pythonstyle |
| 54 | +\lstinputlisting[#1]{#2}}} |
| 55 | + |
| 56 | +% Python for inline |
| 57 | +\newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}} |
| 58 | + |
| 59 | + |
| 60 | +\usepackage{collectbox} |
| 61 | + |
| 62 | +\newcommand{\mybox}[2]{$\quad$\fbox{ |
| 63 | +\begin{minipage}{#1cm} |
| 64 | +\hfill\vspace{#2cm} |
| 65 | +\end{minipage} |
| 66 | +}} |
| 67 | + |
| 68 | + |
| 69 | +\usepackage{fancyhdr} |
| 70 | +\pagestyle{fancy} |
| 71 | +\rhead{Programmazione 1 - Tutorato 3} |
| 72 | + |
| 73 | +\include{book_header} |
| 74 | + |
| 75 | +\begin{document} |
| 76 | +\thispagestyle{empty} |
| 77 | +\hrule |
| 78 | +\begin{center} |
| 79 | + {\Large {\bf Programmazione 1 \hspace{3cm} $\quad \quad \quad$ Tutorato 3}} |
| 80 | +\end{center} |
| 81 | + |
| 82 | +\hrule |
| 83 | + |
| 84 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 85 | +\section*{} |
| 86 | + |
| 87 | +\begin{enumerate} |
| 88 | + |
| 89 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 90 | +\item Scrivere una funzione che prende in input una stringa e un dizionario. Se il dizionario è vuoto restituisce una stringa criptata e un dizionario che decripta, altrimenti utilizza il dizionario dato in input per decriptare la stringa. |
| 91 | + |
| 92 | + |
| 93 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 94 | +\item Scrivere una funzione che dato $n$ restituisce la matrice di Hilbert di ordine $n$: |
| 95 | + |
| 96 | +\begin{center} |
| 97 | +$H=\begin{pmatrix} |
| 98 | + 1 & \frac{1}{2} & \frac{1}{3} & \cdots \\[1ex] |
| 99 | + \frac{1}{2} & \frac{1}{3} & \frac{1}{4} & \\[1ex] |
| 100 | + \frac{1}{3} & \frac{1}{4} & \frac{1}{5} & \\ |
| 101 | + \vdots & & & \ddots |
| 102 | +\end{pmatrix}$ |
| 103 | +$H(i,j)=\frac{1}{i+j+1}$ $i,j=0,\dots,n-1$ |
| 104 | +\end{center} |
| 105 | + |
| 106 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 107 | +\item Scrivere una funzione {\tt MapMat(Matrix, f)} che implementa la "map" su matrici intese come liste di liste. |
| 108 | +Ad esempio:\\ |
| 109 | +\begin{center} |
| 110 | +$ |
| 111 | +\Bigg( |
| 112 | +\begin{bmatrix} |
| 113 | +0 & \pi & 2\pi\\[4pt] |
| 114 | +\pi & \frac{3}{2}\pi & \frac{\pi}{4} \\[4pt] |
| 115 | +\pi & 0 & \frac{-1}{4}\pi\end{bmatrix}, sin \Bigg) \longmapsto |
| 116 | +\begin{bmatrix} |
| 117 | +0 & 0 & 0\\[4pt] |
| 118 | +0 & -1 & \sqrt[]{2}/2 \\[4pt] |
| 119 | +0 & 0 & -\sqrt[]{2}/2\end{bmatrix} |
| 120 | +$ |
| 121 | +\end{center} |
| 122 | + |
| 123 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 124 | +\item Scrivere una funzione che data una matrice e un predicato $p$, |
| 125 | +restituisce la matrice stessa portando a 0 gli elementi $x$ tali che $p(x)=False$.\\ |
| 126 | + |
| 127 | +\item Ricordando le due funzioni: |
| 128 | +\begin{python} |
| 129 | +def MakeImage(F, n, scale=0.01): |
| 130 | + data = [scale*i for i in range(-n,n)] |
| 131 | + return np.matrix([[F(complex(a, b)) for a in data] for b in data]) |
| 132 | +\end{python} |
| 133 | +\begin{python} |
| 134 | +def DrawImage(F, n, scale): |
| 135 | + m = MakeImage(F, n, scale) |
| 136 | + plt.figure(figsize=(8,8)) |
| 137 | + img = plt.imshow(m, extent=(-scale*n, scale*n, -scale*n, scale*n), cmap='hot') |
| 138 | + plt.show() |
| 139 | +\end{python} |
| 140 | +implementare una funzione che prende in input una funzione $f:\mathbb{C}\rightarrow \mathbb{C}$ e restituisce il grafico dell'insieme $J(f)=\{ z\in \mathbb{C}: \exists \delta$ tale che $|(f^n(z))|<\delta$ $\forall n \}$ dove: |
| 141 | +$f^n=\underbrace{f\circ\ldots\circ f}_{n\ \mathrm{volte}}$ |
| 142 | +\end{enumerate} |
| 143 | + |
| 144 | +\end{document} |
0 commit comments