RepozytoriumzprojektemPython/stopy/Ćwiczenia_5.ipynb

379 lines
90 KiB
Plaintext
Raw Normal View History

2024-11-06 08:25:50 +01:00
{
"cells": [
{
"cell_type": "markdown",
"id": "4cc6c96f",
"metadata": {},
"source": [
"# Ćwiczenia 5"
]
},
{
"cell_type": "markdown",
"id": "1276423e",
"metadata": {},
"source": [
"***TEMAT:*** transformata Fouriera"
]
},
{
"cell_type": "markdown",
"id": "4c010a18",
"metadata": {},
"source": [
"## Od szeregów Fouriera do transformaty Fouriera: idea"
]
},
{
"cell_type": "markdown",
"id": "4e550b81",
"metadata": {},
"source": [
"***Przypomnienie:***\n",
"\n",
"Szereg Fouriera dla funkcji $2\\pi$ okresowej $f$ to szereg\n",
"\n",
"$$\n",
"\\sum_{n=-\\infty}^\\infty c_ne^{inx},\n",
"$$\n",
"\n",
"gdzie dla każdego $n\\in\\mathbb{Z}$ mamy:\n",
"\n",
"$$\n",
"c_n=\\frac{1}{2\\pi}\\int_{-\\pi}^\\pi f(x)e^{-inx}dx.\n",
"$$\n",
"\n",
"***Idea:*** przedstawiamy funkcję $f$ jako sumę funkcji o okresach $2\\pi/n$ (odwrotnością okresu w fizyce jest częstotliwość, zatem te funkcje mają częstotliwość $\\frac{n}{2\\pi}$). Wielkość $|c_n|$ mierzy zatem \"jaki udział\" w rozkładzie $f$ na prostsze kawałki ma ten o częstotliwości $\\frac{n}{2\\pi}$. "
]
},
{
"cell_type": "markdown",
"id": "9bb9900d",
"metadata": {},
"source": [
"***Zmiana okresu:***\n",
"\n",
"Szereg Fouriera dla funkcji $T$ okresowej $f$ to szereg\n",
"\n",
"$$\n",
"\\sum_{n=-\\infty}^\\infty c_ne^{2\\pi inx/T},\n",
"$$\n",
"\n",
"gdzie \n",
"dla każdego $n\\in\\mathbb{Z}$ mamy:\n",
"\n",
"$$\n",
"c_n=\\frac{1}{T}\\int_{-T/2}^{T/2} f(x)e^{-2\\pi inx/T}dx.\n",
"$$\n",
"***Idea:*** przedstawiamy funkcję $f$ jako sumę funkcji o okresach $T/n$. Wielkość $|c_n|$ mierzy zatem \"jaki udział\" w rozkładzie $f$ na prostsze kawałki ma ten o częstotliwości $n/T$. \n"
]
},
{
"cell_type": "markdown",
"id": "f4bef5ac-3cbc-4d67-8775-0b88c4a8f8b0",
"metadata": {},
"source": [
"### Przykład\n",
"\n",
"Niech $f$ będzie funkcją taką, że $f(x)=1$ dla $|x|\\leq 1/2$ i $0$ dla $|x|>1/2$.\n",
"\n",
"Dla dużych $T$ niech $g$ będzie taką funkcją określoną wzorem\n",
"\n",
"$$\n",
"g(x)=\\begin{cases}\n",
"1, & x\\in [nT-1/2,nT+1/2],\\quad n\\in \\mathbb{Z}\\\\\n",
"0, & \\text{ w przeciwnym przypadku}.\n",
"\\end{cases}\n",
"$$\n",
"Jest jasne, że $g$ jest $T$ okresowa i pokrywa się z $f$ na przedziale $(-1/2,1/2)$."
]
},
{
"cell_type": "markdown",
"id": "63c5b2b6-4a71-4ac9-bc43-c4cfdab73971",
"metadata": {},
"source": [
"Policzymy współczynniki Fouriera dla funkcji $g$.\n",
"Mamy\n",
"\n",
"$$\n",
"c_0=\\frac{1}{T}\\int_{-T/2}^{T/2}g(x)dx=\\frac{1}{T}\\int_{-1/2}^{1/2}1dx=\\frac{1}{T}\n",
"$$\n",
"\n",
"oraz dla $n\\not=0$ \n",
"\n",
"$$\n",
"c_n=\\frac{1}{T}\\int_{-T/2}^{T/2} g(x)e^{-2\\pi inx/T}dx=\\frac{1}{T}\\int_{-1/2}^{1/2}e^{-2\\pi inx/T}dx=\n",
"-\\frac{1}{2\\pi in}e^{-2\\pi inx/T}\\bigg|_{-1/2}^{1/2}=\\frac{1}{2\\pi in}(e^{\\pi i n/T}-e^{-\\pi i n/T})=\\frac{1}{\\pi n}\\sin\\left(\\frac{\\pi n}{T}\\right).\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "b6ef623a-1338-413c-af6f-493394847b4f",
"metadata": {},
"source": [
"Przypomnijmy, że idea jest następująca: wielkość $|c_n|$ mierzy zatem \"jaki udział\" w rozkładzie $f$ na prostsze kawałki ma ten o częstotliwości $n/T$.\n",
"Poniżej zobaczymy zbiór punktów o współrzędnych \n",
"\n",
"$$\n",
"\\left(\\frac{n}{T}, T c_n\\right).\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b5e26fa7-efbc-4093-9e97-2dbdfabccf08",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/sd/yf84dc5d32vcg5xdf0mng9xw0000gn/T/ipykernel_1001/2269295719.py:12: RuntimeWarning: divide by zero encountered in divide\n",
" y_values = np.where(n_values != 0, (T / (np.pi * n_values)) * np.sin(np.pi * n_values / T), 0)\n",
"/var/folders/sd/yf84dc5d32vcg5xdf0mng9xw0000gn/T/ipykernel_1001/2269295719.py:12: RuntimeWarning: invalid value encountered in multiply\n",
" y_values = np.where(n_values != 0, (T / (np.pi * n_values)) * np.sin(np.pi * n_values / T), 0)\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3IAAAIhCAYAAAALuogMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAABv20lEQVR4nO3deXwTdf7H8XcopVDEytkW5FIRuVQEuVygVTnKURQFdLWCgoqoCHgBrj9Bl0NUKLJerEjFA9AtSF1RLNoCLoeCwKogonKJrQhCQZASwvz+6BJ7t2knmU7m9Xw8+oBMJpN3vt9MMp/Md2ZchmEYAgAAAADYRiWrAwAAAAAAfEMhBwAAAAA2QyEHAAAAADZDIQcAAAAANkMhBwAAAAA2QyEHAAAAADZDIQcAAAAANkMhBwAAAAA2QyEHAAAAADZDIQcAKJOkpCS5XC7vX+XKlXX++efr9ttv1/79+73zpaeny+VyKT093efnWLt2rSZNmqQjR46YF/x/Fi9erFatWqlatWpyuVzasm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PN954o+6991799ttvll+DDwCCEXvkAAABValSJc2YMUO33HKL+vXrp7vvvlvZ2dl65plndOTIEU2fPt07b5s2bSRJs2fP1tChQxUaGqrmzZurRo0a5VquL1q3bi1Jmjt3rmrUqKGqVauqadOmhQ6pLMqYMWOUnJysbt26aezYsbr00kt15swZ7d27Vx9//LEefPBBdezYsUz5zho7dqwWLFigvn376sknn1Tjxo31wQcf6MUXX9Q999xT5AXPfdWmTRstWrRIixcv1gUXXKCqVauqTZs26t+/v/eagnXr1tWePXuUmJioxo0bq1mzZqY8NwDgTxRyAICA++tf/6rq1atr2rRpGjJkiEJCQtSpUyelpaWpS5cu3vliYmI0YcIEvf766/rnP/+pM2fOKC0trcjrvpV2ub5o2rSpEhMTNXv2bMXExMjj8Wj+/PkaNmxYqZdRvXp1rVmzRtOnT9fcuXO1a9cuVatWTY0aNdK1115ryh65unXrau3atZowYYImTJigo0eP6oILLtCMGTM0bty4ci//rMmTJysjI0N33nmnjh07psaNG2v37t2KjY1VcnKyXn31VR09elRRUVHq0aOHHn/88SKPDQQAlJ3LMMp48RoAAAAAgCU4Rg4AAAAAbIZCDgAAAABshkIOAAAAAGzGVoXc6tWr1b9/f9WvX18ul0vvvfdesfOnp6fL5XIV+Pv222/zzJecnKyWLVsqLCxMLVu21NKlS/34KgAAAACgfGxVyB0/flyXXXaZ/vGPf/j0uB07digjI8P7l/s0yOvWrdOQIUOUkJCgrVu3KiEhQYMHD9aGDRvMjg8AAAAAprDtWStdLpeWLl2q6667rsh50tPTFRsbq8OHD+u8884rdJ4hQ4bo6NGj+vDDD73TevfurZo1a2rhwoUmpwYAAACA8nPEdeTatm2rkydPqmXLlvrb3/6m2NhY733r1q3T2LFj88zfq1cvJSYmFrm87OxsZWdne2+fOXNGv/32m2rXri2Xy2V6fgAAAAD2YBiGjh07pvr166tSJf8NgAzqQi46Olpz585Vu3btlJ2drTfeeEPXXHON0tPT1a1bN0lSZmamIiMj8zwuMjJSmZmZRS532rRpmjx5sl+zAwAAALCvffv26fzzz/fb8oO6kGvevLmaN2/uvd25c2ft27dPzz77rLeQk1RgL5phGMXuWZswYYLGjRvnvZ2VlaVGjRrpu+++U61atUx8BSgtt9uttLQ0xcbGKjQ01Oo4jkQfWI8+sJbb7Vbfvn31wQcf0P4WYR2wHn1gPfrAer/99psuvvhi1ahRw6/
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Set the value of T\n",
"T = 10 # You can change this to any other positive value you want\n",
"\n",
"# Create a range for n from -10*T to T\n",
"n_values = np.arange(-10*T, 10*T + 1, 1) # Use np.arange to include T\n",
"\n",
"# Calculate x and y coordinates\n",
"x_values = n_values / T\n",
"y_values = np.where(n_values != 0, (T / (np.pi * n_values)) * np.sin(np.pi * n_values / T), 0)\n",
"\n",
"# Create the plot\n",
"plt.figure(figsize=(10, 6))\n",
"plt.plot(x_values, y_values, 'bo', markersize=2) # 'bo' for blue circles only\n",
"plt.title('Plot of the Points')\n",
"plt.xlabel('n/T')\n",
"plt.ylabel('1/(πn) * sin(πn/T)')\n",
"plt.axhline(0, color='black', linewidth=0.5, ls='--')\n",
"plt.axvline(0, color='black', linewidth=0.5, ls='--')\n",
"plt.grid()\n",
"plt.ylim([-0.5, 1.5]) # Set limits for better visualization\n",
"plt.xlim([-10, 10]) # Adjust according to your needs\n",
"plt.show()\n"
]
},
{
"cell_type": "markdown",
"id": "225fac2e",
"metadata": {},
"source": [
"## Transformata Fouriera"
]
},
{
"cell_type": "markdown",
"id": "82d6b948",
"metadata": {},
"source": [
"***Transformatą Fouriera*** funkcji $f$ nazywamy funkcję $F$ określoną wzorem:\n",
"\n",
"$$\n",
"F(x) = \\int_{-\\infty}^{\\infty} f(t) e^{-i x t} \\, dt .\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "bb1286ff",
"metadata": {},
"source": [
"***Uwaga:*** Jeżeli \n",
"$$\\int\\limits_{-\\infty}^{\\infty}|f(x)|dx<\\infty,$$ to\n",
"funkcja $F(x)$ jest poprawnie określona i jest jednostajnie ciągła."
]
},
{
"cell_type": "markdown",
"id": "c6792098-e423-4eda-803a-5ea25b8dc098",
"metadata": {},
"source": [
"## Zadanie 1\n",
"\n",
"Niech $f$ będzie funkcją taką, że $f(x)=1$ dla $|x|\\leq 1/2$ i $0$ dla $|x|>1/2$. Policzymy jej transformatę Fouriera."
]
},
{
"cell_type": "markdown",
"id": "c1de9622-d10e-4cc5-878b-57da84fc4880",
"metadata": {},
"source": [
"***Rozwiązanie:***\n",
"\n",
"Mamy:\n",
"\n",
"$$\n",
"F(0)=\\int_{-\\infty}^{\\infty} f(t)\\, dt=\\int_{-1/2}^{1/2}1dt=1\n",
"$$\n",
"a dla $x\\not =0$\n",
"mamy\n",
"\n",
"$$\n",
"F(x)=\\int_{-\\infty}^{\\infty} f(t)e^{-ixt}\\, dt=\\int_{-1/2}^{1/2}e^{-ixt}dt=\\frac{1}{-ix}e^{-ixt}\\bigg|_{-1/2}^{1/2}\n",
"=\\frac{1}{-ix}\\left(e^{-ix/2}-e^{ix/2} \\right)=\\frac{2\\sin(x/2)}{x}.\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "4c010520-1fd7-4cfa-9cdd-82d4e6584d16",
"metadata": {},
"source": [
"***Uwaga:*** porównaj poniższy wykres z tym co było poprzednio. Zmiana skali na osi \"x\" wzięła się z przyjętej przez nas definicji transformaty Fouriera."
]
},
{
"cell_type": "code",
"execution_count": 90,
"id": "45863f7e-df74-4736-a49b-adb8af3e2092",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3AAAAIpCAYAAADjHNpcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB8cElEQVR4nO3dd3gU1RrH8d+m0osESOggVUCqNEVARQQBFcWCIogVBQRE7AIqFmzYFUVAEEQUkStYwAuKdBCQJuClQ+gQerJJzv1jTDZLCrvJbIZsvp/n2Sezk5kz787s7M6758w5LmOMEQAAAADgghfidAAAAAAAAN+QwAEAAABAHkECBwAAAAB5BAkcAAAAAOQRJHAAAAAAkEeQwAEAAABAHkECBwAAAAB5BAkcAAAAAOQRJHAAAAAAkEeQwAEAAABAHkECBwDIFfHx8brnnntUsWJFFStWTC1atNCiRYvOu17dunW1ePFin7fz6KOPauLEidmOMzExUfXr19f+/fuzXQYAAIFCAgcAyBWJiYmqWrWqFi5cqGPHjqlv377q2rWrTp8+neV669evV8uWLX3axr59+/TDDz/ojjvuyHacYWFhuvfeezVq1KhslwEAQKCQwAEAckXhwoX1/PPPq1KlSgoJCVGvXr2UnJysLVu2KDk5WQMGDFBUVJSKFSumxo0b69ChQ5KkKlWq6I8//pAkuVwuffLJJ6pWrZpKlSqlF1980WsbX3zxhbp27aqwsDCdOnVKhQsXVlhYmIoUKaIiRYooJCREhQsX1tGjR/XII4/o3nvvlSQlJyfrhhtu0IABAyRJt99+uyZOnCi3252LewgAgPMjgQMAOOLvv//WmTNndPHFF+uXX37RokWLtHXrVh07dkyfffaZChQokOF6//3vf/XXX39pwYIFeuWVV7R58+bU//3000+68sorJVkJ42uvvabu3bvr5MmTOnLkiMLCwrRnzx6VLFlSTz31lL7++mvt3LlTTz75pJKSkvT2229LkqKjo1WyZEmtWLEi8DsCAAA/kMABAHLd6dOn1bNnTz377LMqUqSIwsPDdeLECf39999yuVxq3LixihQpkuG6TzzxhIoUKaJLLrlEDRs21F9//ZX6v7Vr16pGjRqpz9etW6d69epJshLGMmXKqESJEpKkChUq6O6771bXrl31yy+/6KuvvlJoaGjqurVr1/YqGwCACwEJHAAgV7ndbt1666265JJL9PTTT0uSrr76aj300EN64IEHFBMToyFDhmTafLFMmTKp04UKFdLJkydTnx87dswr8Vu3bp3q168vSfrrr79Ut25dr7IaNmyoNWvW6KOPPkqXMBYtWlRxcXE5e7EAANiMBA4ALgDjx4+Xy+VKfYSFhalChQq65557tGfPnnTLbd++3a/yFy1apOHDh+vYsWP2Bi5p6tSpqlu3rgoWLCiXy6XVq1dnumxycrLuvvtuhYaGauzYsXK5XKn/GzRokFavXq1ly5bpp59+0pdfful3LMWLF/dK6NavX59aA7d27VqvBG7ZsmUaMWKEunfvrgkTJqQr68SJEypevLjP2/ZnP1zITpw4oaFDh+raa69V6dKl5XK5NHz48AyXPXnypAYOHKhy5cqpQIECatiwob766iufthOo96Q/8Us5ew0A4AQSOAC4gIwbN06LFy/WnDlzdP/992vKlClq3bq1Tp06laNyFy1apBEjRth+sXzw4EH17NlTF198sX766SctXrxYNWvWzHT5Bx98ULGxsZo6darCwsJS569YsULLly9XYmKiihUrpoiICK/mjL6qX7++tmzZIknas2eP3G63qlatKknatGlTavPKnTt36pZbbtGkSZP0zjvvaPLkydqxY4dXWZs2bUqtvTsff/fDhezw4cMaM2aM4uPjdeONN2a5bLdu3TRhwgQNGzZMP/74oy677DLdcccdmjx58nm3E6j3pD/xSzl7DQDghLDzLwIAyC316tVT06ZNJUnt2rVTUlKSXnzxRc2YMUN33nmnw9Glt3nzZrndbt11111q06ZNlsvu2LEjtXOSqKio1Pk//vijEhISNHDgQG3btk2FCxfWrbfeqh49evgdz3XXXacFCxbopptu0vr163XJJZek1vKVL19eb731ljp16qQuXbpo2LBhatu2rSTprrvu0ksvvaRPP/1UkrR//34dPnw49VjYuR9Onz6tQoUK+f3ackvlypV19OhRuVwuHTp0SJ999lmGy82ePVtz5szR5MmTU4dtaNeunXbs2KHHH39ct912W7aS8JzyNX7pwn0NAJAlAwBw3Lhx44wks3z5cq/5s2bNMpLMyJEjvZbbtm1b6jILFiwwV111lSlSpIgpWLCgadmypfnhhx9S/z9s2DAjKd1j3rx5WcZ0vnJ79eqVrsw2bdrkeF/kxN69e021atVMYmJijsoZPXq0GTRokE/LZrUfUvb9ypUrzc0332xKlChhoqOjU9c93z5OW8aaNWvMLbfcYooVK2ZKlixpBg0aZNxut/n7779Nhw4dTJEiRUzlypXNa6+9lqPXntbBgweNJDNs2LB0/7vvvvtMkSJFjNvt9po/efJkI8ksXLgw03J9eU/6sm9yEn9OXwMAOIUmlABwAfvnn38kSaVLl87w/7/99puuuuoqxcXFaezYsZoyZYqKFi2qLl26aOrUqZKk++67T/3795ckTZ8+XYsXL9bixYvVuHHjTLfrS7nPPfecPvjgA0nSyy+/rMWLF+vDDz+07bVnR0xMjDp37pyj5m+JiYn67LPPNHToUJ+W92U/dOvWTdWrV9e0adP08ccfS/JtH6d16623qkGDBvr22291//336+2339agQYN044036vrrr9d3332nq666Sk888YSmT5+e7dfvq3Xr1qlOnTpeTWEl6dJLL039f2bO9570d9848RoAwDFOZ5AAAE/N2pIlS4zb7TYnTpwwP/zwgyldurQpWrSo2bdvn9dyKTVwLVq0MGXKlDEnTpxILSsxMdHUq1fPVKhQwSQnJxtjjHn99dfT1dxlxddy582bZySZadOm2bAX8q7M9kNKTdPzzz+fbh1f93FKGW+++abX+g0bNjSSzPTp01Pnud1uU7p0adOtWzdbXldWNVg1atQwHTp0SDd/7969RpJ5+eWXsyw7q/ekr/smJ/Hb8RoAwAnUwAHABaRFixYKDw9X0aJF1blzZ0VHR+vHH39U2bJl0y176tQpLV26VLfccotXF/ihoaHq2bOndu/erU2bNvkdQ6DKzc9uvvlmr+fZ2cedO3f2el6nTh25XC517NgxdV5YWJiqV6+erkOWjCQmJno9jDF+v660vYj687+s5Pb7LxCvAQACiU5MAOAC8sUXX6Q26SpbtqxiYmIyXfbo0aMyxmS4TLly5SRZPfL5K1Dl5mfn7svs7OOLLrrI63lERIQKFSqkAgUKpJt//PjxLOPZvn17au+cKebNm5faqYsvSpUqleH74MiRIxnG66vcfP8F6jUAQCCRwAHABaROnTo+93xYsmRJhYSEKDY2Nt3/9u7dK0levT36KlDlBkNtRnZqqaT0rz1Q+9hX5cqV0/Lly73m1apVy68y6tevrylTpigxMdHrHrK1a9dKUur4e/7KzX0TqNcAAIFEE0oAyKMKFy6s5s2ba/r06Tpz5kzq/OTkZE2aNEkVKlRIHYssMjJSkryWs6NcfxhjbH88/PDD6tOnj4wxSkpKUteuXdW/f/+AbCu7yVtu7mNfRUREqGnTpl6PokWL+lXGTTfdpJMnT+rbb7/1mj9hwgSVK1dOzZs3z3L9zN6TublvcvoaAMAJ1MABQB72yiuvqH379mrXrp2GDBmiiIgIffjhh1q3bp2mTJmSWvOTMiD1O++8o169eik8PFy1atXK9KLd13Kd9tRTT6lOnToaNmyY3n//fSUlJentt992OiyfXMj7+Mcff9SpU6d04sQJSdKGDRv0zTffSJI6deqkQoUKqWPHjmrfvr369u2r48ePq3r16poyZYp++uknTZo06bzjp2X1nszpvvElfkk5fg0A4Ai7e0UBAPgvs3HgMlsuo3HgChcubAoWLGhatGh
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Define the range for x from -10 to 10\n",
"x_values = np.linspace(-100, 100, 400)\n",
"\n",
"# Calculate y values while handling the singularity at x = 0\n",
"y_values = np.where(x_values != 0, (2 * np.sin(x_values / 2)) / x_values, 1) # Limit as x->0 is 1\n",
"\n",
"# Create the plot\n",
"plt.figure(figsize=(10, 6))\n",
"plt.plot(x_values, y_values, 'b-', lw=2) # 'b-' for blue line\n",
"plt.title(r'Plot of $\\frac{2\\sin(\\pi x)}{x}$ from -10 to 10')\n",
"plt.xlabel('x')\n",
"plt.ylabel(r'$\\frac{2\\sin(x/2)}{x}$')\n",
"plt.axhline(0, color='black', linewidth=0.5, ls='--')\n",
"plt.axvline(0, color='black', linewidth=0.5, ls='--')\n",
"plt.grid()\n",
"plt.ylim([-1.5, 1.5]) # Set limits for better visualization\n",
"plt.xlim([-100, 100]) # Set x-axis range\n",
"plt.show()\n"
]
},
{
"cell_type": "markdown",
"id": "858bb5bb-3a0a-4278-809f-a7db69485c64",
"metadata": {},
"source": [
"## Zadanie 2\n",
"Niech $f\\colon\\mathbb{R}\\to\\mathbb{R}$ będzie funkcją różniczkowalną taką, że $f$ ma wartość $0$ poza przedziałem $[a,b]$.\n",
"Niech $F$ będzie transformatą Fouriera dla funkcji $f$. Wyznaczymy transformatę Fouriera funkcji $f'$."
]
},
{
"cell_type": "markdown",
"id": "bd2e6695-f678-4e35-ae48-c13d9b7d15ad",
"metadata": {},
"source": [
"##### Rozwiązanie:\n",
"\n",
"Z definicji transformata Fouriera funkcji $f'$ w punkcie $x$ jest równa\n",
"\n",
"$$\n",
"\\int_{-\\infty}^\\infty f'(t)e^{-ixt}dt=\\int_a^bf'(t)e^{-ixt}dt.\n",
"$$\n",
"\n",
"Ze wzoru na całkowanie przez części otrzymujemy, że \n",
"\n",
"$$\n",
"\\int f'(t)e^{-ixt}dt=f(t)e^{-ixt}+ix \\int f(t)e^{-ixt}dt\n",
"$$\n",
"\n",
"Zatem (ponieważ $f(a)=0$ i $f(b)=0$) \n",
"\n",
"$$\n",
"\\int_{-\\infty}^\\infty f'(t)e^{-ixt}dt=\\int_b^b f'(t)e^{-ixt}dt=f(t)e^{-ixt}|_a^b+ix \\int_a^b f(t)e^{-ixt}dt\n",
"=ix\\int_{-\\infty}^\\infty f(t)e^{-ixt}dt=ixF(x). \n",
"$$\n"
]
},
{
"cell_type": "markdown",
"id": "9340dd72-fb0f-4a24-898e-9eb4ebd154d8",
"metadata": {},
"source": [
"***Uwaga:*** powyższa obserwacja ma fundamentalne znaczenie dla równań różniczkowych: transformata Fouriera zamienia różniczkowanie na \n",
"operację mnożenia przez wielomian."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e4033200-249e-4fda-9991-75b60e0c43c2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 5
}