Skip to content

Commit

Permalink
TL: minor corrections and final comment for gfm note 4
Browse files Browse the repository at this point in the history
  • Loading branch information
tlunet committed Sep 8, 2022
1 parent 84976b1 commit 19a3866
Showing 1 changed file with 48 additions and 23 deletions.
71 changes: 48 additions & 23 deletions notes/GFM_Note-4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"cells": [
{
"cell_type": "markdown",
"id": "1fe10a3b",
"id": "baab4555",
"metadata": {},
"source": [
"### Two approaches for defining a collocation method"
]
},
{
"cell_type": "markdown",
"id": "64950dbe",
"id": "8a85460d",
"metadata": {},
"source": [
"The collocation method solves the Dahlquist problem by solving the Picard form of the ODE :\n",
Expand All @@ -19,13 +19,13 @@
"\n",
"using a quadrature rule on some (normalized) nodes $\\tau_1, ..., \\tau_M \\in [0, 1]$ to approximate the integral.\n",
"\n",
"Those nodes can be all strictly contained in $[0,1]$ ($\\tau_1 > 0$, $\\tau_M < 1$ => GAUSS quadrature type), include only the left boundary ($\\tau_1 = 0$, $\\tau_M < 1$ => RADAU-I quadrature type), include only the right boundary ($\\tau_1 > 0$, $\\tau_M = 1$ => RADAU-II quadrature type) or both ($\\tau_1 = 0$, $\\tau_M = 1$ => LOBATTO quadrature type).\n",
"Those nodes can be all strictly contained in $[0,1]$ ($\\tau_1 > 0$, $\\tau_M < 1$ => GAUSS), include only the left boundary ($\\tau_1 = 0$, $\\tau_M < 1$ => RADAU-I), include only the right boundary ($\\tau_1 > 0$, $\\tau_M = 1$ => RADAU-II) or both ($\\tau_1 = 0$, $\\tau_M = 1$ => LOBATTO). Those four approaches define a given _quadrature type_, that can be simply considered as an additional parameter of the collocation method.\n",
"\n",
"This produces the following discrete equation on each nodes solution :\n",
"Now using the quadrature rule we obtain a discrete equation for the solution on each nodes :\n",
"\n",
"$$u(\\tau_m) = u(t_0) + \\int_{t_0}^{\\tau_m} \\lambda u(\\tau)d\\tau$$\n",
"\n",
"which provides the algebraic system :\n",
"and combining all of them in algebraic form gives :\n",
"\n",
"$$(I-\\lambda\\Delta{t}Q) \n",
"\\begin{pmatrix} u(\\tau_1)\\\\ \\vdots\\\\ u(\\tau_M) \\end{pmatrix}\n",
Expand Down Expand Up @@ -90,14 +90,14 @@
"\n",
"$$u(t_1) = u(t_0) + \\int_{t_0}^{t_1} \\lambda u(\\tau)d\\tau$$\n",
"\n",
"Now instead of approximating the solution by a polynomial, we approximate the integral instead using the quadrature rule defined by the nodes :\n",
"Here instead of approximating the solution by a polynomial, we approximate the integral instead using the quadrature rule defined by the nodes :\n",
"\n",
"$$u(t_1) = u(t_0) + \\sum_{i=1}^{M} \\omega_i u(\\tau_i),$$\n",
"\n",
"with $\\omega$ the quadrature weights that can be computed directly from the nodes (for instance, by integrating the Lagrange interpolating polynomials).\n",
"with $\\omega_i$ the quadrature weights that can be computed directly from the nodes (for instance, by integrating the Lagrange interpolating polynomials, or simply by getting the Gauss quadrature rule).\n",
"\n",
"Here we need $u(t_0)$, which implies that $u(t_1)$ must be considered as an unknown of the collocation problem, similarly as any other $u(\\tau_i)$.\n",
"So our block vector is then $\\begin{pmatrix} u(\\tau_1), \\dots, u(\\tau_M), u(t_1) \\end{pmatrix}^T$ and **necessarily include the end-point solution, independent from the quadrature type** (that is, even when using GAUSS points !).\n",
"So our block vector is then $\\begin{pmatrix} u(\\tau_1), \\dots, u(\\tau_M), u(t_1) \\end{pmatrix}^T$ and **necessarily include the end-point solution, independent from the quadrature type** (that is, even if we use GAUSS points !).\n",
"\n",
"This implies that \n",
"\n",
Expand All @@ -121,13 +121,13 @@
"\n",
"Note that with $M$ nodes, we get now $(M+1 \\times M+1)$ matrices for the block operators.\n",
"\n",
"> **Now if we use both approaches to integrate the Dahlquist problem with a given number of quadrature nodes $M$, what is the order of accuracy in function of $M$ and the quadrature type (GAUSS, LOBATTO, ...)**"
"> **Question : if we use both approaches to integrate the Dahlquist problem with a given number of quadrature nodes $M$, what is the order of accuracy in function of $M$ and the quadrature type (GAUSS, LOBATTO, ...)**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "37b6cc1e",
"id": "64bc7aec",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -140,7 +140,7 @@
},
{
"cell_type": "markdown",
"id": "011ed439",
"id": "beb9b1c3",
"metadata": {},
"source": [
"Let's define a function below that computes the global error on a given interval $[0,T]$, with default value for $T=2\\pi$, and $\\lambda=i$.\n",
Expand All @@ -155,7 +155,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "686d47b1",
"id": "a6fc2faa",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -188,7 +188,7 @@
},
{
"cell_type": "markdown",
"id": "6c666e8f",
"id": "c6a846fa",
"metadata": {},
"source": [
"Now lets look at the first approach (exactProlong=False, default value) for Legendre nodes and each of the four quadrature types :"
Expand All @@ -197,7 +197,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "2f4c1c1f",
"id": "8234e62f",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -231,7 +231,7 @@
},
{
"cell_type": "markdown",
"id": "fe4b3038",
"id": "e2d2bda4",
"metadata": {},
"source": [
"We can see the following order of accuracy depending on the quadrature type :\n",
Expand All @@ -244,13 +244,13 @@
"\n",
"For LOBATTO and RADAU-II, this is however different : we don't really use a barycentric interpolation of order $M-1$, because by copying the end-point value we actually use an \"exact\" interpolation. So the limiting accuracy is the one of the quadrature rule, and since we used LEGENDRE nodes, we retrieve the expected order of accuracy for LOBATTO and RADAU-II nodes.\n",
"\n",
"Now is it the same with the second approach ? Let just store the error for LOBATTO here, and go back at it later ..."
"Is it the same with the second approach ? Let just store the error for LOBATTO here, and go back at it later ..."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6ec7f38c",
"id": "f6f32e7f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -259,7 +259,7 @@
},
{
"cell_type": "markdown",
"id": "9fbad3b2",
"id": "d8e88185",
"metadata": {},
"source": [
"Now lets look at the second approach (exactProlong=True) for Legendre nodes and each of the four quadrature types :"
Expand All @@ -268,7 +268,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "d5a03204",
"id": "5b21566a",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -302,7 +302,7 @@
},
{
"cell_type": "markdown",
"id": "f8dea12d",
"id": "d2f29789",
"metadata": {},
"source": [
"Now we retrieve the expected order of accuracy for each quadrature type, that is :\n",
Expand All @@ -318,7 +318,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "4419a1d4",
"id": "fffd705e",
"metadata": {},
"outputs": [
{
Expand All @@ -344,10 +344,35 @@
},
{
"cell_type": "markdown",
"id": "87cbb7c7",
"id": "e09f7d43",
"metadata": {},
"source": [
"We retrieve exactly the same error up to machine precision, which would indicate that the two approaches are probably equivalent for LOBATTO and RADAU-II nodes."
"We retrieve exactly the same error up to machine precision, which indicates that the two approaches are probably equivalent when the last node coincide with the end-point.\n",
"\n",
"This is actually not hard to prove theoretically. If we look at the two last lines of the following system :\n",
"\n",
"$$\n",
"\\begin{pmatrix} \n",
"(I-\\lambda\\Delta{t}Q) & 0 \\\\\n",
"-\\lambda\\delta{t}{\\bf w} & 1\n",
"\\end{pmatrix}\\begin{pmatrix} u(\\tau_{i}) \\\\ u(t_1) \\end{pmatrix}\n",
"= \\begin{pmatrix} u(t_0) \\\\ u(t_0) \\end{pmatrix}\n",
"$$\n",
"\n",
"we get\n",
"\n",
"$$\n",
"u(t_M) - \\lambda\\sum_{i=1}^{M} q_{M,i} u(\\tau_i) = u(t_0) \n",
"\\\\\n",
"u(t_1) - \\lambda\\sum_{i=1}^{M} \\omega_i u(\\tau_i) = u(t_0) \n",
"$$\n",
"\n",
"Since $t_M=t_1$, then the integral up to this node is actually the integral for the whole interval, hence we simply get the standard quadrature rule, _i.e_ $q_{M,i}=\\omega_i$. \n",
"Now substracting both equation leads to\n",
"\n",
"$$ u(t_M) = u(t_1) $$\n",
"\n",
"so the solution $u(t_M)$ of the collocation problem coincides with the initial value for the next interval, so the last line of the system can be removed to get back the formulation of the first approach."
]
}
],
Expand Down

0 comments on commit 19a3866

Please sign in to comment.