Groups
Groups

Question regarding implementation of Method of Lines

37 views
Skip to first unread message

Shiba Biswal

unread,
Apr 13, 2023, 12:22:36 PM4/13/23
to chebfun-users
Hello,

I have questions regarding implementation of Method of Lines (MoL) for a PDE. This method entails discretizing the PDE in space to obtain a system of ODEs, which can then be passed to a standard ODE solver like ODE 45 or so in Matlab.

My primary reference for this work is the paper titled - ``Block Operators and Spectral Discretizations’’. Here are my questions:

1. I am using diffmat, instead of chebop, to discretize the PDE in space. I am not sure but I believe diffmat provides flexibility with regards to the size of discretization and perhaps it is also easier to incorporate non-standard boundary conditions using diffmat. Is there any significant reason why one would prefer chebop over diffmat? I couldn’t find a source to understand the algorithm behind these tools.

2. Following the paper, I obtain the matrix A which is of the size (n+b) X (n+b), where b = number of boundary conditions. I am assuming the matrix A encodes the Chebyshev polynomial coefficients, because  a nonlinear operator can’t be represented by a linear approximation.

3. If indeed A is the Chebyshev coefficient matrix and of the size (n+b) X (n+b), then how should I discretize the initial condition - u_0? I believe I should use chebfun and chebcoeffs to obtain the coefficients = <u_0, Ti(x)>, however I am not able to make sense of the size of the discretization of the initial condition. This is because the last b rows of A encodes the boundary condition, so u_0 must also be (n+b) vector, is that correct?

I would really appreciate your help regarding this.

Thank you for your time,
Shiba Biswal

iajze...@gmail.com

