From a4954879d5239ab1d357882804992ae427315ef3 Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:12:31 +0100 Subject: [PATCH 01/15] First attempt to port Chebyshev documentation. --- docs/src/chebyshev.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/src/chebyshev.md diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md new file mode 100644 index 000000000..e69de29bb From 65c36b0b1df804db89e366185c663e2ed420ba1a Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:15:54 +0100 Subject: [PATCH 02/15] Add Chebyshev documentation to .md file. --- docs/src/chebyshev.md | 251 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index e69de29bb..e5f3b17f2 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -0,0 +1,251 @@ +Chebyshev tranform via Fourier transform +=============================================== + +```math +\begin{equation} +\end{equation} +``` +We express a function $f$ as a sum of Chebyshev polynomials +```math +\begin{equation} f(x) = \sum^N_{n=0} a_{n}T_n(x)\label{eq:cheb-expansion}\end{equation} +``` +The Chebyshev polynomials are defined by +```math +\begin{equation} T_n(\cos \theta) = \cos n \theta, {\rm~with~}x = \cos \theta. \end{equation} +``` +We can see how to find $\{a_{n}\}$ given $\{f(x_j)\}$ via Fourier transform. +The Fourier series representation of $f$ on a uniform grid indexed by $j$ is defined by +```math +\begin{equation} f_j = \sum_{k=0}^{M-1} b_{k}\exp\left[i \frac{2\pi k j}{M}\right].\label{eq:fourier-series}\end{equation} +``` + +Gauss-Chebyshev-Lobotto points +=============================================== + +We pick points +```math +\begin{equation} x_j = \cos \theta_j, \quad \theta_j = \frac{j \pi}{N} \quad 0 \leq j \leq N.\end{equation} +``` +Then +```math +\begin{equation} T_n{x_j} = \cos \frac{n j \pi}{N}.\end{equation} +``` +Assuming that $M = 2N$, with $N$ an integer, and $b_{k} = b_{M-k}$ for $k>0$, we have that +```math +\begin{equation} f_j = b_{0} + b_{N}(-1)^j + \sum_{n=1}^{N-1} +b_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right).\end{equation} +``` +Comparing this to the expression for $f(x_j)$ in the Chebyshev representation, +using the form of $T_n(x_j)$, +```math +\begin{equation} f_j = a_{0} + a_{N}(-1)^j + \frac{1}{2}\sum_{n=1}^{N-1} +a_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right),\end{equation} +``` +we find that the Chebyshev representation on the Chebyshev points is equivalent +to the Fourier representation on the uniform grid points, if we identify +```math +\begin{equation} b_{0} = a_{0}, \quad b_{N} = a_{N}, \quad b_{j} = \frac{a_{j}}{2} {\rm~for~} 1 \leq j \leq N-1. \end{equation} +``` +This fact allows us to carry out the Chebyshev tranform by Fourier transforming the $\{f_j\}$ data +and carrying out the correct normalisation of the resulting coefficients. + +Gauss-Chebyshev-Radau points +=============================================== + +The last subsection dealt with grids which contain both endpoints on the $[-1,1]$ domain. +Certain problems require domains which contain a single endpoint, i.e., $x \in (-1,1]$. For +these cases we choose the points +```math +\begin{equation} x_j = \cos \theta_j, \quad \theta_j = \frac{2 j \pi}{2 N + 1} \quad 0 \leq j \leq N.\end{equation} +``` +Writing out the Chebyshev series \eq{eq:cheb-expansion}, +we have that +```math +\begin{equation} \begin{split} f(x_j) = & \sum^N_{n=0} a_{n} \cos \frac{2 n j \pi}{2 N + 1} \\ & = a_{0} + \sum^N_{n=1} \frac{a_{n}}{2}\left(\exp\left[i \frac{2\pi n j}{2N +1}\right] + \exp\left[-i \frac{2\pi n j}{2N +1}\right]\right).\end{split} \label{eq:cheb-expansion-radau-points}\end{equation} +``` +The form of the series \eq{eq:cheb-expansion-radau-points} is identical to the form of +a Fourier series on an odd number of points, i.e., taking $M = 2 N + 1$ in equation \eq{eq:fourier-series}, +and assuming $b_{k} = b_{M -k}$ for $k>1$, +we have that +```math +\begin{equation} f_j = b_{0} + \sum_{k=1}^{N} b_{k}\left(\exp\left[i \frac{2\pi k j}{2N+1}\right] + \exp\left[-i \frac{2\pi k j}{2N+1} \right]\right). \end{equation} +``` +We can thus take a Chebyshev transform using a Fourier transform on Gauss-Chebyshev-Radau points if we identify +```math +\begin{equation} b_{0} = a_{0}, \quad b_{j} = \frac{a_{j}}{2} {\rm~for~} 1 \leq j \leq N. \end{equation} +``` + +Chebyshev coefficients of derivatives of a function +=============================================== + +Starting from the expression of $f$ as a sum Chebyshev polynomials, equation \eq{eq:cheb-expansion}, +we can obtain an expression for the derivative +```math \begin{equation} +\frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}. \label{eq:derivative-def}\end{equation} +``` +We note that we must be able to express ${d f}/{d x}$ as a sum +of Chebyshev polynomials of up to order $N-1$, i.e., +```math +\begin{equation} \frac{d f}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}. \end{equation} +``` +We must determine the set $\{d_{n}\}$ in terms of the set $\{a_{n}\}$. +First, we equate the two expressions to find that +```math +\begin{equation} \sum^N_{k=0} a_{k}\frac{d T_{k}}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}. \label{eq:dn-def}\end{equation} +``` +We use the Chebyshev polynomials of the second kind $U_n{x}$ to aid us in the calculation of the set $\{d_{n}\}$. +These polynomials are defined by +```math +\begin{equation} U_{0}(x) = 1, \quad U_{1}(x) = 2x, \quad U_{n+1} = 2 x U_{n}(x) - U_{n-1}(x).\end{equation} +``` +Note the useful relations +```math +\begin{equation} \frac{d T_{n}}{d x} = n U_{n-1}, {\rm~for~}n\geq 1, \quad \frac{d T_{0}}{d x} = 0,\end{equation} +``` +```math +\begin{equation} T_{n} = \frac{1}{2}\left(U_{n} - U_{n -2}\right), T_{0} = U_{0}\quad, {\rm ~and~} \quad 2 T_{1} = U_{1}. \end{equation} +``` +Using these identities, which may be obtained from the trigonometric definition of $U_{n}(\cos \theta)$ +```math +\begin{equation} U_{n}(\cos \theta) \sin \theta = \sin \left((n+1)\theta\right),\end{equation} +``` +we find that equation \eq{eq:dn-def} becomes +```math +\begin{equation} \begin{split}\sum^N_{n=1} a_{n} n U_{n-1}(x) =& \frac{d_{N-1}}{2}U_{N-1}+\frac{d_{N-2}}{2}U_{N-2} +\\ & + \sum^{N-3}_{k=1} \frac{d_{k}-d_{k+2}}{2}U_{k} + \left(d_{0} - \frac{d_{2}}{2}\right)U_{0}. \end{split} +\label{eq:dn-def-U}\end{equation} +``` +Using the orthogonality relation +```math +\begin{equation} \int^1_{-1} U_{m}(x)U_{n}(x)\sqrt{1-x^2} \; d x = +\left\{\begin{tabular}{l} $0 {\rm ~if~} n\neq m $ \\ $\pi/2 {\rm ~if~} n=m$ \end{tabular}\right.,\end{equation} +``` +we obtain the (unqiuely-determined) relations +```math +\begin{equation} \begin{split} &d_{N-1} = 2Na_{N},\quad d_{N-2} = 2(N-1)a_{N-1}, \\ +& d_{k} = 2(k+1) a_{k+1} + d_{k+2}, \quad d_{0} = \frac{d_{2}}{2} + a_{1}.\end{split} \label{eq:dn-result-U}\end{equation} +``` +Note the lack of a second relation for $d_{0}$, but that otherwise the expressions \eq{eq:dn-result-U} +agree with those of the last section. + +Clenshaw-Curtis integration weights +=============================================== + +We require the integration weights for the set of points $\{x_j\}$ chosen +in our numerical scheme. The weights $w_{j}$ are defined implicitly by +```math +\begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{j=0}^N f(x_j) w_{j}. \label{eq:w-sum}\end{equation} +``` +In the Chebyshev scheme we use the change of variables $x = \cos \theta$ +to write +```math +\begin{equation} \int^{1}_{-1} f(x) \; d x = \int^\pi_0 f(\cos\theta) \sin \theta \; d \theta . \label{eq:change-of-variables-integral} \end{equation} +``` + Using the series expansion \eq{eq:cheb-expansion} in equation \eq{eq:change-of-variables-integral} + we find that + ```math + \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum^N_{n=0} a_{n}\int^\pi_0 \cos (n \theta) \sin \theta \; d \theta + . \label{eq:series-integral} \end{equation} + ``` + Note the integral identity + ```math +\begin{equation} \int^\pi_0 \cos(n \theta) \sin \theta \; d \theta = \frac{\cos(n \pi) +1}{1 - n^2} {\rm~for~} n \geq 0.\end{equation} +``` + Also note that + ```math + \begin{equation} \frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{tabular}{l} $0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} $ \\ $2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z}$ \end{tabular}\right. \end{equation} + ``` + We define ```math + \begin{equation} \J_{n} = \frac{\cos(n \pi) +1}{1 - n^2}. \end{equation} + ``` + Using this definition, we can write the integral of $f(x)$ can be written + in terms of a sum over of the Chebyshev coefficients: + ```math + \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{n=0}^N \J_{n} a_{n}. \label{eq:Cheb-sum}\end{equation} + ``` + + To avoid computing the set of coefficients $\{a_{n}\}$ every time we wish to integrate $f(x_j)$, + we use the inverse transforms. This transform allows us to rewrite equation \eq{eq:Cheb-sum} in the form \eq{eq:w-sum}. + Since the inverse transform differs between the Gauss-Chebyshev-Lobotto and Gauss-Chebyshev-Radau cases, we treat each + case separately below. + +Weights on Gauss-Chebyshev-Lobotto points +=============================================== + We use the inverse transformation + ```math + \begin{equation} a_{n} = \frac{\q_{n}}{2N}\sum^{2N-1}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N}\right], \label{eq:inverse-transform-GCL}\end{equation} + ``` + where + ```math + \begin{equation} \q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n\neq0,N $ \\ $1 {\rm ~if~} n=0,N$ \end{tabular}\right.,\end{equation} + ``` +and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., +```math +\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j}){\rm~for~} N+1 \leq j \leq 2N-1. \end{equation} +``` + With this inverse tranformation, we can write +```math +\begin{equation} \begin{split}\sum_{n=0}^N \J_{n} a_{n} & = \sum^{2N-1}_{n=0} \frac{a_{n}\J_{n}}{\q_{n}} \\ + & = \sum^{2N-1}_{j=0}\sum^{2N-1}_{n=0} \frac{\hat{f}_j \J_{n}}{2N} \exp\left[-i \frac{2\pi n j}{2N}\right] \\ + & = \sum^{2N-1}_{j=0} \hat{f}_j \v_{j} = \sum^{N}_{j=0} \hat{f}_j \q_{j}\v_{j},\end{split}\label{eq:weights-working}\end{equation} +``` + where in the first step we have extended the sum from $N$ to $2N-1$ and used FFT-order definitions of $\J_{n}$ and $a_{n}$ +```math +\begin{equation} \J_{j} = \J_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1,\end{equation} +``` +```math +\begin{equation} a_{j} = a_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1.\end{equation} +``` +In the second step we use the definition of the inverse transform \eq{eq:inverse-transform-GCR}, and +in the third step we define +```math +\begin{equation} \v_{j} = \sum_{n=0}^{2N-1}\frac{\J_{n}}{2N}\exp\left[-i \frac{2\pi n j}{2N}\right].\end{equation} +``` +Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working} and deduce that +```math +\begin{equation} w_{j} = \q_{j}\v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} +``` +We can write $\v_{j}$ in terms of a discrete cosine transform, i.e., +```math +\begin{equation} \v_{j} = \frac{1}{2N}\left(\J_{0} + (-1)^j\J_{N} + 2\sum_{n=1}^{N-1}\J_{n}\cos\left(\frac{\pi n j}{N}\right)\right).\end{equation} +``` + +Weights on Gauss-Chebyshev-Radau points +=============================================== +We use the inverse transformation +```math +\begin{equation} a_{n} = \frac{\q_{n}}{2N+1}\sum^{2N}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N+1}\right], \label{eq:inverse-transform-GCR}\end{equation} +``` +where +```math +\begin{equation} \q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n > 0 $ \\ $1 {\rm ~if~} n=0$ \end{tabular}\right.,\end{equation} +``` +and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., +```math +\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j+1}){\rm~for~} N+1 \leq j \leq 2N. \end{equation} +``` +Note that the details of what is the appropriate FFT order depends on the order in which the points $x_j$ are stored. +The key detail in the Chebyshev-Radau scheme is that (in the notation above) +$x_0 = 1$ is not a repeated point, and must occupy $\hat{f}_0$. +With this inverse tranformation, we can write +```math +\begin{equation} \begin{split}\sum_{n=0}^N \J_{n} a_{n} & = \sum^{2N}_{n=0} \frac{a_{n}\J_{n}}{\q_{n}} \\ +& = \sum^{2N}_{j=0}\sum^{2N}_{n=0} \frac{\hat{f}_j \J_{n}}{2N+1} \exp\left[-i \frac{2\pi n j}{2N+1}\right] \\ +& = \sum^{2N}_{j=0} \hat{f}_j \v_{j} = \sum^{N}_{j=0} \hat{f}_j \q_{j}\v_{j},\end{split}\label{eq:weights-working}\end{equation} +``` +where in the first step we have extended the sum from $N$ to $2N$ and used FFT-order definitions of $\J_{n}$ and $a_{n}$ +```math +\begin{equation} \J_{j} = \J_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N,\end{equation} +``` +```math +\begin{equation} a_{j} = a_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N.\end{equation} +``` +In the second step we use the definition of the inverse transform \eq{eq:inverse-transform-GCR}, and +in the third step we define +```math +\begin{equation} \v_{j} = \sum_{n=0}^{2N}\frac{\J_{n}}{2N+1}\exp\left[-i \frac{2\pi n j}{2N+1}\right].\end{equation} +``` +Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working} and deduce that +```math +\begin{equation} w_{j} = \q_{j}\v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} +``` \ No newline at end of file From 957264f426fa92a6828e78bbbf11bcab2c0e2de1 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:21:15 +0100 Subject: [PATCH 03/15] Debug chebyshev.md --- docs/src/chebyshev.md | 54 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index e5f3b17f2..e70c5e339 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -28,7 +28,7 @@ We pick points ``` Then ```math -\begin{equation} T_n{x_j} = \cos \frac{n j \pi}{N}.\end{equation} +\begin{equation} T_n(x_j) = \cos \frac{n j \pi}{N}.\end{equation} ``` Assuming that $M = 2N$, with $N$ an integer, and $b_{k} = b_{M-k}$ for $k>0$, we have that ```math @@ -124,9 +124,7 @@ we obtain the (unqiuely-determined) relations ```math \begin{equation} \begin{split} &d_{N-1} = 2Na_{N},\quad d_{N-2} = 2(N-1)a_{N-1}, \\ & d_{k} = 2(k+1) a_{k+1} + d_{k+2}, \quad d_{0} = \frac{d_{2}}{2} + a_{1}.\end{split} \label{eq:dn-result-U}\end{equation} -``` -Note the lack of a second relation for $d_{0}$, but that otherwise the expressions \eq{eq:dn-result-U} -agree with those of the last section. +``` Clenshaw-Curtis integration weights =============================================== @@ -156,12 +154,12 @@ to write \begin{equation} \frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{tabular}{l} $0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} $ \\ $2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z}$ \end{tabular}\right. \end{equation} ``` We define ```math - \begin{equation} \J_{n} = \frac{\cos(n \pi) +1}{1 - n^2}. \end{equation} + \begin{equation} J_{n} = \frac{\cos(n \pi) +1}{1 - n^2}. \end{equation} ``` Using this definition, we can write the integral of $f(x)$ can be written in terms of a sum over of the Chebyshev coefficients: ```math - \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{n=0}^N \J_{n} a_{n}. \label{eq:Cheb-sum}\end{equation} + \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{n=0}^N J_{n} a_{n}. \label{eq:Cheb-sum}\end{equation} ``` To avoid computing the set of coefficients $\{a_{n}\}$ every time we wish to integrate $f(x_j)$, @@ -173,25 +171,25 @@ Weights on Gauss-Chebyshev-Lobotto points =============================================== We use the inverse transformation ```math - \begin{equation} a_{n} = \frac{\q_{n}}{2N}\sum^{2N-1}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N}\right], \label{eq:inverse-transform-GCL}\end{equation} + \begin{equation} a_{n} = \frac{q_{n}}{2N}\sum^{2N-1}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N}\right], \label{eq:inverse-transform-GCL}\end{equation} ``` where ```math - \begin{equation} \q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n\neq0,N $ \\ $1 {\rm ~if~} n=0,N$ \end{tabular}\right.,\end{equation} + \begin{equation} q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n\neq0,N $ \\ $1 {\rm ~if~} n=0,N$ \end{tabular}\right.,\end{equation} ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math -\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j}){\rm~for~} N+1 \leq j \leq 2N-1. \end{equation} +\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,quad \hat{f}_j = f(x_{2N-j}){\rm~for~} N+1 \leq j \leq 2N-1. \end{equation} ``` With this inverse tranformation, we can write ```math -\begin{equation} \begin{split}\sum_{n=0}^N \J_{n} a_{n} & = \sum^{2N-1}_{n=0} \frac{a_{n}\J_{n}}{\q_{n}} \\ - & = \sum^{2N-1}_{j=0}\sum^{2N-1}_{n=0} \frac{\hat{f}_j \J_{n}}{2N} \exp\left[-i \frac{2\pi n j}{2N}\right] \\ - & = \sum^{2N-1}_{j=0} \hat{f}_j \v_{j} = \sum^{N}_{j=0} \hat{f}_j \q_{j}\v_{j},\end{split}\label{eq:weights-working}\end{equation} +\begin{equation} \begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N-1}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ + & = \sum^{2N-1}_{j=0}\sum^{2N-1}_{n=0} \frac{\hat{f}_j J_{n}}{2N} \exp\left[-i \frac{2\pi n j}{2N}\right] \\ + & = \sum^{2N-1}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working}\end{equation} ``` - where in the first step we have extended the sum from $N$ to $2N-1$ and used FFT-order definitions of $\J_{n}$ and $a_{n}$ + where in the first step we have extended the sum from $N$ to $2N-1$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ ```math -\begin{equation} \J_{j} = \J_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1,\end{equation} +\begin{equation} J_{j} = J_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1,\end{equation} ``` ```math \begin{equation} a_{j} = a_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1.\end{equation} @@ -199,26 +197,26 @@ and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., In the second step we use the definition of the inverse transform \eq{eq:inverse-transform-GCR}, and in the third step we define ```math -\begin{equation} \v_{j} = \sum_{n=0}^{2N-1}\frac{\J_{n}}{2N}\exp\left[-i \frac{2\pi n j}{2N}\right].\end{equation} +\begin{equation} v_{j} = \sum_{n=0}^{2N-1}\frac{J_{n}}{2N}\exp\left[-i \frac{2\pi n j}{2N}\right].\end{equation} ``` Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working} and deduce that ```math -\begin{equation} w_{j} = \q_{j}\v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} +\begin{equation} w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} ``` -We can write $\v_{j}$ in terms of a discrete cosine transform, i.e., +We can write $v_{j}$ in terms of a discrete cosine transform, i.e., ```math -\begin{equation} \v_{j} = \frac{1}{2N}\left(\J_{0} + (-1)^j\J_{N} + 2\sum_{n=1}^{N-1}\J_{n}\cos\left(\frac{\pi n j}{N}\right)\right).\end{equation} +\begin{equation} v_{j} = \frac{1}{2N}\left(J_{0} + (-1)^jJ_{N} + 2\sum_{n=1}^{N-1}J_{n}\cos\left(\frac{\pi n j}{N}\right)\right).\end{equation} ``` Weights on Gauss-Chebyshev-Radau points =============================================== We use the inverse transformation ```math -\begin{equation} a_{n} = \frac{\q_{n}}{2N+1}\sum^{2N}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N+1}\right], \label{eq:inverse-transform-GCR}\end{equation} +\begin{equation} a_{n} = \frac{q_{n}}{2N+1}\sum^{2N}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N+1}\right], \label{eq:inverse-transform-GCR}\end{equation} ``` where ```math -\begin{equation} \q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n > 0 $ \\ $1 {\rm ~if~} n=0$ \end{tabular}\right.,\end{equation} +\begin{equation} q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n > 0 $ \\ $1 {\rm ~if~} n=0$ \end{tabular}\right.,\end{equation} ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math @@ -229,13 +227,13 @@ The key detail in the Chebyshev-Radau scheme is that (in the notation above) $x_0 = 1$ is not a repeated point, and must occupy $\hat{f}_0$. With this inverse tranformation, we can write ```math -\begin{equation} \begin{split}\sum_{n=0}^N \J_{n} a_{n} & = \sum^{2N}_{n=0} \frac{a_{n}\J_{n}}{\q_{n}} \\ -& = \sum^{2N}_{j=0}\sum^{2N}_{n=0} \frac{\hat{f}_j \J_{n}}{2N+1} \exp\left[-i \frac{2\pi n j}{2N+1}\right] \\ -& = \sum^{2N}_{j=0} \hat{f}_j \v_{j} = \sum^{N}_{j=0} \hat{f}_j \q_{j}\v_{j},\end{split}\label{eq:weights-working}\end{equation} +\begin{equation} \begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ +& = \sum^{2N}_{j=0}\sum^{2N}_{n=0} \frac{\hat{f}_j J_{n}}{2N+1} \exp\left[-i \frac{2\pi n j}{2N+1}\right] \\ +& = \sum^{2N}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working}\end{equation} ``` -where in the first step we have extended the sum from $N$ to $2N$ and used FFT-order definitions of $\J_{n}$ and $a_{n}$ +where in the first step we have extended the sum from $N$ to $2N$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ ```math -\begin{equation} \J_{j} = \J_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N,\end{equation} +\begin{equation} J_{j} = J_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N,\end{equation} ``` ```math \begin{equation} a_{j} = a_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N.\end{equation} @@ -243,9 +241,9 @@ where in the first step we have extended the sum from $N$ to $2N$ and used FFT-o In the second step we use the definition of the inverse transform \eq{eq:inverse-transform-GCR}, and in the third step we define ```math -\begin{equation} \v_{j} = \sum_{n=0}^{2N}\frac{\J_{n}}{2N+1}\exp\left[-i \frac{2\pi n j}{2N+1}\right].\end{equation} +\begin{equation} v_{j} = \sum_{n=0}^{2N}\frac{J_{n}}{2N+1}\exp\left[-i \frac{2\pi n j}{2N+1}\right].\end{equation} ``` Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working} and deduce that ```math -\begin{equation} w_{j} = \q_{j}\v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} -``` \ No newline at end of file +\begin{equation} w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} +``` From 5e69ba5b66ffcaec6c1711d30499a48c85fdedf6 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:27:22 +0100 Subject: [PATCH 04/15] Debug chebyshev.md --- docs/src/chebyshev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index e70c5e339..61285204d 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -80,8 +80,8 @@ Chebyshev coefficients of derivatives of a function Starting from the expression of $f$ as a sum Chebyshev polynomials, equation \eq{eq:cheb-expansion}, we can obtain an expression for the derivative -```math \begin{equation} -\frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}. \label{eq:derivative-def}\end{equation} +```math +\begin{equation} \frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}. \label{eq:derivative-def}\end{equation} ``` We note that we must be able to express ${d f}/{d x}$ as a sum of Chebyshev polynomials of up to order $N-1$, i.e., From 2cf21670ab257e457e4da052264c1f64a3af7073 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:29:32 +0100 Subject: [PATCH 05/15] Debug chebyshev.md --- docs/src/chebyshev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 61285204d..54c19aea0 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -229,7 +229,7 @@ With this inverse tranformation, we can write ```math \begin{equation} \begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ & = \sum^{2N}_{j=0}\sum^{2N}_{n=0} \frac{\hat{f}_j J_{n}}{2N+1} \exp\left[-i \frac{2\pi n j}{2N+1}\right] \\ -& = \sum^{2N}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working}\end{equation} +& = \sum^{2N}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working-radau}\end{equation} ``` where in the first step we have extended the sum from $N$ to $2N$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ ```math @@ -243,7 +243,7 @@ in the third step we define ```math \begin{equation} v_{j} = \sum_{n=0}^{2N}\frac{J_{n}}{2N+1}\exp\left[-i \frac{2\pi n j}{2N+1}\right].\end{equation} ``` -Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working} and deduce that +Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working-radau} and deduce that ```math \begin{equation} w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} ``` From f12082c7e79a636694fe12f4637245836035b9f6 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:33:06 +0100 Subject: [PATCH 06/15] Debug chebyshev.md --- docs/src/chebyshev.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 54c19aea0..d2f5caf66 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -150,10 +150,11 @@ to write \begin{equation} \int^\pi_0 \cos(n \theta) \sin \theta \; d \theta = \frac{\cos(n \pi) +1}{1 - n^2} {\rm~for~} n \geq 0.\end{equation} ``` Also note that - ```math - \begin{equation} \frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{tabular}{l} $0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} $ \\ $2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z}$ \end{tabular}\right. \end{equation} +```math +\begin{equation} \frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{tabular}{l} $0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} $ \\ $2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z}$ \end{tabular}\right. \end{equation} ``` - We define ```math + We define + ```math \begin{equation} J_{n} = \frac{\cos(n \pi) +1}{1 - n^2}. \end{equation} ``` Using this definition, we can write the integral of $f(x)$ can be written From 616be7a39f0fbcec46d66dc4c2f5b82ae399da1a Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:33:58 +0100 Subject: [PATCH 07/15] Debug chebyshev.md --- docs/src/chebyshev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index d2f5caf66..f14e013b1 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -180,7 +180,7 @@ Weights on Gauss-Chebyshev-Lobotto points ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math -\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,quad \hat{f}_j = f(x_{2N-j}){\rm~for~} N+1 \leq j \leq 2N-1. \end{equation} +\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j}){\rm~for~} N+1 \leq j \leq 2N-1. \end{equation} ``` With this inverse tranformation, we can write ```math From d379912cb9e627b9a1684be9d2138be7470addf8 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:46:42 +0100 Subject: [PATCH 08/15] Debug chebyshev.md --- docs/src/chebyshev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index f14e013b1..721960a89 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -118,7 +118,7 @@ we find that equation \eq{eq:dn-def} becomes Using the orthogonality relation ```math \begin{equation} \int^1_{-1} U_{m}(x)U_{n}(x)\sqrt{1-x^2} \; d x = -\left\{\begin{tabular}{l} $0 {\rm ~if~} n\neq m $ \\ $\pi/2 {\rm ~if~} n=m$ \end{tabular}\right.,\end{equation} +\left\{\begin{array}{l} 0 {\rm ~if~} n\neq m \\ \pi/2 {\rm ~if~} n=m \\ \end{array} \right.,\end{equation} ``` we obtain the (unqiuely-determined) relations ```math From 1893d93ed437bd7fe2392e0e25756973846c1f11 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:48:43 +0100 Subject: [PATCH 09/15] Debug chebyshev.md --- docs/src/chebyshev.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 721960a89..76c76cbf1 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -118,7 +118,7 @@ we find that equation \eq{eq:dn-def} becomes Using the orthogonality relation ```math \begin{equation} \int^1_{-1} U_{m}(x)U_{n}(x)\sqrt{1-x^2} \; d x = -\left\{\begin{array}{l} 0 {\rm ~if~} n\neq m \\ \pi/2 {\rm ~if~} n=m \\ \end{array} \right.,\end{equation} +\left\{\begin{array}{l} 0 {\rm ~if~} n\neq m \\ \pi/2 {\rm ~if~} n=m \\ \end{array} \right.\end{equation} ``` we obtain the (unqiuely-determined) relations ```math @@ -151,7 +151,7 @@ to write ``` Also note that ```math -\begin{equation} \frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{tabular}{l} $0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} $ \\ $2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z}$ \end{tabular}\right. \end{equation} +\begin{equation} \frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{array}{l} 0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} \\ 2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z} \end{array}\right. \end{equation} ``` We define ```math @@ -176,7 +176,7 @@ Weights on Gauss-Chebyshev-Lobotto points ``` where ```math - \begin{equation} q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n\neq0,N $ \\ $1 {\rm ~if~} n=0,N$ \end{tabular}\right.,\end{equation} + \begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n\neq0,N \\ 1 {\rm ~if~} n=0,N \end{array}\right.,\end{equation} ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math @@ -217,7 +217,7 @@ We use the inverse transformation ``` where ```math -\begin{equation} q_{n} = \left\{\begin{tabular}{l} $2 {\rm ~if~} n > 0 $ \\ $1 {\rm ~if~} n=0$ \end{tabular}\right.,\end{equation} +\begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n > 0 \\ 1 {\rm ~if~} n=0 \end{array}\right.,\end{equation} ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math From 9a0a65172db48da996ef7ce4c1256a9c1dbeb1eb Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:49:54 +0100 Subject: [PATCH 10/15] Debug chebyshev.md --- docs/src/chebyshev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 76c76cbf1..8ff0a5de0 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -176,7 +176,7 @@ Weights on Gauss-Chebyshev-Lobotto points ``` where ```math - \begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n\neq0,N \\ 1 {\rm ~if~} n=0,N \end{array}\right.,\end{equation} + \begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n\neq0,N \\ 1 {\rm ~if~} n=0,N \end{array}\right.\end{equation} ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math @@ -217,7 +217,7 @@ We use the inverse transformation ``` where ```math -\begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n > 0 \\ 1 {\rm ~if~} n=0 \end{array}\right.,\end{equation} +\begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n > 0 \\ 1 {\rm ~if~} n=0 \end{array}\right.\end{equation} ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math From c4c17636a19258a345b1eb2b154275283638b2ee Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:59:22 +0100 Subject: [PATCH 11/15] Update chebyshev.md to have a manual label. --- docs/src/chebyshev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 8ff0a5de0..20f772448 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -7,7 +7,7 @@ Chebyshev tranform via Fourier transform ``` We express a function $f$ as a sum of Chebyshev polynomials ```math -\begin{equation} f(x) = \sum^N_{n=0} a_{n}T_n(x)\label{eq:cheb-expansion}\end{equation} +\begin{equation} f(x) = \sum^N_{n=0} a_{n}T_n(x)\label{eq:cheb-expansion} \tag{1}\end{equation} ``` The Chebyshev polynomials are defined by ```math From 37e49bdca3bd97c4e990a2bfb15b158468946306 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:04:44 +0100 Subject: [PATCH 12/15] Update chebyshev.md to have manual labels. --- docs/src/chebyshev.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 20f772448..8d9f42173 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -16,7 +16,7 @@ The Chebyshev polynomials are defined by We can see how to find $\{a_{n}\}$ given $\{f(x_j)\}$ via Fourier transform. The Fourier series representation of $f$ on a uniform grid indexed by $j$ is defined by ```math -\begin{equation} f_j = \sum_{k=0}^{M-1} b_{k}\exp\left[i \frac{2\pi k j}{M}\right].\label{eq:fourier-series}\end{equation} +\begin{equation} f_j = \sum_{k=0}^{M-1} b_{k}\exp\left[i \frac{2\pi k j}{M}\right].\label{eq:fourier-series}\tag{2}\end{equation} ``` Gauss-Chebyshev-Lobotto points @@ -61,7 +61,7 @@ these cases we choose the points Writing out the Chebyshev series \eq{eq:cheb-expansion}, we have that ```math -\begin{equation} \begin{split} f(x_j) = & \sum^N_{n=0} a_{n} \cos \frac{2 n j \pi}{2 N + 1} \\ & = a_{0} + \sum^N_{n=1} \frac{a_{n}}{2}\left(\exp\left[i \frac{2\pi n j}{2N +1}\right] + \exp\left[-i \frac{2\pi n j}{2N +1}\right]\right).\end{split} \label{eq:cheb-expansion-radau-points}\end{equation} +\begin{equation} \begin{split} f(x_j) = & \sum^N_{n=0} a_{n} \cos \frac{2 n j \pi}{2 N + 1} \\ & = a_{0} + \sum^N_{n=1} \frac{a_{n}}{2}\left(\exp\left[i \frac{2\pi n j}{2N +1}\right] + \exp\left[-i \frac{2\pi n j}{2N +1}\right]\right).\end{split} \label{eq:cheb-expansion-radau-points}\tag{3}\end{equation} ``` The form of the series \eq{eq:cheb-expansion-radau-points} is identical to the form of a Fourier series on an odd number of points, i.e., taking $M = 2 N + 1$ in equation \eq{eq:fourier-series}, @@ -81,7 +81,7 @@ Chebyshev coefficients of derivatives of a function Starting from the expression of $f$ as a sum Chebyshev polynomials, equation \eq{eq:cheb-expansion}, we can obtain an expression for the derivative ```math -\begin{equation} \frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}. \label{eq:derivative-def}\end{equation} +\begin{equation} \frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}. \label{eq:derivative-def}\tag{4}\end{equation} ``` We note that we must be able to express ${d f}/{d x}$ as a sum of Chebyshev polynomials of up to order $N-1$, i.e., @@ -91,7 +91,7 @@ of Chebyshev polynomials of up to order $N-1$, i.e., We must determine the set $\{d_{n}\}$ in terms of the set $\{a_{n}\}$. First, we equate the two expressions to find that ```math -\begin{equation} \sum^N_{k=0} a_{k}\frac{d T_{k}}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}. \label{eq:dn-def}\end{equation} +\begin{equation} \sum^N_{k=0} a_{k}\frac{d T_{k}}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}. \label{eq:dn-def}\tag{5}\end{equation} ``` We use the Chebyshev polynomials of the second kind $U_n{x}$ to aid us in the calculation of the set $\{d_{n}\}$. These polynomials are defined by @@ -113,7 +113,7 @@ we find that equation \eq{eq:dn-def} becomes ```math \begin{equation} \begin{split}\sum^N_{n=1} a_{n} n U_{n-1}(x) =& \frac{d_{N-1}}{2}U_{N-1}+\frac{d_{N-2}}{2}U_{N-2} \\ & + \sum^{N-3}_{k=1} \frac{d_{k}-d_{k+2}}{2}U_{k} + \left(d_{0} - \frac{d_{2}}{2}\right)U_{0}. \end{split} -\label{eq:dn-def-U}\end{equation} +\label{eq:dn-def-U}\tag{6}\end{equation} ``` Using the orthogonality relation ```math @@ -123,7 +123,7 @@ Using the orthogonality relation we obtain the (unqiuely-determined) relations ```math \begin{equation} \begin{split} &d_{N-1} = 2Na_{N},\quad d_{N-2} = 2(N-1)a_{N-1}, \\ -& d_{k} = 2(k+1) a_{k+1} + d_{k+2}, \quad d_{0} = \frac{d_{2}}{2} + a_{1}.\end{split} \label{eq:dn-result-U}\end{equation} +& d_{k} = 2(k+1) a_{k+1} + d_{k+2}, \quad d_{0} = \frac{d_{2}}{2} + a_{1}.\end{split} \label{eq:dn-result-U}\tag{7}\end{equation} ``` Clenshaw-Curtis integration weights @@ -132,18 +132,18 @@ Clenshaw-Curtis integration weights We require the integration weights for the set of points $\{x_j\}$ chosen in our numerical scheme. The weights $w_{j}$ are defined implicitly by ```math -\begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{j=0}^N f(x_j) w_{j}. \label{eq:w-sum}\end{equation} +\begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{j=0}^N f(x_j) w_{j}. \label{eq:w-sum}\tag{8}\end{equation} ``` In the Chebyshev scheme we use the change of variables $x = \cos \theta$ to write ```math -\begin{equation} \int^{1}_{-1} f(x) \; d x = \int^\pi_0 f(\cos\theta) \sin \theta \; d \theta . \label{eq:change-of-variables-integral} \end{equation} +\begin{equation} \int^{1}_{-1} f(x) \; d x = \int^\pi_0 f(\cos\theta) \sin \theta \; d \theta . \label{eq:change-of-variables-integral} \tag{9}\end{equation} ``` Using the series expansion \eq{eq:cheb-expansion} in equation \eq{eq:change-of-variables-integral} we find that ```math \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum^N_{n=0} a_{n}\int^\pi_0 \cos (n \theta) \sin \theta \; d \theta - . \label{eq:series-integral} \end{equation} + . \label{eq:series-integral}\tag{10} \end{equation} ``` Note the integral identity ```math @@ -160,7 +160,7 @@ to write Using this definition, we can write the integral of $f(x)$ can be written in terms of a sum over of the Chebyshev coefficients: ```math - \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{n=0}^N J_{n} a_{n}. \label{eq:Cheb-sum}\end{equation} + \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{n=0}^N J_{n} a_{n}. \label{eq:Cheb-sum}\tag{11}\end{equation} ``` To avoid computing the set of coefficients $\{a_{n}\}$ every time we wish to integrate $f(x_j)$, @@ -172,7 +172,7 @@ Weights on Gauss-Chebyshev-Lobotto points =============================================== We use the inverse transformation ```math - \begin{equation} a_{n} = \frac{q_{n}}{2N}\sum^{2N-1}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N}\right], \label{eq:inverse-transform-GCL}\end{equation} + \begin{equation} a_{n} = \frac{q_{n}}{2N}\sum^{2N-1}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N}\right], \label{eq:inverse-transform-GCL}\tag{12}\end{equation} ``` where ```math @@ -186,7 +186,7 @@ and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math \begin{equation} \begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N-1}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ & = \sum^{2N-1}_{j=0}\sum^{2N-1}_{n=0} \frac{\hat{f}_j J_{n}}{2N} \exp\left[-i \frac{2\pi n j}{2N}\right] \\ - & = \sum^{2N-1}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working}\end{equation} + & = \sum^{2N-1}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working}\tag{13}\end{equation} ``` where in the first step we have extended the sum from $N$ to $2N-1$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ ```math @@ -213,7 +213,7 @@ Weights on Gauss-Chebyshev-Radau points =============================================== We use the inverse transformation ```math -\begin{equation} a_{n} = \frac{q_{n}}{2N+1}\sum^{2N}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N+1}\right], \label{eq:inverse-transform-GCR}\end{equation} +\begin{equation} a_{n} = \frac{q_{n}}{2N+1}\sum^{2N}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N+1}\right], \label{eq:inverse-transform-GCR}\tag{14}\end{equation} ``` where ```math @@ -230,7 +230,7 @@ With this inverse tranformation, we can write ```math \begin{equation} \begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ & = \sum^{2N}_{j=0}\sum^{2N}_{n=0} \frac{\hat{f}_j J_{n}}{2N+1} \exp\left[-i \frac{2\pi n j}{2N+1}\right] \\ -& = \sum^{2N}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working-radau}\end{equation} +& = \sum^{2N}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working-radau}\tag{15}\end{equation} ``` where in the first step we have extended the sum from $N$ to $2N$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ ```math From a721ba7e7df33c5306dd336c2577c754915c602b Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:13:05 +0100 Subject: [PATCH 13/15] Update chebyshev.md to reference manual labels. --- docs/src/chebyshev.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 8d9f42173..d7da3da0a 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -58,13 +58,13 @@ these cases we choose the points ```math \begin{equation} x_j = \cos \theta_j, \quad \theta_j = \frac{2 j \pi}{2 N + 1} \quad 0 \leq j \leq N.\end{equation} ``` -Writing out the Chebyshev series \eq{eq:cheb-expansion}, +Writing out the Chebyshev series (1), we have that ```math \begin{equation} \begin{split} f(x_j) = & \sum^N_{n=0} a_{n} \cos \frac{2 n j \pi}{2 N + 1} \\ & = a_{0} + \sum^N_{n=1} \frac{a_{n}}{2}\left(\exp\left[i \frac{2\pi n j}{2N +1}\right] + \exp\left[-i \frac{2\pi n j}{2N +1}\right]\right).\end{split} \label{eq:cheb-expansion-radau-points}\tag{3}\end{equation} ``` -The form of the series \eq{eq:cheb-expansion-radau-points} is identical to the form of -a Fourier series on an odd number of points, i.e., taking $M = 2 N + 1$ in equation \eq{eq:fourier-series}, +The form of the series (3) is identical to the form of +a Fourier series on an odd number of points, i.e., taking $M = 2 N + 1$ in equation (2) <--\eq{eq:fourier-series}-->, and assuming $b_{k} = b_{M -k}$ for $k>1$, we have that ```math @@ -78,7 +78,7 @@ We can thus take a Chebyshev transform using a Fourier transform on Gauss-Chebys Chebyshev coefficients of derivatives of a function =============================================== -Starting from the expression of $f$ as a sum Chebyshev polynomials, equation \eq{eq:cheb-expansion}, +Starting from the expression of $f$ as a sum Chebyshev polynomials, equation (1) , we can obtain an expression for the derivative ```math \begin{equation} \frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}. \label{eq:derivative-def}\tag{4}\end{equation} @@ -109,7 +109,7 @@ Using these identities, which may be obtained from the trigonometric definition ```math \begin{equation} U_{n}(\cos \theta) \sin \theta = \sin \left((n+1)\theta\right),\end{equation} ``` -we find that equation \eq{eq:dn-def} becomes +we find that equation (5) becomes ```math \begin{equation} \begin{split}\sum^N_{n=1} a_{n} n U_{n-1}(x) =& \frac{d_{N-1}}{2}U_{N-1}+\frac{d_{N-2}}{2}U_{N-2} \\ & + \sum^{N-3}_{k=1} \frac{d_{k}-d_{k+2}}{2}U_{k} + \left(d_{0} - \frac{d_{2}}{2}\right)U_{0}. \end{split} @@ -139,7 +139,7 @@ to write ```math \begin{equation} \int^{1}_{-1} f(x) \; d x = \int^\pi_0 f(\cos\theta) \sin \theta \; d \theta . \label{eq:change-of-variables-integral} \tag{9}\end{equation} ``` - Using the series expansion \eq{eq:cheb-expansion} in equation \eq{eq:change-of-variables-integral} + Using the series expansion (1) in equation (9) we find that ```math \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum^N_{n=0} a_{n}\int^\pi_0 \cos (n \theta) \sin \theta \; d \theta @@ -164,7 +164,7 @@ to write ``` To avoid computing the set of coefficients $\{a_{n}\}$ every time we wish to integrate $f(x_j)$, - we use the inverse transforms. This transform allows us to rewrite equation \eq{eq:Cheb-sum} in the form \eq{eq:w-sum}. + we use the inverse transforms. This transform allows us to rewrite equation (11) in the form (8) . Since the inverse transform differs between the Gauss-Chebyshev-Lobotto and Gauss-Chebyshev-Radau cases, we treat each case separately below. @@ -195,12 +195,12 @@ and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math \begin{equation} a_{j} = a_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1.\end{equation} ``` -In the second step we use the definition of the inverse transform \eq{eq:inverse-transform-GCR}, and +In the second step we use the definition of the inverse transform (14) , and in the third step we define ```math \begin{equation} v_{j} = \sum_{n=0}^{2N-1}\frac{J_{n}}{2N}\exp\left[-i \frac{2\pi n j}{2N}\right].\end{equation} ``` -Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working} and deduce that +Finally, we can compare equations (8) and (13) and deduce that ```math \begin{equation} w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} ``` @@ -239,12 +239,12 @@ where in the first step we have extended the sum from $N$ to $2N$ and used FFT-o ```math \begin{equation} a_{j} = a_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N.\end{equation} ``` -In the second step we use the definition of the inverse transform \eq{eq:inverse-transform-GCR}, and +In the second step we use the definition of the inverse transform (14) , and in the third step we define ```math \begin{equation} v_{j} = \sum_{n=0}^{2N}\frac{J_{n}}{2N+1}\exp\left[-i \frac{2\pi n j}{2N+1}\right].\end{equation} ``` -Finally, we can compare equations \eq{eq:w-sum} and \eq{eq:weights-working-radau} and deduce that +Finally, we can compare equations (8) and (15) and deduce that ```math \begin{equation} w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} ``` From b2ccf62fc579a1b01108e8c1d056a0f74189e1d6 Mon Sep 17 00:00:00 2001 From: mrhardman <29800382+mrhardman@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:15:24 +0100 Subject: [PATCH 14/15] Update chebyshev.md --- docs/src/chebyshev.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index d7da3da0a..908daaf09 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -35,8 +35,7 @@ Assuming that $M = 2N$, with $N$ an integer, and $b_{k} = b_{M-k}$ for $k>0$, we \begin{equation} f_j = b_{0} + b_{N}(-1)^j + \sum_{n=1}^{N-1} b_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right).\end{equation} ``` -Comparing this to the expression for $f(x_j)$ in the Chebyshev representation, -using the form of $T_n(x_j)$, +Comparing this to the expression for $f(x_j)$ in the Chebyshev representation, ```math \begin{equation} f_j = a_{0} + a_{N}(-1)^j + \frac{1}{2}\sum_{n=1}^{N-1} a_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right),\end{equation} From aa365d55f3155b5e21c358b7cf26f2ed26f4c913 Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Sat, 26 Oct 2024 20:12:35 +0100 Subject: [PATCH 15/15] Correct formatting of chebyshev.md so that Documenter.jl can correctly render the document. --- docs/src/chebyshev.md | 285 +++++++++++++++++++++++++++--------------- 1 file changed, 186 insertions(+), 99 deletions(-) diff --git a/docs/src/chebyshev.md b/docs/src/chebyshev.md index 908daaf09..c4d38f8ae 100644 --- a/docs/src/chebyshev.md +++ b/docs/src/chebyshev.md @@ -1,22 +1,24 @@ Chebyshev tranform via Fourier transform =============================================== -```math -\begin{equation} -\end{equation} -``` We express a function $f$ as a sum of Chebyshev polynomials ```math -\begin{equation} f(x) = \sum^N_{n=0} a_{n}T_n(x)\label{eq:cheb-expansion} \tag{1}\end{equation} +\begin{equation} +f(x) = \sum^N_{n=0} a_{n}T_n(x) \tag{1} +\end{equation} ``` The Chebyshev polynomials are defined by ```math -\begin{equation} T_n(\cos \theta) = \cos n \theta, {\rm~with~}x = \cos \theta. \end{equation} +\begin{equation} +T_n(\cos \theta) = \cos n \theta, {\rm~with~}x = \cos \theta. +\end{equation} ``` We can see how to find $\{a_{n}\}$ given $\{f(x_j)\}$ via Fourier transform. The Fourier series representation of $f$ on a uniform grid indexed by $j$ is defined by ```math -\begin{equation} f_j = \sum_{k=0}^{M-1} b_{k}\exp\left[i \frac{2\pi k j}{M}\right].\label{eq:fourier-series}\tag{2}\end{equation} +\begin{equation} +f_j = \sum_{k=0}^{M-1} b_{k}\exp\left[i \frac{2\pi k j}{M}\right].\tag{2} +\end{equation} ``` Gauss-Chebyshev-Lobotto points @@ -24,26 +26,36 @@ Gauss-Chebyshev-Lobotto points We pick points ```math -\begin{equation} x_j = \cos \theta_j, \quad \theta_j = \frac{j \pi}{N} \quad 0 \leq j \leq N.\end{equation} +\begin{equation} +x_j = \cos \theta_j, \quad \theta_j = \frac{j \pi}{N} \quad 0 \leq j \leq N. +\end{equation} ``` Then ```math -\begin{equation} T_n(x_j) = \cos \frac{n j \pi}{N}.\end{equation} +\begin{equation} +T_n(x_j) = \cos \frac{n j \pi}{N}. +\end{equation} ``` Assuming that $M = 2N$, with $N$ an integer, and $b_{k} = b_{M-k}$ for $k>0$, we have that ```math -\begin{equation} f_j = b_{0} + b_{N}(-1)^j + \sum_{n=1}^{N-1} -b_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right).\end{equation} +\begin{equation} +f_j = b_{0} + b_{N}(-1)^j + \sum_{n=1}^{N-1} +b_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right). +\end{equation} ``` Comparing this to the expression for $f(x_j)$ in the Chebyshev representation, ```math -\begin{equation} f_j = a_{0} + a_{N}(-1)^j + \frac{1}{2}\sum_{n=1}^{N-1} -a_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right),\end{equation} +\begin{equation} +f_j = a_{0} + a_{N}(-1)^j + \frac{1}{2}\sum_{n=1}^{N-1} +a_{n}\left(\exp\left[i \frac{\pi n j}{N}\right]+\exp\left[-i \frac{\pi n j}{N}\right]\right), +\end{equation} ``` we find that the Chebyshev representation on the Chebyshev points is equivalent to the Fourier representation on the uniform grid points, if we identify ```math -\begin{equation} b_{0} = a_{0}, \quad b_{N} = a_{N}, \quad b_{j} = \frac{a_{j}}{2} {\rm~for~} 1 \leq j \leq N-1. \end{equation} +\begin{equation} +b_{0} = a_{0}, \quad b_{N} = a_{N}, \quad b_{j} = \frac{a_{j}}{2} {\rm~for~} 1 \leq j \leq N-1. +\end{equation} ``` This fact allows us to carry out the Chebyshev tranform by Fourier transforming the $\{f_j\}$ data and carrying out the correct normalisation of the resulting coefficients. @@ -55,74 +67,103 @@ The last subsection dealt with grids which contain both endpoints on the $[-1,1] Certain problems require domains which contain a single endpoint, i.e., $x \in (-1,1]$. For these cases we choose the points ```math -\begin{equation} x_j = \cos \theta_j, \quad \theta_j = \frac{2 j \pi}{2 N + 1} \quad 0 \leq j \leq N.\end{equation} +\begin{equation} +x_j = \cos \theta_j, \quad \theta_j = \frac{2 j \pi}{2 N + 1} \quad 0 \leq j \leq N. +\end{equation} ``` -Writing out the Chebyshev series (1), +Writing out the Chebyshev series (1), we have that ```math -\begin{equation} \begin{split} f(x_j) = & \sum^N_{n=0} a_{n} \cos \frac{2 n j \pi}{2 N + 1} \\ & = a_{0} + \sum^N_{n=1} \frac{a_{n}}{2}\left(\exp\left[i \frac{2\pi n j}{2N +1}\right] + \exp\left[-i \frac{2\pi n j}{2N +1}\right]\right).\end{split} \label{eq:cheb-expansion-radau-points}\tag{3}\end{equation} +\begin{equation} +\begin{split}f(x_j) = & \sum^N_{n=0} a_{n} \cos \frac{2 n j \pi}{2 N + 1} \\ & += a_{0} + \sum^N_{n=1} \frac{a_{n}}{2}\left(\exp\left[i \frac{2\pi n j}{2N +1}\right] + \exp\left[-i \frac{2\pi n j}{2N +1}\right]\right).\end{split} +\tag{3} +\end{equation} ``` -The form of the series (3) is identical to the form of -a Fourier series on an odd number of points, i.e., taking $M = 2 N + 1$ in equation (2) <--\eq{eq:fourier-series}-->, +The form of the series (3) is identical to the form of +a Fourier series on an odd number of points, i.e., taking $M = 2 N + 1$ in equation (2), and assuming $b_{k} = b_{M -k}$ for $k>1$, we have that ```math -\begin{equation} f_j = b_{0} + \sum_{k=1}^{N} b_{k}\left(\exp\left[i \frac{2\pi k j}{2N+1}\right] + \exp\left[-i \frac{2\pi k j}{2N+1} \right]\right). \end{equation} +\begin{equation} +f_j = b_{0} + \sum_{k=1}^{N} b_{k}\left(\exp\left[i \frac{2\pi k j}{2N+1}\right] + \exp\left[-i \frac{2\pi k j}{2N+1} \right]\right). +\end{equation} ``` We can thus take a Chebyshev transform using a Fourier transform on Gauss-Chebyshev-Radau points if we identify ```math -\begin{equation} b_{0} = a_{0}, \quad b_{j} = \frac{a_{j}}{2} {\rm~for~} 1 \leq j \leq N. \end{equation} +\begin{equation} +b_{0} = a_{0}, \quad b_{j} = \frac{a_{j}}{2} {\rm~for~} 1 \leq j \leq N. +\end{equation} ``` Chebyshev coefficients of derivatives of a function =============================================== -Starting from the expression of $f$ as a sum Chebyshev polynomials, equation (1) , +Starting from the expression of $f$ as a sum Chebyshev polynomials, equation (1), we can obtain an expression for the derivative ```math -\begin{equation} \frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}. \label{eq:derivative-def}\tag{4}\end{equation} +\begin{equation} +\frac{d f}{d x} = \sum^N_{n=0} a_{n}\frac{d T_{n}}{d x}.\tag{4} +\end{equation} ``` We note that we must be able to express ${d f}/{d x}$ as a sum of Chebyshev polynomials of up to order $N-1$, i.e., ```math -\begin{equation} \frac{d f}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}. \end{equation} +\begin{equation} +\frac{d f}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}. +\end{equation} ``` We must determine the set $\{d_{n}\}$ in terms of the set $\{a_{n}\}$. First, we equate the two expressions to find that ```math -\begin{equation} \sum^N_{k=0} a_{k}\frac{d T_{k}}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}. \label{eq:dn-def}\tag{5}\end{equation} +\begin{equation} +\sum^N_{k=0} a_{k}\frac{d T_{k}}{d x} = \sum^{N-1}_{n=0} d_{n}T_{n}.\tag{5} +\end{equation} ``` We use the Chebyshev polynomials of the second kind $U_n{x}$ to aid us in the calculation of the set $\{d_{n}\}$. These polynomials are defined by ```math -\begin{equation} U_{0}(x) = 1, \quad U_{1}(x) = 2x, \quad U_{n+1} = 2 x U_{n}(x) - U_{n-1}(x).\end{equation} +\begin{equation} +U_{0}(x) = 1, \quad U_{1}(x) = 2x, \quad U_{n+1} = 2 x U_{n}(x) - U_{n-1}(x). +\end{equation} ``` Note the useful relations ```math -\begin{equation} \frac{d T_{n}}{d x} = n U_{n-1}, {\rm~for~}n\geq 1, \quad \frac{d T_{0}}{d x} = 0,\end{equation} +\begin{equation} +\frac{d T_{n}}{d x} = n U_{n-1}, {\rm~for~}n\geq 1, \quad \frac{d T_{0}}{d x} = 0, +\end{equation} ``` ```math -\begin{equation} T_{n} = \frac{1}{2}\left(U_{n} - U_{n -2}\right), T_{0} = U_{0}\quad, {\rm ~and~} \quad 2 T_{1} = U_{1}. \end{equation} +\begin{equation} +T_{n} = \frac{1}{2}\left(U_{n} - U_{n -2}\right), T_{0} = U_{0}\quad, {\rm ~and~} \quad 2 T_{1} = U_{1}. +\end{equation} ``` Using these identities, which may be obtained from the trigonometric definition of $U_{n}(\cos \theta)$ ```math -\begin{equation} U_{n}(\cos \theta) \sin \theta = \sin \left((n+1)\theta\right),\end{equation} +\begin{equation} +U_{n}(\cos \theta) \sin \theta = \sin \left((n+1)\theta\right), +\end{equation} ``` -we find that equation (5) becomes +we find that equation (5) becomes ```math -\begin{equation} \begin{split}\sum^N_{n=1} a_{n} n U_{n-1}(x) =& \frac{d_{N-1}}{2}U_{N-1}+\frac{d_{N-2}}{2}U_{N-2} -\\ & + \sum^{N-3}_{k=1} \frac{d_{k}-d_{k+2}}{2}U_{k} + \left(d_{0} - \frac{d_{2}}{2}\right)U_{0}. \end{split} -\label{eq:dn-def-U}\tag{6}\end{equation} +\begin{equation} +\begin{split}\sum^N_{n=1} a_{n} n U_{n-1}(x) =& \frac{d_{N-1}}{2}U_{N-1}+\frac{d_{N-2}}{2}U_{N-2} +\\ & + \sum^{N-3}_{k=1} \frac{d_{k}-d_{k+2}}{2}U_{k} + \left(d_{0} - \frac{d_{2}}{2}\right)U_{0}. \end{split}\tag{6} +\end{equation} ``` Using the orthogonality relation ```math -\begin{equation} \int^1_{-1} U_{m}(x)U_{n}(x)\sqrt{1-x^2} \; d x = -\left\{\begin{array}{l} 0 {\rm ~if~} n\neq m \\ \pi/2 {\rm ~if~} n=m \\ \end{array} \right.\end{equation} +\begin{equation} +\int^1_{-1} U_{m}(x)U_{n}(x)\sqrt{1-x^2} \; d x = +\left\{\begin{array}{l} 0 {\rm ~if~} n\neq m \\ \pi/2 {\rm ~if~} n=m \\ \end{array} \right. +\end{equation} ``` we obtain the (unqiuely-determined) relations ```math -\begin{equation} \begin{split} &d_{N-1} = 2Na_{N},\quad d_{N-2} = 2(N-1)a_{N-1}, \\ -& d_{k} = 2(k+1) a_{k+1} + d_{k+2}, \quad d_{0} = \frac{d_{2}}{2} + a_{1}.\end{split} \label{eq:dn-result-U}\tag{7}\end{equation} +\begin{equation} +\begin{split} &d_{N-1} = 2Na_{N},\quad d_{N-2} = 2(N-1)a_{N-1}, \\ +& d_{k} = 2(k+1) a_{k+1} + d_{k+2}, \quad d_{0} = \frac{d_{2}}{2} + a_{1}.\end{split}\tag{7} +\end{equation} ``` Clenshaw-Curtis integration weights @@ -131,119 +172,165 @@ Clenshaw-Curtis integration weights We require the integration weights for the set of points $\{x_j\}$ chosen in our numerical scheme. The weights $w_{j}$ are defined implicitly by ```math -\begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{j=0}^N f(x_j) w_{j}. \label{eq:w-sum}\tag{8}\end{equation} +\begin{equation} +\int^{1}_{-1} f(x) \; d x = \sum_{j=0}^N f(x_j) w_{j}.\tag{8} +\end{equation} ``` In the Chebyshev scheme we use the change of variables $x = \cos \theta$ to write ```math -\begin{equation} \int^{1}_{-1} f(x) \; d x = \int^\pi_0 f(\cos\theta) \sin \theta \; d \theta . \label{eq:change-of-variables-integral} \tag{9}\end{equation} +\begin{equation} +\int^{1}_{-1} f(x) \; d x = \int^\pi_0 f(\cos\theta) \sin \theta \; d \theta .\tag{9} +\end{equation} ``` - Using the series expansion (1) in equation (9) + Using the series expansion (1) in equation (9) we find that - ```math - \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum^N_{n=0} a_{n}\int^\pi_0 \cos (n \theta) \sin \theta \; d \theta - . \label{eq:series-integral}\tag{10} \end{equation} - ``` - Note the integral identity - ```math -\begin{equation} \int^\pi_0 \cos(n \theta) \sin \theta \; d \theta = \frac{\cos(n \pi) +1}{1 - n^2} {\rm~for~} n \geq 0.\end{equation} -``` - Also note that -```math -\begin{equation} \frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{array}{l} 0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} \\ 2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z} \end{array}\right. \end{equation} - ``` - We define - ```math - \begin{equation} J_{n} = \frac{\cos(n \pi) +1}{1 - n^2}. \end{equation} - ``` - Using this definition, we can write the integral of $f(x)$ can be written - in terms of a sum over of the Chebyshev coefficients: - ```math - \begin{equation} \int^{1}_{-1} f(x) \; d x = \sum_{n=0}^N J_{n} a_{n}. \label{eq:Cheb-sum}\tag{11}\end{equation} - ``` - - To avoid computing the set of coefficients $\{a_{n}\}$ every time we wish to integrate $f(x_j)$, - we use the inverse transforms. This transform allows us to rewrite equation (11) in the form (8) . - Since the inverse transform differs between the Gauss-Chebyshev-Lobotto and Gauss-Chebyshev-Radau cases, we treat each - case separately below. - +```math +\begin{equation} +\int^{1}_{-1} f(x) \; d x = \sum^N_{n=0} a_{n}\int^\pi_0 \cos (n \theta) \sin \theta \; d \theta +.\tag{10} +\end{equation} +``` +Note the integral identity +```math +\begin{equation} +\int^\pi_0 \cos(n \theta) \sin \theta \; d \theta = \frac{\cos(n \pi) +1}{1 - n^2} {\rm~for~} n \geq 0. +\end{equation} +``` +Also note that +```math +\begin{equation} +\frac{\cos(n \pi) +1}{1 - n^2} = \left\{\begin{array}{l} 0 {\rm ~if~} n = 2 r + 1, ~r \in \mathbb{Z} \\ 2/(1 - n^2) {\rm ~if~} n=2r,~r. \in \mathbb{Z} \end{array}\right. +\end{equation} +``` +We define +```math +\begin{equation} +J_{n} = \frac{\cos(n \pi) +1}{1 - n^2}. +\end{equation} +``` +Using this definition, we can write the integral of $f(x)$ can be written +in terms of a sum over of the Chebyshev coefficients: +```math +\begin{equation} +\int^{1}_{-1} f(x) \; d x = \sum_{n=0}^N J_{n} a_{n}.\tag{11} +\end{equation} +``` +To avoid computing the set of coefficients $\{a_{n}\}$ every time we wish to integrate $f(x_j)$, +we use the inverse transforms. This transform allows us to rewrite equation (11) in the form (8). +Since the inverse transform differs between the Gauss-Chebyshev-Lobotto and Gauss-Chebyshev-Radau cases, we treat each +case separately below. + Weights on Gauss-Chebyshev-Lobotto points =============================================== - We use the inverse transformation - ```math - \begin{equation} a_{n} = \frac{q_{n}}{2N}\sum^{2N-1}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N}\right], \label{eq:inverse-transform-GCL}\tag{12}\end{equation} - ``` - where - ```math - \begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n\neq0,N \\ 1 {\rm ~if~} n=0,N \end{array}\right.\end{equation} - ``` +We use the inverse transformation +```math +\begin{equation} +a_{n} = \frac{q_{n}}{2N}\sum^{2N-1}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N}\right], \tag{12} +\end{equation} +``` +where +```math +\begin{equation} +q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n\neq0,N \\ 1 {\rm ~if~} n=0,N \end{array}\right. +\end{equation} +``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math -\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j}){\rm~for~} N+1 \leq j \leq 2N-1. \end{equation} +\begin{equation} +\hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j}){\rm~for~} N+1 \leq j \leq 2N-1. +\end{equation} ``` - With this inverse tranformation, we can write +With this inverse tranformation, we can write ```math -\begin{equation} \begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N-1}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ - & = \sum^{2N-1}_{j=0}\sum^{2N-1}_{n=0} \frac{\hat{f}_j J_{n}}{2N} \exp\left[-i \frac{2\pi n j}{2N}\right] \\ - & = \sum^{2N-1}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working}\tag{13}\end{equation} +\begin{equation} +\begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N-1}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ +& = \sum^{2N-1}_{j=0}\sum^{2N-1}_{n=0} \frac{\hat{f}_j J_{n}}{2N} \exp\left[-i \frac{2\pi n j}{2N}\right] \\ +& = \sum^{2N-1}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\tag{13} +\end{equation} ``` - where in the first step we have extended the sum from $N$ to $2N-1$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ +where in the first step we have extended the sum from $N$ to $2N-1$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ ```math -\begin{equation} J_{j} = J_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1,\end{equation} +\begin{equation} +J_{j} = J_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1, +\end{equation} ``` ```math -\begin{equation} a_{j} = a_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1.\end{equation} +\begin{equation} +a_{j} = a_{2N-j}, {\rm~for~} N+1 \leq j \leq 2N-1. +\end{equation} ``` -In the second step we use the definition of the inverse transform (14) , and +In the second step we use the definition of the inverse transform (14) , and in the third step we define ```math -\begin{equation} v_{j} = \sum_{n=0}^{2N-1}\frac{J_{n}}{2N}\exp\left[-i \frac{2\pi n j}{2N}\right].\end{equation} +\begin{equation} +v_{j} = \sum_{n=0}^{2N-1}\frac{J_{n}}{2N}\exp\left[-i \frac{2\pi n j}{2N}\right]. +\end{equation} ``` -Finally, we can compare equations (8) and (13) and deduce that +Finally, we can compare equations (8) and (13) and deduce that ```math -\begin{equation} w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} +\begin{equation} +w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. +\end{equation} ``` We can write $v_{j}$ in terms of a discrete cosine transform, i.e., ```math -\begin{equation} v_{j} = \frac{1}{2N}\left(J_{0} + (-1)^jJ_{N} + 2\sum_{n=1}^{N-1}J_{n}\cos\left(\frac{\pi n j}{N}\right)\right).\end{equation} +\begin{equation} +v_{j} = \frac{1}{2N}\left(J_{0} + (-1)^jJ_{N} + 2\sum_{n=1}^{N-1}J_{n}\cos\left(\frac{\pi n j}{N}\right)\right). +\end{equation} ``` Weights on Gauss-Chebyshev-Radau points =============================================== We use the inverse transformation ```math -\begin{equation} a_{n} = \frac{q_{n}}{2N+1}\sum^{2N}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N+1}\right], \label{eq:inverse-transform-GCR}\tag{14}\end{equation} +\begin{equation} +a_{n} = \frac{q_{n}}{2N+1}\sum^{2N}_{j=0} \hat{f}_j \exp\left[- i \frac{2\pi n j}{2N+1}\right],\tag{14} +\end{equation} ``` where ```math -\begin{equation} q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n > 0 \\ 1 {\rm ~if~} n=0 \end{array}\right.\end{equation} +\begin{equation} +q_{n} = \left\{\begin{array}{l} 2 {\rm ~if~} n > 0 \\ 1 {\rm ~if~} n=0 \end{array}\right. +\end{equation} ``` and $\hat{f}_j$ is $f(x_j)$ on the extended domain in FFT order, i.e., ```math -\begin{equation} \hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j+1}){\rm~for~} N+1 \leq j \leq 2N. \end{equation} +\begin{equation} +\hat{f}_j = f(x_{j}) {\rm~for~} 0 \leq j \leq N ,\quad \hat{f}_j = f(x_{2N-j+1}){\rm~for~} N+1 \leq j \leq 2N. +\end{equation} ``` Note that the details of what is the appropriate FFT order depends on the order in which the points $x_j$ are stored. The key detail in the Chebyshev-Radau scheme is that (in the notation above) $x_0 = 1$ is not a repeated point, and must occupy $\hat{f}_0$. With this inverse tranformation, we can write ```math -\begin{equation} \begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ +\begin{equation} +\begin{split}\sum_{n=0}^N J_{n} a_{n} & = \sum^{2N}_{n=0} \frac{a_{n}J_{n}}{q_{n}} \\ & = \sum^{2N}_{j=0}\sum^{2N}_{n=0} \frac{\hat{f}_j J_{n}}{2N+1} \exp\left[-i \frac{2\pi n j}{2N+1}\right] \\ -& = \sum^{2N}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\label{eq:weights-working-radau}\tag{15}\end{equation} +& = \sum^{2N}_{j=0} \hat{f}_j v_{j} = \sum^{N}_{j=0} \hat{f}_j q_{j}v_{j},\end{split}\tag{15}\end{equation} ``` where in the first step we have extended the sum from $N$ to $2N$ and used FFT-order definitions of $J_{n}$ and $a_{n}$ ```math -\begin{equation} J_{j} = J_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N,\end{equation} +\begin{equation} +J_{j} = J_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N, +\end{equation} ``` ```math -\begin{equation} a_{j} = a_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N.\end{equation} +\begin{equation} +a_{j} = a_{2N+1-j}, {\rm~for~} N+1 \leq j \leq 2N. +\end{equation} ``` -In the second step we use the definition of the inverse transform (14) , and +In the second step we use the definition of the inverse transform (14), and in the third step we define ```math -\begin{equation} v_{j} = \sum_{n=0}^{2N}\frac{J_{n}}{2N+1}\exp\left[-i \frac{2\pi n j}{2N+1}\right].\end{equation} +\begin{equation} +v_{j} = \sum_{n=0}^{2N}\frac{J_{n}}{2N+1}\exp\left[-i \frac{2\pi n j}{2N+1}\right]. +\end{equation} ``` -Finally, we can compare equations (8) and (15) and deduce that +Finally, we can compare equations (8) and (15) and deduce that ```math -\begin{equation} w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. \end{equation} +\begin{equation} +w_{j} = q_{j}v_{j} {\rm~for~} 0 \leq j \leq N. +\end{equation} ```