unread,
Apr 13, 2023, 3:05:04 PM4/13/23
to chebfun-users
Ian
Ian Ajzenszmidt
Articles
About 17,300 results (0.23 sec)
The chebop system for automatic solution of differential equations
TA Driscoll, F Bornemann, LN Trefethen - BIT Numerical Mathematics, 2008 - Springer
… the associated spectral discretization matrices, all implemented … problems by Chebyshev
methods that would normally get a … We choose to solve this equation as an initial value problem …
Save
Chebyshev expansion for impurity models using matrix product states
M Ganahl, P Thunström, F Verstraete, K Held… - Physical Review B, 2014 - APS
… the compressed and original state, and can be estimated by … 1)nμ − , which will indeed decay
exponentially when A(ω) has … with a linear discretization of the bath DOS with N = 120 sites …
Save
An instability phenomenon in spectral methods
LN Trefethen, MR Trummer - SIAM journal on numerical analysis, 1987 - SIAM
… the Chebyshev case D, whose properties are clearer. The … that the exact eigenvectors of the
discrete problem look like (3) … spectral methods are indeed more unreliable than Chebyshev, …
Save
A Chebyshev pseudospectral method to solve the space-time tempered fractional diffusion equation
E Hanert, C Piret - SIAM Journal on Scientific Computing, 2014 - SIAM
… consider an arbitrary initial condition of the form f(x, 0) = f0(x), … ’s matrix approach [32, 33, 34]
and could indeed be seen as a … can express the previous set of discrete equations in matrix
Save
A new approach to solving multiorder time‐fractional advection–diffusion–reaction equations using BEM and Chebyshev matrix
M Khalighi, M Amirianmatlob… - Mathematical Methods in …, 2021 - Wiley Online Library
… , shifted chebyshev polynomials are used, 36 indeed it would … elements discretization and
the integrations are limited only to … (16) with initial conditions (18), we approximate b(t) and f(t) …
Save
[BOOK] Chebyshev and Fourier spectral methods
Indeed, one can show that for this problem, all the odd … Normally, boundary and initial
conditions are not a major … at an increasingly large number of discrete points, it will be smaller and …
Save Cite Cited by 6622 Related articles All 21 versions
Discrete Talbot effect in waveguide arrays
R Iwanow, DA May-Arrioja, DN Christodoulides… - Physical review …, 2005 - APS
… We note that all the Chebyshev coefficients … It turns out that these are indeed roots only if N
… To experimentally demonstrate discrete Talbot effects, we used a channel waveguide array
Save
[BOOK] Chebyshev polynomials
JC Mason, DC Handscomb - 2002 - books.google.com
… The idea that there are really four kinds of Chebyshev … Bivariate discrete data fitting on
or near a family of lines or … Indeed if we average the initial conditions (1.12c) and (1.12d…
Save Cite Cited by 2762 Related articles All 8 versions
Efficient modified Chebyshev differentiation matrices for fractional differential equations
A Dabiri, EA Butcher - … in Nonlinear Science and Numerical Simulation, 2017 - Elsevier
matrices approximate fractional operators via discretization at … coefficient of the interpolating
polynomial, the modified-FCDM … It should be noticed that if all initial conditions of x(t) at the …
Save
The accurate solution of Poisson's equation by expansion in Chebyshev polynomials
DB Haidvogel, T Zang - Journal of Computational Physics, 1979 - Elsevier
… The Chebyshev coefficients can be recovered from the solution of Eq… Indeed, the exact
(discrete) solutions given by ADI and the … The maximum error at these discrete locations was then
Save

iajze...@gmail.com

unread,
Apr 13, 2023, 3:14:30 PM4/13/23
to chebfun-users
The following learned papers, referred to by google scholar may assist in selecting either diffmat or chebfun.
Ian
Ian Ajzenszmidt
Articles
About 13 results (0.08 sec)
Chebyshev spectral method for superconductivity problems
V Sokolovsky, L Prigozhin… - … Science and Technology, 2020 - iopscience.iop.org
… is now fully determined and we find its expansion coefficients using Chebfun toolbox. Since
… the difference between these solutions for different ${r_1}/a$ ratios and we compared them …
Save
Spectral methods for capillary surfaces described by bounded generating curves
R Treinen - Applied Mathematics and Computation, 2023 - Elsevier
… all of the automation implemented in Chebfun. We prefer to … the new method developed
here compared with the shooting … D 0 = diffmat ( [ n − 1 n ] , 0 , X ) ; D 1 = diffmat ( [ n − 1 n ] , 1 , …
Save
Block operators and spectral discretizations
JL Aurentz, LN Trefethen - SIAM review, 2017 - SIAM
… −1, 1], which we obtain by calling diffmat with an argument 0, … continuous level, by the
difference between the two sides of … We invoke this formula via the Chebfun command chebfun(u)…
Save
[BOOK] Handbook of differential equations
D Zwillinger, V Dobrushkin - 2021 - books.google.com
… since |ey| is not always small compared to 10 (for e=0.01 and t=1000 we have ley'|~86). …
A comparison of methods is in Holodniok and Kubicek [592]. Methods for delay differential …
Save Cite Cited by 2348 Related articles All 11 versions
Block operators and spectral discretizations
LN Trefethen, JL Aurentz - SIAM Review, 2017 - ora.ox.ac.uk
… −1, 1], which we obtain by calling diffmat with an argument 0, … continuous level, by the
difference between the two sides of … We invoke this formula via the Chebfun command chebfun(u)…
Save Cite Related articles
Rectangular spectral collocation
TA Driscoll, N Hale - IMA Journal of Numerical Analysis, 2016 - academic.oup.com
Compared with other formulations of spectral methods, such … In the automated computations,
Chebfun uses automatic … All the examples in this section use Chebfun version 5.1.0. …
Save
Discussion of a uniqueness result in" Equilibrium Configurations for a Floating Drop"
R Treinen - arXiv preprint arXiv:2206.14292, 2022 - arxiv.org
… Then we compare the integrands at φ0, and our assumption that αU > βU means that u1
> … range of σ by using the Chebfun command with bigN= 100 diffmat(bigN, 1, [sig_min;sig_max]); …
Save Cite Related articles All 2 versions
LN Trefethen - SIAM Review, 2020 - SIAM
… These curves, computed with a Chebyshev spectral collocation method by Chebfun [11, 59],
are … sented in this paper were computed with MATLAB and Chebfun [11, 59]. Here are a few …
Save
What ODE-Approximation Schemes of Time-Delay Systems Reveal about Lyapunov-Krasovskii Functionals
TH Scholl, V Hagenmeyer, L Gröll - arXiv preprint arXiv:2202.13122, 2022 - arxiv.org
… matrix is, eg, available via diffmat(N+1) from the Chebfun toolbox by Driscoll et al. (2014). …
We compare the results with known bounds on the LK functional in (31) and (32) taking Q0,Q1 …
Save Cite Related articles All 2 versions
Spectral collocation methods in solid mechanics
L Trnka - 2022 - dspace.cuni.cz
… The numerical results are compared to the analytical solution, … in Matlab1 with software
package Chebfun2. The package is very … To create the matrix D, the relevant command is diffmat. …
Save Cite Related articles

On Friday, 14 April 2023 at 02:22:36 UTC+10 Shiba Biswal wrote:

iajze...@gmail.com

unread,
Apr 13, 2023, 3:29:46 PM4/13/23
to chebfun-users
I have attempted to obtain an answer from openai ie artificial intelligence.
Here it is. It may be of interest to compare it with google scholar results.

Is there any significant reason why one would prefer chebop over diffmat?

Yes, there are several reasons why one might prefer using chebop over diffmat in certain contexts.

  1. Functionality: chebop is a toolbox in MATLAB specifically designed for solving boundary value problems (BVPs) and initial value problems (IVPs) using the spectral collocation method with Chebyshev polynomials. It provides a wide range of functionality, including the ability to define and solve linear and nonlinear BVPs and IVPs, handle boundary conditions, and compute eigenvalues and eigenfunctions. On the other hand, diffmat is a MATLAB function that computes differentiation matrices based on finite differences, which is a different numerical method primarily used for solving ordinary differential equations (ODEs) on uniform grids.

  2. Accuracy: The spectral collocation method using Chebyshev polynomials is known for its high accuracy in solving differential equations, particularly for smooth functions and problems with boundary layers. Chebyshev polynomials are well-suited for approximating functions with high precision, and chebop provides efficient algorithms for solving BVPs and IVPs with high accuracy. On the other hand, finite differences used in diffmat can introduce numerical errors, particularly when approximating derivatives of functions with rapid changes or when using non-uniform grids.

  3. Flexibility: chebop provides a flexible and extensible framework for defining and solving a wide range of BVPs and IVPs. It allows users to define their own differential operators, boundary conditions, and nonlinearities, making it suitable for a wide range of applications. diffmat, on the other hand, provides a more limited set of functionalities focused on computing differentiation matrices based on finite differences.

  4. Community and Support: chebop is part of the widely-used Chebfun toolbox, which is a popular software for numerical computing with Chebyshev polynomials in MATLAB. Chebfun has an active community of users and developers, providing a supportive environment for learning, troubleshooting, and getting help with chebop and related tools. diffmat is a standalone function with less community support compared to Chebfun and chebop.

That being said, the choice between chebop and diffmat depends on the specific requirements and constraints of the problem you are trying to solve. diffmat can be useful for certain types of ODEs on uniform grids, and it may be more suitable in certain scenarios where simplicity and computational efficiency are important factors. However, if you need a more powerful and flexible tool for solving BVPs and IVPs with high accuracy and precision, particularly for problems involving Chebyshev polynomials, chebop may be a preferred choice.

ChatGPT Mar 23 Version. Free Research Preview. ChatGPT may produce inaccurate information about people, places, or facts


iajze...@gmail.com

unread,
Apr 13, 2023, 3:31:13 PM4/13/23
to chebfun-users
I have attempted to obtain an answer from openai ie artificial intelligence.
Here it is. It may be of interest to compare it with google scholar results.

Is there any significant reason why one would prefer chebop over diffmat?

Yes, there are several reasons why one might prefer using chebop over diffmat in certain contexts.

  1. Functionality: chebop is a toolbox in MATLAB specifically designed for solving boundary value problems (BVPs) and initial value problems (IVPs) using the spectral collocation method with Chebyshev polynomials. It provides a wide range of functionality, including the ability to define and solve linear and nonlinear BVPs and IVPs, handle boundary conditions, and compute eigenvalues and eigenfunctions. On the other hand, diffmat is a MATLAB function that computes differentiation matrices based on finite differences, which is a different numerical method primarily used for solving ordinary differential equations (ODEs) on uniform grids.

  2. Accuracy: The spectral collocation method using Chebyshev polynomials is known for its high accuracy in solving differential equations, particularly for smooth functions and problems with boundary layers. Chebyshev polynomials are well-suited for approximating functions with high precision, and chebop provides efficient algorithms for solving BVPs and IVPs with high accuracy. On the other hand, finite differences used in diffmat can introduce numerical errors, particularly when approximating derivatives of functions with rapid changes or when using non-uniform grids.

  3. Flexibility: chebop provides a flexible and extensible framework for defining and solving a wide range of BVPs and IVPs. It allows users to define their own differential operators, boundary conditions, and nonlinearities, making it suitable for a wide range of applications. diffmat, on the other hand, provides a more limited set of functionalities focused on computing differentiation matrices based on finite differences.

  4. Community and Support: chebop is part of the widely-used Chebfun toolbox, which is a popular software for numerical computing with Chebyshev polynomials in MATLAB. Chebfun has an active community of users and developers, providing a supportive environment for learning, troubleshooting, and getting help with chebop and related tools. diffmat is a standalone function with less community support compared to Chebfun and chebop.

That being said, the choice between chebop and diffmat depends on the specific requirements and constraints of the problem you are trying to solve. diffmat can be useful for certain types of ODEs on uniform grids, and it may be more suitable in certain scenarios where simplicity and computational efficiency are important factors. However, if you need a more powerful and flexible tool for solving BVPs and IVPs with high accuracy and precision, particularly for problems involving Chebyshev polynomials, chebop may be a preferred choice.

ChatGPT Mar 23 Version. Free Research Preview. ChatGPT may produce inaccurate information about people, places, or facts


On Friday, 14 April 2023 at 02:22:36 UTC+10 Shiba Biswal wrote:

iajze...@gmail.com

unread,
Apr 13, 2023, 3:52:55 PM4/13/23
to chebfun-users
New chat
Chebyshev Initial Condition Discretization
3. If indeed A is the Chebyshev coefficient matrix and of the size (n+b) X (n+b), then how should I discretize the initial condition - u_0?

If A is the Chebyshev coefficient matrix and has a size of (n+b) x (n+b), where n is the number of Chebyshev points and b is the size of the boundary condition, you can discretize the initial condition u_0 using the same Chebyshev points as the columns of A.

The Chebyshev points are the roots of the Chebyshev polynomials of the first kind, which are given by the formula:

x_k = cos((kπ) / n), 0 ≤ k ≤ n

where k is the index of the Chebyshev point, n is the number of Chebyshev points, and π is the mathematical constant pi.

To discretize the initial condition u_0 at these Chebyshev points, you can evaluate the function u_0(x) at each Chebyshev point x_k and store the resulting values in a vector of size (n+b) x 1. This vector will represent the initial condition u_0 in the Chebyshev basis.

For example, if you have n+1 Chebyshev points (x_0, x_1, ..., x_n) and a boundary condition of size b, the discretized initial condition u_0 can be represented as:

u_0 = [u_0(x_0), u_0(x_1), ..., u_0(x_n), u_0(boundary_1), u_0(boundary_2), ..., u_0(boundary_b)]^T

where "^T" denotes the transpose operation, and u_0(x_k) represents the value of the function u_0 at the Chebyshev point x_k. The resulting vector u_0 will have a size of (n+b) x 1, which can be used in conjunction with the Chebyshev coefficient matrix A for solving the corresponding differential equation numerically.

ChatGPT Mar 23 Version. Free Research Preview. ChatGPT may produce inaccurate information about people, places, or facts




On Friday, 14 April 2023 at 02:22:36 UTC+10 Shiba Biswal wrote:

Nick Hale

unread,
Apr 14, 2023, 4:20:25 AM4/14/23
to chebfun-users
Hi Shiba

1. I am using diffmat, instead of chebop, to discretize the PDE in space. I am not sure but I believe diffmat provides flexibility with regards to the size of discretization and perhaps it is also easier to incorporate non-standard boundary conditions using diffmat. Is there any significant reason why one would prefer chebop over diffmat? I couldn’t find a source to understand the algorithm behind these tools.

The advantage of using Chebop is that it deals automatically with: selecting the discretisation size; enforcing boundary and continuity conditions; systems of equations; nonlinear equations; and more. 

You can find most details here: https://www.cs.ox.ac.uk/files/713/NA-08-11.pdf

2. Following the paper, I obtain the matrix A which is of the size (n+b) X (n+b), where b = number of boundary conditions. I am assuming the matrix A encodes the Chebyshev polynomial coefficients, because  a nonlinear operator can’t be represented by a linear approximation.

diffmat returns a spectral collocation differentiation matrix. See Trefethen's book 'Spectral Methods in MATLAB' for more details. 

Section 11 of 'Block Operators and Spectral Discretizations' describes how nonlinear equations can be solved.

3. If indeed A is the Chebyshev coefficient matrix and of the size (n+b) X (n+b), then how should I discretize the initial condition - u_0? I believe I should use chebfun and chebcoeffs to obtain the coefficients = <u_0, Ti(x)>, however I am not able to make sense of the size of the discretization of the initial condition. This is because the last b rows of A encodes the boundary condition, so u_0 must also be (n+b) vector, is that correct?

If you are following  'Block Operators and Spectral Discretizations'  then I thing that the discretisation of the linear operator should have dimensions nx(n+b). The b boundary conditions will then make the system square.

In the case of a collocation discretisation, a Dirichlet condition at the left boundary can be implemented in vector form B = [1, zeros(1, n+b)]. Other boundary constraints are described in 'Block Operators and Spectral Discretizations'.

4. Chebfun does have some method of lines solvers built-in, namely pde15s and pde23t. However, these are largely undocumented. (There is no paper.) There are also the spin() methods for periodic PDEs and chebop.expm() for linear PDEs. You can find some details in the Chebfun Guide: https://www.chebfun.org/docs/guide/

I hope this helps.

Nick

Shiba Biswal

unread,
Apr 17, 2023, 3:21:55 PM4/17/23
to chebfun-users
Dear Nick,

Thank you very much for your reply. I will take some time to peruse through the sources you have mentioned.

Best,
Shiba

Shiba Biswal

unread,
Apr 17, 2023, 3:24:11 PM4/17/23
to chebfun-users
Dear Ian,

Thank you for your help.

Best,
Shiba
Reply all
Reply to author
Forward
0 new messages
Search
Clear search
Close search
Google apps
Main menu